00001
00002 # From here all variables are expected to be updated, as first all
00003 # the variables of englobing projects should be set, then only rules
00004 # based on that variables should be defined.
00005
00006
00007
00008 # Now defining the generic rules operating on the variables.
00009
00010 ERL_FILES = $(wildcard *.erl)
00011
00012 # Includes test beams:
00013 BEAM_FILES = $(patsubst %.erl,%.beam,$(ERL_FILES))
00014
00015 TEST_SOURCES = $(wildcard *_test.erl)
00016
00017 TEST_TARGETS = $(patsubst %.erl,%,$(TEST_SOURCES))
00018
00019
00020 # Regarding dependency management.
00021 #
00022 # One can just ignore dependencies and rebuild "blindly" every module in
00023 # current subtree.
00024 # One just has not to forget to issue 'make' from a right location, before
00025 # running one's Erlang program.
00026
00027 # Another option is to track dependencies explicitly.
00028 # We found no existing way of managing dependencies automatically, thus
00029 # they have to be declared by hand.
00030 # We want these user-specified dependencies to work with the generic
00031 # rules to build beam files and to run programs.
00032 # For example, 'make MyObject_run' would check MyObject_test.beam
00033 # and its dependencies before running it.
00034 # A generic rule like: '%.beam: %.erl' would not take into account
00035 # dependencies.
00036 # A generic rule like: '%.beam: %.erl %_dependencies' with
00037 # a definition like 'MyObject_dependencies: A.beam moduleB.beam'
00038 # would work (and modules not depending on others could be managed with a
00039 # second generic rule: '%.beam: %.erl'), but generic targets, as
00040 # defined in GNUmakerules.inc, seem to be *always* rebuilt, not depending
00041 # on their .PHONY status.
00042 # In our case, MyObject.beam (and all its
00043 # prerequesites!) would thus always be rebuilt, even if no change at all was
00044 # operated on the corresponding sources, which whould not be acceptable.
00045
00046 # Thus we stick from now to the basic strategy: always issue a global 'make'
00047 # at the root of the source before running a program, otherwise be doomed
00048 # (changes not taken into account at runtime, as not recompiled).
00049
00050
00051
00052 .PHONY: all all-recurse test test-recurse doc-recurse build-tests \
00053 launch help-erl clean clean-erlang clean-database clean-recurse \
00054 realclean info info-files $(MODULES_DIRS)
00055
00056
00057 all: all-recurse $(BEAM_FILES)
00058
00059
00060 all-recurse:
00061 @echo " Building all in "$(PWD) #`basename $(PWD)`
00062 @for m in $(MODULES_DIRS); do if ! ( if [ -d $$m ] ; then cd $$m && $(MAKE) -s all CMD_LINE_OPT="${CMD_LINE_OPT}" && cd .. ; else echo " (directory $$m skipped)" ; fi ) ; then exit 1; fi ; done
00063
00064
00065 %.beam: %.erl %.hrl
00066 @echo " Compiling module with header $<"
00067 @$(ERLANG_COMPILER) $(ERLANG_COMPILER_OPT) -o $@ $<
00068
00069
00070 %.beam: %.erl
00071 @echo " Compiling module $<"
00072 @$(ERLANG_COMPILER) $(ERLANG_COMPILER_OPT) -o $@ $<
00073
00074
00075
00076 #%_test: %.beam %_test.beam
00077 # @echo " Executing test function $(STARTUP_FUNCTION) in module $@"
00078 # @$(ERLANG_INTERPRETER) $(ERLANG_INTERPRETER_OPT) -run $@ $(STARTUP_FUNCTION)
00079
00080 #%_test: %_test.beam
00081 # @echo " Executing test function $(STARTUP_FUNCTION) in module $@"
00082 # @$(ERLANG_INTERPRETER) $(ERLANG_INTERPRETER_OPT) -run $@ $(STARTUP_FUNCTION)
00083
00084 %_test: %.beam %_test.beam
00085
00086 %_test: %_test.beam
00087
00088
00089 %_interactive_test: %.beam %_interactive_test.beam
00090 @echo " Executing interactively test function $(STARTUP_FUNCTION) in module $@"
00091 @$(ERLANG_INTERPRETER) $(ERLANG_INTERPRETER_OPT) -run $@ $(STARTUP_FUNCTION)
00092
00093
00094 %_batch_test: %.beam %_batch_test.beam
00095 @echo " Executing non-interactively test function $(STARTUP_FUNCTION) in module $@"
00096 @$(ERLANG_INTERPRETER) $(ERLANG_INTERPRETER_OPT) -run $@ $(STARTUP_FUNCTION)
00097
00098
00099
00100 # _integration prefix added not to match instead of the next rule.
00101 # %_integration_dependencies target is a phony target, so that test dependencies
00102 # can be specified.
00103 %_integration_run: %_integration_test.beam %_integration_dependencies
00104 @echo " Running integration test $@ from $^ with $(ERL_PARAMETERIZED_LAUNCHER)"
00105 @$(ERL_PARAMETERIZED_LAUNCHER) --ln $@ --eval `echo $@ | sed 's|_run|_test:run()|1'` $(CMD_LINE_OPT)
00106
00107
00108
00109 # 'X_run' becomes 'X_test:run()':
00110
00111 %_run: %_test %_test_dependencies
00112 @echo " Running unitary test $@ (first form) from $^, with $(ERL_PARAMETERIZED_LAUNCHER)"
00113 @$(ERL_PARAMETERIZED_LAUNCHER) --ln $@ --eval `echo $@ | sed 's|_run|_test:run()|1'` $(CMD_LINE_OPT)
00114
00115
00116 %_run: %_test %.beam
00117 @echo " Running unitary test $@ (second form) from $^"
00118 $(ERL_PARAMETERIZED_LAUNCHER) --ln $@ --eval `echo $@ | sed 's|_run|_test:run()|1'` $(CMD_LINE_OPT)
00119
00120
00121 %_run: %_test
00122 @echo " Running unitary test $@ (third form) from $^"
00123 @$(ERL_PARAMETERIZED_LAUNCHER) --ln $@ --eval `echo $@ | sed 's|_run|_test:run()|1'` $(CMD_LINE_OPT)
00124
00125
00126 test: all test-recurse
00127 @for t in $(TEST_TARGETS); do if ! $(MAKE) -s `echo $$t | sed 's|_test|_run|1'` CMD_LINE_OPT="${CMD_LINE_OPT}"; then exit 1; fi ; done
00128
00129
00130 test-recurse:
00131 @echo " Testing all in "`basename $(PWD)`
00132 @for m in $(MODULES_DIRS); do if ! ( if [ -d $$m ] ; then cd $$m && $(MAKE) -s test CMD_LINE_OPT="${CMD_LINE_OPT}" && cd .. ; else echo " (directory $$m skipped)" ; fi ) ; then exit 1; fi ; done
00133
00134
00135 # To execute standalone Erlang modules.
00136 %_exec: %.beam
00137 @echo " Running standalone module from $^"
00138 @$(ERL_PARAMETERIZED_LAUNCHER) --ln $@ -noshell --eval `echo $@ | sed 's|_exec|:main()|1'` $(CMD_LINE_OPT) AAA
00139
00140
00141
00142 # Best placed here rather than in GNUmakerules-docutils.inc:
00143 doc: doc-recurse
00144
00145 doc-recurse:
00146 @echo " Preparing documentation in "$(PWD) #`basename $(PWD)`
00147 @for m in $(MODULES_DIRS); do if ! ( if [ -d $$m ] ; then cd $$m && $(MAKE) -s doc CMD_LINE_OPT="${CMD_LINE_OPT}" && cd .. ; else echo " (directory $$m skipped)" ; fi ) ; then exit 1; fi ; done
00148
00149
00150
00151 # Not used any more now that all beams are always built:
00152 build-tests: $(BEAM_FILES)
00153 @for t in $(TEST_TARGETS); do $(MAKE) -s $$t CMD_LINE_OPT="${CMD_LINE_OPT}"; done
00154
00155
00156 launch: Emakefile
00157 @echo " Launching interpreter with default Ceylan settings"
00158 @${ERL_PARAMETERIZED_LAUNCHER} --ln test_shell $(CMD_LINE_OPT)
00159
00160
00161 help-erl:
00162 @echo "To test hello.erl: 'erl', then 'c(hello).'," \
00163 "then 'hello:world().', then CTRL-C CTRL-C"
00164
00165 clean: clean-erlang clean-database clean-recurse
00166
00167
00168 clean-erlang:
00169 @echo " Cleaning all in "$(PWD) #`basename $(PWD)`
00170 -@rm -f *.beam *.jam erl_crash.dump
00171
00172
00173 clean-database:
00174 -@rm -rf Mnesia.*@*
00175
00176
00177 clean-recurse:
00178 @for m in $(MODULES_DIRS); do if ! ( if [ -d $$m ] ; then cd $$m && $(MAKE) -s clean CMD_LINE_OPT="${CMD_LINE_OPT}" && cd .. ; else echo " (directory $$m skipped)" ; fi ) ; then exit 1; fi ; done
00179
00180
00181 realclean: clean
00182 @echo " Deep cleaning in "`basename $(PWD)`
00183 @-rm -f Emakefile
00184
00185
00186 info: info-files
00187 @echo "FQDN = $(FQDN)"
00188 @echo "BEAM_DIRS = $(BEAM_DIRS)"
00189 @echo "BEAM_PATH_OPT = $(BEAM_PATH_OPT)"
00190 @echo "ARCHIVE_FILE = $(ARCHIVE_FILE)"
00191 @echo "ERLANG_INTERPRETER = $(ERLANG_INTERPRETER)"
00192 @echo "ERLANG_INTERPRETER_OPT = $(ERLANG_INTERPRETER_OPT)"
00193 @echo "ERLANG_SRC = $(ERLANG_SRC)"
00194 @echo "VM_TEST_NAME = $(VM_TEST_NAME)"
00195 @echo "PROJECT_NAME = $(PROJECT_NAME)"
00196
00197
00198 info-files:
00199 @echo "ERL_FILES = $(ERL_FILES)"
00200 @echo "BEAM_FILES = $(BEAM_FILES)"
00201 @echo "TEST_SOURCES = $(TEST_SOURCES)"
00202 @echo "TEST_TARGETS = $(TEST_TARGETS)"
00203