comparison Makefile @ 0:2c24602be78f

Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
author lost@l-w.ca
date Wed, 19 Jan 2011 22:27:17 -0700
parents
children 96c4dc89016e
comparison
equal deleted inserted replaced
-1:000000000000 0:2c24602be78f
1 CC := gcc
2
3 CPPFLAGS += -I lwlib -DPACKAGE_STRING='"lwtools 4.0-pre"' -DPACKAGE_BUGREPORT='"lost@l-w.ca"'
4
5 LDFLAGS += -L$(PWD)/lwlib -llw
6
7 MAIN_TARGETS := lwasm/lwasm lwlink/lwlink lwar/lwar
8
9 .PHONY: all
10 all: $(MAIN_TARGETS)
11
12 subdirs := lwasm lwlink lwar lwlib
13
14 -include $(subdirs:=/rules.make)
15
16 lwasm_objs := $(lwasm_srcs:.c=.o)
17 lwlink_objs := $(lwlink_srcs:.c=.o)
18 lwar_objs := $(lwar_srcs:.c=.o)
19 lwlib_objs := $(lwlib_srcs:.c=.o)
20
21 lwasm_deps := $(lwasm_srcs:.c=.d)
22 lwlink_deps := $(lwlink_srcs:.c=.d)
23 lwar_deps := $(lwar_srcs:.c=.d)
24 lwlib_deps := $(lwlib_srcs:.c=.d)
25 lwobjdump_deps := $(lwobjdump_srcs:.c=.d)
26
27 ,PHONY: lwlink lwasm lwar
28 lwlink: lwlink/lwlink
29 lwasm: lwasm/lwasm
30 lwar: lwar/lwar
31 lwobjdump: lwlink/lwobjdump
32
33 lwasm/lwasm: $(lwasm_objs) lwlib
34 $(CC) -o $@ $(lwasm_objs) $(LDFLAGS)
35
36 lwlink/lwlink: $(lwlink_objs)
37 $(CC) -o $@ $(lwlink_objs)
38
39 lwlink/lwobjdump: $(lwobjdump_objs)
40 $(CC) -o $@ $(lwobjdump_objs)
41
42 lwar/lwar: $(lwar_objs)
43 $(CC) -o $@ $(lwar_objs)
44
45
46 .phony: lwlib
47 lwlib: lwlib/liblw.a
48
49 lwlib/liblw.a: $(lwlib_objs)
50 $(AR) rc $@ $^
51
52 %.d: %.c
53 @echo "Building dependencies for $@"
54 @$(CC) -MM $(CPPFLAGS) -o $*.d $<
55 @mv -f $*.d $*.d.tmp
56 @sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d
57 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
58 @rm -f $*.d.tmp
59
60 -include $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) $(lwobjdump_deps)
61
62 extra_clean := $(extra_clean) *~ */*~
63
64 .PHONY: clean
65 clean:
66 rm -f $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) $(lwobjdump_deps)
67 rm -f lwlib/liblw.a lwasm/lwasm lwlink/lwlink lwlink/lwobjdump lwar/lwar
68 rm -f $(lwasm_objs) $(lwlink_objs) $(lwar_objs) $(lwlib_objs) $(lwobjdump_objs)
69 rm -f $(extra_clean)
70