sql/ticker: make pgqd compile & install without PGXS
authorMarko Kreen <markokr@gmail.com>
Mon, 13 Apr 2009 12:42:38 +0000 (15:42 +0300)
committerMarko Kreen <markokr@gmail.com>
Mon, 13 Apr 2009 12:42:38 +0000 (15:42 +0300)
PGXS used Postgres prefix, but we want executables to use
skytools prefix.

This needed also C compilation support from autoconf.
Lift it from pgbouncer.

config.mak.in
configure.ac
sql/Makefile
sql/ticker/Makefile

index cb751d3dcd33dbe7e808585522f7e84b9b0494b9..bc7f41ce0c32d2cf3896d0828e2a8ace081468d2 100644 (file)
@@ -1,14 +1,16 @@
 
 prefix = @prefix@
 datarootdir = @datarootdir@
+exec_prefix = @exec_prefix@
+datadir = @datadir@
 docdir = @docdir@
 mandir = @mandir@
+bindir = @bindir@
 
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 
-
 override PYTHON = @PYTHON@
 override PG_CONFIG = @PG_CONFIG@
 
@@ -24,3 +26,13 @@ DESTDIR =
 ASCIIDOC = @ASCIIDOC@
 XMLTO = @XMLTO@
 
+CC = @CC@
+CPPFLAGS = @CPPFLAGS@
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+
+INSTALL = @INSTALL@
+BININSTALL = @BININSTALL@
+
+
index 6e338059c61f3ee3f9ea681f7ef6706229dade05..04fcd72cefa1f963cfc887cf51d615d2d0d9c231 100644 (file)
@@ -72,6 +72,41 @@ else
   XMLTO="no"
 fi
 
+AC_PROG_CC
+AC_PROG_CPP
+
+# autoconf does not want to find 'install', if not using automake...
+INSTALL=install
+
+dnl Check if linker supports -Wl,--as-needed
+dnl That helps to get rid of unnecessary -lrt
+if test "$GCC" = "yes"; then
+  old_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS -Wl,--as-needed"
+  AC_MSG_CHECKING([whether linker supports --as-needed])
+  AC_LINK_IFELSE([int main(void) { return 0; }],
+    [AC_MSG_RESULT([yes])],
+    [AC_MSG_RESULT([no])
+     LDFLAGS="$old_LDFLAGS"])
+fi
+
+dnl debault to debugging on
+AC_ARG_ENABLE(debug,
+  AC_HELP_STRING([--disable-debug],[strip binary]),
+  [], [enable_debug=yes])
+AC_MSG_CHECKING([whether to build debug binary])
+AC_MSG_RESULT([$enable_debug])
+if test "$enable_debug" = "yes"; then
+  LDFLAGS="-g $LDFLAGS"
+  BININSTALL="$INSTALL"
+else
+  BININSTALL="$INSTALL -s"
+fi
+AC_SUBST(enable_debug)
+AC_SUBST(INSTALL)
+AC_SUBST(BININSTALL)
+
+
 dnl Postres headers on Solaris define incompat unsetenv without that
 AC_CHECK_FUNCS(unsetenv)
 
index d7241e8d28ed98c0929993901a1c0df5d6e26a52..97454691b0fe5551eedf32f8e0975c8a335632b7 100644 (file)
@@ -1,7 +1,7 @@
 
 include ../config.mak
 
-SUBDIRS = londiste pgq pgq_coop pgq_ext pgq_node txid
+SUBDIRS = londiste pgq pgq_coop pgq_ext pgq_node ticker txid
 
 all install clean distclean installcheck:
        for dir in $(SUBDIRS); do \
index 5b739879f91029b58ff6b0649711ee6a10d3a878..c4cb6197121f4148b73eef0882d325f654c413fa 100644 (file)
@@ -12,16 +12,37 @@ PROGRAM = pgqd
 SRCS = connection.c pgqd.c maint.c ticker.c retry.c
 HDRS = connection.h pgqd.h $(USUAL_HDRS)
 
+PG_INCDIR = $(shell $(PG_CONFIG) --includedir)
+PG_LIBDIR = $(shell $(PG_CONFIG) --libdir)
+PG_CPPFLAGS = -I$(PG_INCDIR)
+PG_LDFLAGS = -L$(PG_LIBDIR)
+PG_LIBS = -lpq -lm
+
 OBJS = $(SRCS:.c=.o) $(USUAL_OBJS)
-PG_CPPFLAGS = -I$(libpq_srcdir) $(USUAL_CPPFLAGS)
-PG_LIBS = $(libpq_pgport)
 
-include $(PGXS)
+CPPFLAGS += $(USUAL_CPPFLAGS) $(PG_CPPFLAGS)
+LDFLAGS += $(PG_LDFLAGS)
+LIBS += $(PG_LIBS)
+
+all: $(PROGRAM)
 
-LIBS := $(filter-out -lreadline -ldl -lz, $(LIBS))
+$(PROGRAM): $(OBJS)
+       $(CC) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
 
 $(OBJS): $(HDRS)
 
 %.o: $(USUAL_DIR)/usual/%.c $(USUAL_HDRS)
-       $(CC) -c -o $@ $< $(DEFS) $(CPPFLAGS) $(CFLAGS)
+       $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c -o $@ $<
+
+install: all
+       mkdir -p '$(DESTDIR)$(bindir)'
+       $(BININSTALL) -m 755 pgqd$(X) '$(DESTDIR)$(bindir)/pgqd'
+       mkdir -p '$(DESTDIR)$(docdir)/conf'
+       $(INSTALL) -m 644 pgqd.ini '$(DESTDIR)$(docdir)/conf/pgqd.ini.templ'
+
+clean:
+       rm -f $(PROGRAM) $(OBJS)
+
+distclean: clean
+installcheck: