1 ################################################################################
2 # Desc: APC make script
5 ################################################################################
6 # This makefile builds APC, the Asset Package Compiler for Henge, on the system.
7 ################################################################################
11 YCMD
= $(YACC
) $(YFLAGS
) $<
16 RLCMD
= $(RLC
) $(RLFLAGS
) -o
$@
$<
21 CCMD
= $(CC
) $(CFLAGS
) $(CPPFLAGS
) -c
-o
$@
$<
29 LDCMD
= $(LD
) $(LDFLAGS
) $(LDLIBS
) $($1LIBS) -o
$@
$^
31 # APC is built from Ragel, Bison and C source code only.
32 ySRC
:= $(shell find .
/src
-type f
-name
'*.y')
33 rlSRC
:= $(shell find .
/src
-type f
-name
'*.rl')
34 cSRC
:= $(shell find .
/src
-type f
-name
'*.c')
36 # Generated files from Yacc/Bison and Ragel
37 hGEN
:= $(ySRC
:%.y
=%.tab.h
)
38 cGEN
:= $(strip $(ySRC
:%.y
=%.tab.c
) $(rlSRC
:%.rl
=%.c
))
40 # Deps generation function
41 cGENDEP
= $(if
$(wildcard $1),$(subst $(dir $1),,$(filter-out $1 \
%:,$(shell $(CC
) -MM
-MG
$1))),$(info <$1>))
44 DRIVERS
:= apc testapc
45 $(foreach drv
,$(DRIVERS
),\
46 $(eval
$(drv
)SRC
:= $(patsubst %.c
,%.o
,$(filter-out $(patsubst %,src
/%.c
,$(filter-out $(drv
),$(DRIVERS
))),$(cSRC
) $(cGEN
))))\
47 $(eval
$(drv
)-dSRC
:= $(patsubst %.o
,%-d.o
,$($(drv
)SRC
))))
51 $(DRIVERS
:%=%-d
) $(DRIVERS
): $$($$@SRC
) |
$(hGEN
)
52 $(strip $(call LDCMD
,$@
))
54 %-d.o
: CFLAGS
+= -Og
-ggdb
55 %.o
%-d.o
: %.c
$$(call cGENDEP
,$$(dir $$@
)%.c
)
60 mv
$(notdir $(<:%.y
=%.tab.
[ch
])) $(dir $@
)
65 clean: $(wildcard $(cGEN
) $(hGEN
) $(apcSRC
) $(apc-dSRC
))