Move externel dependency flags into global include.

Clean up configure scripts.
This commit is contained in:
Paul Ramsey 2013-01-15 13:53:13 -08:00
parent 8498bd90af
commit 86ec061ccf
5 changed files with 34 additions and 58 deletions

View File

@ -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 ===========================================================================

View File

@ -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:

View File

@ -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

10
makeglobals.mk Normal file
View File

@ -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

View File

@ -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