diff options
author | Loïc Hoguin <[email protected]> | 2014-05-28 22:07:54 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-05-28 22:17:51 +0200 |
commit | 58b99e7f457bc056e91d2d1721cbb65fcd517afe (patch) | |
tree | 16f20657dcb4f1713ff3bfc02de875b85e7875c4 /core/erlc.mk | |
parent | b47d3f4c3e097aa28a08f72931d2ce8c50039681 (diff) | |
download | erlang.mk-58b99e7f457bc056e91d2d1721cbb65fcd517afe.tar.gz erlang.mk-58b99e7f457bc056e91d2d1721cbb65fcd517afe.tar.bz2 erlang.mk-58b99e7f457bc056e91d2d1721cbb65fcd517afe.zip |
Cut erlang.mk into many small components
* The build.config says what gets into the generated erlang.mk.
* The default erlang.mk in the repository hasn't changed yet.
* Clean targets were separated into "clean" and "distclean".
* The "help" target was added to display some help message.
I probably broke a couple things...
Diffstat (limited to 'core/erlc.mk')
-rw-r--r-- | core/erlc.mk | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/core/erlc.mk b/core/erlc.mk new file mode 100644 index 0000000..cca85ba --- /dev/null +++ b/core/erlc.mk @@ -0,0 +1,62 @@ +# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]> +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: clean-app + +# Configuration. + +ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \ + +warn_shadow_vars +warn_obsolete_guard # +bin_opt_info +warn_missing_spec +COMPILE_FIRST ?= +COMPILE_FIRST_PATHS = $(addprefix src/,$(addsuffix .erl,$(COMPILE_FIRST))) + +# Verbosity. + +appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src; +appsrc_verbose = $(appsrc_verbose_$(V)) + +erlc_verbose_0 = @echo " ERLC " $(filter %.erl %.core,$(?F)); +erlc_verbose = $(erlc_verbose_$(V)) + +xyrl_verbose_0 = @echo " XYRL " $(filter %.xrl %.yrl,$(?F)); +xyrl_verbose = $(xyrl_verbose_$(V)) + +# Core targets. + +app:: ebin/$(PROJECT).app + $(eval MODULES := $(shell find ebin -type f -name \*.beam \ + | sed 's/ebin\///;s/\.beam/,/' | sed '$$s/.$$//')) + $(appsrc_verbose) cat src/$(PROJECT).app.src \ + | sed 's/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/' \ + > ebin/$(PROJECT).app + +define compile_erl + $(erlc_verbose) erlc -v $(ERLC_OPTS) -o ebin/ \ + -pa ebin/ -I include/ $(COMPILE_FIRST_PATHS) $(1) +endef + +define compile_xyrl + $(xyrl_verbose) erlc -v -o ebin/ $(1) + $(xyrl_verbose) erlc $(ERLC_OPTS) -o ebin/ ebin/*.erl + @rm ebin/*.erl +endef + +ifneq ($(wildcard src/),) +ebin/$(PROJECT).app:: + @mkdir -p ebin/ + +ebin/$(PROJECT).app:: $(shell find src -type f -name \*.erl) \ + $(shell find src -type f -name \*.core) + $(if $(strip $?),$(call compile_erl,$?)) + +ebin/$(PROJECT).app:: $(shell find src -type f -name \*.xrl) \ + $(shell find src -type f -name \*.yrl) + $(if $(strip $?),$(call compile_xyrl,$?)) +endif + +clean:: clean-app + +# Extra targets. + +clean-app: + $(gen_verbose) rm -rf ebin/ |