configure.ac 3.86 KB
Newer Older
Craig Silverstein's avatar
Craig Silverstein committed
1
## Process this file with autoconf to produce configure.
2
## In general, the safest way to proceed is to run ./autogen.sh
Craig Silverstein's avatar
Craig Silverstein committed
3 4 5 6

# make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57)

7
AC_INIT(gflags, 1.3, opensource@google.com)
Craig Silverstein's avatar
Craig Silverstein committed
8 9 10
# The argument here is just something that should be in the current directory
# (for sanity checking)
AC_CONFIG_SRCDIR(README)
11
AM_INIT_AUTOMAKE([dist-zip])
Craig Silverstein's avatar
Craig Silverstein committed
12 13 14 15 16 17
AM_CONFIG_HEADER(src/config.h)

# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
18
AM_CONDITIONAL(GCC, test "$GCC" = yes)   # let the Makefile know if we're gcc
19 20 21 22 23 24 25 26 27 28 29
AC_CANONICAL_HOST

# Populate $host_cpu, $host_os, etc.
AC_CANONICAL_HOST
case $host_os in
  *mingw*)
    # Disabling fast install keeps libtool from creating wrapper scripts
    # around the executables it builds.  Such scripts have caused failures on
    # MinGW.  Using this option means an extra link step is executed during
    # "make install".
    AC_DISABLE_FAST_INSTALL
30
    # /tmp is a mount-point in mingw, and hard to use.  use cwd instead
31
    TEST_TMPDIR=gflags_testdir
32 33 34
    ;;
    *)
    AC_ENABLE_FAST_INSTALL
35
    TEST_TMPDIR=/tmp/gflags
36 37
    ;;
esac
38
AC_SUBST(TEST_TMPDIR)
Craig Silverstein's avatar
Craig Silverstein committed
39 40 41 42 43 44 45 46 47 48 49 50

# Uncomment this if you'll be exporting libraries (.so's)
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)

# Check whether some low-level functions/files are available
AC_HEADER_STDC

# These are tested for by AC_HEADER_STDC, but I check again to set the var
AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
51
AC_CHECK_HEADERS([fnmatch.h])
Craig Silverstein's avatar
Craig Silverstein committed
52 53 54 55 56

# These are the types I need.  We look for them in either stdint.h,
# sys/types.h, or inttypes.h, all of which are part of the default-includes.
AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
57
AC_CHECK_TYPE(__int16, ac_cv_have___int16=1, ac_cv_have___int16=0)
Craig Silverstein's avatar
Craig Silverstein committed
58

59
AC_CHECK_FUNCS([strtoll strtoq])
60
AC_CHECK_FUNCS([setenv putenv])    # MinGW has putenv but not setenv
61

Craig Silverstein's avatar
Craig Silverstein committed
62
AX_C___ATTRIBUTE__
63 64 65 66 67 68 69
# We only care about __attribute__ ((unused))
if test x"$ac_cv___attribute__" = x"yes"; then
  ac_cv___attribute__unused="__attribute__ ((unused))"
else
  ac_cv___attribute__unused=
fi

Craig Silverstein's avatar
Craig Silverstein committed
70 71 72 73 74 75 76
ACX_PTHREAD

# Find out what namespace 'normal' STL code lives in, and also what namespace
# the user wants our classes to be defined in
AC_CXX_STL_NAMESPACE
AC_DEFINE_GOOGLE_NAMESPACE(google)

77 78 79 80 81 82 83 84 85
# Solaris 10 6/06 has a bug where /usr/sfw/lib/libstdc++.la is empty.
# If so, we replace it with our own version.
LIBSTDCXX_LA_LINKER_FLAG=
if test -f /usr/sfw/lib/libstdc++.la && ! test -s /usr/sfw/lib/libstdc++.la
then
  LIBSTDCXX_LA_LINKER_FLAG='-L$(top_srcdir)/src/solaris'
fi
AC_SUBST(LIBSTDCXX_LA_LINKER_FLAG)

Craig Silverstein's avatar
Craig Silverstein committed
86 87 88 89
# These are what's needed by gflags.h.in
AC_SUBST(ac_google_start_namespace)
AC_SUBST(ac_google_end_namespace)
AC_SUBST(ac_google_namespace)
90
AC_SUBST(ac_cv___attribute__unused)
Craig Silverstein's avatar
Craig Silverstein committed
91 92 93 94 95
AC_SUBST(ac_cv_have_stdint_h)
AC_SUBST(ac_cv_have_systypes_h)
AC_SUBST(ac_cv_have_inttypes_h)
AC_SUBST(ac_cv_have_uint16_t)
AC_SUBST(ac_cv_have_u_int16_t)
96
AC_SUBST(ac_cv_have___int16)
Craig Silverstein's avatar
Craig Silverstein committed
97 98 99

## Check out ../autoconf/ for other macros you can call to do useful stuff

100 101 102 103 104 105 106 107 108 109
# For windows, this has a non-trivial value (__declspec(export)), but any
# system that uses configure wants this to be the empty string.
AC_DEFINE(GFLAGS_DLL_DECL,,
          [Always the empty-string on non-windows systems.
           On windows, should be "__declspec(dllexport)".
	   This way, when we compile the dll, we export our functions/classes.
	   It's safe to define this here because config.h is only used
	   internally, to compile the DLL, and every DLL source file
	   #includes "config.h" before anything else.])

Craig Silverstein's avatar
Craig Silverstein committed
110
# Write generated configuration file, and also .h files
111
AC_CONFIG_FILES([Makefile src/gflags/gflags.h src/gflags/gflags_completions.h])
Craig Silverstein's avatar
Craig Silverstein committed
112
AC_OUTPUT