dvitomp fix from Akira
[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 AC_PROG_CC
9 AC_PROG_INSTALL
10 AC_PROG_LN_S
11 AC_PROG_MAKE_SET
12
13 sinclude(../libtool.m4)
14
15 AC_PROG_LIBTOOL
16
17 AC_SYS_LARGEFILE
18 AC_FUNC_FSEEKO
19
20 AC_HEADER_DIRENT
21 AC_HEADER_STDC
22 AC_FUNC_CLOSEDIR_VOID
23 AC_CHECK_HEADERS([assert.h float.h limits.h memory.h pwd.h stdlib.h \
24                   string.h strings.h sys/param.h unistd.h])
25 AC_CHECK_DECLS([strstr])
26
27 dnl Libtool supporting objects that may be required on ancient broken system.
28 AC_CHECK_FUNCS(putenv,, LTLIBOBJS="$LTLIBOBJS putenv.lo")
29 AC_CHECK_FUNCS(strcasecmp,, LTLIBOBJS="$LTLIBOBJS strcasecmp.lo")
30 AC_CHECK_FUNCS(strtol,, LTLIBOBJS="$LTLIBOBJS strtol.lo")
31 AC_CHECK_FUNCS(strstr,, LTLIBOBJS="$LTLIBOBJS strstr.lo")
32 AC_SUBST(LTLIBOBJS)
33
34 AC_CHECK_FUNCS(bcmp bcopy bzero getcwd getwd index memcmp memcpy rindex strchr strrchr)
35
36 AC_C_CONST
37
38 # Check whether struct stat provides high-res time.
39 AC_CHECK_MEMBERS([struct stat.st_mtim])
40
41 # Check whether prototypes work.
42 AC_MSG_CHECKING(whether the compiler accepts prototypes)
43 AC_CACHE_VAL(kb_cv_c_prototypes,
44 [AC_TRY_COMPILE([#include <stdarg.h>], [extern void foo(int i,...);],
45   kb_cv_c_prototypes=yes, kb_cv_c_prototypes=no)])dnl
46 AC_MSG_RESULT($kb_cv_c_prototypes)
47 if test "$kb_cv_c_prototypes" = yes; then
48   AC_DEFINE([HAVE_PROTOTYPES], 1,
49     [Define to 1 if your compiler understands prototypes.])
50 fi
51
52 # This is a GNU libc invention.
53 AC_MSG_CHECKING([whether program_invocation_name is predefined])
54 AC_CACHE_VAL([kb_cv_var_program_inv_name],
55 [AC_TRY_LINK(,
56   [extern char *program_invocation_name; program_invocation_name = "love";],
57   [kb_cv_var_program_inv_name=yes], [kb_cv_var_program_inv_name=no])])dnl
58 AC_MSG_RESULT([$kb_cv_var_program_inv_name])
59 if test "$kb_cv_var_program_inv_name" = yes; then
60   AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], 1,
61     [Define to 1 if you are using GNU libc or otherwise have global
62      variables `program_invocation_name' and `program_invocation_short_name'.])
63 fi
64
65 if test $ac_cv_func_getcwd = yes; then
66 # We only need to run this if we have getcwd.
67 AC_MSG_CHECKING([whether getcwd uses fork or vfork])
68 AC_CACHE_VAL([kb_cv_func_getcwd_forks],
69 [AC_TRY_RUN([
70 int fork() { exit(1); }
71 int vfork() { exit(1); }
72 extern char *getcwd();
73 char path[100];
74 int main() {
75 getcwd(path,100);
76 return 0;
77 }], [kb_cv_func_getcwd_forks=no], [kb_cv_func_getcwd_forks=yes],
78     [kb_cv_func_getcwd_forks=no])])dnl
79 AC_MSG_RESULT([$kb_cv_func_getcwd_forks])
80 if test $kb_cv_func_getcwd_forks = yes; then
81   AC_DEFINE([GETCWD_FORKS], 1,
82     [Define to 1 if getcwd is implemented using fork or vfork.  Let me know
83      if you have to add this by hand because configure failed to detect it.])
84 fi
85 fi
86
87 # Common --with and --enable options.
88 sinclude(../../texk/kpathsea/withenable.ac)
89
90 # Implementation of those options.
91 AC_DEFUN([_KPSE_DEFINE_MAKE_BY_DEFAULT],
92 [if test "x$with_$1_default" = xyes; then
93   AC_DEFINE([MAKE_$2_BY_DEFAULT], 1,
94     [Define to 1 if you want to run $1 if $3  missing, and to 0 if you don't.])
95 else
96   AC_DEFINE([MAKE_$2_BY_DEFAULT], 0)
97 fi
98 ])# _KPSE_DEFINE_MAKE_BY_DEFAULT
99
100 _KPSE_DEFINE_MAKE_BY_DEFAULT([mktexmf], [TEX_MF], [MF source])
101 _KPSE_DEFINE_MAKE_BY_DEFAULT([mktexpk], [TEX_PK], [PK font])
102 _KPSE_DEFINE_MAKE_BY_DEFAULT([mktextex], [TEX_TEX], [TeX source])
103 _KPSE_DEFINE_MAKE_BY_DEFAULT([mktexfmt], [TEX_FMT], [format file])
104 _KPSE_DEFINE_MAKE_BY_DEFAULT([mktextfm], [TEX_TFM], [TFM file])
105 _KPSE_DEFINE_MAKE_BY_DEFAULT([mkocp], [OMEGA_OCP], [OCP file])
106 _KPSE_DEFINE_MAKE_BY_DEFAULT([mkofm], [OMEGA_OFM], [OFM file])
107
108 # Is libm present.  FIXME: do we need it at all?
109 AC_CHECK_LIB(m, main)
110
111 # If you're cross-compiling, these macros set up the variables in
112 # ../make/cross.mk: BUILDCC, BUILDCFLAGS, BUILDCCLD etc.
113 KPSE_CROSS_BUILD_VAR(CC, cc)
114 KPSE_CROSS_BUILD_VAR(CFLAGS, $(BUILDXCFLAGS))
115 KPSE_CROSS_BUILD_VAR(CPPFLAGS, $(BUILDXCPPFLAGS))
116 KPSE_CROSS_BUILD_VAR(LDFLAGS, $(BUILDXLDFLAGS))
117 KPSE_CROSS_BUILD_VAR(CCLD, $(BUILDCC))