Skip to content

Instantly share code, notes, and snippets.

@RJ
Last active November 2, 2019 07:29
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save RJ/6977165 to your computer and use it in GitHub Desktop.
Save RJ/6977165 to your computer and use it in GitHub Desktop.
Makefile fragment that generates makefile targets to call make with a given target on all apps/* subdirs. Useful for erlang projects using erlang.mk that have apps/{app1,app2,app3..} structure (which rebar doesn't mind). Eg: call "make app" and it will call "make -C apps/app1 app; make -C apps/app2 app; ..." for you.
APPDIRS := $(wildcard apps/*)
## Example hack to filter one out:
## APPDIRS := $(filter-out apps/fooapp, $(APPDIRS))
define PROXY_TARGET
$(1):
$(foreach appdir,$(APPDIRS),$(MAKE) -C $(appdir) $(1) ;)
endef
## add erlang.mk targets you care about here:
PROXY_TARGETS = all app clean built-plt dialyze docs tests
$(foreach targ,$(PROXY_TARGETS),$(eval $(call PROXY_TARGET,$(targ))))
@RJ
Copy link
Author

RJ commented Oct 14, 2013

This is in my top-level Makefile, with the "real" makefiles that include erlang.mk in my various apps/ dirs.

@RomanShestakov
Copy link

Hello Richard,
thanks for a snippet - this is very nice.
How do you build an app release with this make file? In the situation when you have an apps dir you would need to build a release using relx.config which would live in the root dir (which contains apps) and the release should pack all the applications in the apps?

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