~ubuntu-branches/ubuntu/jaunty/maloc/jaunty

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
751
752
753
754
755
756
dnl ##########################################################################
dnl MALOC = < Minimal Abstraction Layer for Object-oriented C >
dnl Copyright (C) 1994--2000  Michael Holst
dnl
dnl This program is free software; you can redistribute it and/or modify it
dnl under the terms of the GNU General Public License as published by the
dnl Free Software Foundation; either version 2 of the License, or (at your
dnl option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
dnl See the GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License along
dnl with this program; if not, write to the Free Software Foundation, Inc.,
dnl 675 Mass Ave, Cambridge, MA 02139, USA.
dnl
dnl rcsid="$Id: configure.ac,v 1.91 2006/06/03 07:22:28 mholst Exp $"
dnl ##########################################################################

dnl ##########################################################################
dnl File:    configure.ac
dnl
dnl Purpose: configure.ac script for MALOC (Minimal Abstraction Layer
dnl          for Object-oriented C).
dnl
dnl Notes:   You process this file with autoconf to produce a "configure"
dnl          shell script by using several tools in the autoconf suite in
dnl          succession:
dnl
dnl             rm -rf config.cache autom4te.cache
dnl             aclocal \
dnl             && automake --gnu --add-missing --copy \
dnl             && autoconf \
dnl             && autoheader \
dnl             && libtoolize --automake --copy --force
dnl             rm -rf config.cache autom4te.cache
dnl
dnl          The above generates the script "configure", the package
dnl          pre-header "config.h", and all required "Makefile.in"
dnl          pre-makefiles.  To build the package you type the following:
dnl
dnl             rm -rf config.cache autom4te.cache
dnl             ./configure
dnl             make
dnl             make install
dnl
dnl          Running the "configure" script generates the package header
dnl          "config.h" from the pre-header "config.h.in", and generates
dnl          all "Makefiles" from all pre-makefiles "Makefile.in".
dnl
dnl Details: Below are some diagrams twisted from the GNU autoconf info
dnl          pages, with some automake paths thrown in, which show the
dnl          relationships between the various autoconf utilities.  The
dnl          names followed by "*" indicate the execution of a program
dnl          or a script (possibly produced at an earlier stage).  The
dnl          names in brackets "[ ]" represent optional steps, such as
dnl          the use of automake and/or autoheader.
dnl
dnl
dnl          Preparing a software package for distribution using autoconf:
dnl
dnl
dnl             source files-->[autoscan*]-->[configure.scan]-->configure.ac
dnl
dnl             [Makefile.am] -+---------> [automake*] --------> Makefile.in
dnl                            |
dnl             configure.ac --.   .--------> autoconf* ---------> configure
dnl                            +---+
dnl             [aclocal.m4] --+   `---.
dnl             [acsite.m4] ---'       |
dnl                                    +--> [autoheader*] ---> [config.h.in]
dnl                                    |
dnl             - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
dnl                                    |
dnl             [acconfig.h] ----.     |  BELOW THIS LINE IS NOW DEPRECATED;
dnl                              +-----'  AUTOCONF NOW SUPPORTS A COMPLETELY
dnl             [config.h.top] --+        SELF-CONTAINED configure.ac FILE.
dnl             [config.h.bot] --'
dnl
dnl
dnl
dnl          Building the resulting package using "configure" and "make":
dnl
dnl
dnl                                   .------------> config.cache
dnl             configure* -----------+------------> config.log
dnl                                   |
dnl             [config.h.in] -.      v           .-> [config.h] -.
dnl                            +-->config.status*-+               +--> make*
dnl             Makefile.in ---'                  `-> Makefile ---'
dnl
dnl Author:  Michael Holst
dnl ##########################################################################

dnl ##########################################################################
dnl 0. autoconf initialization
dnl ##########################################################################

dnl # Autoconf init, autoheader output location, config and prefix directories
AC_INIT(maloc, 1.0, mholst@math.ucsd.edu)
AC_CONFIG_SRCDIR(src/aaa_inc/maloc/maloc.h)
AC_CONFIG_HEADERS(src/aaa_inc/maloccf.h)
AC_CONFIG_AUX_DIR(config)
AC_PREFIX_DEFAULT(${HOME})

dnl # Get the CPU-VENDOR-OS triplet
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
fetk_cpu_vendor_os="${host_cpu}-${host_vendor}-${host_os}";
AC_SUBST(fetk_cpu_vendor_os)

dnl ##########################################################################
dnl 1. automake initialization
dnl ##########################################################################

dnl -------------------------------------------
dnl AM_INIT_AUTOMAKE does:    PACKAGE="fetk";
dnl                           VERSION="1.0";
dnl                           AC_SUBST(PACKAGE)
dnl                           AC_SUBST(VERSION)
dnl                           AC_ARG_PROGRAM
dnl                           AC_PROG_MAKE_SET
dnl                           AM_SANITY_CHECK
dnl                           AC_PROG_INSTALL
dnl                           AM_MISSING_PROG
dnl So, we do this all in one shot
dnl AM_INIT_AUTOMAKE(maloc, 1.0)
dnl -------------------------------------------
dnl The above is deprecated; now we only do:
AM_INIT_AUTOMAKE([foreign]) 

dnl We need a separate FETK_VERSION macro for use by libtool
FETK_VERSION="1:0:0"
AC_SUBST(FETK_VERSION)

dnl Autoconf (or rather Automake) is not very smart about making sure that
dnl even if the various autotools exist that they actually WORK.  A common
dnl problem is that someone has installed autoconf and automake, but they
dnl forgot to replace the native (broken) version of M4 with GNU M4.  This
dnl makes everything break.  Moreover, automake always places targets in
dnl the Makefile.in files that will try to run autoconf/automake/etc if
dnl various dependencies seem to require it, as long as autoconf/automake
dnl seem to exist (even with broken M4).  Therefore, we override
dnl AM_INIT_AUTOMAKE and set the autotools to no-ops with the following
dnl macro definitions.  (This just means that if you change a Makefile.am,
dnl then you have to remember to re-run automake yourself.  This can be
dnl done by running the config/bootstrap shell script.)
dnl ACLOCAL=":";
dnl AUTOCONF=":";
dnl AUTOMAKE=":";
dnl AUTOHEADER=":";
dnl AC_SUBST(ACLOCAL)
dnl AC_SUBST(AUTOCONF)
dnl AC_SUBST(AUTOMAKE)
dnl AC_SUBST(AUTOHEADER)
AM_MAINTAINER_MODE

dnl ##########################################################################
dnl 2. checks for programs
dnl ##########################################################################

dnl # Basic compiler and related tools
AC_LANG_C
AC_PROG_CC
AC_PROG_CPP
AM_PROG_LEX
AC_PROG_YACC

dnl # Libtool stuff
AC_DISABLE_SHARED
AM_PROG_LIBTOOL
dnl AM_PROG_LIBTOOL makes AC_PROG_RANLIB unnecessary
dnl striplib="";
dnl old_striplib="";
dnl AC_SUBST(striplib)
dnl AC_SUBST(old_striplib)

dnl ##########################################################################
dnl 3. checks for libraries
dnl ##########################################################################

dnl # Check for the math library.
AC_CHECK_LIB(m,pow,[math_lib="-lm"],[math_lib=""])
AC_SUBST(math_lib)

dnl # Check for the Liberty library (useful for debugging on Linux).
AC_CHECK_LIB(iberty,strerrno,[liberty_lib="-liberty"],[liberty_lib=""])
AC_SUBST(liberty_lib)

dnl # Check for "gethostbyname" and nsl library
nsl_lib="";
AC_CHECK_FUNC(gethostbyname,[try_nsl=""],[try_nsl="yes"])
if test -n "${try_nsl}"; then
    AC_CHECK_LIB(nsl,gethostbyname,[nsl_lib="-lnsl"],[nsl_lib=""])
fi
AC_SUBST(nsl_lib)

dnl # Check for "connect" and socket library
socket_lib="";
AC_CHECK_FUNC(connect,[try_socket=""],[try_socket="yes"])
if test -n "${try_socket}"; then
    AC_CHECK_LIB(socket,connect,[socket_lib="-lsocket"],[socket_lib=""])
fi
AC_SUBST(socket_lib)

dnl # Check for "thr_create" and thread library
thread_lib="";
AC_CHECK_FUNC(thr_create,[try_thread=""],[try_thread="yes"])
if test -n "${try_thread}"; then
    AC_CHECK_LIB(thread,thr_create,[thread_lib="-lthread"],[thread_lib=""])
fi
AC_SUBST(thread_lib)

dnl ##########################################################################
dnl 4. checks for header files
dnl ##########################################################################

dnl # Check for the 15 Standard C (ANSI-C/ISO-C) headers.
AC_HEADER_STDC
dnl AC_CHECK_HEADER(assert.h,, AC_MSG_ERROR([STDC <assert.h> not found.]))
dnl AC_CHECK_HEADER(ctype.h,,  AC_MSG_ERROR([STDC <ctype.h> not found.]))
dnl AC_CHECK_HEADER(errno.h,,  AC_MSG_ERROR([STDC <errno.h> not found.]))
dnl AC_CHECK_HEADER(float.h,,  AC_MSG_ERROR([STDC <float.h> not found.]))
dnl AC_CHECK_HEADER(limits.h,, AC_MSG_ERROR([STDC <limits.h> not found.]))
dnl AC_CHECK_HEADER(locale.h,, AC_MSG_ERROR([STDC <locale.h> not found.]))
dnl AC_CHECK_HEADER(math.h,,   AC_MSG_ERROR([STDC <math.h> not found.]))
dnl AC_CHECK_HEADER(setjmp.h,, AC_MSG_ERROR([STDC <setjmp.h> not found.]))
dnl AC_CHECK_HEADER(signal.h,, AC_MSG_ERROR([STDC <signal.h> not found.]))
dnl AC_CHECK_HEADER(stdarg.h,, AC_MSG_ERROR([STDC <stdarg.h> not found.]))
dnl AC_CHECK_HEADER(stddef.h,, AC_MSG_ERROR([STDC <stddef.h> not found.]))
dnl AC_CHECK_HEADER(stdio.h,,  AC_MSG_ERROR([STDC <stdio.h> not found.]))
dnl AC_CHECK_HEADER(stdlib.h,, AC_MSG_ERROR([STDC <stdlib.h> not found.]))
dnl AC_CHECK_HEADER(string.h,, AC_MSG_ERROR([STDC <string.h> not found.]))
dnl AC_CHECK_HEADER(time.h,,   AC_MSG_ERROR([STDC <time.h> not found.]))

dnl # Check for some additional UNIX-like headers that we need.
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS( \
    unistd.h \
    sys/types.h \
    sys/time.h \
    sys/times.h \
    sys/stat.h \
    fcntl.h \
    sys/socket.h \
    sys/un.h \
    netinet/in.h \
    arpa/inet.h \
    netdb.h \
    rpc/rpc.h \
)

dnl ##########################################################################
dnl 5. checks for typedefs
dnl ##########################################################################

AC_TYPE_MODE_T
AC_TYPE_PID_T

dnl ##########################################################################
dnl 6. checks for structures
dnl ##########################################################################

dnl ##########################################################################
dnl 7. checks for compiler characteristics
dnl ##########################################################################

dnl ##########################################################################
dnl 8. checks for library functions
dnl ##########################################################################

AC_HEADER_STAT

AC_MSG_CHECKING([for xdrmem_create in <rpc/rpc.h>])
AC_HEADER_EGREP(xdrmem_create, rpc/rpc.h,
    [xdrmem_create_ok=yes;AC_DEFINE(HAVE_XDR)],[xdrmem_create_ok=no;])
AC_MSG_RESULT(${xdrmem_create_ok})

AC_MSG_CHECKING([for getcwd in <unistd.h>])
AC_HEADER_EGREP(getcwd, unistd.h,
    [getcwd_ok=yes;AC_DEFINE(HAVE_GETCWD)],[getcwd_ok=no;])
AC_MSG_RESULT(${getcwd_ok})

AC_MSG_CHECKING([for O_NONBLOCK in <fcntl.h>])
AC_TRY_COMPILE(
    [#include <fcntl.h>],
    [unsigned short a; a && O_NONBLOCK;],
    [o_nonblock_ok=yes;AC_DEFINE(HAVE_O_NONBLOCK)],[o_nonblock_ok=no])
AC_MSG_RESULT(${o_nonblock_ok})

AC_MSG_CHECKING([whether accept() in <sys/socket.h> wants ulong, uint, or int])
dnl AC_DEFINE(ACCEPT_USES_ULONG)
dnl AC_DEFINE(ACCEPT_USES_UINT)
AC_MSG_RESULT([unclear])

dnl ##########################################################################
dnl 9. checks for system services
dnl ##########################################################################

dnl ##########################################################################
dnl 10. checks for anything else
dnl ##########################################################################

dnl # ---------------------------------------------------
dnl # HANDLE VARIOUS ARCHITECTURE-SPECIFIC CONFIGURATIONS
dnl # ---------------------------------------------------
if test "${host_os}" = "cygwin"; then
    AC_DEFINE(HAVE_CYGWIN)
fi

dnl # ---------------------------
dnl # HANDLE THE READLINE LIBRARY
dnl # ---------------------------
rl_lib="";
rl_inc="";

dnl # READLINE header location ENV specification
AC_MSG_CHECKING([whether your environment defines FETK_RL_INCLUDE])
if test -n "${FETK_RL_INCLUDE}"; then
    AC_MSG_RESULT([yes])
    rl_inc_path="-I${FETK_RL_INCLUDE} ";
else
    AC_MSG_RESULT([no])
    rl_inc_path="";
fi

dnl # READLINE library location ENV specification
AC_MSG_CHECKING([whether your environment defines FETK_RL_LIBRARY])
if test -n "${FETK_RL_LIBRARY}"; then
    AC_MSG_RESULT([yes])
    rl_lib_path="-L${FETK_RL_LIBRARY} ";
else
    AC_MSG_RESULT([no])
    rl_lib_path="";
fi

dnl # Setup temp LDFLAGS and CPPFLAGS and look for READLINE library/header
LDFLAGS_SAVE=${LDFLAGS};
CPPFLAGS_SAVE=${CPPFLAGS};
LDFLAGS=${rl_lib_path};
CPPFLAGS=${rl_inc_path};
AC_CHECK_HEADER(readline/readline.h,
    [rl_use="yes";rl_inc="${rl_inc_path}"],
    [rl_use="";rl_inc=""])
if test -n "${rl_use}"; then
    AC_CHECK_HEADER(readline/history.h,
        [rl_use="yes";rl_inc="${rl_inc_path}"],
        [rl_use="";rl_inc=""])
    if test -n "${rl_use}"; then
        AC_CHECK_LIB(ncurses,tgetnum,
            [ncurses_lib="-lncurses"],
            [ncurses_lib=""],
            [${math_lib}])
        AC_CHECK_LIB(readline,readline,
            [rl_use="yes";rl_lib="${rl_lib_path}-lreadline ${ncurses_lib}"],
            [rl_use="";rl_lib=""],
            [${rl_lib_path} ${ncurses_lib} ${math_lib}])
        if test -n "${rl_use}"; then
            AC_CHECK_LIB(readline,add_history,
                [rl_use="yes";rl_lib="${rl_lib_path}-lreadline ${ncurses_lib}"],
                [rl_use="";rl_lib=""],
                [${rl_lib_path} ${ncurses_lib} ${math_lib}])
        fi
        if test -n "${rl_use}"; then
            AC_DEFINE(HAVE_READLINE_READLINE_H)
            AC_DEFINE(HAVE_READLINE_HISTORY_H)
        fi
    fi
fi

dnl # Return LDFLAGS and CPPFLAGS to normal
LDFLAGS=${LDFLAGS_SAVE};
CPPFLAGS=${CPPFLAGS_SAVE};

AC_SUBST(rl_lib)
AC_SUBST(rl_inc)

dnl # ----------------------
dnl # HANDLE THE MPI LIBRARY
dnl # ----------------------
AC_MSG_CHECKING([whether you want MPI])
AC_ARG_ENABLE(mpi,
    [  --enable-mpi            enable MPI layer [[default=no]]],
    [ mpi_use="yes" ],
    [ mpi_use=""    ]
)
mpi_lib="";
mpi_inc="";
if test -z "${mpi_use}"; then
    AC_MSG_RESULT([no])
else
    AC_MSG_RESULT([yes ...poking around])

    dnl # MPI header location ENV specification
    AC_MSG_CHECKING([whether your environment defines FETK_MPI_INCLUDE])
    if test -n "${FETK_MPI_INCLUDE}"; then
        AC_MSG_RESULT([yes])
        mpi_inc_path="-I${FETK_MPI_INCLUDE} ";
    else
        AC_MSG_RESULT([no])
        mpi_inc_path="";
    fi

    dnl # MPI library location ENV specification
    AC_MSG_CHECKING([whether your environment defines FETK_MPI_LIBRARY])
    if test -n "${FETK_MPI_LIBRARY}"; then
        AC_MSG_RESULT([yes])
        mpi_lib_path="-L${FETK_MPI_LIBRARY} ";
    else
        AC_MSG_RESULT([no])
        mpi_lib_path="";
    fi

    dnl # Setup temp LDFLAGS and CPPFLAGS and look for MPI library/header
    LDFLAGS_SAVE=${LDFLAGS};
    CPPFLAGS_SAVE=${CPPFLAGS};
    LDFLAGS=${mpi_lib_path};
    CPPFLAGS=${mpi_inc_path};
    mpi_use="";
    AC_CHECK_HEADER(mpi.h,
        [mpi_use="yes";mpi_inc="${mpi_inc_path}"],
        [mpi_use="";mpi_inc=""])
    if test -n "${mpi_use}"; then
        AC_CHECK_LIB(mpi,main,
            [mpi_use="yes";mpi_lib="${mpi_lib_path}-lmpi"],
            [mpi_use="";mpi_lib=""],${mpi_lib_path})
        if test -z "${mpi_use}"; then
            AC_CHECK_LIB(mpich,main,
                [mpi_use="yes";mpi_lib="${mpi_lib_path}-lmpich"],
                [mpi_use="";mpi_lib=""],${mpi_lib_path})
        fi
        if test -n "${mpi_use}"; then
            AC_DEFINE([HAVE_MPI_H], [], [We have and want to use MPI])
        fi
    fi

    dnl # Return LDFLAGS and CPPFLAGS to normal
    LDFLAGS=${LDFLAGS_SAVE};
    CPPFLAGS=${CPPFLAGS_SAVE};
fi
AC_SUBST(mpi_lib)
AC_SUBST(mpi_inc)

dnl # -----------------------
dnl # HANDLE SYMBOL EMBEDDING
dnl # -----------------------
AC_MSG_CHECKING([whether EMBED macro can be used without compilation errors])
AC_TRY_COMPILE(,
    [#define EMBED(rctag) \
     static const char* rctag; \
     static void* use_rcsid=(0 ? &use_rcsid : (void*)&rcsid);
     EMBED(rcsid)],
    [embed_ok=yes;AC_DEFINE(HAVE_EMBED)],[embed_ok=no])
AC_MSG_RESULT(${embed_ok})

AC_MSG_RESULT([----------- begin processing MALOC configure options ---------])

dnl # ------------------------
dnl # HANDLE DEBUG COMPILATION
dnl # ------------------------
AC_MSG_CHECKING([whether you want debug compilation])
AC_ARG_ENABLE(vdebug,
    [  --enable-vdebug         enable debug compilation [[default=no]]],
    [ vdebug_use="yes" ],
    [ vdebug_use=""    ]
)
if test -z "${vdebug_use}"; then
    AC_MSG_RESULT([no])
else
    AC_MSG_RESULT([yes])
    AC_DEFINE(HAVE_DEBUG)
fi

dnl # --------------------------------
dnl # HANDLE ANSI/PEDANTIC COMPILATION
dnl # --------------------------------
AC_MSG_CHECKING([whether you want pedantic ANSI compilation])
AC_ARG_ENABLE(pansi,
    [  --enable-pansi          enable pedantic ANSI compilation [[default=no]]],
    [ pansi_use="yes" ],
    [ pansi_use=""    ]
)
if test -z "${pansi_use}"; then
    AC_MSG_RESULT([no])
    wall=""
    wall_pedantic=""
    wall_pedantic_ansi=""
    pedantic_ansi=""
else
    AC_MSG_RESULT([yes])
    wall="-Wall"
    wall_pedantic="-Wall -pedantic"
    wall_pedantic_ansi="-Wall -pedantic -ansi"
    pedantic_ansi="-pedantic -ansi"
fi
AC_SUBST(wall)
AC_SUBST(wall_pedantic)
AC_SUBST(wall_pedantic_ansi)
AC_SUBST(pedantic_ansi)

dnl # ----------------
dnl # HANDLE PROFILING
dnl # ----------------
AC_MSG_CHECKING([whether you want profiling])
AC_ARG_ENABLE(gprof,
    [  --enable-gprof          enable gprof profiling [[default=no]]],
    [ gprof_use="yes" ],
    [ gprof_use=""    ]
)
if test -z "${gprof_use}"; then
    AC_MSG_RESULT([no])
    profile=""
    profile_lib=""
else
    AC_MSG_RESULT([yes])
    profile="-pg"
    profile_lib="-pg"
fi
AC_SUBST(profile)
AC_SUBST(profile_lib)

dnl # ---------------------------------
dnl # HANDLE THE ELECTRIC FENCE LIBRARY
dnl # ---------------------------------
AC_MSG_CHECKING([whether you want to build ElectricFence])
AC_ARG_ENABLE(efence,
    [  --enable-efence         build ElectricFence ourself [[default=no]]],
    [ efence_build="yes" ],
    [ efence_build="" ]
)
if test -n "${efence_build}"; then
    AC_MSG_RESULT([yes])
    efence="efence"
else
    AC_MSG_RESULT([no])
    efence=""
fi
AC_SUBST(efence)
AM_CONDITIONAL(BUILD_EFENCE, test x$efence = xefence)

AC_MSG_RESULT([------------ end processing MALOC configure options ----------])

dnl ##########################################################################
dnl 11. templates
dnl ##########################################################################

AH_TEMPLATE([HAVE_XDR],
            [Do I have the XDR datastructure in the RPC package?])

AH_TEMPLATE([HAVE_O_NONBLOCK],
            [Do I have the O_NONBLOCK macro?])

AH_TEMPLATE([ACCEPT_USES_ULONG],
            [Does accept() use unsigned long?])

AH_TEMPLATE([ACCEPT_USES_UINT],
            [Does accept() use unsigned int?])

AH_TEMPLATE([HAVE_GETCWD],
            [Do I have the getcwd routine?])

AH_TEMPLATE([HAVE_CYGWIN],
            [Am I running in a Cygwin/Win32 environment?])

AH_TEMPLATE([HAVE_EMBED],
            [Does EMBED macro for embedding rcsid symbols into binaries work?])

AH_TEMPLATE([HAVE_DEBUG],
            [Do I compile as a debug version?])

AH_TEMPLATE([HAVE_MPI_H],
            [Do I have MPI header?])

AH_TEMPLATE([HAVE_READLINE_READLINE_H],
            [Do I have readline.h header?])

AH_TEMPLATE([HAVE_READLINE_HISTORY_H],
            [Do I have history.h header?])

AH_TOP([
/*
 * ***************************************************************************
 * MALOC = < Minimal Abstraction Layer for Object-oriented C >
 * Copyright (C) 1994--2000  Michael Holst
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * rcsid="$Id: configure.ac,v 1.91 2006/06/03 07:22:28 mholst Exp $"
 * ***************************************************************************
 */

/*
 * ***************************************************************************
 * File:     acconfig.h
 *
 * Purpose:  Generates the main configuration header "maloccf.h" for MALOC.
 *
 * Notes:    See the comments at the top of the file "configure.ac" for
 *           an outline of the sequence of steps that turns acconfig.h
 *           into <src/aaa_inc/maloccf.h.in> and then eventually into
 *           <src/aaa_inc/maloccf.h> when you are using GNU autoconf.
 *
 *           This file can also form the basis for a manually-produced
 *           maloccf.h file.  In fact, a correct Win32 maloccf.h file can be
 *           generated simply by removing the two lines containing the
 *           GNU autoconf tags "TOP" and "BOTTOM".
 *
 *           The final autoconf (or manually) generated "maloccf.h" attempts
 *           to produce a correct header file layout for various UNIX-like
 *           and Win32 machines, giving access to several things beyond ISO
 *           C/C++, including BSD Signals, UNIX Domain sockets, INET TCP/IP
 *           sockets, and the WINSOCK implementation of INET TCP/IP sockets.
 *
 *           The MALOC library then provides a portable abstract interface
 *           to UNIX domain sockets, INET sockets, pipes, signals, and other
 *           system-dependent things that one usually wants to get to in a
 *           fairly standard C or C++ scientific software package.  Once
 *           MALOC is built, "maloccf.h" is no longer needed (it is not
 *           included in the set of API headers that are copied into the
 *           specified header install directory.  In other words, none of
 *           the MALOC headers forming the API include the config file
 *           "maloccf.h"; it is only included by the source files.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */

#ifndef _MALOCCF_H_
#define _MALOCCF_H_
])

AH_BOTTOM([
/*
 * ***************************************************************************
 * Handle some additional things manually (Win32, NeXT, etc)
 * ***************************************************************************
 */

/* Win32 configuration (non-CygWin) */
#if !defined(HAVE_CYGWIN)
#   if defined(WIN32) || defined(__WATCOMC__)

        /* Set the main key for specifying WIN32 code */
#       define HAVE_WIN32

        /* Deal with some basic problems with UNIX/WIN32 compatibility */
#       define HAVE_O_NONBLOCK 1
#       define HAVE_MODE_T 1
#       define HAVE_GETCWD 1

        /* WATCOM does STAT macros right; Microsoft does not */
#       if !defined(__WATCOMC__)
#           define STAT_MACROS_BROKEN 1
#       endif

        /* Required headers that exist in both UNIX and WIN32 */
#       define HAVE_SYS_TYPES_H 1
#       define HAVE_SYS_STAT_H 1
#       define HAVE_FCNTL_H 1
#       define HAVE_RPC_H 1

        /* Required headers that exist only in WIN32 (non-CygWin) */
#       define HAVE_DIRECT_H 1
#       define HAVE_PROCESS_H 1
#       define HAVE_WINSOCK_H 1
#       define HAVE_IO_H 1

#   endif
#endif

#if defined(NeXT) || defined(__NeXT__)
#   define HAVE_NEXT
#endif

/*
 * ***************************************************************************
 * Deal with macros we need that are sometimes missing
 * ***************************************************************************
 */

/* Deal with broken stat macros on some platforms */
#if !defined(STAT_MACROS_BROKEN)
#   define VS_ISREG(a) (((a) & S_IFMT) == S_IFREG)
#else
#   define VS_ISREG(a) (0)
#endif

/* Deal a missing macro on some unix platforms (NeXT, etc) */
#if !defined(HAVE_O_NONBLOCK)
#   define VO_NONBLOCK 00004
#else
#   define VO_NONBLOCK O_NONBLOCK
#endif

/*
 * ***************************************************************************
 * Define some RCS tag embedding and debug I/O macros
 * ***************************************************************************
 */

/* Embedded RCS tags ("ident filename" prints module versions in filename) */
#if defined(HAVE_EMBED)
#    define VEMBED(rctag) \
         VPRIVATE const char* rctag; \
         static void* use_rcsid=(0 ? &use_rcsid : (void*)&rcsid);
#else
#    define VEMBED(rctag)
#endif

/* Produce additional debugging I/O */
#if defined(HAVE_DEBUG)
#    define VDEBUGIO(str) fprintf(stderr,str)
#else
#    define VDEBUGIO(str)
#endif

#endif /* _MALOCCF_H_ */
])

dnl ##########################################################################
dnl 12. generate the makefiles
dnl ##########################################################################

AC_OUTPUT([
    Makefile
    src/Makefile

    src/base/Makefile

    src/efence/Makefile

    src/vsys/Makefile
    src/vsh/Makefile
    src/psh/Makefile

    src/aaa_inc/Makefile
    src/aaa_inc/maloc/Makefile

    src/aaa_lib/Makefile
])