Use std=c++0x for now until Ubuntu has a newer compiler
[planetdump.git] / Makefile
index dc99e18..f1d94af 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,29 @@
-all: UTF8sanitize
+MYSQL_CFLAGS += -g -O2 -Wall
+MYSQL_CFLAGS += $(shell mysql_config --cflags)
 
-UTF8sanitize: UTF8sanitizer.c
-       gcc UTF8sanitizer.c -o UTF8sanitize
+MYSQL_LDFLAGS += $(shell mysql_config --libs)
 
+PGSQL_CFLAGS += $(shell pkg-config --cflags libpqxx)
+PGSQL_LDFLAGS += $(shell pkg-config --libs libpqxx)
+
+.PHONY: all clean
+
+all: planet05 planet06 UTF8Sanitizer planet06_pg
+
+clean:
+       rm -f UTF8Sanitizer planet05 planet06 planet06_pg *.o
+
+planet05: planet05.c keyvals.c
+       $(CC) $(MYSQL_CFLAGS) $(MYSQL_LDFLAGS) -o $@ $^
+
+planet06: planet06.c keyvals.c
+       $(CC) $(MYSQL_CFLAGS) $(MYSQL_LDFLAGS) -o $@ $^
+
+UTF8Sanitizer: UTF8sanitizer.c
+       $(CC) UTF8sanitizer.c -o UTF8Sanitizer
+
+planet06_pg: planet06_pg.o users.o keyvals.o output_osm.o
+       $(CXX) -o $@ $^ $(PGSQL_LDFLAGS)
+
+%.o: %.cpp
+       $(CXX) $(PGSQL_CFLAGS) -std=c++0x -o $@ -c $<