Buildsys2
[henge/webcc.git] / src / Makefile
1 ##################################################
2 #Desc: Mihrtec Standard Makefile
3 #Author: Mihrtec LLC
4 #Date: 2016
5 ##################################################
6 #Application Information
7 ##################################################
8 #Executable name, also passed as -DAPPNAME to compiler
9 APPNAME := the_march
10 #Directory in which we expect to find main()
11 APPMODULE := core
12 #Compiler flags for the final executable
13 APPFLAGS :=
14 #Object files statically linked for the executable
15 APPOBJ :=
16 #Dependencies which must be built before the executable
17 APPDEPS :=
18 ##################################################
19 #Emscripten Info
20 ##################################################
21 #Functions to export for JS Module
22 EXPORT_FUNCS := em_main auth_encrypt
23 #Flags to always run on emcc/em++
24 EMFLAGS :=
25
26 #Import the build system setup
27 include .make/build.mk
28
29 #Directories to be constructed
30 DIRS := $(sort $(dir $(APPDEPS) $(APPTARG)))
31
32 #Targets that don't generate a file
33 .PHONY: $(APPNAME) run push dox doc clean scrub all default
34 #Define default rules to point to APPNAME
35 all default: $(APPTARG)
36
37 #Build the executable
38 $(APPNAME) $(APPTARG): $(DIRS) $(APPDEPS)
39 $(APPC) -o $(APPTARG) $(APPFLAGS) $(APPSRC)
40
41 #create directories
42 $(DIRS):
43 @mkdir -p $@
44
45 #run the game after making it
46 run: $(APPNAME)
47 $(APPTARG)
48
49 #push to github after successful compile
50 push: $(APPTARG)
51 @printf '\nEnter a commit message:\n'; \
52 read CMT; \
53 git commit -am "$$CMT"
54 git push
55
56 dox doc:
57 doxygen dox.conf
58
59 #clean up intermediate dependency files and binaries
60 clean:
61 @echo "Cleaning build targets"
62 rm -f $(APPTARG) $(WEBTARG) $(CTARG)
63
64 #Scrub down to minimal distribution
65 scrub: | clean
66
67 ################## DEFAULTS #####################
68 #cancel default %.o behavior for %.d dependency
69 %.o : %.c
70
71 #Generate and evaluate C dependencies
72 $(foreach base,$(basename $(sort $(strip $(CTARG)))),\
73 $(eval $(strip $(base)$(COBJSUF): $(shell $(subst $BASE,$(base),$(CDEPSCOMMAND)))) $(CDEPS)))
74
75 #new default C build rule
76 %.bc %.o: %.c $(CDEPS)
77 $(CC) $(CXXFLAGS) $(CFLAGS) $< -c -o $@
78
79 #construct list of cp rules for each web item
80 ifdef WEBTARG
81 $(WEBTARG): $(subst $(DISTDIR),$(HTSRCDIR),$(WEBTARG))
82 cp -f $(subst $(DISTDIR),$(HTSRCDIR),$@) $@
83 endif
84
85 #force including rules for making each lib if
86 #we have identified any missing libs
87 #(fail if no rule exists)
88 ifdef MISSINGLIBS
89 include $(foreach lib,$(MISSINGLIBS),.make/lib$(lib).mk)
90 endif
91