configure.ac
author J. Ali Harlow <ali@juiblex.co.uk>
Sat Oct 04 18:12:58 2014 +0100 (2014-10-04)
changeset 454 56ff755c268c
parent 443 b2d6a8273459
child 455 df914f383f5c
permissions -rw-r--r--
Only export symbols starting with razor_ in dynamic library.

Apart from being good practice to avoid clashes with higher-level
libraries and the application, this also fixes an obscure bug: The
gnulib library is used both by librazor (the dynamic library) and
by razor (the executable). In doing so, we want to have two separate
copies of the library despite the code duplication this involves.
Without the explicit limit to export only razor_ symbols, the razor
executable under mingw64 was picking up the getopt_long function
from librazor and the optind variable from libgnu which meant that
it did not see optind changing. Hiding librazor's copy of getopt
causes the linker to find libgnu's copy and everything works.

Note that under mingw librazor-#.dll still contains undocumented
(private) razor_ symbols but these will do no harm as long as nobody
tries to use them.
     1 dnl Process this file with autoconf to produce a configure script.
     2 
     3 AC_PREREQ(2.59c)
     4 AC_INIT([razor], [0.5.7], [ali@juiblex.co.uk])
     5 AM_INIT_AUTOMAKE([])
     6 AM_CONFIG_HEADER([config.h])
     7 AM_MAINTAINER_MODE
     8 
     9 # libtool versioning - this applies to all libraries in this package
    10 #
    11 # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
    12 #
    13 LT_CURRENT=5
    14 LT_REVISION=0
    15 LT_AGE=1
    16 AC_SUBST(LT_CURRENT)
    17 AC_SUBST(LT_REVISION)
    18 AC_SUBST(LT_AGE)
    19 
    20 AC_ISC_POSIX
    21 AC_PROG_CC
    22 gl_EARLY
    23 AM_PROG_CC_STDC
    24 AC_HEADER_STDC
    25 AC_HEADER_SYS_WAIT
    26 AC_CHECK_HEADERS([sys/mman.h])
    27 gl_INIT
    28 AC_CHECK_FUNCS([symlink chroot])
    29 LT_INIT([win32-dll])
    30 # Libtool supports a --disable-shared option to tell it to avoid
    31 # building shared versions of libraries. In addition to this,we want
    32 # to support building static versions of our executables. Libtool
    33 # can do this (under the right circumstances) so we overload this
    34 # switch for this purpose.
    35 #
    36 # The libtool option that we use (-static-libtool-libs) means to use
    37 # static linking with libraries that supply a .la file and which
    38 # include a non-empty value for "old_library". If the library doesn't
    39 # include a .la file (they are deleted by some distributions), then
    40 # this option will have no effect and likewise if old_library is set
    41 # to '' (eg., if the library was build with --disable-static) then
    42 # again -static-libtool-libs will have no effect.
    43 #
    44 # If old_library is set to a non-empty value, then specifying
    45 # -static-libtool-libs will cause the link to fail if the old library
    46 # cannot be found (libtool will not fallback to a shared library
    47 # in these circumstances). This can happen with Fedora, for example,
    48 # if a main mingw32 library package is installed but not the
    49 # coresponding static sub-package. The solution is to either
    50 # install the relevant static sub-packages or don't use --disable-shared.
    51 AS_IF([test "$enable_shared" = no],[
    52   LDFLAGS="$LDFLAGS -static-libtool-libs"
    53 ])
    54 LT_OUTPUT
    55 ac_compile="./libtool --mode=compile --tag=CC $ac_compile"
    56 ac_link="./libtool --mode=link --tag=CC $ac_link"
    57 AC_PROG_MAKE_SET
    58 AC_PROG_LN_S
    59 AC_SYS_LARGEFILE
    60 AM_PROG_CC_C_O
    61 
    62 AC_ARG_ENABLE([atomic],
    63 	      [AS_HELP_STRING([--disable-atomic],
    64 	      		      [disable atomic transactions])],
    65 	      [],
    66 	      [enable_atomic=yes])
    67 if test "$enable_atomic" = "yes"; then
    68     AC_DEFINE([ENABLE_ATOMIC],[1],[Define if atomic transactions are wanted.])
    69     AC_SUBST([RAZOR_HAVE_ATOMIC_ROLLBACK],
    70       ['#define RAZOR_HAVE_ATOMIC_ROLLBACK 1'])
    71 else
    72     AC_SUBST([RAZOR_HAVE_ATOMIC_ROLLBACK],['#undef RAZOR_HAVE_ATOMIC_ROLLBACK'])
    73 fi
    74 
    75 AC_MSG_CHECKING([for Microsoft Windows native API])
    76 case $host_os in
    77     *mingw*)	AC_DEFINE([MSWIN_API], 1,
    78 		  [Define to 1 to use Microsoft Windows native API.])
    79 		EXTRA_LIBS='-lshell32 -lws2_32'
    80 		mswin_api=yes;;
    81     *)		mswin_api=no;;
    82 esac
    83 AC_MSG_RESULT([$mswin_api])
    84 AM_CONDITIONAL(MSWIN_API, test "$mswin_api" = "yes")
    85 AC_SUBST(EXTRA_LIBS)
    86 
    87 if test "$enable_atomic" = "yes" -a "$mswin_api" = "yes"; then
    88     AC_MSG_CHECKING([for Microsoft Windows Kernel Transaction Manager])
    89     save_LIBS="$LIBS"
    90     LIBS="-lktmw32 $LIBS"
    91     AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
    92 #include <windows.h>
    93 #include <ktmw32.h>
    94 ], [(void)CreateTransaction(NULL,0,0,0,0,0,NULL);])],
    95       [have_windows_ktm="yes"; EXTRA_LIBS="-lktmw32 $EXTRA_LIBS"],
    96       [have_windows_ktm="no"])
    97     LIBS="$save_LIBS"
    98     AC_MSG_RESULT([$have_windows_ktm])
    99 else
   100     have_windows_ktm="no"
   101 fi
   102 if test "$have_windows_ktm" = "yes"; then
   103     AC_DEFINE([HAVE_WINDOWS_KTM],[1],[Define if Windows KTM is available.])
   104 fi
   105 
   106 # Taken from dbus
   107 AC_ARG_ENABLE(ansi,             [  --enable-ansi           enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
   108 AC_ARG_ENABLE(verbose-mode,     [  --enable-verbose-mode   support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
   109 
   110 if test "${enable_verbose_mode}" != no; then
   111     # To get -rdynamic you pass -export-dynamic to libtool.
   112     AC_DEFINE(BUILT_R_DYNAMIC,1,[whether -export-dynamic was passed to libtool])
   113     R_DYNAMIC_LDFLAG=-export-dynamic
   114 else
   115     R_DYNAMIC_LDFLAG=
   116 fi
   117 AC_SUBST(R_DYNAMIC_LDFLAG)
   118 
   119 #### gcc warning flags
   120 
   121 if test "x$GCC" = "xyes"; then
   122   changequote(,)dnl
   123   case " $CFLAGS " in
   124   *[\ \	]-Wall[\ \	]*) ;;
   125   *) CFLAGS="$CFLAGS -Wall -Wno-parentheses" ;;
   126   esac
   127 
   128   case " $CFLAGS " in
   129   *[\ \	]-Wchar-subscripts[\ \	]*) ;;
   130   *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
   131   esac
   132 
   133   case " $CFLAGS " in
   134   *[\ \	]-Wmissing-declarations[\ \	]*) ;;
   135   *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
   136   esac
   137 
   138   case " $CFLAGS " in
   139   *[\ \	]-Wnested-externs[\ \	]*) ;;
   140   *) CFLAGS="$CFLAGS -Wnested-externs" ;;
   141   esac
   142 
   143   case " $CFLAGS " in
   144   *[\ \	]-Wcast-align[\ \	]*) ;;
   145   *) CFLAGS="$CFLAGS -Wcast-align" ;;
   146   esac
   147 
   148   case " $CFLAGS " in
   149   *[\ \	]-Wformat[\ \	]*) ;;
   150   *) CFLAGS="$CFLAGS -Wformat" ;;
   151   esac
   152 
   153   case " $CFLAGS " in
   154   *[\ \	]-Wformat-security[\ \	]*) ;;
   155   *) CFLAGS="$CFLAGS -Wformat-security" ;;
   156   esac
   157 
   158   if test "x$enable_ansi" = "xyes"; then
   159     case " $CFLAGS " in
   160     *[\ \	]-ansi[\ \	]*) ;;
   161     *) CFLAGS="$CFLAGS -ansi" ;;
   162     esac
   163 
   164     case " $CFLAGS " in
   165     *[\ \	]-D_POSIX_C_SOURCE*) ;;
   166     *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
   167     esac
   168 
   169     case " $CFLAGS " in
   170     *[\ \	]-D_BSD_SOURCE[\ \	]*) ;;
   171     *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
   172     esac
   173 
   174     case " $CFLAGS " in
   175     *[\ \	]-pedantic[\ \	]*) ;;
   176     *) CFLAGS="$CFLAGS -pedantic" ;;
   177     esac
   178   fi
   179   changequote([,])dnl
   180 fi
   181 
   182 
   183 # gcc default visibility stuff
   184 
   185 have_gcc4=no
   186 AC_MSG_CHECKING(for -fvisibility)
   187 AC_COMPILE_IFELSE([
   188 #if defined(__GNUC__) && (__GNUC__ >= 4)
   189 #else
   190 #error Need GCC 4.0 for visibility
   191 #endif
   192 int main () { return 0; } 
   193 ], have_gcc4=yes)
   194 
   195 if test "x$have_gcc4" = "xyes"; then
   196    CFLAGS="$CFLAGS -fvisibility=hidden"
   197 fi
   198 AC_MSG_RESULT($have_gcc4)
   199 
   200 REQUIREMENTS=""
   201 AC_ARG_WITH([curl],
   202             [AS_HELP_STRING([--without-curl], [disable support for curl])],
   203             [],
   204             [with_curl=yes])
   205           
   206 CURL_CFLAGS=
   207 CURL_LIBS=
   208 AS_IF([test "x$with_curl" != xno],
   209   [PKG_CHECK_MODULES(CURL, [libcurl])
   210    AC_DEFINE([HAVE_CURL], [1], [Define if you have curl])])
   211 AC_SUBST(CURL_CFLAGS)
   212 AC_SUBST(CURL_LIBS)
   213 
   214 ZLIB_LIBS=""
   215 AC_ARG_WITH(zlib, [  --with-zlib=<dir>       Use zlib from here],
   216                       [
   217                       zlib=$withval
   218                       CPPFLAGS="$CPPFLAGS -I$withval/include"
   219                       ]
   220                       )
   221 AC_CHECK_HEADERS(zlib.h, [AC_DEFINE(HAVE_ZLIB_H)],
   222                  [AC_MSG_ERROR([Can't find zlib.h. Please install zlib.])])
   223 save_ldflags="$LDFLAGS"
   224 LDFLAGS="$LDFLAGS -L$zlib/lib"
   225 AC_CHECK_LIB(z, inflate, [ZLIB_LIBS="-L$zlib/lib -lz"],
   226 	     [AC_MSG_ERROR([Can't find zlib library. Please install zlib.])])
   227 LDFLAGS="$save_ldflags"
   228 AC_SUBST(ZLIB_LIBS)
   229 
   230 EXPAT_LIB=""
   231 AC_ARG_WITH(expat, [  --with-expat=<dir>      Use expat from here],
   232                       [
   233                       expat=$withval
   234                       CPPFLAGS="$CPPFLAGS -I$withval/include"
   235                       ]
   236                       )
   237 AC_CHECK_HEADERS(expat.h, [AC_DEFINE(HAVE_EXPAT_H)], 
   238 		 [AC_MSG_ERROR([Can't find expat.h. Please install expat.])])
   239 save_ldflags="$LDFLAGS"
   240 LDFLAGS="$LDFLAGS -L$expat/lib"
   241 AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-L$expat/lib -lexpat"],
   242 	     [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
   243 LDFLAGS="$save_ldflags"
   244 AC_SUBST(EXPAT_LIBS)
   245 
   246 RPM_LIBS=""
   247 AC_ARG_WITH(rpm, [  --with-rpm=<dir>      Use rpm from here])
   248 
   249 AS_IF([test "$with_rpm" != no],
   250       [if test "$with_rpm" != yes; then
   251 	    CPPFLAGS="$CPPFLAGS -I$with_rpm/include"
   252        fi
   253        AC_CHECK_HEADERS(rpm/rpmlib.h, [], 
   254 		 [AC_MSG_ERROR([Can't find rpm/rpmlib.h. Please install rpm-devel or use --without-rpm.])])
   255        save_ldflags="$LDFLAGS"
   256        LDFLAGS="$LDFLAGS -L$with_rpm/lib"
   257        AC_CHECK_LIB(rpm,rpmdbOpen,[RPM_LIBS="-L$with_rpm/lib -lrpm"],
   258 	     [AC_MSG_ERROR([Can't find rpm library. Please install rpm-devel or use --without-rpm.])])
   259        LDFLAGS="$save_ldflags"
   260        AC_DEFINE([HAVE_RPMLIB], [1], [Define if you have librpm])])
   261 AC_SUBST(RPM_LIBS)
   262 AM_CONDITIONAL([HAVE_RPMLIB], [test -n "$RPM_LIBS"])
   263 
   264 AC_ARG_WITH([lua],
   265             [AS_HELP_STRING([--without-lua], [disable support for lua])],
   266             [],
   267             [with_lua=yes])
   268 
   269 AS_IF([test "x$with_lua" != xno],
   270   [PKG_CHECK_MODULES(LUA, [lua])
   271    REQUIREMENTS="$REQUIREMENTS lua"
   272    AC_DEFINE([HAVE_LUA], [1], [Define if you have lua])
   273    AC_PATH_PROG(LUA, [lua], [no])
   274    AS_IF([test "x$LUA" = xno],
   275      [AC_MSG_ERROR([Can't find lua program. Please install lua-devel or use --without-lua.])])
   276    AC_DEFINE_UNQUOTED([LUA_BINARY], ["$LUA"],
   277      [Define to the location of the lua binary])])
   278 AC_SUBST(LUA_CFLAGS)
   279 AC_SUBST(LUA_LIBS)
   280 AM_CONDITIONAL([HAVE_LUA], [test "x$with_lua" != xno])
   281 
   282 AC_SUBST(REQUIREMENTS)
   283 
   284 if test "x$GCC" = "xyes"; then
   285   LDFLAGS="-Wl,--as-needed $LDFLAGS"
   286 fi
   287 
   288 # *****************************
   289 # Make available to Makefile.am
   290 # *****************************
   291 AC_SUBST(SYSCONFDIR, $sysconfdir)
   292 
   293 # ********************
   294 # Internationalisation
   295 # ********************
   296 
   297 IT_PROG_INTLTOOL([0.35.0])
   298 GETTEXT_PACKAGE=razor
   299 AC_SUBST([GETTEXT_PACKAGE])
   300 AM_GLIB_GNU_GETTEXT
   301 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext domain])
   302 
   303 GTK_DOC_CHECK([1.9])
   304 
   305 AC_OUTPUT([
   306 Makefile
   307 data/razor.pc
   308 data/Makefile
   309 librazor/Makefile
   310 librazor/razor.h
   311 librazor/types/Makefile
   312 src/Makefile
   313 docs/Makefile
   314 docs/version.xml
   315 po/Makefile.in
   316 gl/Makefile
   317 test/Makefile
   318 ])
   319 
   320 dnl ==========================================================================
   321 echo "
   322                   razor $VERSION
   323                 =================
   324 
   325         prefix:                     ${prefix}
   326         libdir:                     ${libdir}
   327         libexecdir:                 ${libexecdir}
   328         bindir:                     ${bindir}
   329         sbindir:                    ${sbindir}
   330         datadir:                    ${datadir}
   331         sysconfdir:                 ${sysconfdir}
   332         localstatedir:              ${localstatedir}
   333         docdir:                     ${docdir}
   334 
   335         compiler:                   ${CC}
   336         cflags:                     ${CFLAGS}
   337         Maintainer mode:            ${USE_MAINTAINER_MODE}
   338         Building verbose mode:      ${enable_verbose_mode}
   339         Building gtk-doc:           ${enable_gtk_doc}
   340 "