1## -*- Autoconf -*- 2## Process this file with autoconf to produce a configure script. 3 4# Specify the name of this "application" and a version number 5AC_INIT([xport], [2.05]) 6 7# Explain that a file "config.h" should be generated 8# AM_CONFIG_HEADER(config.h) 9 10AC_COPYRIGHT([A C Norman]) 11 12AC_PREREQ(2.57) 13 14# My source file is expected to have "xport.c" in it. This is just a small 15# sanity check in case somebody tries to configure with directories 16# messed up. 17AC_CONFIG_SRCDIR(xport.c) 18AC_CONFIG_FILES(Makefile) 19AC_CONFIG_MACRO_DIRS([m4]) 20AC_CONFIG_AUX_DIR([.]) 21AM_INIT_AUTOMAKE([1.8.3 foreign]) 22 23# What host am I on? 24AC_CANONICAL_HOST() 25 26AC_DEFINE_UNQUOTED(HOST_CPU,"$host_cpu",[Name of CPU]) 27AC_DEFINE_UNQUOTED(HOST_VENDOR,"$host_vendor",[Name of vendor]) 28AC_DEFINE_UNQUOTED(HOST_OS,"$host_os",[Name of Operating System]) 29 30case $host in 31 *-*-cygwin*) 32 AC_MSG_NOTICE([Building under cygwin]) 33# Here is the normal situation where cygwin is the BUILD environment. 34 if test "x$prefix" = "xNONE"; then 35 prefix="/cygdrive/c" 36 AC_MSG_NOTICE([For windows I install in c:\bin by default]) 37 fi 38# 39# This comments has to go SOMEWHERE so here is maybe good enough. Some 40# versions of gcc (in March 2004) come with a BROKEN set of include 41# files for bits of <stdio.h> so that getc() can return negative values 42# if a (binary) file contains characters with codes >= 128. Specifically 43# a byte 0xff in a file can be returned as "-1" rather than as 0xff, and this 44# then looks like EOF. This glitch is to do with defaulting to use of 45# signed characters. Because the bad behaviour seems to be within getch 46# I can not work around it in my C code! But by forcing use of unsigned 47# characters the world moves back towards sanity... 48# 49 CPPFLAGS="$CPPFLAGS -funsigned-char" 50 windows_build=yes 51 exeext=yes 52 ;; 53 *-*-msdos* | *-*-go32* | *-*-windows* | *-*-mingw*) 54 AC_MSG_ERROR([For Windows you are expected to use cygwin]) 55 ;; 56 *-*solaris*) 57 AC_MSG_NOTICE([Building for Solaris]) 58# I USED to make a Solaris build default to using cc, because that was what 59# worked on the system I had access to. I am changing that to use the 60# default autoconf way of selecting a C compiler, which will more often find 61# and use gcc. I will test this case under Solaris 10 x86 with gcc and 62# assocated tools installed. 63# AC_MSG_NOTICE([Uses a Sun compiler by default]) 64# If the user has defined CC in advance then that version of the C compiler 65# will be used and a default search will find a C++ compiler. But without 66# any action I will use "cc" and "CC", which on the machine I have tested 67# on gives me a Sun compiler. 68# if test "x$CC" = "x" ; then 69# CC=cc 70# fi 71 ;; 72 *darwin*) 73 AC_MSG_NOTICE([Building for Macintosh/Darwin with X]) 74 darwin_build=yes 75 macintosh_build=yes 76# If the person who invoked configure provide an override for CC or CXX so 77# as to force use of a compiler other than gcc/g++ then it becomes entirely 78# their responsibility to arrange access to a suitable SDK and to set 79# any other Mac-specific compiler options that are needed. 80 if test "x$CC$CXX" == "x" || (test "x$CC" == "xgcc" && test "x$CXX" == "xg++") 81 then 82 LDFLAGS="$LDFLAGS -framework Carbon -framework CoreServices -framework ApplicationServices" 83# I need to make a provisional judgement about whether I will be supporting 84# fat binaries here so that if I am I can disable dependency tracking. The 85# mode of dependency tracking gets decided during the elaboration of 86# AC_PROG_CC, and the "proper" test for fat binary support can only happen 87# after I have found myself a C compiler. 88 AC_LANG_CONFTEST( 89 [AC_LANG_PROGRAM([], [])]) 90# First check a path that is best for Snow Leopard (10.6) in September 2009. 91 if gcc -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch ppc -arch i386 $CFLAGS $LDFLAGS conftest.c -o conftest 92 then 93 AC_MSG_NOTICE([fat binary creation will probably be possible using 10.6]) 94 enable_dependency_tracking="no" 95 else 96 if gcc -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386 $CFLAGS $LDFLAGS conftest.c -o conftest 97 then 98 AC_MSG_NOTICE([fat binary creation will probably be possible using 10.5]) 99 enable_dependency_tracking="no" 100 else 101# This is path works if I am on Tiger (10.4) in Spring 2007! 102 if gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 $CFLAGS $LDFLAGS conftest.c -o conftest 103 then 104 AC_MSG_NOTICE([fat binary creation will probably be possible using 10.4]) 105 enable_dependency_tracking="no" 106 else 107 AC_MSG_NOTICE([fat binary creation will probably NOT be possible]) 108 fi 109 fi 110 fi 111 fi 112 ;; 113 *-freebsd*) 114 AC_MSG_NOTICE([Building on FreeBSD]) 115 ;; 116 *) 117 AC_MSG_NOTICE([Assuming a Unix-like environment, including Linux]) 118 ;; 119esac 120 121save="$CFLAGS" 122 123# find C compiler 124AC_PROG_CC 125 126# Find the C preprocessor. 127 128AC_PROG_CPP 129 130CFLAGS="$save" 131 132if test "x$macintosh_build" = "xyes" 133then 134 sysroot="" 135 AC_MSG_NOTICE([Checking for OSX10.6 framework]) 136 OLDCFLAGS="$CFLAGS" 137 CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.6.sdk" 138 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], 139 [[printf("Hello\n");]])], 140 [CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.6.sdk" 141 AC_MSG_NOTICE([MacOS10.6 SDK found]) 142 sysroot="/Developer/SDKs/MacOSX10.6.sdk"], 143 [CFLAGS="$OLDCFLAGS" 144 AC_MSG_NOTICE([MacOS10.6 SKD NOT found])]) 145 if test "x$sysroot" = "x" 146 then 147 AC_MSG_NOTICE([Checking for OSX10.5 framework]) 148 CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk" 149 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], 150 [[printf("Hello\n");]])], 151 [CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk" 152 AC_MSG_NOTICE([MacOS10.5 SDK found]) 153 sysroot="/Developer/SDKs/MacOSX10.5"], 154 [CFLAGS="$OLDCFLAGS" 155 AC_MSG_NOTICE([MacOS10.5 SKD NOT found])]) 156 fi 157 if test "x$sysroot" = "x" 158 then 159 AC_MSG_NOTICE([Checking for OSX10.4u framework]) 160 CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk" 161 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], 162 [[printf("Hello\n");]])], 163 [CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk" 164 AC_MSG_NOTICE([MacOS10.4u SDK found]) 165 sysroot="/Developer/SDKs/MacOSX10.4u"], 166 [CFLAGS="$OLDCFLAGS" 167 AC_MSG_NOTICE([MacOS10.4u SKD NOT found])]) 168 fi 169 OLDCFLAGS="$CFLAGS" 170 CFLAGS="$CFLAGS -arch ppc -arch i386" 171 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], 172 [[printf("Hello\n");]])], 173 [CXXFLAGS="$CXXFLAGS -arch ppc -arch i386" 174 LDFLAGS="$LDFLAGS -arch ppc -arch i386" 175 fat_support_available="yes"], 176 [CFLAGS="$OLDCFLAGS" 177 fat_support_available="no"]) 178 AC_MSG_NOTICE([fat_support=$fat_support_available]) 179fi 180 181 182# If I am using gcc I will try to build a 32-bit executable even if on 183# a 64-bit system. This is to increase the changes that I can move 184# executables around. Note that I explicitly verify that the version of 185# gcc that I am using will build exeutables if given an "-m32" flag, so I 186# hope that on platforms that are not able to cope with both widths I will 187# not get caught out. This is mainly for Linux/x86_64 where 32-bit binaries 188# are still good. And where a 32-bit binary can then be passed into any 189# 32-bit sub-world or to another machine while 64-bit binaries would be 190# less portable. 191 192if test "x$darwin_build" != "xyes"; then 193if test "x$GCC" = "xyes"; then 194 OLDCPPFLAGS="$CPPFLAGS" 195 OLDLDFLAGS="$LDFLAGS" 196 CPPFLAGS="$CPPFLAGS -m32" 197 LDFLAGS="$LDFLAGS -m32" 198 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], 199 [[printf("Hello\n");]])], 200 [AC_MSG_NOTICE([Using -m32 to force 32-bit compilation])], 201 [CPPFLAGS="$OLDCPPFLAGS" 202 LDFLAGS="$OLDLDFLAGS" 203 AC_MSG_NOTICE([This version of gcc does not accept -m32])]) 204fi 205fi 206 207# Debugging turned on? 208AC_MSG_CHECKING(for debugging) 209AC_ARG_ENABLE(debug,[ --enable-debug compile for debugging]) 210AC_MSG_RESULT([$enable_debug]) 211 212# In lots of cases I will be using gcc. In that case I will use -O2 for 213# release code, but -O1 when debugging. I also stick in -Wall so I get 214# loads of comments about code style etc. For other C compilers I do 215# not set any optimisation flags but I do expect "-g" to be available 216# to enable debugging. 217 218 219if test "x$GCC" = "xyes" ; then 220 if test "x$enable_debug" = "xyes" ; then 221 CFLAGS="${CFLAGS} -fno-strict-aliasing -O1 -g -DDEBUG=1 -Wall" 222 LDFLAGS="${LDFLAGS} -g" 223 else 224 CFLAGS="$CFLAGS -fno-strict-aliasing -O2 -Wall" 225 fi 226else 227 if test "x$enable_debug" = "xyes" ; then 228 CFLAGS="${CFLAGS} -g -DDEBUG=1" 229 LDFLAGS="${LDFLAGS} -g" 230 fi 231fi 232 233# Checks for header files. 234AC_HEADER_DIRENT 235 236AC_CHECK_HEADERS([sys/time.h unistd.h utime.h sys/stat.h]) 237AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h]) 238 239# Checks for typedefs, structures, and compiler characteristics. 240AC_HEADER_STAT 241AC_STRUCT_TM 242AC_CHECK_SIZEOF(int) 243AC_CHECK_SIZEOF(long) 244 245# Certainly Solaris needs extra libraries scanned for socket stuff 246 247AC_CHECK_LIB(socket,socket) 248AC_CHECK_LIB(nsl,gethostbyname) 249 250 251# Checks for library functions. 252AC_FUNC_STAT 253AC_CHECK_FUNCS([ftruncate gethostbyaddr gethostbyname inet_ntoa]) 254AC_CHECK_FUNCS([mkdir rmdir socket]) 255 256AM_PROG_CC_C_O 257 258# 259# Make some things available for conditional segments of a Makefile 260# 261 262AM_CONDITIONAL(windows,test "x$windows_build" = "xyes") 263AM_CONDITIONAL(cygwin,test "x$cygwin_build" = "xyes") 264AM_CONDITIONAL(darwin,test "x$darwin_build" = "xyes") 265AM_CONDITIONAL(debug,test "x$enable_debug" = "xyes") 266AM_CONDITIONAL(exeext,test "x$exeext" = "xyes") 267 268AC_OUTPUT 269 270# end of "configure.ac" 271 272