1 ##################################################
2 #Desc: C Compiler Setup
5 ##################################################
6 #Included from ./build.mk
7 #Defines variables used in the make process to
8 #compile C files either to native bc through gcc,
9 #or web through emscripten
10 ##################################################
11 #Manually defined resources
12 ##################################################
13 #Libraries to link for the build
14 CLIBS
:= wolfssl SDL2 SDL2_image SDL2_ttf
15 #Modules for C (directories in src/ with C code)
16 CMODULES
:= $(APPMODULE
)
21 ##################################################
22 #Allow compiler-specific and OS-specific
23 #makefiles to override C environment vars
24 ##################################################
25 -include .make
/buildc_
$(strip $(notdir $(CC
))).mk
27 -include .make
/buildc_
$(strip $(OS
)).mk
30 #Link each CLIB with -l
31 CFLAGS
+= $(patsubst %,-l
%,$(CLIBS
))
32 #Include each module's root directory and .
33 CFLAGS
+= $(patsubst %,-I
%, $(CMODULES
)) -I.
34 #C Preprocessor defines
35 CFLAGS
+= -DAPPNAME
=$(APPNAME
)
37 ##################################################
38 #Conditional (may be set in buildc_*.mk files)
39 ##################################################
40 #Sources are found in any CMODULE subdir
41 CSRC ?
= $(wildcard $(patsubst %,%/*.c
,$(CMODULES
)))
45 CARCH ?
= $(shell uname
-m
)
48 #C binary distribution directory
49 CDISTDIR ?
= $(DISTDIR
)
50 #Directory for C binary/executable output files
51 CBINDIR ?
= $(CDISTDIR
)/bin
52 #Set up the final C build targets
53 CTARG ?
= $(CSRC
:.c
=$(COBJSUF
))
55 #Set of shell functions used to determine dependencies
56 #for building each c source file
57 #$BASE is a keyword replaced in the main Makefile iteratively
58 #for each source file.
59 CDPIPE ?
= $(strip $(CC
)) -MM
-MG
$(CXXFLAXS
) $(CFLAGS
) $BASE.c
60 CDSED ?
= sed
-e
's@^.*\.o:@@'
62 #The shell command to execute and evaluate for deps
63 CDEPSCOMMAND ?
= $(CDPIPE
) |
$(CDSED
) |
$(CDTR
)
65 #Set of shell functions used to determine the
66 #name of each library the compiler/LD can't find
67 LDPIPE ?
= $(CC
) $(patsubst %,-l
%,$(CLIBS
)) 2>&1 >/dev
/null
68 LDGREP ?
= grep
"cannot find"
69 LDSED ?
= sed
-e
's@^.*cannot find -l\([a-zA-Z0-9\.]*\).*@\1@g'
70 #Calculate missing libs
71 MISSINGLIBS ?
= $(strip $(shell $(LDPIPE
) |
$(LDGREP
) |
$(LDSED
)))
73 #Include handler for building missing libs, if any
75 include .make
/buildclibs.mk