summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/configure.in
blob: 40ec4974d270c1e414996829c69c1462aa36e864 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
dnl Process this file with Autoconf to produce a configure script for Web2c.
dnl
dnl Some things are no longer configurable:
dnl - SMALL{TeX,MF,BibTeX}: too painful to maintain the separate patch
dnl   files, and, for TeX, texmfmem.h would have to be fixed to support
dnl   more than 256 fonts.
dnl - NONASCII: necessary for the character translation feature.
dnl - REGFIX: modern compilers mostly ignore register declarations, anyway.
dnl The code for these things remains (where applicable), so you can
dnl get these features if you are willing to hack the sources. If not,
dnl it'll take a good argument to convince me to invest the time to make
dnl them configurable.
dnl 
dnl We don't use (for example) tex/tex.web because people who only want
dnl to build part of the distribution may not have any given program.
dnl Even main.c isn't guaranteed, but then nothing is, really ...
AC_INIT(web2c/main.c)

WEB2CVERSION=7.5.5
AC_SUBST(WEB2CVERSION)
AC_DEFINE_UNQUOTED(WEB2CVERSION," (Web2C $WEB2CVERSION)")

dnl Write output here, instead of putting a zillion -D's on the command line.
AC_CONFIG_HEADERS([c-auto.h:c-auto.in], [date >stamp-auto])

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_PROG_YACC
AC_PROG_LEX
# Work around a problem with Flex Version 2.5.31 which needs -l flag.
# Since all recent versions of flex support -l, don't check for the
# specific version, but check that at least "--version" is supported.
# We also want to catch LEX=/some/where/flex, so:
case $LEX in
  *flex) $LEX --version >/dev/null 2>&1 && LEX="$LEX -l" ;;
esac
AC_PROG_RANLIB
AC_CHECK_HEADERS(sys/time.h sys/timeb.h)
AC_CHECK_FUNCS(strerror gettimeofday ftime mkstemp mktemp)

AC_TYPE_SIGNAL

# AC_DECL_YYTEXT is just used to set LEX_OUTPUT_ROOT.
AC_DECL_YYTEXT
pb_AC_ASM_UNDERSCORE

dnl pdfTeX likes inline functions in C code.
AC_C_INLINE

dnl These are standard among *NIX systems, but not when cross-compiling
AC_DEFUN([CF_SUBST],
[AC_MSG_CHECKING(for $1 (symbol $2))
AC_CACHE_VAL(cf_cv_subst_$2,[
test -z "[$]$2" && $2=$3
cf_cv_subst_$2=[$]$2])
$2=${cf_cv_subst_$2}
AC_MSG_RESULT([$]$2)
AC_SUBST($2)
])dnl
CF_SUBST(loader,LD,ld)
CF_SUBST(archiver,AR,ar)
CF_SUBST(archiver options,ARFLAGS,rc)

# Needed on A/UX 3.0. I don't want to pull in other -lposix's, though.
# From: bernt@weinberg.pop.bio.aau.dk (Bernt Guldbrandtsen)
if test `(uname) 2>/dev/null` = aux; then
  AC_CHECK_LIB(posix, sigemptyset)
fi

dnl These tests prevent reliable cross-compilation.  Sigh.
dnl Some special hacks are used to make cross-compilation
dnl succeed in one special case.

AC_UNSET_CC
AC_C_CHAR_UNSIGNED
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(long)
AC_RESET_CC

# --with and --enable options.
test "x$with_x_toolkit" = xyes && with_x=yes
test "x$with_x_toolkit" = xxt && with_x=yes
test "x$with_x_toolkit" = xathena && with_x=yes
test "x$with_x" = xno && with_x_toolkit=no

: ${with_x=no} # tell PATH_XTRA no X by default, if not specified.

sinclude(withenable.ac)
sinclude(../kpathsea/withenable.ac)
sinclude(../../libs/zlib/withenable.ac)
sinclude(../../libs/libpng/withenable.ac)
sinclude(../../libs/zlib/zlib.ac)
sinclude(../../libs/libpng/libpng.ac)
sinclude(../../libs/xpdf/libxpdf.ac)
sinclude(../../libs/freetype2/withenable.ac)
sinclude(../../libs/freetype2/freetype2.ac)
sinclude(../../libs/teckit/withenable.ac)
sinclude(../../libs/teckit/teckit.ac)
sinclude(../../libs/icu-xetex/withenable.ac)
sinclude(../../libs/icu-xetex/icu-xetex.ac)

# Whether to build mf-nowin.
: ${with_mf_nowin=no} # Default.
if test "x$with_mf_nowin" = xyes; then
  MFN=
else
  MFN='#! '
fi
AC_SUBST(MFN)

# For Omega.
if test -d $srcdir/omegadir; then
  test "${with_omega+set}" = set || with_omega=yes
else
  if test "x$with_omega" = xyes; then
    AC_MSG_WARN(The Omega sources are not available.)
  fi
  with_omega=no
fi
if test "x$with_omega" = xyes; then
  OMEGA=
  KPSE_CONFIG_FILES([omegafonts/Makefile otps/Makefile])
else
  OMEGA='#! '
fi
AC_SUBST(OMEGA)

# For Aleph
if test -d $srcdir/alephdir && test -d $srcdir/omegadir; then
  test "${with_aleph+set}" = set || with_aleph=yes
else
  if test "x$with_aleph" = xyes; then
    AC_MSG_WARN(The Aleph sources are not available.)
  fi
  with_aleph=no
fi
if test "x$with_aleph" = xyes; then
  ALEPH=
else
  ALEPH='#! '
fi
AC_SUBST(ALEPH)

# For pdfTeX.
if test -d $srcdir/pdftexdir; then
  # Create build dir, if necessary.
  test -d pdftexdir || mkdir pdftexdir
  test "${with_pdftex+set}" = set || with_pdftex=yes
else
  if test "x$with_pdftex" = xyes; then
    AC_MSG_WARN(The pdfTeX sources are not available.)
  fi
  with_pdftex=no
fi

# For pdfeTeX
if test -d $srcdir/pdfetexdir && test -d $srcdir/pdftexdir \
    && test -d $srcdir/etexdir; then
  test "${with_pdfetex+set}" = set || with_pdfetex=yes
else
  if test "x$with_pdfetex" = xyes; then
    AC_MSG_WARN(Not all sources of pdfeTeX are available.)
  fi
  with_pdfetex=no
fi

# For XeTeX
if test -d $srcdir/xetexdir \
    && test -d $srcdir/etexdir; then
  test "${with_xetex+set}" = set || with_xetex=yes
else
  if test "x$with_xetex" = xyes; then
    AC_MSG_WARN(Not all sources of XeTeX are available.)
  fi
  with_xetex=no
fi

# Check whether C++ compiler works.  Prevent exit if it doesn't.
if test "x$with_pdftex"  = xyes ||
   test "x$with_pdfetex" = xyes ||
   test "x$with_xetex"   = xyes
then
  # First test whether the compiler works in a subshell, and if so,
  # do it again in the main shell so we see the result.
(
  AC_PROG_CXX
) && {
  AC_PROG_CXX
} || {
  test "x$with_pdftex" = xyes \
    && AC_MSG_WARN(No C++ compiler: pdfTeX will not be compiled.)
  test "x$with_pdfetex" = xyes \
    && AC_MSG_WARN(No C++ compiler: pdfeTeX will not be compiled.)
  test "x$with_xetex" = xyes \
    && AC_MSG_WARN(No C++ compiler: XeTeX will not be compiled.)
  with_pdftex=no
  with_pdfetex=no
  with_xetex=no
  true
}
fi

# Check if we can link the C++ runlime lib statically. Only check, if we are
# going to build pdf[ex]tex. And, only try the magic hack, if C++ is
# GNU C++ (i.e. if $ac_cv_prog_gxx=yes). The reason for using a static C++
# runtime is that binaries are more portable. That's only important if you are
# planning to distribute binaries, so all the neat stuff is disabled by default:
flags_try1='-nodefaultlibs -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lm -lgcc_eh -lgcc -lc -lgcc_eh -lgcc'
flags_try2='-nodefaultlibs -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lm -lgcc -lc -lgcc'
CXXLDEXTRA=
CXXHACKLINK='$(kpathsea_cxx_link)'
CXXHACKLDLIBS='$(LOADLIBES)'
if test "x$with_cxx_runtime_hack" = xyes &&
   { test "x$with_pdftex"  = xyes ||
     test "x$with_pdfetex" = xyes ||
     test "x$with_xetex"   = xyes; }
then
  AC_MSG_CHECKING(for statically linking C++ runtime library)

  cpp_link_hack=false
  old_flags=$flags
  old_ac_ext=$ac_ext
  old_ac_link=$ac_link
  if test "$ac_cv_prog_gxx" = yes; then

    ac_ext=C
    cat > conftest.$ac_ext << EOF
#include <iostream.h>
int main()
{
  cout <<"worksok\n";
}
EOF

    for flags in "$flags_try1" "$flags_try2"; do
      ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS $flags 1>&5'
      if { (eval echo configure: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
        case `(./conftest; exit) 2>/dev/null` in
          worksok)
            cpp_link_hack=true; break;;
        esac
      else
        echo "configure: failed program was:" >&5
        cat conftest.$ac_ext >&5
      fi
    done
  fi

  if $cpp_link_hack; then
    CXXLDEXTRA=$flags
    CXXHACKLINK='$(cxx_link_command)'
    CXXHACKLDLIBS='$(proglib) $(kpathsea_dir)/.libs/libkpathsea.a $(LIBS) $(XLOADLIBES)'
    AC_MSG_RESULT(ok using $flags)
  else
    AC_MSG_RESULT(not supported)
  fi

  flags=$old_flags
  ac_ext=$old_ac_ext
  ac_link=$old_ac_link
fi
AC_SUBST(CXXLDEXTRA)
AC_SUBST(CXXHACKLINK)
AC_SUBST(CXXHACKLDLIBS)

if test "x$with_pdftex" = xyes; then
  PTEX=
else
  PTEX='#! '
fi
AC_SUBST(PTEX)

if test "x$with_pdfetex" = xyes; then
  PETEX=
else
  PETEX='#! '
fi
AC_SUBST(PETEX)

if test "x$with_xetex" = xyes; then
  XETEX=
else
  XETEX='#! '
fi
AC_SUBST(XETEX)

sinclude(xetexdir/withenable.ac)
sinclude(xetexdir/tests.ac)
if test "x$with_xetex" = xyes; then
  AC_HAS_CARBON

  if test "x$has_carbon" = "xyes"; then
    XETEX_MACOSX=
    XETEX_GENERIC='#! '
  else
    XETEX_MACOSX='#! '
    XETEX_GENERIC=

    AC_HAS_LIBFONTCONFIG
    if test "x$LDFONTCONFIG" = "x"; then
      AC_MSG_ERROR([
Cannot build XeTeX without libfontconfig.
Use the --with-fontconfig=DIR option to specify the prefix where
fontconfig is installed.
      ])
    fi
    AC_SUBST(FONTCONFIGCPPFLAGS)
    AC_SUBST(FONTCONFIGLDFLAGS)
    AC_SUBST(LDFONTCONFIG)
  fi
  AC_SUBST(XETEX_MACOSX)
  AC_SUBST(XETEX_GENERIC)
fi

# For e-TeX, three choices: no, yes, and tex.  In the latter case, we
# have to comment out the normal TeX build (TEX), as well as enable the
# e-TeX build (ETEX) and the replacement of TeX with e-TeX in compatibilty
# mode(CTEX).
if test -d $srcdir/etexdir; then
  # Create build dir, if necessary.
  test -d etexdir || mkdir etexdir
  test "${with_etex+set}" = set || with_etex=yes
else
  if test "x$with_etex" = xyes; then
    AC_MSG_WARN(The e-TeX sources are not available.)
  fi
  with_etex=no
fi
if test "x$with_etex" = xyes; then
  ETEX=
else
  ETEX='#! '
fi
AC_SUBST(ETEX)


# --with-x* options: Distinguish no X at all, no toolkit, or toolkit.
AC_PATH_XTRA
if test "x$with_x" = xyes; then
  if test -n "$x_libraries"; then
    XLFLAG="-L$x_libraries"
    wlibs="-lX11 $wlibs $XLFLAG"
  else
    wlibs="-lX11 $wlibs"
  fi
  if test -z "$x_ext_lib"; then # allow envvar override
    AC_CHECK_LIB(Xext, XextCreateExtension,
                 x_ext_lib=-lXext, :, $wlibs $X_EXTRA_LIBS $XLFLAG)
  fi
  if test "x$with_mf_x_toolkit" = xno; then
    wfile=x11-Xlib.c
  else
    # Effectively demote --with-x-toolkit=athena to xt since 
    # the code does not distinguish.
    x_tool_libs="-lXt $x_tool_libs"
    wfile=x11-Xt.c
  fi
  test -d window || mkdir window
  case "$srcdir" in
    /*) wfile=$srcdir/window/$wfile;;
    .)  ;;
    *)  wfile=../$srcdir/window/$wfile;;
  esac
  (cd window && (rm -f x11.c; $LN_S $wfile x11.c))
  AC_DEFINE(X11WIN)
fi
AC_SUBST(x_ext_lib)
AC_SUBST(x_tool_libs)
AC_SUBST(wlibs)

if test "x$enable_fmtutil" = xyes; then
  FMU='# '
else
  FMU=
fi
AC_SUBST(FMU)

# Don't bother with pdflib unless pdf*TeX is requested.
if test "$with_pdftex" = yes || \
   test "$with_pdfetex" = yes
then
  KPSE_CONFIG_FILES([pdftexdir/Makefile])
fi

# Don't bother with pdfelib unless pdfeTeX is requested.
if test "$with_pdfetex" = yes; then
  AC_CONFIG_FILES([pdfetexdir/Makefile])
fi

dnl Create tests subdirectory.
test -d tests || mkdir tests

# Is libm present.  FIXME: do we need it at all?
AC_CHECK_LIB(m, main)

# For cross-compilation.  Put at the end so there is a fair chance
# these are still visible when the configure script has finished.

# The variables we need to build binaries that will run on the build
# machine: BUILDCC, BUILDCFLAGS, BUILDCCLD.
KPSE_CROSS_BUILD_VAR(CC, cc)
KPSE_CROSS_BUILD_VAR(CFLAGS, $(BUILDXCFLAGS))
KPSE_CROSS_BUILD_VAR(CPPFLAGS, $(BUILDXCPPFLAGS))
KPSE_CROSS_BUILD_VAR(LDFLAGS, $(BUILDXLDFLAGS))
KPSE_CROSS_BUILD_VAR(CCLD, $(BUILDCC))

# And supporting programs we need to have available on the build
# machine.
KPSE_CROSS_PATH_PROG(TANGLEBOOT, tangle, ./tangleboot)
KPSE_CROSS_PATH_PROG(TANGLE, tangle, ./tangle)
KPSE_CROSS_PATH_PROG(CTANGLEBOOT, ctangle, ./ctangleboot)
KPSE_CROSS_PATH_PROG(CTANGLE, ctangle, ./ctangle)
KPSE_CROSS_PATH_PROG(TIE, tie, ./tie)
if test "x$with_omega" = xyes || test "x$with_aleph" = xyes || test "x$with_xetex" = xyes; then
KPSE_CROSS_PATH_PROG(OTANGLE, otangle, ./otangle)
fi

dnl Generate `Makefile's, `config.status', and our header file.
KPSE_CONFIG_FILES([Makefile doc/Makefile lib/Makefile man/Makefile mpware/Makefile 
          mpdir/Makefile web2c/Makefile window/Makefile])
AC_CONFIG_FILES([fmtutil.cnf:fmtutil.in])
AC_OUTPUT