summaryrefslogtreecommitdiff
path: root/util/sconfig/Makefile.inc
blob: 54207ebd1687f0e7a727ac26222aa9c13a7237d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
sconfigobj :=
sconfigobj += lex.yy.o
sconfigobj += sconfig.tab.o

$(obj)/util/sconfig:
	mkdir -p $@

$(obj)/util/sconfig/%.o: $(obj)/util/sconfig/%.c
	printf "    HOSTCC     $(subst $(obj)/,,$(@))\n"
	$(HOSTCC) $(SCONFIGFLAGS) $(HOSTCFLAGS) -c -o $@ $<

ifdef SCONFIG_GENPARSER
$(top)/util/sconfig/lex.yy.c_shipped: $(top)/util/sconfig/sconfig.l
	flex -o $@ $<

# the .c rule also creates .h
$(top)/util/sconfig/sconfig.tab.h_shipped: $(top)/util/sconfig/sconfig.tab.c_shipped
$(top)/util/sconfig/sconfig.tab.c_shipped: $(top)/util/sconfig/sconfig.y
	bison --defines=$(top)/util/sconfig/sconfig.tab.h_shipped -o $@ $<

endif

$(obj)/util/sconfig/lex.yy.o: $(obj)/util/sconfig/sconfig.tab.h

$(obj)/util/sconfig/%: $(top)/util/sconfig/%_shipped
	cp $< $@

$(obj)/util/sconfig/sconfig: $(obj)/util/sconfig $(addprefix $(obj)/util/sconfig/,$(sconfigobj))
	printf "    HOSTCXX    $(subst $(obj)/,,$(@)) (link)\n"
	$(HOSTCXX) $(SCONFIGFLAGS) -o $@ $(addprefix $(obj)/util/sconfig/,$(sconfigobj))