1 ##################################################
2 #Desc: Mihrtec Standard Makefile
5 ##################################################
6 #Application Information
7 ##################################################
8 #Executable name, also passed as -DAPPNAME to compiler
10 #Directory in which we expect to find main()
12 #Compiler flags for the final executable
14 #Object files statically linked for the executable
16 #Dependencies which must be built before the executable
18 #Directories containing independent tools for GNU
20 ##################################################
22 ##################################################
23 #Functions to export for JS Module
24 EXPORT_FUNCS
:= em_main auth_encrypt
25 #Flags to always run on emcc/em++
28 #Import the build system setup
29 include .make
/build.mk
31 #Directories to be constructed
32 DIRS
:= $(sort $(dir $(APPDEPS
) $(APPTARG
)))
34 #Targets that don't generate a file
35 .PHONY
: $(APPNAME
) run push dox doc
clean scrub
all default
36 #Define default rules to point to APPNAME
37 all default
: $(APPTARG
)
40 $(APPNAME
) $(APPTARG
): $(DIRS
) $(APPDEPS
)
41 $(APPC
) -o
$(APPTARG
) $(APPFLAGS
) $(APPSRC
)
47 #run the game after making it
51 #push to github after successful compile
53 @printf
'\nEnter a commit message:\n'; \
55 git commit
-am
"$$CMT"
61 ################## DEFAULTS #####################
62 #cancel default %.o behavior for %.d dependency
65 #construct list of make rules for tools
67 TOOLTRG
:= $(foreach tool
,$(TOOLS
),$(tool
)/$(tool
))
74 $(TOOLTRG
): $(TOOLOBJ
)
75 $($TCC) $($TFLG) $($TSRC:.c
=.o
) -o
$@
77 #Tools only work on whatever system they're designed for
78 #(typically GNU), so their creation rules are dependent
79 #on each tool (define in .make/.buildtools.mk)
80 $(foreach tool
,$(TOOLS
),$(tool
)/%.o
): $(dir $@
)%.c
81 $($BCC) $(BFLG
) $< -c
-o
$@
83 #Put our toolsrc on the ctarg list for generating deps
84 CTARG
:= $(CTARG
) $(TOOLOBJ
)
87 #Generate and evaluate C dependencies
88 $(foreach base
,$(basename $(sort $(strip $(CTARG
)))),\
89 $(eval
$(strip $(base
)$(COBJSUF
): $(shell $(subst $BASE,$(base
),$(CDEPSCOMMAND
)))) $(CDEPS
)))
91 #new default C build rule
92 %.bc
%.o
: %.c
$(CDEPS
)
93 $(CC
) $(CXXFLAGS
) $(CFLAGS
) $< -c
-o
$@
95 #construct list of cp rules for each web item
97 $(WEBTARG
): $(subst $(DISTDIR
),$(HTSRCDIR
),$(WEBTARG
))
98 cp
-f
$(subst $(DISTDIR
),$(HTSRCDIR
),$@
) $@
101 #force including rules for making each lib if
102 #we have identified any missing libs
103 #(fail if no rule exists)
105 include $(foreach lib
,$(MISSINGLIBS
),.make
/lib
$(lib
).mk
)
108 #include rules for making each app
110 include $(foreach app
,$(APPTARGS
),.make
/app
$(app
).mk
)
113 #clean up intermediate dependency files and binaries
115 @echo
"Cleaning build targets"
116 rm -f
$(APPTARG
) $(WEBTARG
) $(CTARG
)
118 #Scrub down to minimal distribution