build.mk 2.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
# Some make rules to make output pretty....

# default ARFLAGS also has 'v', but we don't want it to be verbose.
ARFLAGS= -r

# make sure libs from /usr/local/lib are found
VPATH= /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib

LIBTOOL=libtool

OS= $(shell uname -s)
12
13
HW= $(shell uname -m)

14
15
16
17
18
19
ifneq ($(OS), FreeBSD)
FLEX=flex
else
FLEX=/usr/local/bin/flex
endif

Jeroen Vreeken's avatar
Jeroen Vreeken committed
20
21
22
23
ifdef HOST
CC=${HOST}-gcc
LIBTOOL=${HOST}-libtool
CONF_HOST=--host=${HOST}
24
HW=$(HOST)
25
26
endif

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

%.o : %.c
	@echo "     CC $<"
	@$(CC) -MMD $(CFLAGS) -c $< -o $@

%.o : %.il2c.c
	@echo "LT   CCil $<"
	@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $< -o $@
	@sed -e "s:\.il2c.c:\.il:" -i -i $*.il2c.d

%: %.o
	@echo "     LD $@"
	@${LIBTOOL} --quiet --mode=link --tag=CC $(LINK.o) $(filter %.o,$^) $(LOADLIBS) $(LDLIBS) $($@_LDFLAGS) -o $@

%.lo: %.c
	@echo "LT   CC $<"
	@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $< -o $@
	@cat $(dir $*).libs/$(*F).d | sed -e "s:\.libs/::" -e "s:\.o:\.lo:" > $*.d

%.lo: %.il2c.c
	@echo "LT  ilCC $<"
	@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
	@cat $(dir $*).libs/$(*F).d | sed -e "s:\.libs/::" -e "s:\.o:\.lo:" -e "s:\.il2c.c:\.il:" > $*.d

define LIB_LINK
	@echo "LT   LD $@"
53
	@${LIBTOOL} --quiet --mode=link --tag=CC $(CC) $(filter %.lo,$^) -o $@ $(LDFLAGS) $($@_LDFLAGS) -static-libtool-libs -rpath $(abspath $(@D))
54
55
	@echo "LT INST $@"
	@${LIBTOOL} --quiet --mode=install install $@ $(abspath $(@D))
56
	@sed s\|=$(CURDIR)\|$(CURDIR)\|g -i -i $@
57
58
endef

Jeroen Vreeken's avatar
Jeroen Vreeken committed
59
60
%.so:
	@echo "LT soLD $@"
Jeroen Vreeken's avatar
Jeroen Vreeken committed
61
	@${LIBTOOL}  --quiet --mode=link --tag=CC $(CC) $(filter %.lo,$^) -o $@ $(LDFLAGS) $($@_LDFLAGS)
Jeroen Vreeken's avatar
Jeroen Vreeken committed
62

63
64
65
66
67
68
(%): %
	@echo "   AR  $^ in $@"
	@$(AR) $(ARFLAGS) $@ $^

%.tab.c %.tab.h: %.y
	@echo "BISON   $<"
Jeroen Vreeken's avatar
Jeroen Vreeken committed
69
	@bison --defines=$*.tab.h $< -o $*.tab.c
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

%.yy.c %.yy.h: %.l %.tab.h
	@echo "   FLEX $<"
	@$(FLEX) --header-file=$*.yy.h -o $*.yy.c $<

# il2c: instruction list 2 c 'compiler'
%.il2c.c: %.il
	@echo "   IL2C $<"
	@$(IL2C) $<

# dot -> pdf
%.pdf: %.dot
	@echo "  DOT  $<"
	@dot $< -o $@ -Tpdf