summaryrefslogtreecommitdiffstats
path: root/libasprintf/configure.in
blob: 80978924583b656e8fee71350fa74ebcefa83b82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
AC_INIT
AC_CONFIG_SRCDIR(vasprintf.c)
AM_INIT_AUTOMAKE(libasprintf, 1.0)
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL

dnl Check for host type.
AC_CANONICAL_HOST

dnl Checks for compiler output filename suffixes.
AC_OBJEXT
AC_EXEEXT

dnl Check for build configuration.
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

dnl Checks for libraries.

dnl Checks for header files.

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
bh_C_SIGNED
AC_TYPE_SIZE_T
gt_TYPE_LONGLONG
gt_TYPE_LONGDOUBLE
gt_TYPE_WCHAR_T
AC_CHECK_TYPES(ptrdiff_t)
gt_TYPE_INTMAX_T

dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_CHECK_FUNCS([snprintf vasprintf])

dnl Check for C++ libraries needed to avoid link errors when creating
dnl libasprintf.
LIBCXX=
cat > conftest.cc <<EOF
#ifdef __SUNPRO_C
SunPro C
#endif
#ifdef __SUNPRO_CC
SunPro C++
#endif
EOF
if $CXX -E conftest.cc | grep SunPro > /dev/null ; then
  # SUNWspro CC, defines __SUNPRO_CC
  cxxcmd=CC
  for word in $CXX; do
    case "$word" in
      CC | */CC) cxxcmd=$word ;;
    esac
  done
  case "$cxxcmd" in
    */*) ;;
    *)
      IFS="${IFS=	 }"; save_ifs="$IFS"; IFS="${IFS}:"
      for dir in $PATH; do
        test -z "$dir" && dir=.
        if test -f "$dir/$cxxcmd"; then
          cxxcmd="$dir/$cxxcmd"
          break
        fi
      done
      IFS="$save_ifs"
      ;;
  esac
  case "$cxxcmd" in
    */bin/CC)
      cxxdir=`echo "$cxxcmd" | sed -e 's,/bin/CC$,,'`
      LIBCXX="-L$cxxdir/lib -lCstd -lCrun"
      ;;
  esac
fi
cat > conftest.cc <<EOF
#ifdef __GNUC__
GCC
#endif
EOF
if $CXX -E conftest.cc | grep GCC > /dev/null ; then
  # GNU g++
changequote(,)dnl
  lib1=`g++ --print-file-name libstdc++.a`
  case "$lib1" in
    */*)
      libdir1=`echo "$lib1" | sed -e 's,/[^/]*$,,'`
      LIBCXX="$LIBCXX -L$libdir1"
      ;;
  esac
  LIBCXX="$LIBCXX -lstdc++"
  lib2=`g++ --print-file-name libgcc.a`
  case "$lib2" in
    */*)
      libdir2=`echo "$lib2" | sed -e 's,/[^/]*$,,'`
      LIBCXX="$LIBCXX -L$libdir2"
      ;;
  esac
  LIBCXX="$LIBCXX -lgcc"
  LIBCXX="$LIBCXX -lm"
changequote([, ])dnl
fi
rm -f conftest.cc
AC_SUBST(LIBCXX)

dnl Check for tools needed for formatting the documentation.
ac_aux_dir_abs=`cd $ac_aux_dir && pwd`
AC_PATH_PROG(DVIPS, dvips, $ac_aux_dir_abs/missing dvips)
AC_PATH_PROG(TEXI2PDF, texi2pdf, $ac_aux_dir_abs/missing texi2pdf)
AC_PATH_PROG(PERL, perl, $ac_aux_dir_abs/missing perl)

AC_OUTPUT([Makefile], [
  dnl Fix unesthetic build commands generated by automake.
  for m in Makefile; do
    sed -e "s,\`test -f \\\$< || echo '\\\$(srcdir)/'\`\\\$<,\\\$<," < $m > $m.tmp
    mv $m.tmp $m
  done
  dnl Fix an automake-1.5 bug.
  for m in Makefile; do
    sed -e 's,^#distdir:,distdir:,' < $m > $m.tmp
    mv $m.tmp $m
  done
  dnl Fix an automake-1.5 bug: all info files are erased by "make".
  for m in Makefile; do
    sed -e '/cd \$(srcdir) && rm -f /d' < $m > $m.tmp
    mv $m.tmp $m
  done
])