Last active
December 11, 2015 18:18
-
-
Save nobonobo/4640170 to your computer and use it in GitHub Desktop.
複数パッケージを寄せ集めてビルドチェイン組むサンプルをつくった。 pkg2をビルドしようとするとpkg1が先にビルドされてからpkg2のビルドが始まる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUILD_DIR=./build | |
DIST_DIR=./dist | |
define PullProc | |
$(BUILD_DIR)/$1: | |
@echo Pull: $(NAME) | |
mkdir -p $(BUILD_DIR)/$1 | |
cd $(BUILD_DIR); #git clone $(URL) | |
endef | |
define ConfigProc | |
$(BUILD_DIR)/$1/.config: $(BUILD_DIR)/$1 | |
@echo Config: $(NAME) | |
touch $(BUILD_DIR)/$1/.config | |
endef | |
define BuildProc | |
$(BUILD_DIR)/$1/.build: $(BUILD_DIR)/$1/.config | |
@echo Build: $(NAME) | |
touch $(BUILD_DIR)/$1/.build | |
endef | |
define InstallProc | |
$(BUILD_DIR)/$1/.install: $(BUILD_DIR)/$1/.build | |
@echo Install: $(NAME) | |
touch $(BUILD_DIR)/$1/.install | |
endef | |
define Package | |
NAME= | |
URL= | |
DEPENDS= | |
$(eval $(call Define/$1)) | |
$(eval $(call PullProc,$1)) | |
$(eval $(call ConfigProc,$1)) | |
$(eval $(call BuildProc,$1)) | |
$(eval $(call InstallProc,$1)) | |
$1: $(DEPENDS) | |
$1: $(BUILD_DIR)/$1/.install | |
endef | |
.PHONY: all clean | |
all: pkg2 | |
clean: | |
@rm -rf $(BUILD_DIR) | |
define Define/pkg1 | |
NAME=Hoge Package | |
URL=http://github.com/hogehoge/pkg1 | |
endef | |
$(eval $(call Package,pkg1)) | |
define Define/pkg2 | |
NAME=Hoge Package2 | |
DEPENDS=pkg1 | |
URL=http://github.com/hogehoge/pkg2 | |
endef | |
$(eval $(call Package,pkg2)) |
DEPENDSに書いたパッケージ名が優先してビルドされる仕組み。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
「define Define/XXX…endef」を追加して「$(eval $(call Package,XXX))」を呼べば
ビルドチェインルールが展開される仕組み。