build.mk 1.63 KB
Newer Older
1
2
3
4
5
6
7
8
# 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

Jeroen Vreeken's avatar
Jeroen Vreeken committed
9
10
LIBTOOL=libtool

11
12
13
14
15
16
17
OS= $(shell uname -s)
ifneq ($(OS), FreeBSD)
FLEX=flex
else
FLEX=/usr/local/bin/flex
endif

18
%.o : %.c
19
	@echo "LT   CC $<"
20
	@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
21
22

#	@echo "     CC $<"
23
#	@$(CC) -MMD $(CFLAGS) -c $<
24
25

%: %.o
Jeroen Vreeken's avatar
Jeroen Vreeken committed
26
	@echo "     LD $@"
Jeroen Vreeken's avatar
Jeroen Vreeken committed
27
	@${LIBTOOL} --quiet --mode=link --tag=CC $(LINK.o) $(filter %.o,$^) $(LOADLIBS) $(LDLIBS) $($@_LDFLAGS) -o $@
28

Jeroen Vreeken's avatar
Jeroen Vreeken committed
29
30
%.lo: %.c
	@echo "LT   CC $<"
31
	@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
32
33
34
35
36
# compatibility hack: Linux's sed doesn't have a separate argument to '-i',
# while on FreeBSD, '-i' takes a non-optional extension argument. With
# '-i -i' we'll specify '-i' twice on Linux and let FreeBSD use '[filename]-i'
# as intermediate file for in-place editing.
	@sed -e "s:\.libs/::" -e "s:\.o:\.lo:" -i -i .libs/$*.d
37

Jeroen Vreeken's avatar
Jeroen Vreeken committed
38
39
40
41
42
43
44
%.la:
	@echo "LIBTOOL $@"
	@${LIBTOOL} --quiet --mode=link gcc $^ -o $@ $(LDFLAGS) $($@_LDFLAGS) -static-libtool-libs

(%): %
	@echo "   AR  $^ in $@"
	@$(AR) $(ARFLAGS) $@ $^
45

46
%.tab.c %.tab.h: %.y
Jeroen Vreeken's avatar
Jeroen Vreeken committed
47
	@echo "  BISON $<"
Jeroen Vreeken's avatar
Jeroen Vreeken committed
48
	@bison -d $<
49

Jeroen Vreeken's avatar
Jeroen Vreeken committed
50
51
%.yy.c %.yy.h: %.l %.tab.h
	@echo "   FLEX $<"
52
53
	@echo $(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
	@$(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
54
55
56

# il2c: instruction list 2 c 'compiler'
%.c %.h: %.il
Jeroen Vreeken's avatar
Jeroen Vreeken committed
57
	@echo "   IL2C $<"
58
59
60
61
62
63
64
	@$(IL2C) $<

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

Jeroen Vreeken's avatar
Jeroen Vreeken committed
65
-include $(SRCS:.c=.d) $(patsubst %.c,.libs/%.d,$(SRCS))