beta-0.89.2
[luatex.git] / source / texk / kpathsea / configure.ac
blobf244058ec37684b13bcb31c595d7ba5d38296e50
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl   Copyright (C) 2009-2015 Peter Breitenlohner <tex-live@tug.org>
4 dnl
5 dnl   This file is free software; the copyright holder
6 dnl   gives unlimited permission to copy and/or distribute it,
7 dnl   with or without modifications, as long as this notice is preserved.
8 dnl
9 m4_include([version.ac])[] dnl define kpse_version
10 AC_INIT([Kpathsea], kpse_version, [tex-k@tug.org])
11 AC_PREREQ([2.65])
12 AC_CONFIG_SRCDIR([pathsearch.c])
13 AC_CONFIG_AUX_DIR([../../build-aux])
14 AC_CONFIG_MACRO_DIR([../../m4])
16 AC_SUBST([KPSEVERSION], [kpse_version])
17 KPSE_LT_VERSION([kpse])
19 m4_include([../../version.ac])[] dnl define tex_live_version
20 AC_SUBST([WEB2CVERSION], [" (TeX Live tex_live_version)"])
22 dnl Common code for all programs using libkpathsea.
23 KPSE_COMMON([kpathsea])
24 dnl Include additional code for kpathsea.
25 KPSE_MKTEX_PREPARE
26 m4_sinclude([ac/mktex.ac])
28 dnl Generate MAKE_TEX_*_BY_DEFAULT and MAKE_OMEGA_*_BY_DEFAULT defines.
29 m4_foreach([Kpse_Mktex], [kpse_mktex_opts],
30            [m4_ifset([Kpse_Mktex],
31                      [KPSE_MKTEX_DEFINE(Kpse_Mktex)])])[]dnl
33 # So we can use reasonable awk in the Makefile.
34 AC_PROG_AWK
36 AC_CHECK_SIZEOF([long])
38 dnl Replacement functions that may be required on ancient broken system.
39 AC_CHECK_DECLS([putenv])
40 AC_REPLACE_FUNCS([putenv])
42 if test "x$ac_cv_func_getcwd" = xyes; then
43 # We only need to run this if we have getcwd.
44 AC_CACHE_CHECK([whether getcwd uses fork or vfork],
45                [kb_cv_func_getcwd_forks],
46                [AC_RUN_IFELSE([AC_LANG_PROGRAM([[int fork() { exit(1); }
47                                                  int vfork() { exit(1); }
48                                                  extern char *getcwd();
49                                                  char path[100];]],
50                                                [[getcwd(path,100);]])],
51                               [kb_cv_func_getcwd_forks=no],
52                               [kb_cv_func_getcwd_forks=yes],
53                               [kb_cv_func_getcwd_forks=no])])
54 if test "x$kb_cv_func_getcwd_forks" = xyes; then
55   AC_DEFINE([GETCWD_FORKS], 1,
56             [Define to 1 if getcwd is implemented using fork or vfork.
57              Let me know if you have to add this by hand because configure
58              failed to detect it.])
62 KPSE_COND_MINGW32
64 AC_SUBST([LT_OBJDIR], ["$lt_cv_objdir"])
66 # Checking snprintf and vsnprintf
67 AC_ARG_WITH([snprintf-wrapper],
68             AS_HELP_STRING([--with-snprintf-wrapper],
69                            [use (v)snprintf wrapper functions @<:@automatic
70                             for native compilation or Windows@:>@]),
71             [kpse_cv_wrap_snprintf=$withval],
72             [test "x$kpse_cv_have_win32" != xno && kpse_cv_wrap_snprintf=yes])[]dnl
73 if test "x$kpse_cv_have_win32" = xno; then
74   snfunc=snprintf vsnfunc=vsnprintf
75 else
76   snfunc=_snprintf vsnfunc=_vsnprintf
78 AC_CACHE_CHECK([for $snfunc and $vsnfunc],
79                [kpse_cv_have_snfuncs],
80                [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
81                                                   char buf[16];
82                                                   va_list ap;]],
83                                                 [[$snfunc (buf, 16, "%s", "abc");
84                                                   $vsnfunc (buf, 16, "%s", ap);]])],
85                                [kpse_cv_have_snfuncs=yes],
86                                [kpse_cv_have_snfuncs=no])])
87 if test "x$kpse_cv_have_snfuncs" != xyes; then
88   AC_MSG_ERROR([Sorry, you need $snfunc and $vsnfunc.])
90 AC_RUN_IFELSE([AC_LANG_PROGRAM([[char buf[4] = "abc";]],
91                                [[if ($snfunc (buf, 1, "%s", "x") == 0 || buf[1] != 'b')
92                                    return 1;]])],
93               [],
94               [AC_MSG_ERROR([Sorry, your $snfunc is badly broken.])],
95               [:])
96 AC_CACHE_CHECK([if we need (v)snprintf wrapper functions],
97                [kpse_cv_wrap_snprintf],
98                [AC_RUN_IFELSE([AC_LANG_PROGRAM([[char buf[4] = "abc";]],
99                                                [[$snfunc (buf, 3, "xyz");
100                                                  if (buf[2] != 0) return 1;
101                                                  $snfunc (buf, 2, "xyz");
102                                                  if (buf[1] != 0) return 1;]])],
103                               [kpse_cv_wrap_snprintf=no],
104                               [kpse_cv_wrap_snprintf=yes],
105                               [kpse_cv_wrap_snprintf=no])])
106 if test "x$kpse_cv_wrap_snprintf" = xyes; then
107   AC_DEFINE([WRAP_SNPRINTF], 1,
108             [Define to 1 if we need (v)snprintf wrapper functions.])
109 fi               
111 AM_CONDITIONAL([have_EXEEXT], [test -n "$EXEEXT"])
113 dnl Write output here, instead of putting a zillion -D's on the command line.
114 AC_CONFIG_HEADERS([c-auto.h:c-auto.in],
115  [sed -e 's/^#define PACKAGE/#define KPSE_PACKAGE/' \
116       -e 's/^#define VERSION/#define KPSE_VERSION/' c-auto.h >c-auto.tmp && mv -f c-auto.tmp c-auto.h])
118 AH_TOP([/* c-auto.h: defines for kpathsea, as determined by configure.
120    Copyright 1994-97, 2008-2015 Karl Berry.
121    Copyright 1997-99, 2002, 2005 Olaf Weber.
123    This library is free software; you can redistribute it and/or
124    modify it under the terms of the GNU Lesser General Public
125    License as published by the Free Software Foundation; either
126    version 2.1 of the License, or (at your option) any later version.
128    This library is distributed in the hope that it will be useful,
129    but WITHOUT ANY WARRANTY; without even the implied warranty of
130    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
131    Lesser General Public License for more details.
133    You should have received a copy of the GNU Lesser General Public License
134    along with this library; if not, see <http://www.gnu.org/licenses/>.  */
136 /* Guard against double inclusion. */
137 #ifndef KPATHSEA_C_AUTO_H
138 #define KPATHSEA_C_AUTO_H
140 /* kpathsea: the version string. */
141 #define KPSEVERSION "kpathsea version] kpse_version["])
142 AH_BOTTOM([#endif /* !KPATHSEA_C_AUTO_H */])
144 AC_CONFIG_FILES([Makefile doc/Makefile man/Makefile win32/Makefile kpathsea.pc])
146 AC_OUTPUT