tentative fix for issue 3 (ex 53)
[mplib] / src / texk / kpathsea / common.ac
1 dnl Public domain.
2 dnl Originally written by Karl Berry
3 dnl
4 dnl Common Autoconf sinclude file for kpathsea-using programs.  (Have to
5 dnl use the m4 `sinclude' builtin instead of `include', since Autoconf
6 dnl disables `include'.)
7
8 dnl These configure scripts won't work with anything else.
9 AC_PREREQ(2.12.1)
10
11 dnl Write output here, instead of putting a zillion -D's on the command line.
12 AC_CONFIG_HEADERS([c-auto.h:c-auto.in], [date >stamp-auto])
13
14 AC_PROG_CC
15 AC_PROG_INSTALL
16 AC_PROG_LN_S
17 AC_PROG_MAKE_SET
18
19 sinclude(../libtool.m4)
20
21 AC_PROG_LIBTOOL
22
23 AC_HEADER_DIRENT
24 AC_HEADER_STDC
25 AC_FUNC_CLOSEDIR_VOID
26 AC_CHECK_HEADERS(assert.h float.h limits.h memory.h pwd.h stdlib.h \
27                  string.h strings.h sys/param.h unistd.h)
28
29 dnl Libtool supporting objects that may be required on ancient broken system.
30 AC_CHECK_FUNCS(putenv,, LTLIBOBJS="$LTLIBOBJS putenv.lo")
31 AC_CHECK_FUNCS(strcasecmp,, LTLIBOBJS="$LTLIBOBJS strcasecmp.lo")
32 AC_CHECK_FUNCS(strtol,, LTLIBOBJS="$LTLIBOBJS strtol.lo")
33 AC_CHECK_FUNCS(strstr,, LTLIBOBJS="$LTLIBOBJS strstr.lo")
34 AC_SUBST(LTLIBOBJS)
35
36 AC_CHECK_FUNCS(bcmp bcopy bzero getcwd getwd index memcmp memcpy rindex strchr strrchr)
37
38 AC_C_CONST
39
40 # Check whether struct stat provides high-res time.
41 KPSE_STRUCT_ST_MTIM
42
43 # Check whether prototypes work.
44 AC_MSG_CHECKING(whether the compiler accepts prototypes)
45 AC_CACHE_VAL(kb_cv_c_prototypes,
46 [AC_TRY_COMPILE([#include <stdarg.h>], [extern void foo(int i,...);],
47   kb_cv_c_prototypes=yes, kb_cv_c_prototypes=no)])dnl
48 AC_MSG_RESULT($kb_cv_c_prototypes)
49 if test "$kb_cv_c_prototypes" = yes; then
50   AC_DEFINE(HAVE_PROTOTYPES)
51 fi
52
53 # This is a GNU libc invention.
54 AC_MSG_CHECKING(whether program_invocation_name is predefined)
55 AC_CACHE_VAL(kb_cv_var_program_inv_name,
56 [AC_TRY_LINK(,
57   [extern char *program_invocation_name; program_invocation_name = "love";],
58   kb_cv_var_program_inv_name=yes, kb_cv_var_program_inv_name=no)])dnl
59 AC_MSG_RESULT($kb_cv_var_program_inv_name)
60 if test "$kb_cv_var_program_inv_name" = yes; then
61   AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME)
62 fi
63
64 if test $ac_cv_func_getcwd = yes; then
65 # We only need to run this if we have getcwd.
66 AC_MSG_CHECKING(whether getcwd uses fork or vfork)
67 AC_CACHE_VAL(kb_cv_func_getcwd_forks,
68 [AC_TRY_RUN([
69 int fork() { exit(1); }
70 int vfork() { exit(1); }
71 extern char *getcwd();
72 char path[100];
73 int main() {
74 getcwd(path,100);
75 return 0;
76 }], kb_cv_func_getcwd_forks=no, kb_cv_func_getcwd_forks=yes,
77     kb_cv_func_getcwd_forks=no)])dnl
78 AC_MSG_RESULT($kb_cv_func_getcwd_forks)
79 if test $kb_cv_func_getcwd_forks = yes; then
80   AC_DEFINE(GETCWD_FORKS)
81 fi
82 fi
83
84 # Common --with and --enable options.
85 sinclude(../../texk/kpathsea/withenable.ac)
86
87 # Implementation of those options.
88 if test "x$with_mktexmf_default" = xyes; then
89   AC_DEFINE(MAKE_TEX_MF_BY_DEFAULT)
90 fi
91 if test "x$with_mktexpk_default" = xyes; then
92   AC_DEFINE(MAKE_TEX_PK_BY_DEFAULT)
93 fi
94 if test "x$with_mktextex_default" = xyes; then
95   AC_DEFINE(MAKE_TEX_TEX_BY_DEFAULT)
96 fi
97 if test "x$with_mktexfmt_default" = xyes; then
98   AC_DEFINE(MAKE_TEX_FMT_BY_DEFAULT)
99 fi
100 if test "x$with_mktextfm_default" = xyes; then
101   AC_DEFINE(MAKE_TEX_TFM_BY_DEFAULT)
102 fi
103 if test "x$with_mkocp_default" = xyes; then
104   AC_DEFINE(MAKE_OMEGA_OCP_BY_DEFAULT)
105 fi
106 if test "x$with_mkofm_default" = xyes; then
107   AC_DEFINE(MAKE_OMEGA_OFM_BY_DEFAULT)
108 fi
109
110 # Is libm present.  FIXME: do we need it at all?
111 AC_CHECK_LIB(m, main)
112
113 # If you're cross-compiling, these macros set up the variables in
114 # ../make/cross.mk: BUILDCC, BUILDCFLAGS, BUILDCCLD etc.
115 KPSE_CROSS_BUILD_VAR(CC, cc)
116 KPSE_CROSS_BUILD_VAR(CFLAGS, $(BUILDXCFLAGS))
117 KPSE_CROSS_BUILD_VAR(CPPFLAGS, $(BUILDXCPPFLAGS))
118 KPSE_CROSS_BUILD_VAR(LDFLAGS, $(BUILDXLDFLAGS))
119 KPSE_CROSS_BUILD_VAR(CCLD, $(BUILDCC))