Last active
January 31, 2021 13:56
-
-
Save yeger00/4a6be979311c9b0679286ac1553bd9dd to your computer and use it in GitHub Desktop.
Makefile
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
dependencies = $(foreach dependency, $(1), build-module-$(dependency)) | |
module1_dependencies = | |
module2_dependencies = $(call dependencies, module1) | |
module3_dependencies = $(call dependencies, module2) | |
module4_dependencies = $(call dependencies, module1) | |
all_modules = $(call dependencies, module1 module2 module3 module4) | |
docker1_dependencies = $(call dependencies, module1) | |
docker2_dependencies = $(call dependencies, module2, module4) | |
all_dockers = $(call dependencies, docker1, docker2) | |
all = $(all_modules) $(all_dockers) | |
# There are 4 targets for each module or docker. | |
# 1. build - | |
# First it build all the other dependencies defined in the module_dependencies variable. | |
# Then it copies each dependencies to the module/packages dir | |
# Last it calls to the build target of the module's Makefile | |
# | |
# 2. clean - Cleans the module by calling the clean target of the module's Makefile | |
# 3. start - Starts the module by calling the start target of the module's Makefile | |
# 4. stop - Stops the module by calling the stop target of the module's Makefile | |
.SECONDEXPANSION: | |
build-%: $$(%_dependencies) | |
mkdir $*/packages | |
for dependency in $^; do \ | |
cp ${dependency}/dist/* $*/packages; \ | |
done | |
make -C $* build | |
clean-%: | |
make -C $* clean | |
rm -r $*/packages | |
start-%: | |
make -C $* start | |
stop-%: | |
make -C $* stop | |
build-all-modules: $(all_modules) | |
build-all-dockers: $(all_dockers) | |
build-al: $(all) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment