]> err.no Git - sope/blob - libFoundation/configure.in
Drop apache 1 build-dependency
[sope] / libFoundation / configure.in
1 AC_PREREQ(2.4)
2
3 AC_INIT(${srcdir}/Foundation/NSObject.h.in)
4
5 # ******************** GNUstep env ************************************
6
7 if test "x${GNUSTEP_MAKEFILES}" = "x"; then
8   AC_MSG_ERROR(Your GNUstep.sh is not sourced, please load GNUstep.sh prior running configure!)
9 fi
10
11 # ******************** version ****************************************
12
13 # todo: read from Version file?
14 MAJOR_VERSION=1
15 MINOR_VERSION=1
16 SUBMINOR_VERSION=3
17
18 AC_SUBST(MAJOR_VERSION)
19 AC_SUBST(MINOR_VERSION)
20 AC_SUBST(SUBMINOR_VERSION)
21
22
23 # ******************** options ****************************************
24
25 AC_ARG_WITH(ffcall,[
26 --with-ffcall
27     Use the ffcall library to implement dynamic invocation of methods. Note
28     the licensing restrictions of ffcall before enabling that switch !],
29 ac_cv_use_ffcall=yes,
30 ac_cv_use_ffcall=no
31 )
32
33 AC_ARG_WITH(gc,[
34 --with-gc
35 --with-gc=DIR
36     Use the Boehm's garbage collector for automatic memory management instead
37     of the normal OpenStep memory management policy.
38     Search in DIR for GC include files (eg DIR=objc leads to <objc/gc.h>)],
39 [ac_cv_use_gc=yes; ac_cv_link_gc=yes;
40 if [ test x${withval} != xyes ]; then
41     GC_INCLUDE_DIR="${withval}/"
42 else
43     GC_INCLUDE_DIR=""
44 fi
45 ],
46 [ac_cv_use_gc=no; ac_cv_link_gc=no; GC_INCLUDE_DIR=""]
47 )
48
49 AC_ARG_WITH(gc-lib,[
50 --with-gc-lib
51 --with-gc-lib=LIB
52     Link against GC library LIB. The default is 'gc'. Do not specify
53     --with-gc-lib if you have the GC contained in some of your system
54     libraries (eg libobjc.a)],
55 [ac_cv_link_gc=yes;
56 if [ test x${withval} != xyes ]; then
57     GC_LIB="${withval}"
58 else
59     GC_LIB="gc"
60 fi
61 ],
62 [ac_cv_link_gc=no; GC_LIB=""]
63 )
64
65 AC_SUBST(GC_INCLUDE_DIR)
66 AC_SUBST(GC_LIB)
67
68
69 # ******************** system type ************************************
70
71 # Determine the host, build, and target systems
72 CC_TARGET=$target # use --target value for CC, not the canonical form
73 AC_CANONICAL_SYSTEM
74 AC_PREFIX_DEFAULT(/usr/local)
75
76 AC_CONFIG_HEADER(config.h:config.h.in.sed dnl
77                  Foundation/NSObject.h:Foundation/NSObject.h.in.sed dnl
78                  Foundation/lfmemory.h:Foundation/lfmemory.h.in.sed)
79
80 # check for cross compilation
81
82 if [[ x$target = xNONE ]]; then
83   set target $host
84 fi
85
86 if test "x$host" != "x$target"; then
87         cross_defines="CROSS=-DCROSS_COMPILE"
88         cross_compiling="yes"
89         echo "cross compiling from $host to $target .."
90         CC=${CC_TARGET}-gcc
91         LD=${CC_TARGET}-ld
92         AR=${CC_TARGET}-ar
93         RANLIB=${CC_TARGET}-ranlib
94 fi
95
96 changequote(,)dnl
97 case "x${host_cpu}" in
98     xi[456]86*) host_cpu=i386;;
99     xhppa1.1)   host_cpu=hppa;;
100 esac
101
102 if test "x$cross_compiling" = xyes; then
103   case "x${target_cpu}" in
104     xi[456]86*) target_cpu=i386;;
105     xhppa1.1)   target_cpu=hppa;;
106   esac
107 else
108   target_cpu=${host_cpu}
109   target_os=${host_os}
110   target_vendor=${host_vendor}
111 fi
112
113 case "x${target_os}" in
114   xfreebsd*) target_os=freebsd;;
115 esac
116
117 changequote([,])dnl
118
119 # Assign the HOST/TARGET variables for sharedlib.mak
120 HOST=$host
121 HOST_CPU=$host_cpu
122 HOST_VENDOR=$host_vendor
123 HOST_OS=$host_os
124 TARGET=$target
125 TARGET_CPU=$target_cpu
126 TARGET_VENDOR=$target_vendor
127 TARGET_OS=$target_os
128
129 if test ! -f ${srcdir}/config/${target_cpu}/${target_os}.h; then
130     if test -d ${srcdir}/config/${target_cpu}; then
131         echo
132         echo '*************** Warning ****************'
133         echo This package was not ported to $target_cpu running $target_os operating system.
134         echo We\'ll use the default configuration file ${srcdir}/config/$target_cpu/$target_cpu.h.
135         echo '****************************************'
136         echo
137         target_os=$target_cpu
138     else
139         echo
140         echo '*************** Warning ****************'
141         echo This package was not ported to $target_cpu running $target_os operating system.
142         echo We\'ll use a generic configuration file, thus you will be able to compile the library, but most probably the NSInvocation, NSMethodSignature and all classes that use them will not work correctly or will not work at all.
143         echo '****************************************'
144         target_cpu=generic
145         target_os=generic
146     fi
147 fi
148
149
150 # ******************** autoconf vars **********************************
151
152 AC_SUBST(WITH_GNUSTEP)
153 WITH_GNUSTEP=yes
154 AC_DEFINE(WITH_GNUSTEP)
155
156 AC_SUBST(WITH_FFCALL)
157 WITH_FFCALL=$ac_cv_use_ffcall
158 if test "x$ac_cv_use_ffcall" = xyes; then
159   AC_DEFINE(WITH_FFCALL)
160 fi
161
162 AC_SUBST(WITH_GC)
163 WITH_GC=$ac_cv_use_gc
164 if test "$WITH_GC" = yes; then
165   AC_DEFINE(LIB_FOUNDATION_BOEHM_GC)
166 fi
167
168 AC_PROG_CC
169 if test "x$cross_compiling" = xyes; then
170         echo "cross compiling to $target"
171 fi
172
173
174 # ******************** system tools ***********************************
175
176 AC_ISC_POSIX
177 AC_PROG_CPP
178 AC_CHECK_PROGS(MAKE, gmake gnumake make)
179 AC_CHECK_PROGS(AR, ar)
180 AC_CHECK_PROGS(LD, ld)
181 AC_CHECK_PROGS(PERL, perl)
182
183 # uses AC_TRY_RUN
184
185 if test "x$cross_compiling" = xyes; then
186   if [[ "x${target_cpu}" = xi386 ]]; then
187     echo "WARNING: using predefined structure alignment of 4 for i386 !"
188     ac_cv_struct_alignment=4
189     STRUCT_ALIGNMENT=4
190   elif [[ "x${target_cpu}" = xsparc ]]; then
191     echo "WARNING: using predefined structure alignment of 8 for ${target_cpu} !"
192     ac_cv_struct_alignment=8
193     STRUCT_ALIGNMENT=8
194   elif [[ "x${target_cpu}" = xmipsel ]]; then
195     echo "WARNING: using predefined structure alignment of 8 for ${target_cpu} !"
196     ac_cv_struct_alignment=8
197     STRUCT_ALIGNMENT=8
198   else
199     echo "ERROR: unknown structure alignment for CPU ${target_cpu}, using 4 !"
200     ac_cv_struct_alignment=4
201     STRUCT_ALIGNMENT=4
202   fi
203 else
204   AC_STRUCT_ALIGNMENT
205 fi
206
207 AC_CHECK_LIB(dl, dlopen)
208 AC_CHECK_LIB(pcthread, pthread_create,
209             ,
210             AC_CHECK_LIB(pthread, pthread_create))
211 AC_CHECK_LIB(m,      sqrt)
212 AC_CHECK_LIB(nsl,    chown)
213 AC_CHECK_LIB(socket, accept)
214
215 RUNTIME=GNU
216 transformed_target_cpu=`${GNUSTEP_MAKEFILES}/clean_cpu.sh ${TARGET_CPU}`
217 ac_cv_file_output_prefix=Foundation/$transformed_target_cpu/${TARGET_OS}/$RUNTIME
218
219
220 AC_CHECK_NESTED_FUNCTIONS
221 AC_BROKEN_COMPILER
222
223 if test $target_cpu = i386; then
224     AC_BROKEN_BUILTIN_APPLY
225 fi
226
227 # If we're using the Boehm's GC check to see if we have the gc.h file and
228 # libgc.a installed.
229 AC_DEFINE(WITH_GC)
230 AC_HAVE_HEADERS(${GC_INCLUDE_DIR}gc.h)
231
232 if test "x$ac_cv_link_gc" = xyes; then
233     AC_CHECK_LIB(${GC_LIB}, GC_malloc)
234     if test "x$ac_cv_header_gc_h" != xyes -o "x$ac_cv_lib_gc_GC_malloc" != xyes; then
235         changequote(,)
236         AC_MSG_ERROR(It appears your system doesn't have the Boehm's garbage collector installed! Please install it first or check your paths in case it's already installed. Note that we expect the Boehm's GC library to be named so that linking using -lgc works; please be careful as the normal 'make' in Boehm's GC neither creates the library nor installs it. You should copy the files gc.h and gc.a in the appropriate directories and rename gc.a to libgc.a.)
237         changequote([,])
238     fi
239 fi
240
241 # uses AC_TRY_RUN
242 if test x"$cross_compiling" = xyes; then
243     echo "WARNING: cannot check for byte-order during cross compilation."
244 else
245     AC_C_BIGENDIAN
246 fi
247
248 AC_COMPILE_CHECK_SIZEOF(short)
249 AC_COMPILE_CHECK_SIZEOF(int)
250 AC_COMPILE_CHECK_SIZEOF(long)
251 AC_COMPILE_CHECK_SIZEOF(long long)
252 AC_COMPILE_CHECK_SIZEOF(float)
253 AC_COMPILE_CHECK_SIZEOF(double)
254 AC_COMPILE_CHECK_SIZEOF(long double)
255
256 AC_HEADER_DIRENT
257 AC_HAVE_HEADERS(dir.h libc.h sys/time.h stdlib.h memory.h string.h dnl
258                 strings.h sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h dnl
259                 netinet/in.h windows.h dnl
260                 Windows32/Sockets.h pwd.h process.h grp.h sys/param.h dnl
261                 sys/file.h sys/errno.h sys/select.h)
262 AC_HEADER_SYS_WAIT
263
264 AC_CHECK_FUNCS(memcpy ualarm getcwd getuid getpwnam getpwuid kill raise dnl
265                getpagesize statvfs chown symlink readlink opendir fsync dnl
266                sysconf GetSystemInfo gettimeofday GetLocalTime sigsetmask dnl
267                sigset sigaction sighold dnl
268                gethostbyname_r gethostbyaddr_r gethostent_r)
269 AC_FUNC_MMAP
270 AC_FUNC_VFORK
271 AC_TYPE_SIGNAL
272
273 AC_CHECK_MATH_LIB
274
275 # uses AC_TRY_RUN
276 if test "$cross_compiling" = yes; then
277     echo "WARNING: cannot check for restartable system calls during cross compilation."
278 else
279     AC_SYS_RESTARTABLE_SYSCALLS
280 fi
281
282
283 # ******************** GNUstep.sh-less compilation ********************
284
285 AC_SUBST(GNUSTEP_FLATTENED)
286 AC_SUBST(GNUSTEP_HOST)
287 AC_SUBST(GNUSTEP_HOST_CPU)
288 AC_SUBST(GNUSTEP_HOST_OS)
289 AC_SUBST(GNUSTEP_HOST_VENDOR)
290 AC_SUBST(GNUSTEP_LOCAL_ROOT)
291 AC_SUBST(GNUSTEP_MAKEFILES)
292 AC_SUBST(GNUSTEP_NETWORK_ROOT)
293 AC_SUBST(GNUSTEP_PATHLIST)
294 AC_SUBST(GNUSTEP_ROOT)
295 AC_SUBST(GNUSTEP_SYSTEM_ROOT)
296 AC_SUBST(GNUSTEP_USER_ROOT)
297 AC_SUBST(LIBRARY_COMBO)
298
299
300 # ******************** output *****************************************
301
302 AC_OUTPUT(config.h.in.sed:config.h.in config.mak gsfix.make dnl
303           Foundation/libFoundation.make dnl
304           Foundation/NSObject.h.in.sed:Foundation/NSObject.h.in dnl
305           Foundation/lfmemory.h.in.sed:Foundation/lfmemory.h.in,
306 [rm -f config.h.in.sed Foundation/NSObject.h.in.sed Foundation/lfmemory.h.in.sed
307 # Read the variables from config.cache
308 . ./config.cache
309
310 # Create the output directory
311 if test ! -d $ac_cv_file_output_prefix; then
312   ${srcdir}/mkinstalldirs $ac_cv_file_output_prefix
313 fi
314
315 # Move the config.h and config.mak over to the $ac_cv_file_output_prefix
316 mv config.h   $ac_cv_file_output_prefix
317 mv config.mak $ac_cv_file_output_prefix
318
319 #
320 # create the appropriate memory management file
321 #
322 mv -f Foundation/lfmemory.h $ac_cv_file_output_prefix
323
324 # Create the NSException.h file to include a file in
325 #       $ac_cv_file_output_prefix
326 # which is the actual exceptions definition file.
327 (cd Foundation;
328   rm -f NSException.h;
329   echo "#include <real_exception_file.h>" >NSException.h)
330
331 #
332 # Now create the real_exception_file.h based upon the compiler support
333 #
334 rm -f Foundation/$ac_cv_file_output_prefix/real_exception_file.h
335 if test ${ac_cv_nested_functions} = no; then
336   echo "creating $ac_cv_file_output_prefix/real_exception_file.h from ${srcdir}/Foundation/NSExceptionWithoutNested.h"
337   cp ${srcdir}/Foundation/NSExceptionWithoutNested.h $ac_cv_file_output_prefix/real_exception_file.h
338 elif test ${ac_cv_broken_compiler} = yes; then
339   echo "creating $ac_cv_file_output_prefix/real_exception_file.h from ${srcdir}/Foundation/NSClassicException.h"
340   cp ${srcdir}/Foundation/NSClassicException.h $ac_cv_file_output_prefix/real_exception_file.h
341 else
342   echo "creating $ac_cv_file_output_prefix/real_exception_file.h from ${srcdir}/Foundation/NSFuncallException.h"
343   cp ${srcdir}/Foundation/NSFuncallException.h $ac_cv_file_output_prefix/real_exception_file.h
344 fi
345 ])