1
dnl @synopsis AC_CREATE_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])]
3
dnl this is a new variant from ac_prefix_config_
4
dnl this one will use a lowercase-prefix if
5
dnl the config-define was starting with a lowercase-char, e.g.
6
dnl #define const or #define restrict or #define off_t
7
dnl (and this one can live in another directory, e.g. testpkg/config.h
8
dnl therefore I decided to move the output-header to be the first arg)
10
dnl takes the usual config.h generated header file; looks for each of
11
dnl the generated "#define SOMEDEF" lines, and prefixes the defined name
12
dnl (ie. makes it "#define PREFIX_SOMEDEF". The result is written to
13
dnl the output config.header file. The PREFIX is converted to uppercase
14
dnl for the conversions.
16
dnl default OUTPUT-HEADER = $PACKAGE-config.h
17
dnl default PREFIX = $PACKAGE
18
dnl default ORIG-HEADER, derived from OUTPUT-HEADER
19
dnl if OUTPUT-HEADER has a "/", use the basename
20
dnl if OUTPUT-HEADER has a "-", use the section after it.
21
dnl otherwise, just config.h
23
dnl In most cases, the configure.in will contain a line saying
24
dnl AC_CONFIG_HEADER(config.h)
25
dnl somewhere *before* AC_OUTPUT and a simple line saying
26
dnl AC_PREFIX_CONFIG_HEADER
27
dnl somewhere *after* AC_OUTPUT.
30
dnl AC_INIT(config.h.in) # config.h.in as created by "autoheader"
31
dnl AM_INIT_AUTOMAKE(testpkg, 0.1.1) # "#undef VERSION" and "PACKAGE"
32
dnl AM_CONFIG_HEADER(config.h) # in config.h.in
33
dnl AC_MEMORY_H # "#undef NEED_MEMORY_H"
34
dnl AC_C_CONST_H # "#undef const"
35
dnl AC_OUTPUT(Makefile) # creates the "config.h" now
36
dnl AC_CREATE_PREFIX_CONFIG_H # creates "testpkg-config.h"
37
dnl and the resulting "testpkg-config.h" contains lines like
38
dnl #ifndef TESTPKG_VERSION
39
dnl #define TESTPKG_VERSION "0.1.1"
41
dnl #ifndef TESTPKG_NEED_MEMORY_H
42
dnl #define TESTPKG_NEED_MEMORY_H 1
44
dnl #ifndef _testpkg_const
45
dnl #define _testpkg_const const
48
dnl and this "testpkg-config.h" can be installed along with other
49
dnl header-files, which is most convenient when creating a shared
50
dnl library (that has some headers) where some functionality is
51
dnl dependent on the OS-features detected at compile-time. No
52
dnl need to invent some "testpkg-confdefs.h.in" manually. :-)
54
dnl @version $Id: AC_CREATE_PREFIX_CONFIG_H.m4,v 1.5 2002/07/30 23:09:22 bastiaan Exp $
55
dnl @author Guido Draheim <guidod@gmx.de>
57
AC_DEFUN([AC_CREATE_PREFIX_CONFIG_H],
59
ac_prefix_conf_OUT=`echo ifelse($1, , ${PACKAGE_TARNAME}-config.h, $1)`
60
ac_prefix_conf_DEF=`echo _$ac_prefix_conf_OUT | sed -e 'y:abcdefghijklmnopqrstuvwxyz./,-:ABCDEFGHIJKLMNOPQRSTUVWXYZ____:'`
61
ac_prefix_conf_PKG=`echo ifelse($2, , ${PACKAGE_TARNAME}, $2)`
62
ac_prefix_conf_LOW=`echo _$ac_prefix_conf_PKG | sed -e 'y:ABCDEFGHIJKLMNOPQRSTUVWXYZ-:abcdefghijklmnopqrstuvwxyz_:'`
63
ac_prefix_conf_UPP=`echo $ac_prefix_conf_PKG | sed -e 'y:abcdefghijklmnopqrstuvwxyz-:ABCDEFGHIJKLMNOPQRSTUVWXYZ_:' -e '/^[0-9]/s/^/_/'`
64
ac_prefix_conf_INP=`echo ifelse($3, , _, $3)`
65
if test "$ac_prefix_conf_INP" = "_"; then
66
case $ac_prefix_conf_OUT in
67
*/*) ac_prefix_conf_INP=`basename $ac_prefix_conf_OUT`
69
*-*) ac_prefix_conf_INP=`echo $ac_prefix_conf_OUT | sed -e 's/[a-zA-Z0-9_]*-//'`
71
*) ac_prefix_conf_INP=config.h
76
if test -z "$ac_prefix_conf_PKG" ; then
77
AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H])
79
AC_MSG_RESULT(creating $ac_prefix_conf_OUT - prefix $ac_prefix_conf_UPP for $ac_prefix_conf_INP defines)
80
if test -f $ac_prefix_conf_INP ; then
81
AS_DIRNAME([/* automatically generated */], $ac_prefix_conf_OUT)
83
echo '#ifndef '$ac_prefix_conf_DEF >$ac_prefix_conf_OUT
84
echo '#define '$ac_prefix_conf_DEF' 1' >>$ac_prefix_conf_OUT
85
echo ' ' >>$ac_prefix_conf_OUT
86
echo /'*' $ac_prefix_conf_OUT. Generated automatically at end of configure. '*'/ >>$ac_prefix_conf_OUT
88
echo 's/#undef *\([A-Z_]\)/#undef '$ac_prefix_conf_UPP'_\1/' >conftest.sed
89
echo 's/#undef *\([a-z]\)/#undef '$ac_prefix_conf_LOW'_\1/' >>conftest.sed
90
echo 's/#define *\([A-Z_][A-Za-z0-9_]*\)\(.*\)/#ifndef '$ac_prefix_conf_UPP"_\\1 \\" >>conftest.sed
91
echo '#define '$ac_prefix_conf_UPP"_\\1 \\2 \\" >>conftest.sed
92
echo '#endif/' >>conftest.sed
93
echo 's/#define *\([a-z][A-Za-z0-9_]*\)\(.*\)/#ifndef '$ac_prefix_conf_LOW"_\\1 \\" >>conftest.sed
94
echo '#define '$ac_prefix_conf_LOW"_\\1 \\2 \\" >>conftest.sed
95
echo '#endif/' >>conftest.sed
96
sed -f conftest.sed $ac_prefix_conf_INP >>$ac_prefix_conf_OUT
97
echo ' ' >>$ac_prefix_conf_OUT
98
echo '/*' $ac_prefix_conf_DEF '*/' >>$ac_prefix_conf_OUT
99
echo '#endif' >>$ac_prefix_conf_OUT
102
AC_MSG_ERROR([input file $ac_prefix_conf_IN does not exist, dnl
103
skip generating $ac_prefix_conf_OUT])