From 809e43483fe31bd05cdcac4d7b749ac1dfa615f6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 4 May 2007 10:39:02 +0000 Subject: [PATCH] Put Autotools-generated files into subdirectory config/; add macro files used from PostgreSQL there so you don't need a PostgreSQL source tree to bootstrap the code. --- Makefile.am | 12 ++-- config/general.m4 | 152 ++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + 3 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 config/general.m4 diff --git a/Makefile.am b/Makefile.am index b393aa5..fd7b814 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,11 +2,13 @@ # # Makefile.am for psqlodbc30w (PostgreSQL ODBC driver) # -# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Makefile.am,v 1.43 2007/04/24 19:54:11 h-saito Exp $ +# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Makefile.am,v 1.44 2007/05/04 10:39:01 petere Exp $ # #------------------------------------------------------------------------- -AUTOMAKE_OPTIONS = 1.6 foreign +AUTOMAKE_OPTIONS = 1.8 foreign + +ACLOCAL_AMFLAGS = -I config if enable_unicode lib_LTLIBRARIES = psqlodbcw.la @@ -63,6 +65,6 @@ EXTRA_DIST = license.txt readme.txt \ MAINTAINERCLEANFILES = \ - Makefile.in config.guess config.h.in config.sub configure \ - install-sh missing mkinstalldirs aclocal.m4 ltmain.sh \ - libtool.m4 depcomp + Makefile.in config/config.guess config.h.in config/config.sub configure \ + config/install-sh config/missing aclocal.m4 config/ltmain.sh \ + config/depcomp diff --git a/config/general.m4 b/config/general.m4 new file mode 100644 index 0000000..84495e2 --- /dev/null +++ b/config/general.m4 @@ -0,0 +1,152 @@ +# $PostgreSQL: pgsql/config/general.m4,v 1.9 2006/11/30 22:21:23 tgl Exp $ + +# This file defines new macros to process configure command line +# arguments, to replace the brain-dead AC_ARG_WITH and AC_ARG_ENABLE. +# The flaw in these is particularly that they only differentiate +# between "given" and "not given" and do not provide enough help to +# process arguments that only accept "yes/no", that require an +# argument (other than "yes/no"), etc. +# +# The point of this implementation is to reduce code size and +# redundancy in configure.in and to improve robustness and consistency +# in the option evaluation code. + + +# Convert type and name to shell variable name (e.g., "enable_long_strings") +m4_define([pgac_arg_to_variable], + [$1[]_[]patsubst($2, -, _)]) + + +# PGAC_ARG(TYPE, NAME, HELP-STRING, +# [ACTION-IF-YES], [ACTION-IF-NO], [ACTION-IF-ARG], +# [ACTION-IF-OMITTED]) +# ---------------------------------------------------------- +# This is the base layer. TYPE is either "with" or "enable", depending +# on what you like. NAME is the rest of the option name, HELP-STRING +# as usual. ACTION-IF-YES is executed if the option is given without +# an argument (or "yes", which is the same); similar for ACTION-IF-NO. + +AC_DEFUN([PGAC_ARG], +[ +pgac_args="$pgac_args pgac_arg_to_variable([$1],[$2])" +m4_case([$1], + +enable, [ +AC_ARG_ENABLE([$2], [$3], [ + case [$]enableval in + yes) + m4_default([$4], :) + ;; + no) + m4_default([$5], :) + ;; + *) + $6 + ;; + esac +], +[$7])[]dnl AC_ARG_ENABLE +], + +with, [ +AC_ARG_WITH([$2], [$3], [ + case [$]withval in + yes) + m4_default([$4], :) + ;; + no) + m4_default([$5], :) + ;; + *) + $6 + ;; + esac +], +[$7])[]dnl AC_ARG_WITH +], + +[m4_fatal([first argument of $0 must be 'enable' or 'with', not '$1'])] +) +])# PGAC_ARG + +# PGAC_ARG_CHECK() +# ---------------- +# Checks if the user passed any --with/without/enable/disable +# arguments that were not defined. Just prints out a warning message, +# so this should be called near the end, so the user will see it. + +AC_DEFUN([PGAC_ARG_CHECK], +[for pgac_var in `set | sed 's/=.*//' | $EGREP 'with_|enable_'`; do + for pgac_arg in $pgac_args with_gnu_ld; do + if test "$pgac_var" = "$pgac_arg"; then + continue 2 + fi + done + pgac_txt=`echo $pgac_var | sed 's/_/-/g'` + AC_MSG_WARN([option ignored: --$pgac_txt]) +done])# PGAC_ARG_CHECK + +# PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING, +# [ACTION-IF-YES], [ACTION-IF-NO]) +# ----------------------------------------------- +# Accept a boolean option, that is, one that only takes yes or no. +# ("no" is equivalent to "disable" or "without"). DEFAULT is what +# should be done if the option is omitted; it should be "yes" or "no". +# (Consequently, one of ACTION-IF-YES and ACTION-IF-NO will always +# execute.) + +AC_DEFUN([PGAC_ARG_BOOL], +[PGAC_ARG([$1], [$2], [$4], [$5], [$6], + [AC_MSG_ERROR([no argument expected for --$1-$2 option])], + [m4_case([$3], + yes, [pgac_arg_to_variable([$1], [$2])=yes +$5], + no, [pgac_arg_to_variable([$1], [$2])=no +$6], + [m4_fatal([third argument of $0 must be 'yes' or 'no', not '$3'])])])[]dnl +])# PGAC_ARG_BOOL + + +# PGAC_ARG_REQ(TYPE, NAME, HELP-STRING, [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN]) +# ------------------------------------------------------------------------------- +# This option will require an argument; "yes" or "no" will not be +# accepted. + +AC_DEFUN([PGAC_ARG_REQ], +[PGAC_ARG([$1], [$2], [$3], + [AC_MSG_ERROR([argument required for --$1-$2 option])], + [AC_MSG_ERROR([argument required for --$1-$2 option])], + [$4], + [$5])])# PGAC_ARG_REQ + + +# PGAC_ARG_OPTARG(TYPE, NAME, HELP-STRING, [DEFAULT-ACTION], [ARG-ACTION] +# [ACTION-ENABLED], [ACTION-DISABLED]) +# ----------------------------------------------------------------------- +# This will create an option that behaves as follows: If omitted, or +# called with "no", then set the enable_variable to "no" and do +# nothing else. If called with "yes", then execute DEFAULT-ACTION. If +# called with argument, set enable_variable to "yes" and execute +# ARG-ACTION. Additionally, execute ACTION-ENABLED if we ended up with +# "yes" either way, else ACTION-DISABLED. +# +# The intent is to allow enabling a feature, and optionally pass an +# additional piece of information. + +AC_DEFUN([PGAC_ARG_OPTARG], +[PGAC_ARG([$1], [$2], [$3], [$4], [], + [pgac_arg_to_variable([$1], [$2])=yes +$5], + [pgac_arg_to_variable([$1], [$2])=no]) +dnl Add this code only if there's a ACTION-ENABLED or ACTION-DISABLED. +m4_ifval([$6[]$7], +[ +if test "[$]pgac_arg_to_variable([$1], [$2])" = yes; then + m4_default([$6], :) +m4_ifval([$7], +[else + $7 +])[]dnl +fi +])[]dnl +])# PGAC_ARG_OPTARG diff --git a/configure.ac b/configure.ac index e82ca23..71036b8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(psqlodbc, 08.02.0400, [pgsql-odbc@postgresql.org]) AC_PREREQ(2.57) +AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([bind.c]) AM_CONFIG_HEADER([config.h]) -- 2.39.5