# Generic Makefile for use with Gaius Mulley's # GNU Modula-2 Compiler # Author: Duke Normandin - dukeofperl@ml1.net # with the help of: # Edward Welbourne eddy(at)chaos(dot)org(dot)uk # Henrik Carlqvist hc123(at)poolhem.se # 5 Oct. 2010 -> 1st edition # # If you make improvements, please forward me a # copy, so that I too can get a clue. Thanks! # enjoy! define assert $(call assert,$($ARGS), The variable "$ARGS" is null) endef # save CLI arguments EXEC-FILE = $(word 1, $(ARGS)) SRCS = $(wordlist 2, 999, $(ARGS)) # The GM2 Compiler is pretty simple to operate # # to compile a 1+ modules "long-hand" would require: # gm2 -c module1.mod # gm2 -c module2.mod # gm2 -o exec-file module1.mod # LINK = gm2 -g MODULA = gm2 -c -g # Rule #1 generate the executable file from its dependencies (source files) # In turn generate the object code (.o files) from its like-named source (.mod) file # Using the command on the TAB-indented line $(EXEC-FILE): $(SRCS:%.mod=%.o) $(LINK) $(SRCS) -o $@ # Rule #2 generate the object code (.o files) from its like-named source (.mod) file # Using the command on the TAB-indented line %.o:%.mod $(MODULA) $< .PHONY: usage usage: @echo "Usage:" @echo "make ARGS=\"exec-file src1.mod src2.mod ... srcn.mod\"" @echo "Make sure that the IMPORTed modules precede the \"main\" module" @echo "in the command line ARGS. Enjoy!" .PHONY: clean clean: rm -rf *.o