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