author | Tero Marttila <terom@fixme.fi> |
Thu, 31 Dec 2009 16:40:13 +0200 | |
changeset 19 | ebcc49de97d0 |
parent 18 | f92a24ab046e |
child 27 | e5c5a89d8308 |
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 |
|
16
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
7 |
CPPFLAGS = -Iinclude -Isrc/ |
0 | 8 |
|
1
f3cde3db1fef
basic image/cache code compiles
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
9 |
# libraries to use |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
10 |
LOADLIBES = -lpng -lpthread |
1
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 : \ |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
19 |
build/obj/lib/ctx.o build/obj/lib/image.o build/obj/lib/cache.o build/obj/lib/tile.o build/obj/lib/error.o \ |
16
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
20 |
build/obj/shared/util.o build/obj/shared/log.o |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
21 |
|
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
22 |
lib/pypngtile.so : \ |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
23 |
lib/libpngtile.so |
0 | 24 |
|
2 | 25 |
bin/util: \ |
26 |
lib/libpngtile.so \ |
|
27 |
build/obj/shared/log.o |
|
28 |
||
0 | 29 |
SRC_PATHS = $(wildcard src/*/*.c) |
30 |
SRC_NAMES = $(patsubst src/%,%,$(SRC_PATHS)) |
|
31 |
SRC_DIRS = $(dir $(SRC_NAMES)) |
|
32 |
||
33 |
.PHONY : dirs clean depend dist |
|
34 |
||
35 |
dirs: |
|
36 |
mkdir -p bin lib run dist |
|
37 |
mkdir -p $(SRC_DIRS:%=build/deps/%) |
|
38 |
mkdir -p $(SRC_DIRS:%=build/obj/%) |
|
39 |
||
40 |
clean: |
|
41 |
rm -f build/obj/*/*.o build/deps/*/*.d |
|
42 |
rm -f bin/* lib/*.so run/* |
|
43 |
rm -rf dist/* |
|
44 |
||
45 |
# .h dependencies |
|
46 |
depend: $(SRC_NAMES:%.c=build/deps/%.d) |
|
47 |
||
48 |
build/deps/%.d : src/%.c |
|
49 |
@set -e; rm -f $@; \ |
|
50 |
$(CC) -MM -MT __ $(CPPFLAGS) $< > $@.$$$$; \ |
|
51 |
sed 's,__[ :]*,build/obj/$*.o $@ : ,g' < $@.$$$$ > $@; \ |
|
52 |
rm -f $@.$$$$ |
|
53 |
||
54 |
include $(wildcard build/deps/*/*.d) |
|
55 |
||
56 |
# build (potential) library targets with specific cflags |
|
57 |
# XXX: just build everything with -fPIC? |
|
58 |
build/obj/shared/%.o : src/shared/%.c |
|
59 |
$(CC) -c -fPIC $(CPPFLAGS) $(CFLAGS) $< -o $@ |
|
60 |
||
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
61 |
# XXX: hax in -pthread |
0 | 62 |
build/obj/lib/%.o : src/lib/%.c |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
63 |
$(CC) -c -fPIC -pthread $(CPPFLAGS) $(CFLAGS) $< -o $@ |
0 | 64 |
|
65 |
# general binary objects |
|
66 |
build/obj/%.o : src/%.c |
|
67 |
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
|
68 |
||
69 |
# output binaries |
|
70 |
bin/% : build/obj/%/main.o |
|
71 |
$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@ |
|
72 |
||
73 |
# output libraries |
|
74 |
lib/lib%.so : |
|
75 |
$(CC) -shared $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@ |
|
76 |
||
16
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
77 |
build/pyx/%.c : src/py/%.pyx |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
78 |
cython -o $@ $< |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
79 |
|
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
80 |
build/obj/py/%.o : build/pyx/%.c |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
81 |
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
82 |
|
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
83 |
lib/py%.so : build/obj/py/%.o |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
84 |
$(CC) -shared $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@ |
6e781cf3d459
move public headers to include/, python stuff to python/ sub-dir
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
85 |
|
0 | 86 |
dist: |
87 |
mkdir -p dist/$(DIST_NAME) |
|
88 |
cp -rv Makefile $(DIST_RESOURCES) src/ dist/$(DIST_NAME)/ |
|
89 |
rm dist/$(DIST_NAME)/src/*/.*.sw[op] |
|
90 |
make -C dist/$(DIST_NAME) dirs |
|
91 |
tar -C dist -czvf dist/$(DIST_NAME).tar.gz $(DIST_NAME) |
|
92 |
@echo "*** Output at dist/$(DIST_NAME).tar.gz" |
|
93 |