Skip to content

Instantly share code, notes, and snippets.

@nobonobo
Last active December 11, 2015 18:18
Show Gist options
  • Save nobonobo/4640170 to your computer and use it in GitHub Desktop.
Save nobonobo/4640170 to your computer and use it in GitHub Desktop.
複数パッケージを寄せ集めてビルドチェイン組むサンプルをつくった。 pkg2をビルドしようとするとpkg1が先にビルドされてからpkg2のビルドが始まる。
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))
@nobonobo
Copy link
Author

DEPENDSに書いたパッケージ名が優先してビルドされる仕組み。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment