50fd45da897f4e0e59ebbce6c0bb13a9eb2ecb37
1 ################################################################################
2 # Desc: APC make script
5 ################################################################################
6 # This makefile builds APC, the Asset Package Compiler for Henge, on the system.
7 ################################################################################
8 # Directories (can override with env vars)
9 APC_ROOTDIR
:= $(if
$(APC_ROOTDIR
),$(APC_ROOTDIR
),.
)
10 APC_SRCDIR
:= $(if
$(APC_SRCDIR
),$(APC_SRCDIR
),$(APC_ROOTDIR
)/src
)
12 # APC is built from Ragel, Bison and C source code only.
13 ySRC
:= $(shell find
$(APC_SRCDIR
) -type f
-name
'*.y')
14 rlSRC
:= $(shell find
$(APC_SRCDIR
) -type f
-name
'*.rl')
15 cSRC
:= $(shell find
$(APC_SRCDIR
) -type f
-name
'*.c')
17 # Specify the linker (allow env var override)
18 LD
:= $(if
$(LD
),$(LD
),ld)
20 # Generated files from Yacc/Bison and Ragel
21 hGEN
:= $(ySRC
:%.y
=%.tab.h
)
22 cGEN
:= $(strip $(ySRC
:%.y
=%.tab.c
) $(rlSRC
:%.rl
=%.c
))
25 apc-d
: $(patsubst %.c
,%-d.o
,$(cSRC
) $(cGEN
)) |
$(hGEN
)
26 $(LD
) $(LDFLAGS
) $(LDLIBS
) $<
28 apc
: $(patsubst %.c
,%.o
,$(cSRC
) $(cGEN
)) |
$(hGEN
)
29 $(LD
) $(LDFLAGS
) $(LDLIBS
) $<
34 cFLAGS
= $(strip $(CFLAGS
) $(CPPFLAGS
) $1 $2 $3 $4 $5 $6 $7 $8 $9)
35 GENDEP
= $(filter-out $1 \
%:,$(shell $(CC
) -MM
-MG
$1))
37 %.o
: %.c
$$(info $$(call GENDEP
,$$(dir $$@
)%.c
))
38 $(CC
) $(call cFLAGS
,-c
,-o
$@
) $<
40 %-d.o
: %.c
$$(info $$@DEPS-
$$(call GENDEP
,$$(dir $$@
)%.c
)) $$(call GENDEP
,$$(dir $$@
)%.c
)
41 $(CC
) $(call cFLAGS
,-c
,-Og
,-ggdb
,-o
$@
) $<