From 86ec061ccf7a788b1fafdb79147fbea8bea207f0 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 15 Jan 2013 13:53:13 -0800 Subject: [PATCH] Move externel dependency flags into global include. Clean up configure scripts. --- configure.ac | 23 +++++++++-------------- libpc/Makefile | 18 ++++++------------ libpc/cunit/Makefile | 37 ++++++------------------------------- makeglobals.mk | 10 ++++++++++ postgis/Makefile | 4 +++- 5 files changed, 34 insertions(+), 58 deletions(-) create mode 100644 makeglobals.mk diff --git a/configure.ac b/configure.ac index 134b3cb..2851c2a 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,6 @@ dnl * Copyright (c) 2012, OpenGeo dnl * dnl ***********************************************************************/ - AC_INIT() AC_CONFIG_MACRO_DIR([macros]) @@ -17,7 +16,7 @@ dnl AC_PROG_CC dnl -dnl Define executable suffix for use with the loader Makefiles +dnl Define executable suffix to use for utility programs dnl EXESUFFIX="$ac_cv_exeext" AC_SUBST([EXESUFFIX]) @@ -25,7 +24,6 @@ AC_SUBST([EXESUFFIX]) dnl dnl Search for flex/bison to build the parser dnl - AC_PROG_LEX AC_PROG_YACC AC_SUBST([LEX]) @@ -33,21 +31,20 @@ AC_SUBST([YACC]) dnl =========================================================================== -dnl Detect CUnit if it is installed (used for unit testing) -dnl -dnl Note that we pass any specified CPPFLAGS and LDFLAGS into the Makefile -dnl as CUnit is the only compile-time dependency that cannot obtain any -dnl specialised flags using a --with-X parameter, and so we allow this -dnl information to be passed in if required. +dnl Detect CUnit if it is installed dnl =========================================================================== CUNIT_LDFLAGS="" AC_CHECK_HEADER([CUnit/CUnit.h], [ CUNIT_CPPFLAGS="$CPPFLAGS" - AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], [AC_MSG_WARN([could not locate CUnit required for unit tests])]) + AC_CHECK_LIB([cunit], + [CU_initialize_registry], + [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], + [AC_MSG_ERROR([could not locate CUnit required for unit tests])] + ) ], [ - AC_MSG_WARN([could not locate CUnit required for unit tests]) + AC_MSG_ERROR([could not locate CUnit required for unit tests]) ]) AC_SUBST([CUNIT_CPPFLAGS]) @@ -98,7 +95,6 @@ fi AC_SUBST([PGXS]) - dnl Extract the version information from pg_config dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give dnl the final version. This is to guard against user error... @@ -237,7 +233,7 @@ AC_SUBST([PROJ_CPPFLAGS]) AC_SUBST([PROJ_LDFLAGS]) dnl Ensure that we are using PROJ >= 4.6.0 (requires pj_set_searchpath) -if test ! "$PROJ_VERSION" -ge 46; then +if test ! "$PC_PROJ_VERSION" -ge 46; then AC_MSG_ERROR([PointCloud requires PROJ >= 4.6.0]) fi @@ -250,7 +246,6 @@ AC_CHECK_LIB([proj], [pj_get_release], []) LIBS="$LIBS_SAVE" - dnl =========================================================================== dnl Output the relevant files dnl =========================================================================== diff --git a/libpc/Makefile b/libpc/Makefile index 9bc4a87..6b87e0c 100644 --- a/libpc/Makefile +++ b/libpc/Makefile @@ -1,12 +1,8 @@ -CC = gcc -CFLAGS = -g -O0 +include ../makeglobals.mk -XML_CPPFLAGS = -I/opt/local/include/libxml2 -XML_LDFLAGS = -lxml2 - -CPPFLAGS = $(XML_CPPFLAGS) -LDFLAGS = $(XML_LDFLAGS) +CPPFLAGS = $(XML2_CPPFLAGS) +LDFLAGS = $(XML2_LDFLAGS) OBJS = \ pc_core.o \ @@ -17,16 +13,14 @@ OBJS = \ stringbuffer.o \ hashtable.o -LIB = libpc.a - -all: $(LIB) +all: $(LIBPC_A) $(MAKE) -C cunit $@ -$(LIB): $(OBJS) +$(LIBPC_A): $(OBJS) ar rs $@ $^ clean: - @rm -f $(OBJS) $(LIB) + @rm -f $(OBJS) $(LIBPC_A) $(MAKE) -C cunit $@ check: diff --git a/libpc/cunit/Makefile b/libpc/cunit/Makefile index 9c4f89c..20dc332 100644 --- a/libpc/cunit/Makefile +++ b/libpc/cunit/Makefile @@ -1,16 +1,9 @@ -PC_CPPFLAGS = -I../ -PC_LIB = ../libpc.a +include ../../makeglobals.mk -XML2_CPPFLAGS = -I/opt/local/include/libxml2 -XML2_LDFLAGS = -lxml2 +LIBPC = ../$(LIBPC_A) -CUNIT_CPPFLAGS = -I/usr/local/include -CUNIT_LDFLAGS = -L/usr/local/lib -lcunit - -CC = gcc -CFLAGS = -g -O0 -CPPFLAGS = $(PC_CPPFLAGS) $(XML2_CPPFLAGS) $(CUNIT_CPPFLAGS) +CPPFLAGS = $(XML2_CPPFLAGS) $(CUNIT_CPPFLAGS) -I.. LDFLAGS = $(XML2_LDFLAGS) $(CUNIT_LDFLAGS) EXE = cu_tester @@ -20,12 +13,6 @@ OBJS = \ cu_tester.o \ cu_pc_schema.o -# If we couldn't find the cunit library then display a helpful message -ifeq ($(CUNIT_LDFLAGS),) -all: requirements_not_met_cunit -check: requirements_not_met_cunit -else - # Build the unit tester all: $(EXE) @@ -33,26 +20,14 @@ all: $(EXE) check: $(EXE) @./$(EXE) -endif - # Build the main unit test executable -$(EXE): $(OBJS) $(PC_LIB) +$(EXE): $(OBJS) $(LIBPC) $(CC) $(LDFLAGS) -o $@ $^ -$(PC_LIB): - $(MAKE) -C .. libpc.a +$(LIBPC): + $(MAKE) -C .. $(LIBPC_A) # Clean target clean: @rm -f $(OBJS) @rm -f $(EXE) - - -# Requirements message -requirements_not_met_cunit: - @echo - @echo "WARNING:" - @echo - @echo "configure was unable to find CUnit which is required for unit testing." - @echo "In order to enable unit testing, you must install CUnit and then re-run configure." - @echo diff --git a/makeglobals.mk b/makeglobals.mk new file mode 100644 index 0000000..03dc08a --- /dev/null +++ b/makeglobals.mk @@ -0,0 +1,10 @@ +CC = gcc +CFLAGS = -g -O0 + +XML2_CPPFLAGS = -I/opt/local/include/libxml2 +XML2_LDFLAGS = -lxml2 + +CUNIT_CPPFLAGS = -I/usr/local/include +CUNIT_LDFLAGS = -L/usr/local/lib -lcunit + +LIBPC_A = libpc.a \ No newline at end of file diff --git a/postgis/Makefile b/postgis/Makefile index 8f3a893..dffdd4a 100644 --- a/postgis/Makefile +++ b/postgis/Makefile @@ -1,5 +1,7 @@ # pointcloud +include ../makeglobals.mk + MODULE_big = pointcloud OBJS = \ pc_functions.o @@ -9,7 +11,7 @@ DATA = pointcloud--1.0.sql REGRESS = pointcloud -SHLIB_LINK += $(filter -lm, $(LIBS)) ../libpc/libpc.a +SHLIB_LINK += $(filter -lm, $(LIBS)) ../libpc/$(LIBPC_A) # We are going to use PGXS for sure PG_CONFIG = pg_config