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