1dnl Copyright (c) 2005-2019 Michael Scholz <mi-scholz@users.sourceforge.net> 2dnl All rights reserved. 3dnl 4dnl Redistribution and use in source and binary forms, with or without 5dnl modification, are permitted provided that the following conditions 6dnl are met: 7dnl 1. Redistributions of source code must retain the above copyright 8dnl notice, this list of conditions and the following disclaimer. 9dnl 2. Redistributions in binary form must reproduce the above copyright 10dnl notice, this list of conditions and the following disclaimer in the 11dnl documentation and/or other materials provided with the distribution. 12dnl 13dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16dnl ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23dnl SUCH DAMAGE. 24dnl 25dnl @(#)configure.ac 1.205 12/3/19 26dnl 27dnl Process this file with autoconf to produce configure. 28 29AC_COPYRIGHT( 30[Copyright (c) 2004-2019 Michael Scholz <mi-scholz@users.sourceforge.net> 31All rights reserved. 32 33Redistribution and use in source and binary forms, with or without 34modification, are permitted provided that the following conditions 35are met: 361. Redistributions of source code must retain the above copyright 37 notice, this list of conditions and the following disclaimer. 382. Redistributions in binary form must reproduce the above copyright 39 notice, this list of conditions and the following disclaimer in the 40 documentation and/or other materials provided with the distribution. 41 42THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 43ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 44IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 45ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 46FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 48OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 50LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 51OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52SUCH DAMAGE.]) 53 54AC_PREREQ(2.62) 55dnl 56dnl AC_INIT arg 1: PACKAGE_NAME 57dnl AC_INIT arg 2: PACKAGE_VERSION 58dnl AC_INIT arg 1+2: PACKAGE_STRING 59dnl AC_INIT arg 3: PACKAGE_BUGREPORT 60dnl AC_INIT arg 4: PACKAGE_TARNAME 61dnl AC_INIT arg 5: PACKAGE_URL 62dnl 63AC_INIT([FTH], 64 [1.4.1], 65 [mi-scholz@users.sourceforge.net], 66 [fth], 67 [fth.sourceforge.net]) 68AC_CONFIG_HEADERS([src-config.h fth-config.h]) 69AC_CONFIG_SRCDIR([src/fth.c]) 70AM_MAINTAINER_MODE # --enable-maintainer-mode 71 72dnl 73dnl Set target name. 74dnl 75AC_CANONICAL_TARGET 76AC_ARG_PROGRAM # --program-prefix 77 # --program-suffix 78 # --program-transform-name 79AC_DEFINE([fth], [1], [Define to 1 if you have fth.]) 80AC_DEFINE_UNQUOTED([FTH_TARGET], ["${target}"], 81 [Canonical target string.]) 82AC_DEFINE_UNQUOTED([FTH_TARGET_CPU], ["${target_cpu}"], 83 [Canonical target cpu string.]) 84AC_DEFINE_UNQUOTED([FTH_TARGET_VENDOR], ["${target_vendor}"], 85 [Canonical target vendor string.]) 86AC_DEFINE_UNQUOTED([FTH_TARGET_OS], ["${target_os}"], 87 [Canonical target os string.]) 88AC_DEFINE_UNQUOTED([FTH_CONFIGURE_ARGS], ["${ac_configure_args}"], 89 [Configure arguments.]) 90AC_DEFINE_UNQUOTED([FTH_PACKAGE_NAME], ["${PACKAGE_NAME}"], 91 [Package name.]) 92AC_DEFINE_UNQUOTED([FTH_PACKAGE_TARNAME], ["${PACKAGE_TARNAME}"], 93 [Package name.]) 94AC_DEFINE_UNQUOTED([FTH_PACKAGE_VERSION], ["${PACKAGE_VERSION}"], 95 [Package version.]) 96 97dnl 98dnl Additional configure command line options. 99dnl 100AC_ARG_ENABLE([shared], [AS_HELP_STRING([--disable-shared], 101 [disable shared library support])], 102 [AC_MSG_CHECKING([whether to disable shared library support]) 103 if test "X${enableval}" != "Xyes"; then 104 AC_MSG_RESULT([yes]) 105 else 106 AC_MSG_RESULT([no]) 107 fi]) 108AC_ARG_ENABLE([warnings],[AS_HELP_STRING([--enable-warnings], 109 [enable C compiler warning flags @<:@default=no@:>@])], 110 [AC_MSG_CHECKING([whether to enable C compiler warning flags]) 111 AC_MSG_RESULT([${enableval}])]) 112AC_ARG_WITH([tecla], [AS_HELP_STRING([--without-tecla], 113 [do not use tecla(7) command-line editing])]) 114AC_ARG_WITH([tecla-prefix], [AS_HELP_STRING([--with-tecla-prefix@<:@=DIR@:>@], 115 [search for tecla(7) in DIR/include and DIR/lib])], 116 [CFLAGS="${CFLAGS} -I${withval}/include" 117 CPPFLAGS="${CPPFLAGS} -I${withval}/include" 118 LDFLAGS="${LDFLAGS} -L${withval}/lib"]) 119 120dnl 121dnl Check for programs. 122dnl 123AC_PROG_CC 124AC_GNU_SOURCE 125AC_PROG_CPP 126AC_PROG_INSTALL 127AC_PROG_MAKE_SET 128AC_CHECK_TOOL([MANDOC], [mandoc], [:]) 129AC_PATH_PROGS([AR], [llvm-ar ar], [:]) 130AC_PATH_PROGS([RANLIB], [llvm-ranlib ranlib], [:]) 131AC_PATH_PROGS([PKGCONF], [pkgconf pkg-config], [:]) 132 133dnl 134dnl Check for header files. 135dnl 136AC_CHECK_HEADERS([arpa/inet.h complex.h dirent.h dlfcn.h]) 137AC_CHECK_HEADERS([errno.h fcntl.h fenv.h float.h]) 138AC_CHECK_HEADERS([limits.h netdb.h netinet/in.h]) 139AC_CHECK_HEADERS([regex.h setjmp.h signal.h stdarg.h sys/socket.h]) 140AC_CHECK_HEADERS([sys/time.h sys/times.h sys/uio.h sys/un.h]) 141AC_CHECK_HEADERS([sys/wait.h time.h varargs.h]) 142# Special FreeBSD library 'libmissing' 143# added to ports/math/libmissing (2012/12/20). 144AC_CHECK_HEADERS([missing_math.h missing_complex.h], 145 [], [], [@%:@include <complex.h>]) 146 147dnl 148dnl Check for type sizes, typdefs, structs etc. 149dnl 150AC_CHECK_SIZEOF([long]) 151AC_CHECK_SIZEOF([long long]) 152AC_CHECK_SIZEOF([void *]) 153AC_CHECK_ALIGNOF([void *]) 154AC_DEFINE_UNQUOTED([FTH_SIZEOF_LONG], [${ac_cv_sizeof_long}], 155 [The size of `long', as computed by sizeof.]) 156AC_DEFINE_UNQUOTED([FTH_SIZEOF_LONG_LONG], [${ac_cv_sizeof_long_long}], 157 [The size of `long long', as computed by sizeof.]) 158AC_DEFINE_UNQUOTED([FTH_SIZEOF_VOID_P], [${ac_cv_sizeof_void_p}], 159 [The size of `void *', as computed by sizeof.]) 160AC_DEFINE_UNQUOTED([FTH_ALIGNOF_VOID_P], [${ac_cv_alignof_void_p}], 161 [The normal alignment of `void *', in bytes.]) 162 163AC_STRUCT_TM 164AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.tm_zone]) 165AC_C_INLINE 166AC_TYPE_MODE_T 167AC_TYPE_OFF_T 168AC_TYPE_SIZE_T 169AC_TYPE_PID_T 170AC_TYPE_UID_T 171AC_TYPE_SIGNAL 172AC_CHECK_MEMBERS([struct dirent.d_ino, 173 struct dirent.d_fileno, struct dirent.d_namlen], [], [], [ 174@%:@if HAVE_DIRENT_H 175@%:@include <dirent.h> 176@%:@endif]) 177AC_CHECK_TYPES([long long]) 178AC_CHECK_TYPES([long double]) 179AC_CHECK_TYPES([sig_t], [], [], [ 180@%:@if HAVE_SIGNAL_H 181@%:@include <signal.h> 182@%:@endif]) 183AC_CHECK_TYPES([struct sockaddr_un], [], [], [ 184@%:@if HAVE_SYS_UN_H 185@%:@include <sys/un.h> 186@%:@endif]) 187AC_CHECK_MEMBERS([struct sockaddr_un.sun_len], [], [], [ 188@%:@if HAVE_SYS_UN_H 189@%:@include <sys/un.h> 190@%:@endif]) 191AC_CHECK_TYPES([struct tms], [], [], [ 192@%:@if HAVE_SYS_TIMES_H 193@%:@include <sys/times.h> 194@%:@endif]) 195 196dnl 197dnl Check for libraries. 198dnl 199AC_CHECK_LIB([c], [main]) 200AC_CHECK_LIB([m], [main]) 201# Special FreeBSD library 'libmissing' 202# added to ports/math/libmissing (2012/12/20). 203AC_CHECK_LIB([missing], [acoshl]) 204AC_SEARCH_LIBS([socket], [socket]) 205AC_SEARCH_LIBS([gethostbyname], [nsl]) 206AC_SEARCH_LIBS([dlopen], [c dl], [AC_DEFINE([HAVE_DLOPEN], [1], 207 [Define to 1 if you have `dlopen'.])]) 208AC_SEARCH_LIBS([regcomp], [c regex gnuregex], [AC_DEFINE([HAVE_POSIX_REGEX], 209 [1], [Define to 1 if you have POSIX regex.])]) 210AC_CHECK_DECLS([isnan, isinf], [], [], [@%:@include <math.h>]) 211AC_CHECK_DECLS([_SC_CLK_TCK], [], [], [@%:@include <sys/unistd.h>]) 212 213dnl 214dnl Check for functions. 215dnl 216# Minix seems to lack asinh(3), acosh(3), atanh(3) 217AC_CHECK_FUNCS([acosh asinh atanh]) 218AC_CHECK_FUNCS([access ceil chdir chmod chroot]) 219AC_CHECK_FUNCS([execlp execvp expm1 fegetround fesetround]) 220AC_CHECK_FUNCS([floor fork ftruncate]) 221AC_CHECK_FUNCS([getegid getenv geteuid getgid gethostname getlogin getpid]) 222AC_CHECK_FUNCS([getppid getservbyname getservbyport gettimeofday getuid]) 223AC_CHECK_FUNCS([issetugid kill labs log1p log2 lstat]) 224AC_CHECK_FUNCS([mkdir mkfifo opendir pow psignal qsort]) 225AC_CHECK_FUNCS([realpath rename rint rmdir setegid setenv seteuid setgid]) 226AC_CHECK_FUNCS([sethostname setuid sleep strncasecmp strerror]) 227AC_CHECK_FUNCS([strptime symlink sysconf times trunc truncate]) 228AC_CHECK_FUNCS([tzset utimes wait waitpid vsnprintf]) 229 230dnl 231dnl Check for --with-tecla. 232dnl 233if test "X${with_tecla}" != "Xno"; then 234 AC_CHECK_HEADERS([libtecla.h]) 235 # If only a static library exists (libtecla.a), 236 # tputs() from curses is required. 237 OLD_LIBS="${LIBS}" 238 LIBS="-ltecla ${OLD_LIBS}" 239 AC_LINK_IFELSE([AC_LANG_CALL([], [new_GetLine])], 240 # libtecla.so found 241 [LIBS="${OLD_LIBS}" 242 AC_CHECK_LIB([tecla], [new_GetLine])], 243 # libtecla.a? 244 [LIBS="${OLD_LIBS}" 245 AC_SEARCH_LIBS([tputs], [curses ncurses]) 246 NEW_LIBS="${LIBS}" 247 LIBS="-ltecla ${LIBS}" 248 AC_LINK_IFELSE([AC_LANG_CALL([], [new_GetLine])], 249 # libtecla.a found 250 [LIBS="${NEW_LIBS}" 251 AC_CHECK_LIB([tecla], [new_GetLine])], 252 # no tecla support 253 [LIBS="${OLD_LIBS}"])]) 254fi 255 256dnl 257dnl Missing functions with replacements in lib/. 258dnl 259AC_CONFIG_LIBOBJ_DIR(lib) 260# getopt(3) 261AC_CHECK_FUNC([getopt], [], [AC_LIBOBJ(getopt)]) 262# getopt_long(3) 263AC_CHECK_FUNC([getopt_long], [], [AC_LIBOBJ(getopt_long)]) 264# snprintf(3) 265AC_CHECK_FUNC([snprintf], [AC_DEFINE([HAVE_SNPRINTF], [1], 266 [Define to 1 if you have `snprintf'.])], [AC_LIBOBJ(snprintf)]) 267# strftime(3) 268AC_CHECK_FUNC([strftime], [AC_DEFINE([HAVE_STRFTIME], [1], 269 [Define to 1 if you have `strftime'.])], [AC_LIBOBJ(strftime)]) 270# strsep(3) 271AC_CHECK_FUNC([strsep],[AC_DEFINE([HAVE_STRSEP], [1], 272 [Define to 1 if you have `strsep'.])], [AC_LIBOBJ(strsep)]) 273# strsignal(3) 274AC_CHECK_FUNC([strsignal],[AC_DEFINE([HAVE_STRSIGNAL], [1], 275[Define to 1 if you have `strsignal'.])], [AC_LIBOBJ(strsignal)]) 276 277dnl 278dnl Check for C99 complex support. 279dnl 280AC_MSG_CHECKING([for _Complex_I]) 281AC_RUN_IFELSE([AC_LANG_PROGRAM([ 282@%:@if HAVE_COMPLEX_H 283@%:@include <complex.h> 284@%:@endif], 285 [return (creal(1.0 + 1.0 * _Complex_I) != 1.0);])], 286 [AC_MSG_RESULT([yes]) 287 AC_DEFINE([HAVE_COMPLEX_I], [1], [Define to 1 if you have `_Complex_I'.])], 288 [AC_MSG_RESULT([no])]) 289AC_MSG_CHECKING([for 1.0fi]) 290AC_RUN_IFELSE([AC_LANG_PROGRAM([ 291@%:@if HAVE_COMPLEX_H 292@%:@include <complex.h> 293@%:@endif], 294 [return (creal(1.0 + 1.0 * 1.0fi) != 1.0);])], 295 [AC_MSG_RESULT([yes]) 296 AC_DEFINE([HAVE_1_0_FI], [1], [Define to 1 if compiler accepts `1.0fi'.])], 297 [AC_MSG_RESULT([no])]) 298AC_CHECK_FUNCS([cabs cabs2 cacos cacosh carg casin casinh]) 299AC_CHECK_FUNCS([catan catan2 catanh ccos ccosh cexp clog clog10]) 300AC_CHECK_FUNCS([conj cpow csin csinh csqrt ctan ctanh]) 301 302dnl 303dnl Extensions in examples/. 304dnl 305# dbm(3) 306SO_DBM_LIB="" 307AC_CHECK_HEADERS([ndbm.h]) 308AC_SEARCH_LIBS([dbm_open], [c dbm ndbm], 309 [SO_DBM_LIB="dbm.so" 310 AC_DEFINE([HAVE_DBM], [1], [Define to 1 if you have `dbm_open'.])]) 311 312CWARNFLAGS="-ansi -std=c99" 313CWARNFLAGS="${CWARNFLAGS} -Wall -Wextra -Wunused" 314CWARNFLAGS="${CWARNFLAGS} -Wmissing-declarations" 315CWARNFLAGS="${CWARNFLAGS} -Wmissing-prototypes" 316CWARNFLAGS="${CWARNFLAGS} -Wundef" 317# 318# CWARNFLAGS="${CWARNFLAGS} -pedantic" 319# Pedantic is problematic because of 320# - ISO C restricts enumerator values to range of 'int' 321# (ficlInstructionEightByteTrick in ficl/ficl.h) 322# - imaginary constants are an extension (_Complex_I in src/numbers.c) 323# - use of non-standard escape character ('\e' in src/utils.c) 324# 325# For testing use 326# % ./configure --enable-warnings CFLAGS=-pedantic 327# instead. 328# 329 330MPCFLAGS="${CFLAGS}" 331 332dnl 333dnl Check for --enable-warnings. 334dnl 335if test "X${enable_warnings}" = "Xyes"; then 336 CFLAGS="${CFLAGS} ${CWARNFLAGS}" 337fi 338 339dnl 340dnl Check for --program-prefix|suffix. 341dnl 342# prog_name: --program-suffix="-1.4" ==> bin/fth-1.4 343# include/fth-1.4/ 344# lib/fth-1.4/ 345# lib/libfth-1.4.so 346prog_name="fth" 347if test "X${program_prefix}" != "XNONE" ; then 348 prog_name="${program_prefix}${prog_name}" 349fi 350if test "X${program_suffix}" != "XNONE" ; then 351 prog_name="${prog_name}${program_suffix}" 352fi 353 354dnl 355dnl Check for --enable-shared. 356dnl 357if test "X${enable_shared}" != "Xno"; then 358 FTH_PROG="fth-shared" 359 FTH_LIB="lib${prog_name}.so" 360else 361 AC_DEFINE([FTH_STATIC], [1], [Define to 1 if you want static linking.]) 362 FTH_PROG="fth-static" 363 FTH_LIB="lib${prog_name}.a" 364 SO_DBM_LIB="" 365fi 366 367dnl 368dnl From sndlib/autoconf.ac. 369dnl 370# If prefix isn't set in the environment eg. via prefix=/home/mike etc, 371# ${prefix} isn't set here! 372if test "X${prefix}" = "XNONE"; then 373 prefix="${ac_default_prefix}" 374fi 375SO_LD="${CC}" 376SO_LDFLAGS="" 377SO_DLDFLAGS="" 378LDFLAGS="${LDFLAGS} -L${prefix}/lib" 379case "${host}" in 380 *-sgi* | *-apple-* | *-*-minix*) 381 SO_LD=":" 382 enable_shared="no" 383 ;; 384 *-*-solaris*) 385 SO_LDFLAGS="-G" 386 ;; 387 # Fri Mar 8 00:20:24 CET 2013 [ms] 388 # Hannu Vuolasaho <vuokkosetae@gmail.com> 389 *-mingw*) 390 # no -fPIC 391 ;; 392 # As of Thu Jan 18 13:53:33 CET 2018 tested on 393 # freebsd (arbornet.org i386-mnet-freebsd11.14) 394 # openbsd (grex.org i386-intel-openbsd6.1) 395 # netbsd (localhost x86_64-netbsd8) 396 # linux (freeshell.de x86_64-debian-linux-gnu3.16.0) 397 *) 398 CFLAGS="-fPIC ${CFLAGS}" 399 MPCFLAGS="-fPIC ${MPCFLAGS}" 400 SO_LDFLAGS="-shared" 401 SO_DLDFLAGS="-Wl,-soname,${FTH_LIB}" 402 ;; 403esac 404 405dnl 406dnl Substitute variables and write config files. 407dnl 408AC_SUBST(FTH_PROG) 409AC_SUBST(FTH_LIB) 410AC_DEFINE_UNQUOTED([FTH_LIBS], ["${LIBS}"], [Required libraries.]) 411AC_SUBST(prog_name) 412AC_SUBST(SO_DBM_LIB) 413AC_SUBST(MPCFLAGS) 414AC_SUBST(SO_LD) 415AC_SUBST(SO_LDFLAGS) 416AC_SUBST(SO_DLDFLAGS) 417 418AC_CONFIG_TESTDIR(tests) 419AC_CONFIG_FILES([ 420 Makefile 421 ficl/Makefile 422 lib/Makefile 423 src/Makefile 424 tests/Makefile 425 tests/atlocal 426 examples/dbm/Makefile]) 427AC_CONFIG_FILES([examples/scripts/fth-test.fth], 428 [chmod +x examples/scripts/fth-test.fth]) 429AC_CONFIG_FILES([examples/scripts/install.fth], 430 [chmod +x examples/scripts/install.fth]) 431AC_CONFIG_FILES([examples/scripts/play-sound.fth], 432 [chmod +x examples/scripts/play-sound.fth]) 433AC_CONFIG_FILES([examples/scripts/xm.fth], 434 [chmod +x examples/scripts/xm.fth]) 435AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 436AC_CONFIG_FILES([fth.sh], [chmod +x fth.sh]) 437AC_OUTPUT 438 439dnl 440dnl Check for --enable-maintainer-mode 441dnl 442if test "X${MAINTAINER_MODE_TRUE}" != "X#"; then 443 AC_MSG_RESULT([ 444${PACKAGE_STRING} configuration summary: 445 446Program name ........... : ${prog_name} 447Library name ........... : ${FTH_LIB} 448Install prefix ......... : ${prefix} 449C preprocessor ......... : ${CPP} 450C compiler ............. : ${CC} 451Shared linker .......... : ${SO_LD} 452C preprocessor flags ... : ${CPPFLAGS} 453C compiler flags ....... : ${CFLAGS} 454C compiler flags (mp) .. : ${MPCFLAGS} 455Linker flags ........... : ${LDFLAGS} 456Shared dlflags ......... : ${SO_LDFLAGS} 457Shared dldflags ........ : ${SO_DLDFLAGS} 458Libraries .............. : ${LIBS} 459]) 460fi 461 462dnl configure.ac ends here. 463