author | Tero Marttila <terom@fixme.fi> |
Mon, 28 Dec 2009 20:36:29 +0200 | |
changeset 4 | 49362b34116c |
parent 2 | 05de54150a4c |
child 16 | 6e781cf3d459 |
permissions | -rw-r--r-- |
0 | 1 |
# :set noexpandtab |
2 |
||
3 |
# warnings, and use C99 with GNU extensions |
|
4 |
CFLAGS = -Wall -std=gnu99 -g |
|
5 |
||
6 |
# preprocessor flags |
|
7 |
CPPFLAGS = -Isrc/ |
|
8 |
||
1
f3cde3db1fef
basic image/cache code compiles
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
9 |
# libraries to use |
f3cde3db1fef
basic image/cache code compiles
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
10 |
LOADLIBES = -lpng |
f3cde3db1fef
basic image/cache code compiles
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
11 |
|
0 | 12 |
# output name |
1
f3cde3db1fef
basic image/cache code compiles
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
13 |
DIST_NAME = 78949E-as2 |
0 | 14 |
DIST_RESOURCES = README "Learning Diary.pdf" |
15 |
||
2 | 16 |
all: depend lib/libpngtile.so bin/util |
0 | 17 |
|
1
f3cde3db1fef
basic image/cache code compiles
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
18 |
lib/libpngtile.so : \ |
4
49362b34116c
open cache as .tmp, and rename to .cache when done
Tero Marttila <terom@fixme.fi>
parents:
2
diff
changeset
|
19 |
build/obj/lib/image.o build/obj/lib/cache.o \ |
49362b34116c
open cache as .tmp, and rename to .cache when done
Tero Marttila <terom@fixme.fi>
parents:
2
diff
changeset
|
20 |
build/obj/shared/util.o |
0 | 21 |
|
2 | 22 |
bin/util: \ |
23 |
lib/libpngtile.so \ |
|
24 |
build/obj/shared/log.o |
|
25 |
||
0 | 26 |
SRC_PATHS = $(wildcard src/*/*.c) |
27 |
SRC_NAMES = $(patsubst src/%,%,$(SRC_PATHS)) |
|
28 |
SRC_DIRS = $(dir $(SRC_NAMES)) |
|
29 |
||
30 |
.PHONY : dirs clean depend dist |
|
31 |
||
32 |
dirs: |
|
33 |
mkdir -p bin lib run dist |
|
34 |
mkdir -p $(SRC_DIRS:%=build/deps/%) |
|
35 |
mkdir -p $(SRC_DIRS:%=build/obj/%) |
|
36 |
||
37 |
clean: |
|
38 |
rm -f build/obj/*/*.o build/deps/*/*.d |
|
39 |
rm -f bin/* lib/*.so run/* |
|
40 |
rm -rf dist/* |
|
41 |
||
42 |
# .h dependencies |
|
43 |
depend: $(SRC_NAMES:%.c=build/deps/%.d) |
|
44 |
||
45 |
build/deps/%.d : src/%.c |
|
46 |
@set -e; rm -f $@; \ |
|
47 |
$(CC) -MM -MT __ $(CPPFLAGS) $< > $@.$$$$; \ |
|
48 |
sed 's,__[ :]*,build/obj/$*.o $@ : ,g' < $@.$$$$ > $@; \ |
|
49 |
rm -f $@.$$$$ |
|
50 |
||
51 |
include $(wildcard build/deps/*/*.d) |
|
52 |
||
53 |
# build (potential) library targets with specific cflags |
|
54 |
# XXX: just build everything with -fPIC? |
|
55 |
build/obj/shared/%.o : src/shared/%.c |
|
56 |
$(CC) -c -fPIC $(CPPFLAGS) $(CFLAGS) $< -o $@ |
|
57 |
||
58 |
build/obj/lib/%.o : src/lib/%.c |
|
59 |
$(CC) -c -fPIC $(CPPFLAGS) $(CFLAGS) $< -o $@ |
|
60 |
||
61 |
# general binary objects |
|
62 |
build/obj/%.o : src/%.c |
|
63 |
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
|
64 |
||
65 |
# output binaries |
|
66 |
bin/% : build/obj/%/main.o |
|
67 |
$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@ |
|
68 |
||
69 |
# output libraries |
|
70 |
lib/lib%.so : |
|
71 |
$(CC) -shared $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@ |
|
72 |
||
73 |
dist: |
|
74 |
mkdir -p dist/$(DIST_NAME) |
|
75 |
cp -rv Makefile $(DIST_RESOURCES) src/ dist/$(DIST_NAME)/ |
|
76 |
rm dist/$(DIST_NAME)/src/*/.*.sw[op] |
|
77 |
make -C dist/$(DIST_NAME) dirs |
|
78 |
tar -C dist -czvf dist/$(DIST_NAME).tar.gz $(DIST_NAME) |
|
79 |
@echo "*** Output at dist/$(DIST_NAME).tar.gz" |
|
80 |