Makefile: do no link bin/pngtile directly with libpngtile, but rather use -lpngtile and -Rlib; add install target
authorTero Marttila <terom@qmsk.net>
Fri, 03 Oct 2014 22:52:35 +0300
changeset 156 01a05c807e82
parent 155 cda90b8d94b8
child 157 0d8674e64221
Makefile: do no link bin/pngtile directly with libpngtile, but rather use -lpngtile and -Rlib; add install target
Makefile
README
--- a/Makefile	Fri Oct 03 21:34:08 2014 +0300
+++ b/Makefile	Fri Oct 03 22:52:35 2014 +0300
@@ -1,6 +1,8 @@
+PREFIX = opt
+
 # debug
-CFLAGS_DBG = -g
-LDFLAGS_DBG = 
+CFLAGS_DEV = -g
+LDFLAGS_DEV = -Wl,-Rlib
 
 # profile
 CFLAGS_PRF = -g -O2 -pg
@@ -8,30 +10,31 @@
 
 # release
 CFLAGS_REL = -O2
-LDFLAGS_REL =
+LDFLAGS_REL = -Wl,-R${PREFIX}/lib
 
 # preprocessor flags
-CPPFLAGS = -Iinclude -Isrc/
+CPPFLAGS = -Iinclude -Isrc
 CFLAGS = -Wall -std=gnu99 -fPIC -pthread ${CFLAGS_REL}
-LDFLAGS = ${LDFLAGS_ALL} ${LDFLAGS_REL}
-LDLIBS = -lpng -lpthread
+LDFLAGS = -Llib ${LDFLAGS_REL}
+LDLIBS_LIB = -lpng -lpthread
+LDLIBS_BIN = -lpngtile
 
 all: build lib bin lib/libpngtile.so bin/pngtile
 
 # binary deps
-lib/libpngtile.so : \
+lib/libpngtile.so: \
 	build/lib/ctx.o build/lib/image.o build/lib/cache.o build/lib/tile.o build/lib/png.o build/lib/error.o \
 	build/shared/util.o build/shared/log.o
 
-lib/libpngtile.a : \
+lib/libpngtile.a: \
 	build/lib/ctx.o build/lib/image.o build/lib/cache.o build/lib/tile.o build/lib/png.o build/lib/error.o \
 	build/shared/util.o build/shared/log.o
 
-bin/pngtile : \
+bin/pngtile: \
 	build/pngtile/main.o \
 	lib/libpngtile.so build/shared/log.o
 
-bin/pngtile-static : \
+bin/pngtile-static: \
 	build/pngtile/main.o \
 	lib/libpngtile.a
 
@@ -56,19 +59,30 @@
 
 # output libraries
 lib/lib%.so:
-	$(CC) -shared $(LDFLAGS) $+ $(LDLIBS) -o $@
+	$(CC) -shared $(LDFLAGS) $+ $(LDLIBS_LIB) -o $@
 
 lib/lib%.a:
 	$(AR) rc $@ $+
 
 # output binaries
 bin/%:
-	$(CC) $(LDFLAGS) $+ -o $@ $(LDLIBS)
+	$(CC) $(LDFLAGS) $+ -o $@ $(LDLIBS_BIN)
 
 clean:
 	rm -f build/*/*.o build/*/*.d
 	rm -f bin/pngtile bin/pngtile-static lib/*.so lib/*.a
 
+# install
+INSTALL_INCLUDE = include/pngtile.h
+INSTALL_LIB = lib/libpngtile.so
+INSTALL_BIN = bin/pngtile
+
+install: $(INSTALL_INCLUDE) $(INSTALL_LIB) $(INSTALL_BIN)
+	install -d $(PREFIX)/bin $(PREFIX)/lib $(PREFIX)/include
+	install -t $(PREFIX)/include $(INSTALL_INCLUDE)
+	install -t $(PREFIX)/lib $(INSTALL_LIB)
+	install -t $(PREFIX)/bin $(INSTALL_BIN)
+
 # dist builds
 DIST_NAME = pngtile-${shell hg id -i}
 DIST_DEPS = 
@@ -85,5 +99,4 @@
 	tar -C dist -czvf dist/$(DIST_NAME).tar.gz $(DIST_NAME)
 	@echo "*** Output at dist/$(DIST_NAME).tar.gz"
 
-
 .PHONY : dirs clean depend dist-clean dist
--- a/README	Fri Oct 03 21:34:08 2014 +0300
+++ b/README	Fri Oct 03 22:52:35 2014 +0300
@@ -30,19 +30,12 @@
         * libpng12-dev      png.h       1.2.15~beta5-3ubuntu0.1
         * libc6-dev         pthread.h   NPTL 2.7 (glibc 2.7-10ubuntu5)
 
-    To compile dist versions, simply execute
+    To compile:
 
         $ make
 
-    To compile source versions, execute:
-        
-        $ make dirs
-        $ make
-
     The libpngtile.so and pypngtile.so libraries will be placed under lib/, and the 'pngtile' binary under bin/.
 
-    XXX: If compiling the pypngtile.so library with make fails, then `setup.py build_ext -i` should build it.
-
 ## Usage
     Store the .png data files in a directory. You must have write access to the directory when updating the caches,
     which are written as a .cache file alongside the .png file.