BuildSys1
[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 APPSRC := 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 #Targets that don't generate a file
30 .PHONY: $(APPNAME) run push dox doc clean scrub all default
31 #Define default rules to point to APPNAME
32 all default: $(APPTARG)
33
34 #Build the executable
35 $(APPNAME) $(APPTARG): $(APPDEPS) | $(APPDIRS)
36 $(CC) -o $(APPTARG) $(APPFLAGS) $(APPDEPS)
37
38 #create directories
39 $(APPDIRS):
40 @mkdir -p $@
41
42 #run the game after making it
43 run: $(APPNAME)
44 $(APPTARG)
45
46 #push to github after successful compile
47 push: $(APPTARG)
48 @printf '\nEnter a commit message:\n'; \
49 read CMT; \
50 git commit -am "$$CMT"
51 git push
52
53 dox doc:
54 doxygen dox.conf
55
56 #clean up intermediate dependency files and binaries
57 clean:
58 @echo "Cleaning build targets"
59 rm -f $(APPTARG) $(WEBTARG) $(CTARG)
60
61 #Scrub down to minimal distribution
62 scrub: | clean
63
64 ################## DEFAULTS #####################
65 #cancel default %.o behavior for %.d dependency
66 %.o : %.c
67
68 #Generate and evaluate C dependencies
69 $(foreach base,$(basename $(sort $(strip $(CTARG)))),\
70 $(eval $(strip $(base)$(COBJSUF): $(shell $(subst $BASE,$(base),$(CGENDEP))))))
71
72 #new default C build rule
73 %.bc %.o: %.c $(CDEPS)
74 $(CC) $(CXXFLAGS) $(CFLAGS) $< -c -o $@
75
76 #construct list of cp rules for each web item
77 ifdef WEBTARG
78 $(WEBTARG): $(HTMLDIR)/$(filter-out $(EXEDIR),$@)
79 cp -f $< $@
80 endif
81
82 #force including rules for making each lib in this case
83 ifdef MISSINGLIBS
84 include $(foreach lib,$(MISSINGLIBS),.make/lib$(lib).mk)
85 endif
86