1dnl Copyright (C) 2006, 2014, 2017 Free Software Foundation, Inc 2dnl Process this file with autoconf to produce a configure script. 3 4AC_INIT(GNU units,2.16,adrianm@gnu.org) 5AC_PREREQ(2.59) 6AC_ARG_PROGRAM 7 8AC_SUBST(DEFIS) 9AC_SUBST(STRFUNC) 10AC_SUBST(UDAT) 11AC_SUBST(HAVE_PYTHON) 12AC_SUBST(PYTHON_VERSION) 13AC_SUBST(MKS_POSIX) 14AC_SUBST(MKS_RES) 15AC_SUBST(MKS_DRIVE) 16AC_SUBST(HAVE_MKS) 17 18 19dnl Hack to set correct CFLAGS for cl compiler while still 20dnl allowing user to override the CFLAGS setting 21 22saveCFLAGS=$CFLAGS 23 24AC_PROG_CC(gcc cc egcs cl.exe) 25AC_PROG_CC_C99 26 27AC_DEFUN([AX_CHECK_COMPILE_FLAG], 28[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 29AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 30AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 31 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 32 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 33 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 34 [AS_VAR_SET(CACHEVAR,[yes])], 35 [AS_VAR_SET(CACHEVAR,[no])]) 36 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 37AS_VAR_IF(CACHEVAR,yes, 38 [m4_default([$2], :)], 39 [m4_default([$3], :)]) 40AS_VAR_POPDEF([CACHEVAR])dnl 41])dnl AX_CHECK_COMPILE_FLAGS 42 43if test "$CC" = cl.exe; then 44 if test -z "$saveCFLAGS" ; then 45 AC_MSG_NOTICE([setting special CFLAGS value for cl]) 46 CFLAGS="-O2 -W3 -D_CRT_SECURE_NO_WARNINGS -nologo" 47 fi 48 if test `expr "$CFLAGS" : '.*D_CRT_SECURE_NO_WARNINGS'` -eq 0; then 49 AC_MSG_NOTICE([disabling CRT_SECURE warnings for cl]) 50 CFLAGS="$CFLAGS -D_CRT_SECURE_NO_WARNINGS" 51 fi 52else 53 dnl The -fpic option is needed with gcc if you want to compile a shared lib 54 dnl and causes no harm for regular compilation. But cl.exe accepts it 55 dnl and then prints a warning. 56 AX_CHECK_COMPILE_FLAG(-fpic,[CFLAGS="$CFLAGS -fpic"]) 57fi 58 59 60AC_C_CONST 61AC_PROG_INSTALL 62AC_PROG_MKDIR_P 63 64dnl Checks for libraries. 65 66AC_SEARCH_LIBS(sin,m) 67 68dnl Check for readline with various possible required support libs 69 70AS_UNSET(ac_cv_lib_readline_readline) 71for termlib in "" -ltermcap -lncurses -lcurses; do 72 if test "$ac_cv_lib_readline_readline" != yes ; then 73 AS_UNSET(ac_cv_lib_readline_readline) 74 AC_CHECK_LIB(readline,readline, 75 [LIBS="-lreadline $termlib $LIBS";DEFIS="$DEFIS -DREADLINE"], 76 [],[$termlib]) 77 fi 78done 79 80if test "$ac_cv_lib_readline_readline" = yes; then 81 AC_CHECK_DECL(rl_completion_suppress_append, [], 82 [DEFIS="$DEFIS -DNO_SUPPRESS_APPEND"], 83 [[#include <readline/readline.h>]]) 84fi 85 86 87dnl Checks for header files. 88AC_CHECK_HEADER(string.h,[],[DEFIS="$DEFIS -DSTRINGS_H"]) 89AC_CHECK_HEADER(stdlib.h,[],[DEFIS="$DEFIS -DNO_STDLIB_H"]) 90 91dnl Checks for library functions. 92AC_CHECK_FUNC(strchr,[],DEFIS="$DEFIS -DNO_STRCHR") 93AC_CHECK_FUNC(strspn,[],DEFIS="$DEFIS -DNO_STRSPN";STRFUNC="strfunc.$OBJEXT") 94AC_CHECK_FUNC(strtok,[],DEFIS="$DEFIS -DNO_STRTOK";STRFUNC="strfunc.$OBJEXT") 95 96AC_CHECK_FUNC(setenv,[],DEFIS="$DEFIS -DNO_SETENV") 97AC_CHECK_FUNC(setlocale,[],DEFIS="$DEFIS -DNO_SETLOCALE") 98 99AC_CACHE_CHECK([for locale and UTF-8 support], am_cv_utf8, 100 [AC_TRY_LINK([ 101#define _XOPEN_SOURCE 600 102#include <wchar.h> 103#include <locale.h> 104#include <langinfo.h> 105], [wchar_t *out;char *in;char *res; 106 res=setlocale(LC_CTYPE,"");res=in; 107 mbsrtowcs(out, &res, 2, NULL); 108 wcswidth(out,2);], 109 am_cv_utf8=yes, 110 am_cv_utf8=no) 111]) 112 113if test $am_cv_utf8 = yes; then 114 DEFIS="$DEFIS -DSUPPORT_UTF8" 115fi 116 117AC_CACHE_CHECK([for isfinite], am_cv_isfinite, 118 [AC_TRY_LINK([ 119#define _XOPEN_SOURCE 600 120#include <math.h> 121], [float a;a=1;isfinite(a);], 122 am_cv_isfinite=yes, 123 am_cv_isfinite=no) 124]) 125 126if test $am_cv_isfinite = no; then 127 DEFIS="$DEFIS -DNO_ISFINITE" 128fi 129 130AC_CHECK_PROG(mkstoolkit,mksinfo,found,no) 131 132 133# assume that if we have the MKS Toolkit, we're running the Korn shell 134HAVE_MKS=no 135if test $mkstoolkit = found; then 136 if mksinfo > /dev/null; then 137 if test -n "$ROOTDIR"; then 138 DEFIS="$DEFIS -DHAVE_MKS_TOOLKIT" 139 echo 'using MKS Toolkit' 140 MKS_POSIX=".POSIX:" 141 MKS_RES='$(RES)' 142 HAVE_MKS=yes 143 # if the user has specified a drive, leave things alone. 144 # otherwise, prepend the drive on which the Toolkit is installed 145 case "$prefix" in 146 ?:*) 147 MKS_DRIVE= ;; 148 *) 149 MKS_DRIVE="${ROOTDIR%%:*}:" ;; 150 esac 151 else 152 echo 'no ROOTDIR... cannot use MKS Toolkit' 153 fi 154 else 155 echo 'mksinfo failed... not using MKS Toolkit' 156 fi 157fi 158 159 160AC_PATH_PROG(PYTHON, python, no) 161 162if test $PYTHON = no; then 163 HAVE_PYTHON=no 164 echo ' Units will work without python but the currency update' 165 echo ' script, units_cur, will not be installed' 166 PYTHON='' 167else 168 HAVE_PYTHON=yes 169fi 170 171dnl Check for path search option 172AC_ARG_ENABLE([relocation], 173 AC_HELP_STRING([--enable-relocation], 174 [look in program directory for units data files (default is NO)]), 175 [if test $enable_relocation = yes ;then 176 UDAT="" 177 echo relocation enabled 178 else 179 UDAT="$datadir/units/" 180 echo relocation disabled 181 fi 182 ], [UDAT="$datadir/units/"]) 183 184 185AC_CONFIG_FILES(Makefile) 186AC_OUTPUT 187