File: configure.ac

package info (click to toggle)
gnu-smalltalk 3.1-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 33,300 kB
  • ctags: 13,999
  • sloc: ansic: 88,106; sh: 23,223; asm: 7,889; perl: 4,493; cpp: 3,539; awk: 1,483; yacc: 1,355; xml: 1,272; makefile: 1,192; lex: 843; sed: 258; objc: 124
file content (750 lines) | stat: -rw-r--r-- 23,369 bytes parent folder | download
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
dnl Hey Emacs, I want this in -*- Autoconf -*- mode, please.
dnl ---
dnl Copyright 1992,93,94,95,99,2000,2001,2002,2003,2004,2005,2006,2007,2008
dnl Free Software Foundation, Inc.
dnl Please see COPYING for a description your rights and responsibilities
dnl with this software.
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.60)
AC_INIT([GNU Smalltalk], 3.1, help-smalltalk@gnu.org, smalltalk)
MAINTAINER="bonzini@gnu.org"

dnl CURRENT:REVISION:AGE means this is the REVISION-th version of
dnl the CURRENT-th interface; all the interface from CURRENT-AGE
dnl to CURRENT are supported.
GST_REVISION(7:2:0)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_TESTDIR(tests)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE
AC_CANONICAL_HOST

RSE_BOLD

dnl 
dnl ------------------------------- PROGRAMS ------------------

{ echo; echo "${term_bold}Build Tools:${term_norm}"; } >& AS_MESSAGE_FD

GST_PROG_CC(strict-aliasing,	   	 		           dnl enabled optimizations
    gcse,                               	                   dnl disabled optimizations
    all write-strings pointer-arith declaration-after-statement,   dnl enabled warnings
    strict-aliasing pointer-sign long-double format switch)	   dnl disabled warnings

if test "$GCC" != yes; then
  AC_MSG_ERROR([Please use GCC to compile GNU Smalltalk.])
fi

case "$host" in
  alpha*-*-*) CFLAGS="$CFLAGS -mieee" ;;
esac

# We don't require Automake 1.10, so invoke _AM_DEPENDENCIES manually.  And
# since we actually use Objective-C only on Mac OS (for libsdl), for now we
# get by with using gcc as an Objective-C compiler.
AC_SUBST(OBJC, [$CC])
AC_SUBST(OBJCFLAGS, [$CFLAGS])
_AM_DEPENDENCIES(OBJC)

AC_PROG_SED
AC_PROG_AWK
AC_PROG_LN_S
GST_PROG_LN
AC_PATH_TOOL(WINDRES, windres, no)
AC_PATH_PROG(INSTALL_INFO, install-info, :, $PATH:/sbin:/usr/sbin)
AC_PATH_PROG(ZIP, zip, no, $PATH)
if test "$ZIP" = no; then
  AC_MSG_ERROR([Please install InfoZIP to use GNU Smalltalk.])
fi

AC_ARG_WITH(emacs, 
[  --without-emacs         disable Emacs modes for Smalltalk], ,
with_emacs=yes)
test "$with_emacs" = no && EMACS=no

AM_PATH_LISPDIR
GST_EMACS_PACKAGE(comint)

AM_CONDITIONAL(WITH_EMACS, test "$EMACS" != no)
AM_CONDITIONAL(WITH_EMACS_COMINT, test "$ac_cv_emacs_comint" != no)

dnl We only want the GNU implementations
AM_MISSING_PROG(LEX, flex, $missing_dir)
AM_MISSING_PROG(YACC, bison, $missing_dir)
AM_MISSING_PROG(GPERF, gperf, $missing_dir)
AM_MISSING_PROG(AUTOM4TE, autom4te, $missing_dir)

dnl 
dnl ------------------------------ SUBDIRS --------------------

AC_ARG_WITH(system-libffi,
[  --with-system-libffi[=PATH]   use system libffi.la (search in PATH if given)],
[], [with_system_libffi=no])

if test $with_system_libffi = no; then
  AC_CONFIG_SUBDIRS(libffi)
  INCFFI='-I$(top_srcdir)/libffi/include -I$(top_builddir)/libffi/include'
  LIBFFI='$(top_builddir)/libffi/libffi.la'
elif test $with_system_libffi = yes; then
  PKG_CHECK_MODULES(FFI, libffi,
    [ INCFFI="$FFI_CFLAGS" LIBFFI="$FFI_LIBS" ],
    [ INCFFI= LIBFFI=-lffi ]
  )
else
  INCFFI="-I$withval/../include" LIBFFI="-L$withval -lffi"
fi
AC_SUBST(INCFFI)
AC_SUBST(LIBFFI)

case $ac_configure_args in
  *--enable-subdir) ;;
  *) ac_configure_args="$ac_configure_args --enable-subdir" ;;
esac
AC_SNPRINTFV_CONVENIENCE
AC_CONFIG_SUBDIRS(snprintfv)

AC_ARG_ENABLE(generational-gc,
[  --disable-generational-gc disable generational garbage collection], ,
[case $host in
	*-k*bsd-gnu | \
        *-*-cygwin* | *-*-mingw* | \
	ia64-*-* | alpha*-*-* )
	  enable_generational_gc=no ;;
        *)
	  enable_generational_gc=yes ;;
esac])

AC_ARG_WITH(system-libsigsegv,
[  --with-system-libsigsegv[=PATH]   use system libsigsegv.la likewise],
[], [with_system_libsigsegv=no])

if test $enable_generational_gc = no; then
  INCSIGSEGV= LIBSIGSEGV=
else
  AC_DEFINE(HAVE_SIGSEGV_H, 1, [Define to 1 if libsigsegv is being used])
  if test $with_system_libsigsegv = no; then
    AC_CONFIG_SUBDIRS(sigsegv)
    INCSIGSEGV='-I$(top_srcdir)/sigsegv/src -I$(top_builddir)/sigsegv/src'
    LIBSIGSEGV='$(top_builddir)/sigsegv/src/libsigsegv.la'
  elif test $with_system_libsigsegv = yes; then
    INCSIGSEGV= LIBSIGSEGV=-lsigsegv
  else
    INCSIGSEGV="-I$withval/../include" LIBSIGSEGV="-L$withval -lsigsegv"
  fi
fi
AC_SUBST(INCSIGSEGV)
AC_SUBST(LIBSIGSEGV)

AC_ARG_WITH(imagedir,
[  --with-imagedir=PATH   path where to place the system image
			  (default: /usr/local/var/lib/$PACKAGE)],
[imagedir="$withval"],
[imagedir=`echo "$libdir" | sed \
		-e 's,${exec_prefix},${localstatedir},' \
		-e "s,${exec_prefix},\${localstatedir}," `/$PACKAGE ])
AC_SUBST(imagedir)

AC_ARG_WITH(moduledir,
[  --with-moduledir=PATH  path where to look for modules
			  (default: /usr/local/lib/$PACKAGE)],
[moduledir="$withval"],
[moduledir='${pkglibdir}'])
AC_SUBST(moduledir)

dnl 
dnl ------------------------------ C COMPILER / OS ------------

{ echo; echo "${term_bold}Platform environment:${term_norm}"; } >& AS_MESSAGE_FD

GST_C_SYNC_BUILTINS
GST_LOCK
AC_SYS_LARGEFILE
AC_C_INLINE
AC_C_RESTRICT

dnl Test for broken solaris include file.  Should be moved to gnulib maybe?
AC_MSG_CHECKING([for broken sys/avl.h])
AC_PREPROC_IFELSE([#include <sys/avl.h>
  #ifndef _AVL_H
  would be useless anyway :-(
  #endif], [
  AC_MSG_RESULT(yes)
  AC_DEFINE(_AVL_H, 1,
    [Define to 1 if, like Solaris, your system has a sys/avl.h header that
pollutes the name space.])], [
  AC_MSG_RESULT(no)])

GST_C_HIDDEN_VISIBILITY
GST_C_WARN_LONG_DOUBLE
GST_C_GOTO_VOID_P

AC_DEFINE_UNQUOTED(HOST_SYSTEM, "$host",
  [Define to the host triplet.])

AC_DEFINE_UNQUOTED(EXEEXT, "$ac_exeext",
  [Define to the extension for executable files.])

case "$ac_exeext:$host_os" in
  :*) ac_argv_exeext= ;;
  .exe:cygwin*) ac_argv_exeext= ;;
  .exe:*) ac_argv_exeext=$ac_exeext ;;
esac
AC_DEFINE_UNQUOTED(ARGV_EXEEXT, "$ac_argv_exeext",
  [Define to the extension for executable files, as it appears in argv[0].])

AC_C_BIGENDIAN
AC_CHECK_ALIGNOF(double)
AC_CHECK_ALIGNOF(long double)
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(wchar_t, , [[
#include <wchar.h>]])
AC_CHECK_SIZEOF(OOP, , [[
typedef void *OOP;]])

GST_LIBC_SO_NAME

AC_LIBTOOL_TAGS
AC_LIBTOOL_DLOPEN
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

# We define two tags for LIBTOOL, one of which is special
# for libgst.

save_enable_shared=$enable_shared
GST_LIBTOOL_TAG(LIBGST, CC, [
  case "$host_cpu:$GCC:`$CC -v 2>&1 | sed -n '[s/^gcc version \([0-9.]*\).*/\1/p]'`" in
   *:no:*)
     enable_shared=no ;;

   # Old versions of GCC do not support the visibility attribute,
   # and we need it otherwise the library is dead slow.
   [*:*:[12].*])
     enable_shared=no ;;

   [*:*:3.[012]*])
     enable_shared=no ;;

   i*86:yes:*)
     # For the x86, building a shared library with the frame pointer
     # is too slow.  On the other hand, most people will find a static
     # library without it undebuggable, which is a problem with respeect
     # to bug reports.  For this reason, we hack libtool to allow
     # additional flags to be specified for the PIC case.
     _LT_AC_TAGVAR(lt_prog_compiler_pic, LIBGST)="dnl
$lt_prog_compiler_pic -fomit-frame-pointer" ;;

   *) ;;
  esac
])
enable_shared=$save_enable_shared

case "$host_os:$WINDRES" in
  *:no) ICON= ;;
  cygwin*|mingw*) ICON=gsticon.o ;;
  *) ICON= ;;
esac
AC_SUBST(ICON)

dnl 
dnl ------------------------------- C LIBRARY -----------------

{ echo; echo "${term_bold}C library features:${term_norm}"; } >& AS_MESSAGE_FD

AC_TYPE_SIGNAL
AC_TYPE_PID_T
AC_TYPE_SIZE_T

AC_HEADER_ASSERT
AC_CHECK_HEADERS_ONCE(stdint.h inttypes.h unistd.h poll.h sys/ioctl.h \
	sys/resource.h sys/utsname.h stropts.h sys/param.h stddef.h limits.h \
	sys/timeb.h termios.h sys/mman.h sys/file.h execinfo.h utime.h \
	sys/select.h sys/wait.h fcntl.h, [], [], [AC_INCLUDES_DEFAULT])

AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec,
		  struct stat.st_mtimespec.tv_nsec])

AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INTMAX_T
AC_TYPE_INTPTR_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINTMAX_T
AC_TYPE_UINTPTR_T

if test x$ac_cv_header_poll_h = xno; then
  AC_CONFIG_LINKS([lib-src/poll.h:lib-src/poll_.h])
fi

AC_FUNC_ALLOCA
AC_FUNC_OBSTACK

AC_CHECK_LIB(m, atan)
GST_REPLACE_POLL
gt_FUNC_SETENV
GST_SOCKETS
AC_REPLACE_FUNCS(putenv strdup strerror strsignal mkstemp getpagesize \
	getdtablesize strstr ftruncate floorl ceill sqrtl frexpl ldexpl asinl \
	acosl atanl logl expl tanl sinl cosl powl truncl lrintl strsep strpbrk \
	symlink mkdtemp)
AC_CHECK_FUNCS_ONCE(gethostname memcpy memmove sighold uname usleep lstat \
	grantpt popen getrusage gettimeofday fork strchr utimes utime readlink \
	sigsetmask alarm select mprotect madvise waitpid \
	setsid spawnl nanosleep pread pwrite _NSGetExecutablePath)

GST_FUNC_LRINT
GST_FUNC_STRTOUL
GST_FUNC_LOCALTIME

{ echo; echo "${term_bold}Dynamic linking capabilities:${term_norm}"; } >& AS_MESSAGE_FD

AC_LIB_LTDL

dnl ------------------------- OTHER LIBRARIES -------------------

{ echo; echo "${term_bold}Auxiliary libraries:${term_norm}"; } >& AS_MESSAGE_FD

GST_HAVE_GMP
GST_HAVE_READLINE

GST_PACKAGE_PREFIX([packages])
GST_PACKAGE_DEPENDENCIES([gst-tool gst.im])

GST_PACKAGE_ENABLE([BloxTK], [blox/tk],
   [GST_HAVE_TCLTK],
   [gst_cv_tcltk_libs],
   [Makefile], [blox-tk.la])
GST_PACKAGE_ENABLE([Browser], [browser])
GST_PACKAGE_ENABLE([Complex], [complex])
GST_PACKAGE_ENABLE([Continuations], [continuations])
GST_PACKAGE_ENABLE([CParser], [cpp])
GST_PACKAGE_ENABLE([DebugTools], [debug])

GST_PACKAGE_ENABLE([DBD-MySQL], [dbd-mysql])
AC_MSG_CHECKING([whether to run MySQL tests])
AC_ARG_ENABLE(mysql-tests,
[  --enable-mysql-tests=USER:PWD:DATABASE
                          test MySQL bindings [default=root:root:test]], ,
[enable_mysql_tests=no])
AC_SUBST(enable_mysql_tests)
AC_MSG_RESULT($enable_mysql_tests)

GST_PACKAGE_ENABLE([DBD-PostgreSQL], [dbd-postgresql],
   [GST_HAVE_LIB(pq, PQconnectdb)],
   [ac_cv_lib_pq_PQconnectdb])

GST_PACKAGE_ENABLE([DBD-SQLite], [dbd-sqlite],
   [AC_CHECK_HEADER([sqlite3.h])
    GST_HAVE_LIB(sqlite3, sqlite3_clear_bindings)],
   [ac_cv_header_sqlite3_h],
   [Makefile], [dbd-sqlite3.la])

GST_PACKAGE_ENABLE([DBI], [dbi])

GST_PACKAGE_ENABLE([GDBM], [gdbm],
   [AC_CHECK_HEADER([gdbm.h])],
   [ac_cv_header_gdbm_h],
   [Makefile], [gdbm.la])
GST_PACKAGE_ENABLE([Glorp], [glorp])
GST_PACKAGE_ENABLE([GTK], [gtk], [
  AC_ARG_ENABLE(gtk,
  [  --enable-gtk={yes,no,blox}
                          enable GTK+ bindings.  Blox/GTK is experimental.], ,
  enable_gtk=yes)

  if test "$enable_gtk" != no; then
    maybe_enable_gtk=$enable_gtk
    enable_gtk=no
    AM_PATH_GLIB_2_0(2.0.0, [
      AM_PATH_GTK_2_0(2.0.0, [
        PKG_CHECK_MODULES(ATK, atk >= 1.0.0, [
          PKG_CHECK_MODULES(PANGO, pango >= 1.0.0, [enable_gtk=$maybe_enable_gtk])
        ])
      ])
    ], [], gobject)
  fi],
  [enable_gtk],
  [Makefile], [gst-gtk.la])
GST_PACKAGE_ENABLE([BloxGTK], [blox/gtk],, [enable_gtk])
GST_PACKAGE_ENABLE([Blox], [blox/tests],
	    [enable_blox=no
	     case x"$enable_gtk" in
		 xno|xnot\ found) ;; *) enable_blox=yes ;; esac
	     case x"$gst_cv_tcltk_libs" in
		 xno|xnot\ found) ;; *) enable_blox=yes ;; esac], 
	    [enable_blox], [package.xml])
GST_PACKAGE_ENABLE([WebServer], [httpd])
GST_PACKAGE_ENABLE([I18N], [i18n],
  [AC_CHECK_FUNCS_ONCE([nl_langinfo])
  AM_LANGINFO_CODESET
  AM_ICONV],
  [ac_cv_func_nl_langinfo am_cv_func_iconv],
  [Makefile], [i18n.la])
GST_PACKAGE_ENABLE([Iconv], [iconv],
  [AM_ICONV],
  [am_cv_func_iconv],
  [Makefile], [iconv.la])
GST_PACKAGE_ENABLE([Java], [java])
GST_PACKAGE_ENABLE([Digest], [digest], [], [], [Makefile], [digest.la])
GST_PACKAGE_ENABLE([GNUPlot], [gnuplot])
GST_PACKAGE_ENABLE([Magritte], [magritte])
GST_PACKAGE_ENABLE([Magritte-Seaside], [seaside/magritte])

GST_PACKAGE_ENABLE([NCurses],
  [ncurses],
  [GST_HAVE_LIB(ncurses, initscr)],
  [ac_cv_lib_ncurses_initscr])
GST_PACKAGE_ENABLE([NetClients], [net])
GST_PACKAGE_ENABLE([DhbNumericalMethods], [numerics])
GST_PACKAGE_ENABLE([OpenGL], [opengl],
   [GST_HAVE_OPENGL],
   [gst_cv_opengl_libs],
   [Makefile], [gstopengl.la])
GST_PACKAGE_ENABLE([GLUT], [glut],
   [GST_HAVE_GLUT],
   [gst_cv_glut_libs],
   [Makefile], [gstglut.la])

GST_PACKAGE_ENABLE([Cairo], [cairo],
  [GST_HAVE_LIB(cairo, cairo_save)],
  [ac_cv_lib_cairo_cairo_save])

GST_PACKAGE_ENABLE([LibSDL], [sdl/libsdl],
  [AM_PATH_SDL([], gst_cv_sdl=yes, gst_cv_sdl=no)
  case "$SDL_LIBS" in
    *-framework,Cocoa* | *"-framework Cocoa"*) gst_cv_sdl_uses_cocoa=yes ;;
    *) gst_cv_sdl_uses_cocoa=no ;;
  esac
  AM_CONDITIONAL([HAVE_COCOA], [test $gst_cv_sdl_uses_cocoa = yes])],
  [gst_cv_sdl],
  [Makefile], [sdl.la])
GST_PACKAGE_ENABLE([LibSDL_GL], [sdl/libsdl_gl], [],
		   [gst_cv_sdl gst_cv_opengl_libs])
GST_PACKAGE_ENABLE([CairoSDL], [sdl/cairo],
  [],
  [ac_cv_lib_cairo_cairo_save gst_cv_sdl])
GST_PACKAGE_ENABLE([LibSDL_image], [sdl/libsdl_image],
  [GST_HAVE_LIB(SDL_image, IMG_Linked_Version)],
  [ac_cv_lib_SDL_image_IMG_Linked_Version])
GST_PACKAGE_ENABLE([LibSDL_mixer], [sdl/libsdl_mixer],
  [GST_HAVE_LIB(SDL_mixer, Mix_Linked_Version)],
  [ac_cv_lib_SDL_mixer_Mix_Linked_Version])
GST_PACKAGE_ENABLE([LibSDL_sound], [sdl/libsdl_sound],
  [GST_HAVE_LIB(SDL_sound, Sound_GetLinkedVersion)],
  [ac_cv_lib_SDL_sound_Sound_GetLinkedVersion])
GST_PACKAGE_ENABLE([LibSDL_ttf], [sdl/libsdl_ttf],
  [GST_HAVE_LIB(SDL_ttf, TTF_Init)],
  [ac_cv_lib_SDL_ttf_TTF_Init])

GST_PACKAGE_ENABLE([Compiler], [stinst/compiler])
GST_PACKAGE_ENABLE([Parser], [stinst/parser])
GST_PACKAGE_ENABLE([ClassPublisher], [stinst/doc])
GST_PACKAGE_ENABLE([ROE], [roe])
GST_PACKAGE_ENABLE([Seaside-Core], [seaside/core])
GST_PACKAGE_ENABLE([Seaside-Development], [seaside/dev])
GST_PACKAGE_ENABLE([Seaside-Examples], [seaside/examples])
GST_PACKAGE_ENABLE([Seaside], [seaside/swazoo])
GST_PACKAGE_ENABLE([Sport], [sport])
GST_PACKAGE_ENABLE([SUnit], [sunit])
GST_PACKAGE_ENABLE([Swazoo], [swazoo-httpd])
GST_PACKAGE_ENABLE([Sockets], [sockets], [],
  [gst_cv_sockets],
  [Makefile], [sockets.la])
GST_PACKAGE_ENABLE([VFSAddOns], [vfs], [], [], [Makefile])
GST_PACKAGE_ENABLE([XML-XMLNodeBuilder], [xml/builder])
GST_PACKAGE_ENABLE([XML-DOM], [xml/dom])
GST_PACKAGE_ENABLE([XML-XMLParser], [xml/parser])
GST_PACKAGE_ENABLE([XML-SAXDriver], [xml/saxdriver])
GST_PACKAGE_ENABLE([XML-SAXParser], [xml/saxparser])
GST_PACKAGE_ENABLE([XPath], [xml/xpath])
GST_PACKAGE_ENABLE([XSL], [xml/xsl])
GST_PACKAGE_ENABLE([ZLib],
  [zlib],
  [AC_CHECK_HEADER([zlib.h])],
  [ac_cv_header_zlib_h],
  [Makefile], [zlib.la])

if test "$enable_gtk" = blox; then
  BLOX_IMPLEMENTATION=BloxGTK
else
  BLOX_IMPLEMENTATION=BloxTK
fi
AC_SUBST(BLOX_IMPLEMENTATION)

AC_ARG_ENABLE(jit, 
[  --enable-jit            enable dynamic translation to machine code], ,
enable_jit=no)

LIGHTNING_CONFIGURE_IF_NOT_FOUND([], enable_jit=no)
if test "$enable_jit" != no; then
  AC_DEFINE(ENABLE_JIT_TRANSLATION, 1, 
    [Define to enable dynamic translation to machine code])
fi

AC_ARG_ENABLE(disassembler, 
[  --enable-disassembler   include a disassembler in the gst executable], ,
enable_disassembler=no)
AM_CONDITIONAL(ENABLE_DISASSEMBLER, test "$enable_disassembler" != no)
if test "$enable_disassembler" != no; then
  AC_DEFINE(ENABLE_DISASSEMBLER, 1, 
    [Define to include a disassembler in the gst executable])
fi

AC_ARG_ENABLE(dld,
[  --disable-dld           disable loading of external modules at runtime], ,
enable_dld=yes)

if test "$enable_dld" != no; then
  AC_DEFINE(ENABLE_DLD, 1,
    [Define to enable usage of libltdl to load external modules at runtime])
fi

AC_ARG_ENABLE(checking,
[  --enable-checking       enable assertions at runtime], ,
enable_checking=no)

if test "$enable_checking" = no; then
  AC_DEFINE(OPTIMIZE, 1,
    [Define to disable assertion checking at runtime])
fi

AC_ARG_ENABLE(preemption,
[  --enable-preemption     enable preemptive multitasking], ,
enable_preemption=no)

if test "$enable_preemption" != no; then
  AC_DEFINE(ENABLE_PREEMPTION, 1,
    [Define to enable preemptive multitasking of Smalltalk processes])
fi

GST_ARG_ENABLE_MODULES([Blox,TCP])

dnl 
dnl ------------------------------- RELOCATABILITY ------------

# See if we can make the installed binaries relocatable

AC_MSG_CHECKING([whether to enable relocatable install])
AC_RELOCATABLE_NOP
relocatable_reason=$RELOCATABLE

# First of all, compute the final paths for the various components.

AC_LIB_PREPARE_PREFIX

acl_final_datadir=`echo "${datadir}" | sed \
	-e "s,\\\${datarootdir},$datarootdir," \
	-e "s,\\\${exec_prefix},$acl_final_exec_prefix," \
	-e "s,\\\${prefix},$acl_final_prefix," `
acl_final_bindir=`echo "${bindir}" | sed \
	-e "s,\\\${exec_prefix},$acl_final_exec_prefix," \
	-e "s,\\\${prefix},$acl_final_prefix," `
acl_final_libdir=`echo "${libdir}" | sed \
	-e "s,\\\${exec_prefix},$acl_final_exec_prefix," \
	-e "s,\\\${prefix},$acl_final_prefix," `
acl_final_libexecdir=`echo "${libexecdir}" | sed \
	-e "s,\\\${exec_prefix},$acl_final_exec_prefix," \
	-e "s,\\\${prefix},$acl_final_prefix," `

acl_final_pkgdatadir="$acl_final_datadir/$PACKAGE"
acl_final_pkglibdir="$acl_final_libdir/$PACKAGE"

acl_final_imagedir=`echo "${imagedir}" | sed \
	-e "s,\\\${localstatedir},$localstatedir," \
	-e "s,\\\${pkgdatadir},$pkgdatadir," \
	-e "s,\\\${datadir},$datadir," \
	-e "s,\\\${docdir},$docdir," \
	-e "s,\\\${datarootdir},$datarootdir," \
	-e "s,\\\${pkglibdir},$acl_final_pkglibdir," \
	-e "s,\\\${libdir},$acl_final_libdir," \
	-e "s,\\\${exec_prefix},$acl_final_exec_prefix," \
	-e "s,\\\${prefix},$acl_final_prefix," `
acl_final_moduledir=`echo "${moduledir}" | sed \
	-e "s,\\\${localstatedir},$localstatedir," \
	-e "s,\\\${pkgdatadir},$pkgdatadir," \
	-e "s,\\\${datadir},$datadir," \
	-e "s,\\\${docdir},$docdir," \
	-e "s,\\\${datarootdir},$datarootdir," \
	-e "s,\\\${pkglibdir},$acl_final_pkglibdir," \
	-e "s,\\\${libdir},$acl_final_libdir," \
	-e "s,\\\${exec_prefix},$acl_final_exec_prefix," \
	-e "s,\\\${prefix},$acl_final_prefix," `


# If shared libraries are enabled, there are a few extra constraints.

if test "$enable_shared" != no; then
  case $host in
    *-*-cygwin* | *-*-mingw*)
      # For Windows, the shared library must be in the bindir
      if test "$acl_final_libdir" != "${acl_final_bindir}"; then
        relocatable_reason='no, libdir not equal to bindir'
      fi
      ;;

    *-linux*)
      # For Linux, we can use a relative rpath via -Wl,-rpath,...
      case "$acl_final_libdir" in
        "${acl_final_exec_prefix}"/*) ;;
        /*) relocatable_reason='no, libdir outside exec-prefix' ;;
        *) relocatable_reason='no, relative libdir' ;;
      esac
      ;;

    *)
      relocatable_reason="no,
	relocatable shared libraries not supported on $host"
      ;;
  esac
fi

# Further OS-independent tests ensure that we can make relative
# paths from the executable's location.

if test "$relocatable_reason" = yes; then
  case "${acl_final_bindir}" in
    "${acl_final_exec_prefix}"/*) ;;
    /*) relocatable_reason='no, bindir outside exec-prefix' ;;
    *) relocatable_reason='no, relative bindir' ;;
  esac
  case "${acl_final_libexecdir}" in
    ${acl_final_exec_prefix}/*) ;;
    /*) relocatable_reason='no, libexecdir outside exec_prefix' ;;
    *) relocatable_reason='no, relative libexecdir' ;;
  esac
  case "${acl_final_datadir}" in
    ${acl_final_prefix}/*) ;;
    /*) relocatable_reason='no, datadir outside prefix' ;;
    *) relocatable_reason='no, relative datadir' ;;
  esac
  case "${acl_final_imagedir}" in
    ${acl_final_prefix}/*) ;;
    /*) relocatable_reason='no, imagedir outside prefix' ;;
    *) relocatable_reason='no, relative imagedir' ;;
  esac
  case "${acl_final_moduledir}" in
    ${acl_final_prefix}/*) ;;
    /*) relocatable_reason='no, moduledir outside prefix' ;;
    *) relocatable_reason='no, relative moduledir' ;;
  esac

  test "$acl_final_prefix" != "$acl_final_exec_prefix" && \
    relocatable_reason='no, prefix does not match exec prefix'
fi

# echo the relative path from ${acl_final_bindir} to $1
# (Works only if both are absolute.)
[func_make_relpath ()
{
  dir=$1
  idir=${acl_final_bindir}

  while true; do
    dfirst=`echo "$dir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'`
    ifirst=`echo "$idir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'`
    test x"$dfirst" = x && break
    test x"$ifirst" = x && break
    test "$dfirst" != "$ifirst" && break

    dir=`echo "$dir" | sed -e 's,^//*[^/]*,,'`
    idir=`echo "$idir" | sed -e 's,^//*[^/]*,,'`
  done
  idir=`echo "$idir" | sed -e 's,//*[^/]*,/..,g' -e 's,^/,,' `
  if test x"$idir$dir" = x; then
    echo .
  else
    echo "$idir$dir"
  fi
}]

case "$relocatable_reason" in
  yes)
    # Command-line option to include a relative search path for
    # shared libraries
    if test "$enable_shared" != no; then
      case "$host" in
        *-linux*)
          RELOC_LDFLAGS='-Wl,-rpath,"\$$ORIGIN/'`func_make_relpath ${acl_final_libdir}`'"'
	  ;;
      esac
    fi

    KERNEL_PATH=`func_make_relpath ${acl_final_pkgdatadir}/kernel`
    IMAGE_PATH=`func_make_relpath ${acl_final_imagedir}`
    MODULE_PATH=`func_make_relpath ${acl_final_moduledir}`
    LIBEXEC_PATH=`func_make_relpath "${acl_final_libexecdir}/${PACKAGE}"`
    AC_DEFINE_UNQUOTED(KERNEL_PATH, "$KERNEL_PATH",
		       [The relative path from the program to the kernel path.
		        Defined only for relocatable installs.])
    AC_DEFINE_UNQUOTED(IMAGE_PATH, "$IMAGE_PATH",
		       [The relative path from the program to the image path.
		        Defined only for relocatable installs.])
    AC_DEFINE_UNQUOTED(MODULE_PATH, "$MODULE_PATH",
		       [The relative path from the program to the module path.
		        Defined only for relocatable installs.])
    AC_DEFINE_UNQUOTED(LIBEXEC_PATH, "$LIBEXEC_PATH",
		       [The relative path from the program to the per-package
			libexec path.  Defined only for relocatable installs.])
    ;;

  *)
    # Pass paths on the command-line to allow specifying a prefix at "make"
    # time.
    RELOC_CPPFLAGS='-DKERNEL_PATH=\""${pkgdatadir}/kernel"\" \
	-DIMAGE_PATH=\""${imagedir}"\" \
	-DMODULE_PATH=\""${moduledir}"\" \
	-DLIBEXEC_PATH=\""${libexecdir}/${PACKAGE}"\"'
    ;;
esac

RELOC_CPPFLAGS=$RELOC_CPPFLAGS' \
	-DDEFAULT_EXECUTABLE=\""${bindir}/gst${EXEEXT}"\"'
AC_MSG_RESULT([$relocatable_reason])
AC_SUBST(RELOC_CPPFLAGS)
AC_SUBST(RELOC_LDFLAGS)

dnl 
dnl ------------------------------- FILE GENERATION -----------

{ echo; echo "${term_bold}Output substitutions:${term_norm}"; } >& AS_MESSAGE_FD

AC_CONFIG_COMMANDS_PRE([
  LTLIBOBJS=`echo "$LIB@&t@OBJS" |
                sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`

  LTALLOCA=`echo "$ALLOCA" | sed 's/\.o/.lo/g'`
])

GST_RUN='$(top_builddir)/gst -I $(top_builddir)/gst.im -f'

AC_SUBST(GST_RUN)
AC_SUBST(CFLAGS)
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
AC_SUBST(LTALLOCA)
AC_SUBST(LTLIBOBJS)

dnl Scripts & data files
AC_CONFIG_FILES(gnu-smalltalk.pc)
AC_CONFIG_FILES(gst-config, chmod +x gst-config)
AC_CONFIG_FILES(tests/gst, chmod +x tests/gst)
AC_CONFIG_FILES(tests/atlocal)
AC_CONFIG_FILES(libc.la)

dnl Master Makefile
AC_CONFIG_FILES(Makefile)

dnl VM makefiles
AC_CONFIG_FILES(doc/Makefile lib-src/Makefile libgst/Makefile)
AC_CONFIG_FILES(opcode/Makefile lightning/Makefile tests/Makefile)

AC_OUTPUT