aboutsummaryrefslogtreecommitdiff
path: root/BuildUnix/configure.in
blob: eda554ff14c1415e1c0822cbc59f0ab2ab50f7ee (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
dnl ======================================================================================
dnl	Copyright (c) 1998-2001 Palm, Inc. or its subsidiaries.
dnl	All rights reserved.
dnl ======================================================================================

dnl ========================================================
dnl Process this file with autoconf to produce a configure script.
dnl ========================================================

AC_INIT(../SrcUnix/Platform_Unix.cpp)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(pose, 0, no)

AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB


dnl ========================================================
dnl Check for programs.
dnl ========================================================

AC_PROG_CPP


dnl ========================================================
dnl Check for libraries.
dnl ========================================================

AC_PATH_XTRA

AC_ARG_WITH(fltk,
	[  --with-fltk=DIR         use FLTK in DIR], [
	CPPFLAGS="${CPPFLAGS} -I$withval/include"
	LDFLAGS="${LDFLAGS} -L$withval/lib"
])


dnl ========================================================
dnl Check for header files.
dnl ========================================================

AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(endian.h machine/endian.h sys/isa_defs.h fcntl.h limits.h strings.h sys/time.h unistd.h)


dnl ========================================================
dnl Check for typedefs, structures, and compiler characteristics.
dnl ========================================================

AC_C_CONST
AC_C_INLINE


dnl ----------------------------
dnl Check sa_len of sockaddr
dnl ----------------------------

AC_DEFUN(AC_STRUCT_SA_LEN,
	[AC_CACHE_CHECK([for 'sa_len' in 'struct sockaddr'], ac_cv_struct_sa_len,
	[AC_TRY_COMPILE([
		#include <sys/types.h>
		#include <sys/socket.h>
	], [
		struct sockaddr sa;
		sa.sa_len = 0;
	], ac_cv_struct_sa_len=yes, ac_cv_struct_sa_len=no)])
	if test "$ac_cv_struct_sa_len" = yes; then
		AC_DEFINE(HAVE_SA_LEN)
	fi])

AC_DEFUN(AC_STRUCT_SIN_LEN,
	[AC_CACHE_CHECK([for 'sin_len' in 'struct sockaddr_in'], ac_cv_struct_sin_len,
	[AC_TRY_COMPILE([
		#include <sys/types.h>
		#include <sys/socket.h>
		#include <netinet/in.h>
	], [
		struct sockaddr_in sin;
		sin.sin_len = 0;
	], ac_cv_struct_sin_len=yes, ac_cv_struct_sin_len=no)])
	if test "$ac_cv_struct_sin_len" = yes; then
		AC_DEFINE(HAVE_SIN_LEN)
	fi])

AC_DEFUN(AC_TYPE_SOCKLEN_T,
	[AC_CACHE_CHECK([for 'socklen_t'], ac_cv_type_socklen_t,
	[AC_TRY_COMPILE([
		#include <sys/types.h>
		#include <sys/socket.h>
	], [
		socklen_t var;
		var = 0;
	], ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no)])
	if test "$ac_cv_type_socklen_t" = yes; then
		AC_DEFINE(HAVE_TYPE_SOCKLEN_T)
	fi])

AC_STRUCT_SA_LEN
AC_STRUCT_SIN_LEN
AC_TYPE_SOCKLEN_T


dnl ========================================================
dnl Check for library functions.
dnl ========================================================

AC_FUNC_ALLOCA
AC_CHECK_FUNCS(mkdir)
AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(tempnam)


dnl ========================================================
dnl Set the defaults first
dnl ========================================================

AR='ar'
FLAGS_COMMON="-DPLATFORM_UNIX=1 -D__PALMOS_TRAPS__=0 -DEMULATION_LEVEL=EMULATION_UNIX"


dnl ========================================================
dnl Define some standard warning flags 
dnl ========================================================

_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -fexceptions -Wall -Wno-multichar -Wno-unknown-pragmas -Wno-conversion"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -fexceptions -Wall -Wno-multichar -Wno-unknown-pragmas -Wno-conversion"

_COMPILER_CFLAGS="${_COMPILER_CFLAGS}"
_COMPILER_CXXFLAGS="${_COMPILER_CXXFLAGS}"


dnl ========================================================
dnl Define the standard OMNITHREAD options
dnl ========================================================

THREAD_FLAGS="-D_REENTRANT -DNoNanoSleep -DPthreadDraftVersion=10"
THREAD_LIBS="-lpthread"
USE_SOLARIS_CPP="false"


dnl ========================================================
dnl System overrides of the defaults
dnl ========================================================

case "$target" in
*-aix*)
	THREAD_FLAGS="-DNoNanoSleep -DPthreadDraftVersion=8"
	THREAD_LIBS="-lpthread"
	;;

*-hpux*)
	THREAD_FLAGS="-D_REENTRANT -DPthreadDraftVersion=4"
	THREAD_LIBS="-lpthread -lmach -lc_r"
	;;

*-irix*)
	THREAD_FLAGS="-DUsePthread -D_REENTRANT -DPthreadDraftVersion=10 -DPthreadSupportThreadPriority"
	THREAD_LIBS="-lpthread"
	;;

*-linux*) 
	THREAD_FLAGS="-D_REENTRANT -DNoNanoSleep -DPthreadDraftVersion=10"
	THREAD_LIBS="-lpthread"
	;;

*-nto*) 
	THREAD_FLAGS="-D_REENTRANT -DPthreadDraftVersion=10"
	THREAD_LIBS=""
	POSER_CFLAGS="$POSER_CFLAGS  -D_QNX_SOURCE -D_POSIX_SOURCE -D__i386__ -D_i386 -DNSCAP_NO_EXPLICIT -DNO_REGEX -DSTRINGS_ALIGNED -D_SEEKPOS_DEFINED_ -I/usr/gcc/lib/gcc-lib/ntox86/2.8.1/include"
	POSER_CXXFLAGS="$POSER_CFLAGS"
	_WARNINGS_CFLAGS='-w'
	_WARNINGS_CXXFLAGS='-w'
	LIBS="$LIBS -lsocket"
	poser_optimize="-O2"
	poser_debug="-gdwarf-2"
	AR='/usr/local/bin/ar.elf'
	;;

*-osf*)
dnl I am not sure how to test for these versions...
dnl Options for OSF 1.3.2
dnl	THREAD_FLAGS="-D_REENTRANT -DNoNanoSleep -DPthreadDraftVersion=4"
dnl	THREAD_LIBS="-lpthread -lmach -lc_r"
dnl Options for OSF 1.4
	THREAD_FLAGS="-D_REENTRANT -pthread -DNoNanoSleep -DPthreadDraftVersion=10"
	THREAD_LIBS="-lcma"
	;;

*-solaris*)
	# -g somehow helps the assembler understand long symbol names
	THREAD_FLAGS="-g -D_REENTRANT -DPthreadDraftVersion=10 -DPthreadSupportThreadPriority"
	THREAD_LIBS="-lnsl -lsocket -lthread -lposix4"
dnl I'd really like to check the compiler directly to see if it supports -fpermissive,
dnl but I don't know how to get autoconf to do that.
	_COMPILER_CFLAGS="${_COMPILER_CFLAGS} -fpermissive"
	_COMPILER_CXXFLAGS="${_COMPILER_CXXFLAGS} -fpermissive"
	USE_SOLARIS_CPP="true"
	;;

*-sunos*)
	# -g somehow helps the assembler understand long symbol names
	THREAD_FLAGS="-g -D_REENTRANT -DPthreadDraftVersion=10 -DPthreadSupportThreadPriority"
	THREAD_LIBS="-lnsl -lsocket -lthread -lposix4"
	USE_SOLARIS_CPP="true"
	;;

*-freebsd*)
	THREAD_FLAGS="-pthread -D_THREAD_SAFE -D_REENTRANT -DPthreadDraftVersion=10"
	THREAD_LIBS=
	;;

*-bsdi4*)
	THREAD_LIBS=
	;;
esac


dnl ========================================================
dnl Check for gprof profiling
dnl ========================================================

AC_ARG_ENABLE(profile,
	[  --enable-profile        include gprof profiling (default no)],
	FLAGS_PROFILE="-pg",
	FLAGS_PROFILE="")


dnl ========================================================
dnl Check for built-in profiling
dnl ========================================================

AC_ARG_ENABLE(palm_profile,
	[  --enable-palm-profile   include profiling of Palm applications (default no)],
	FLAGS_PALM_PROFILE="-DHAS_PROFILING=1",
	FLAGS_PALM_PROFILE="-DHAS_PROFILING=0")


dnl ========================================================
dnl Check for static link.
dnl ========================================================

AC_ARG_ENABLE(static-link,
	[  --enable-static-link    static link; no shared libraries (default no)],
	LDFLAGS="${LDFLAGS} -static"
)


dnl ========================================================
dnl Check for Optimize
dnl
dnl NOTE: turning on optimizations when using egcs 1.1.2
dnl runs afoul of a code generation bug on x86's (as
dnl shipped with RedHat 6.0).  The specific cases I know
dnl about (in SkinScaleDown and SkinScaleUp) are coded
dnl around, but there may be more lurking...
dnl
dnl I haven't checked this, but I hear the bug is fixed
dnl in gcc 2.95.
dnl ========================================================

dnl This is now on by default.  It gets turned off if the
dnl user selects --enable-debug.
dnl
dnl AC_ARG_ENABLE(optimize,
dnl	[  --enable-optimize       optimize code (default no)],
dnl	FLAGS_OPTIMIZE="-O2",
dnl	FLAGS_OPTIMIZE="")

FLAGS_OPTIMIZE="-O2"


dnl ========================================================
dnl Check whether default arguments which call a virtual
dnl function in another object work -- GCC 2.95.x crashes
dnl trying to compile something like this.
dnl ========================================================

AC_LANG_CPLUSPLUS
AC_CACHE_CHECK([whether virtual function default arguments work],
	pose_cv_virtual_defarg_ok,
	AC_TRY_COMPILE([
		class C
		{ 
			public:
				virtual int foo ();
		} *c;
		void bar (int = c->foo ());
		], [bar ();],
		pose_cv_virtual_defarg_ok=yes, pose_cv_virtual_defarg_ok=no))

if test $pose_cv_virtual_defarg_ok = no; then
	AC_DEFINE(BROKEN_VIRTUAL_DEFAULT_ARGUMENTS)
fi


dnl ========================================================
dnl Check for debugging
dnl ========================================================

AC_ARG_ENABLE(debug,
	[  --enable-debug          include debugging symbols (default no)],
	FLAGS_DEBUG="-D_DEBUG -g"
	FLAGS_PROFILE="-DHAS_PROFILING=1"
	FLAGS_PALM_PROFILE=""
	FLAGS_OPTIMIZE="",
	FLAGS_DEBUG="-DNDEBUG")


dnl ========================================================
dnl Check for OpenGL.  This is pretty much the same code
dnl that FLTK uses to check for it.  We'll assume that if
dnl OpenGL is present, FLTK was configured to use it, and
dnl so we need to link with it.
dnl ========================================================

GLLIB=

AC_CHECK_HEADER(GL/gl.h,
	AC_CHECK_LIB(GL, glXMakeCurrent, AC_DEFINE(HAVE_GL) GLLIB="-lGL", \
		AC_CHECK_LIB(MesaGL, glXMakeCurrent, AC_DEFINE(HAVE_GL) GLLIB=" -lMesaGL",,\
		-L${ac_x_libraries} -lX11 -lXext $X_EXTRA_LIBS -lm), \
		-L${ac_x_libraries} -lX11 -lXext $X_EXTRA_LIBS -lm)
)

AC_CHECK_HEADER(GL/glu.h,
	AC_DEFINE(HAVE_GL_GLU_H)
	if test x$ac_cv_lib_GL_glXMakeCurrent = xyes; then
		GLLIB="-lGLU $GLLIB"
	fi
	if test x$ac_cv_lib_MesaGL_glXMakeCurrent = xyes; then
		GLLIB="-lMesaGLU $GLLIB"
	fi
)

AC_SUBST(GLLIB)


dnl ========================================================
dnl Make sure FLTK is available.  It must be installed on
dnl a standard path, or on $x_libraries.
dnl ========================================================

AC_CACHE_SAVE

dnl Temporarily add -lfltk and OTHER-LIBRARIES (cf AC_CHECK_LIB) to $LIBS
save_LIBS="$LIBS"
LIBS="-lfltk ${GLLIB} -L${ac_x_libraries} -lXext -lX11 -lm $X_EXTRA_LIBS $LIBS"

AC_LANG_CPLUSPLUS
AC_CACHE_CHECK([for 'int fl_height (void)' in -lfltk], pose_cv_lib_fltk_found,
	AC_TRY_LINK([#include <Fl/fl_draw.H>], [fl_height ();],
		pose_cv_lib_fltk_found=yes, pose_cv_lib_fltk_found=no))

LIBS="$save_LIBS"

if test $pose_cv_lib_fltk_found = yes; then
	AC_DEFINE(HAVE_LIBFLTK)
else
	AC_MSG_ERROR(*** FLTK *must* be installed before running configure. ***)
fi


dnl ========================================================
dnl = Append the FLAGS variable that contains options for
dnl = debug, profiling and optimizing poser.
dnl ========================================================

FLAGS="$FLAGS_COMMON $FLAGS_OPTIMIZE $FLAGS_PROFILE $FLAGS_PALM_PROFILE $FLAGS_DEBUG"
POSER_CFLAGS="$POSER_CFLAGS $FLAGS $_WARNINGS_CFLAGS $_COMPILER_CFLAGS"
POSER_CXXFLAGS="$POSER_CXXFLAGS $FLAGS $_WARNINGS_CXXFLAGS $_COMPILER_CXXFLAGS"

AC_SUBST(AR)
AC_SUBST(POSER_CFLAGS)
AC_SUBST(POSER_CXXFLAGS)
AC_SUBST(THREAD_FLAGS)
AC_SUBST(THREAD_LIBS)
AC_SUBST(THREAD_SRC)


dnl ========================================================
dnl Determine which file to use for threading support.  NB:
dnl this may be obvious to most UNIX hacks, but it's very
dnl important to put spaces around the '='.  I didn't do
dnl that the first time, and I guess "test" needs those
dnl in order to know that '=' is an operator.  Without the
dnl spaces, I got incorrect results.
dnl ========================================================

AM_CONDITIONAL(SOLARIS, test x$USE_SOLARIS_CPP = xtrue)

AC_OUTPUT(Makefile Gzip/Makefile jpeg/Makefile espws-2.0/Makefile)