source: git/omalloc/configure.in @ 2362bb

spielwiese
Last change on this file since 2362bb was 2362bb, checked in by Olaf Bachmann <obachman@…>, 23 years ago
* bug fix git-svn-id: file:///usr/local/Singular/svn/trunk@4911 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 15.9 KB
Line 
1dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
2dnl File: configure.in
3dnl Purpose: Process this file with autoconf to produce configure
4dnl Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
5dnl Created: 11/99
6dnl Version: $Id: configure.in,v 1.10 2000-12-15 08:44:28 obachman Exp $
7dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
8
9AC_INIT(om_Alloc.c)
10
11VERSION=0.9.5
12AC_SUBST(VERSION)
13
14dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
15dnl help for configure
16dnl
17AC_ARG_WITH(
18  external-config_h,
19  [ --with-external-config_h=HEADER_FILE
20                    use HEADER_FILE for external configuration])
21AC_ARG_WITH(
22  external-config_c,
23  [ --with-external-config_c=C_FILE
24                    use C_FILE for external implementations])
25AC_ARG_WITH(
26  malloc,
27  [ --with-malloc=system|dlmalloc|gmalloc|pmalloc|external
28                    which malloc to use, default: dlmalloc ])
29AC_ARG_WITH(
30  external-malloc_h,
31  [ --with-external-malloc-h=HEADER_FILE
32                    use HEADER_FILE for external malloc declaration])
33AC_ARG_WITH(
34  external-malloc_c,
35  [ --with-external-malloc-c=C_FILE
36                    use C_FILE for external malloc implementation])
37AC_ARG_WITH(
38  valloc,
39  [ --with-valloc=mmap|malloc|emulate
40                    how to get page-aligned memory, default: use first possible])
41AC_ARG_WITH(
42  provide-malloc,
43  [ --with-provide-malloc=yes|debug|malloc
44                    provide normal|debug|underlying malloc ANSI-C conforming
45                    versions of malloc|calloc|realloc|free])
46AC_ARG_WITH(
47  emulate-omalloc,
48  [ --with-emulate-omalloc
49                    provide only omallocs interface, but do not use its features])
50AC_ARG_WITH(
51  align,
52  [ --with-align=8|sloppy|strict
53                    how memory is aligned,
54                    default: if possible sloppy, else strict])
55AC_ARG_WITH(
56  dense-bins,
57  [ --with-dense-bins  use dense bin distribution])
58AC_ARG_WITH(
59  inline,
60  [ --without-inline   do not inline])
61AC_ARG_WITH(
62  debug,
63  [ --without-debug    disable all debugging facilities])
64AC_ARG_WITH(
65  track,
66  [ --without-track    disable debug tracking functionality])
67AC_ARG_WITH(
68  track-fl,
69  [ --with-track-fl    track file and line numbers])
70AC_ARG_WITH(
71  track-return,
72  [ --with-track-return track return addresses])
73AC_ARG_WITH(
74  track-backtrace,
75  [ --with-track-backtrace track stack backtraces])
76AC_ARG_WITH(
77  track-custom,
78  [ --with-track-custom track custom values])
79AC_ARG_WITH(
80  internal_debug,
81  [ --with-internal-debug       
82                       turn on internal debugging])
83dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
84dnl compiler/make  config
85dnl
86dnl I'm not sure why I did this
87dnl if test "${CFLAGS+set}" != set; then
88dnl  CFLAGS="-O"
89dnl  ac_cflags_set=no
90dnl fi
91
92AC_PROG_MAKE_SET
93AC_PROG_CC
94AC_PROG_CPP
95AC_PROG_RANLIB
96AC_PROG_LN_S
97AC_PROG_INSTALL
98AC_C_CONST
99AC_C_INLINE
100
101dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
102dnl check for programs
103dnl
104AC_CHECK_PROG(AR, ar, ar, :)
105if test "$ac_cv_prog_AR" != ar; then
106  AC_MSG_ERROR(*** ar program not found)
107fi
108AC_CHECK_PROGS(PERL, perl, "no")
109if test "$ac_cv_prog_PERL" = no; then
110  AC_MSG_ERROR(*** perl program not found)
111fi
112
113AC_CHECK_PROG(ADDR2LINE, addr2line, addr2line, no)
114if test "$ac_cv_prog_ADDR2LINE" = addr2line; then
115  AC_DEFINE_UNQUOTED(OM_PROG_ADDR2LINE, "$ac_cv_prog_ADDR2LINE")
116fi
117
118dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
119dnl header file checks
120dnl
121AC_HEADER_STDC
122AC_CHECK_HEADERS(limits.h,,
123  AC_MSG_ERROR(Can not compile without limits.h))
124AC_CHECK_HEADERS(unistd.h sys/mman.h fcntl.h /usr/include/malloc.h)
125
126AC_CHECK_FUNCS(popen readlink getcwd getwd mmap sbrk random)
127
128dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
129dnl Find out more about particularity of the system
130dnl
131
132# sizes
133AC_CHECK_SIZEOF(long,4)
134AC_CHECK_SIZEOF(void*,4)
135AC_CHECK_SIZEOF(double, 8)
136AC_CHECK_SIZEOF(size_t, 4)
137
138if test "$ac_cv_sizeof_long" != "$ac_cv_sizeof_voidp"; then
139  AC_MSG_ERROR(need equal sizes for long and void*)
140fi
141if test "$ac_cv_sizeof_voidp" != 4 && test "$ac_cv_sizeof_voidp" != 8; then
142  AC_MSG_ERROR(need void* to be 4 or 8 bytes long)
143fi
144if test "$ac_cv_sizeof_double" != 4 && test "$ac_cv_sizeof_double" != 8; then
145  AC_MSG_ERROR(need double to be 4 or 8 bytes long)
146fi
147
148dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
149dnl figure out page size of the system
150dnl
151AC_MSG_CHECKING(size of system page)
152AC_CACHE_VAL(ac_cv_pagesize,
153AC_TRY_RUN([#include <stdio.h>
154#include "omGetPageSize.h"
155
156main()
157{
158  FILE *f=fopen("conftestval", "w");
159  if (!f) exit(1);
160  fprintf(f, "%d\n", omalloc_getpagesize);
161  exit(0);
162}], ac_cv_pagesize=`cat conftestval`, ac_cv_pagesize=0, ac_cv_pagesize=0))
163AC_MSG_RESULT($ac_cv_pagesize)
164if test "$ac_cv_pagesize" = 4096 || test "$ac_cv_pagesize" = 8192; then
165  AC_DEFINE_UNQUOTED(SIZEOF_SYSTEM_PAGE, $ac_cv_pagesize)
166else
167AC_MSG_ERROR(need sytem page to be of size 4096 or 8192, but is $ac_cv_pagesize)
168fi
169
170dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
171dnl check whether mmap actually works
172dnl
173if test "$ac_cv_func_mmap" = yes; then
174AC_MSG_CHECKING(whether mmap works)
175AC_CACHE_VAL(ac_cv_working_mmap,
176AC_TRY_RUN([
177#include "omMmap.c"
178main()
179{
180  void* addr = omVallocMmap(128*${ac_cv_pagesize});
181  if (addr == 0 || ((unsigned long) addr % ${ac_cv_pagesize}))
182    exit(1);
183  exit(omVfreeMmap(addr, 128*${ac_cv_pagesize}));
184}], ac_cv_working_mmap=yes, ac_cv_working_mmap=no, ac_cv_working_mmap=no))
185AC_MSG_RESULT($ac_cv_working_mmap)
186if test "$ac_cv_working_mmap" = yes; then
187  AC_DEFINE(HAVE_WORKING_MMAP)
188fi
189fi
190
191dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
192dnl for strict alignment
193dnl
194AC_CACHE_CHECK(whether alignment needs to be strict, ac_cv_align_need_strict,
195AC_TRY_RUN([
196main()
197{
198  void* ptr = (void*) malloc(12);
199  double* d_ptr;
200  if ((unsigned long) ptr % 8 == 0) ptr = ptr + 4; 
201  d_ptr = (double*) ptr;
202  *d_ptr = (double) 1.1;
203  if (*d_ptr != (double) 1.1) exit(1);
204  else exit(0);
205}
206], ac_cv_align_need_strict=no, ac_cv_align_need_strict=yes, ac_cv_align_need_strict=yes))
207
208dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
209dnl external config files
210dnl
211AC_MSG_CHECKING(for external config files)
212if test "${with_external_config_h+set}" = set; then
213    AC_DEFINE(OM_HAVE_EXTERNAL_CONFIG_H)
214    EXTERNAL_CONFIG_HEADER=${with_external_config_h}
215    rm -f omExternalConfig.h
216    cp ${with_external_config_h} omExternalConfig.h
217fi
218if test "${with_external_config_c+set}" = set; then
219    AC_DEFINE(OM_HAVE_EXTERNAL_CONFIG_C)
220    EXTERNAL_CONFIG_SOURCE=${with_external_config_c}
221fi
222AC_SUBST(EXTERNAL_CONFIG_HEADER)
223AC_SUBST(EXTERNAL_CONFIG_SOURCE)
224if test "${EXTERNAL_CONFIG_HEADER+set}" = set || test "${EXTERNAL_CONFIG_SOURCE+set}" = set; then
225AC_MSG_RESULT(${EXTERNAL_CONFIG_HEADER} ${EXTERNAL_CONFIG_SOURCE})
226else
227AC_MSG_RESULT(none)
228fi
229
230dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
231dnl for malloc
232dnl
233AC_MSG_CHECKING(which malloc to use)
234if test "${with_malloc}" = system; then
235  OM_MALLOC_HEADER=omMallocSystem.h
236  if test "${with_provide_malloc}" = yes || test "${with_provide_malloc}" = debug; then
237    AC_MSG_ERROR("can not provide malloc for --with-malloc=system")
238  fi
239elif test "${with_malloc}" = gmalloc; then
240  OM_MALLOC_HEADER=gmalloc.h
241  OM_MALLOC_SOURCE=gmalloc.c
242elif test "${with_malloc}" = pmalloc; then
243  OM_MALLOC_HEADER=pmalloc.h
244  OM_MALLOC_SOURCE=pmalloc.c
245elif test "${with_malloc}" = external; then
246  if test "${with_external_malloc_h+set}" != set; then
247    AC_MSG_ERROR(need --with_external_malloc_h for external malloc)
248  fi
249  if test "${with_provide_malloc}" = yes || test "${with_provide_malloc}" = debug; then
250    AC_MSG_ERROR("can not provide malloc for --with_malloc=external")
251  fi
252  OM_MALLOC_HEADER=$with_external_malloc_h
253  OM_MALLOC_SOURCE=$with_external_malloc_c
254else
255  with_malloc=dlmalloc
256  OM_MALLOC_HEADER=dlmalloc.h
257  OM_MALLOC_SOURCE=dlmalloc.c
258fi
259AC_MSG_RESULT($with_malloc)
260AC_SUBST(OM_MALLOC_HEADER)
261AC_SUBST(OM_MALLOC_SOURCE)
262if test "${OM_MALLOC_SOURCE+set}" = set; then
263  AC_DEFINE(OM_HAVE_MALLOC_SOURCE)
264fi
265
266AC_MSG_CHECKING(whether malloc provides SizeOfAddr)
267if test "${ac_cv_malloc_sizeof_addr}" = no; then
268  AC_MSG_RESULT( (cached) no)
269elif test "${ac_cv_malloc_sizeof_addr}" = "${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}"; then
270   AC_MSG_RESULT( (cached) yes)
271else
272AC_TRY_RUN([
273#include "$OM_MALLOC_HEADER"
274#ifdef OM_HAVE_MALLOC_SOURCE
275#include "$OM_MALLOC_SOURCE"
276#endif
277
278main()
279{
280  void* addr = OM_MALLOC_MALLOC(512);
281  if (OM_MALLOC_SIZEOF_ADDR(addr) < 512)
282    exit(1);
283  exit(0);
284}
285], ac_cv_malloc_sizeof_addr="${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}", ac_cv_malloc_sizeof_addr=no, ac_cv_malloc_sizeof_addr=no)
286if test "${ac_cv_malloc_sizeof_addr}" = no; then
287AC_MSG_RESULT(no)
288else
289AC_MSG_RESULT(yes)
290fi
291fi
292if test "$ac_cv_malloc_sizeof_addr" != no; then
293AC_DEFINE(OM_MALLOC_PROVIDES_SIZEOF_ADDR)
294fi
295 
296if test "${with_provide_malloc}" = malloc; then
297   AC_DEFINE(OM_PROVIDE_MALLOC, 3)
298elif test "${with_provide_malloc}" = debug; then
299   AC_DEFINE(OM_PROVIDE_MALLOC, 2)
300elif test "${with_provide_malloc}" = yes; then
301  AC_DEFINE(OM_PROVIDE_MALLOC, 1)
302else
303  AC_DEFINE(OM_PROVIDE_MALLOC, 0)
304fi
305
306dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
307dnl check whether valloc is provided and that it works
308dnl
309AC_MSG_CHECKING(whether working valloc exists)
310if test "${ac_cv_working_valloc}" = no; then
311  AC_MSG_RESULT( (cached) no)
312elif test "${ac_cv_working_valloc}" = "${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}"; then
313  AC_MSG_RESULT( (cached) yes)
314else
315AC_TRY_RUN([
316#include "$OM_MALLOC_HEADER"
317#ifdef OM_HAVE_MALLOC_SOURCE
318#include "$OM_MALLOC_SOURCE"
319#endif
320
321main()
322{
323  void* addr = OM_MALLOC_VALLOC(128*${ac_cv_pagesize});
324  if (addr == 0 || ((unsigned long) addr % ${ac_cv_pagesize}))
325    exit(1);
326  OM_MALLOC_VFREE(addr, 128*${ac_cv_pagesize});
327  exit(0);
328}
329], ac_cv_working_valloc="${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}", ac_cv_working_valloc=no, ac_cv_working_valloc=no)
330if test "${ac_cv_working_valloc}" = no; then
331AC_MSG_RESULT(no)
332else
333AC_MSG_RESULT(yes)
334fi
335fi
336
337dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
338dnl for valloc
339dnl
340AC_MSG_CHECKING(which valloc to use)
341if test "${with_valloc+set}" != set || test "${with_valloc}" = mmap; then
342  if test "${ac_cv_working_mmap}" = yes; then
343    with_valloc=mmap
344    AC_DEFINE(OM_HAVE_VALLOC_MMAP)
345  else
346    with_valloc=malloc
347  fi
348fi
349if test "${with_valloc}" = malloc; then
350  if test "{ac_cv_working_valloc}" != no; then
351    AC_DEFINE(OM_HAVE_VALLOC_MALLOC)
352  else
353    with_valloc=emulate
354  fi
355fi
356AC_MSG_RESULT($with_valloc)
357
358dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
359dnl emulation
360dnl
361AC_MSG_CHECKING(whether to emulate omalloc)
362if test "${with_emulate_omalloc}" = yes; then
363  AC_DEFINE(OM_EMULATE_OMALLOC)
364  AC_MSG_RESULT(yes)
365else
366  AC_MSG_RESULT(no)
367fi
368
369dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
370dnl alignment
371dnl
372AC_MSG_CHECKING(how to align)
373if test "$with_align" = 8 || test "$ac_cv_sizeof_long" = 8; then
374  ac_cv_align=8
375  AC_DEFINE(OM_ALIGN_8)
376else
377if test "$ac_cv_align_need_strict" = "yes" || test "$with_align" = "strict"; then
378  AC_DEFINE(OM_ALIGNMENT_NEEDS_WORK)
379  ac_cv_align="strict"
380else
381  ac_cv_align="sloppy"
382fi     
383fi
384AC_MSG_RESULT($ac_cv_align)
385
386dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
387dnl dense bins
388dnl
389AC_MSG_CHECKING(whether to use dense bins)
390if test "$with_dense_bins" = yes; then
391AC_MSG_RESULT(yes)
392AC_DEFINE(OM_HAVE_DENSE_BIN_DISTRIBUTION)
393else
394AC_MSG_RESULT(no)
395fi
396
397dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
398dnl debug and inline
399dnl
400AC_MSG_CHECKING(whether to disable debugging)
401if test "$with_debug" != no; then
402AC_MSG_RESULT(no)
403else
404AC_MSG_RESULT(yes)
405AC_DEFINE(OM_NDEBUG)
406with_track=no
407fi
408
409AC_MSG_CHECKING(whether to have tracking debug functionality)
410if test "$with_track" != no; then
411AC_MSG_RESULT(yes)
412AC_DEFINE(OM_HAVE_TRACK)
413else
414AC_MSG_RESULT(no)
415fi
416
417AC_MSG_CHECKING(whether to use internal debug)
418if test "$with_internal_debug" = yes; then
419AC_MSG_RESULT(yes)
420AC_DEFINE(OM_INTERNAL_DEBUG)
421with_inline=no
422else
423AC_MSG_RESULT(no)
424fi
425
426AC_MSG_CHECKING(whether to inline)
427if test "$ac_cv_c_inline" != no && test "$with_inline" != no; then
428  AC_DEFINE_UNQUOTED(OM_INLINE, static $ac_cv_c_inline)
429  AC_DEFINE_UNQUOTED(OM_INLINE_DECL, static $ac_cv_c_inline)
430  AC_DEFINE_UNQUOTED(OM_INLINE_IMPL, static $ac_cv_c_inline)
431  AC_DEFINE_UNQUOTED(OM_INLINE_LOCAL, static $ac_cv_c_inline)
432  AC_MSG_RESULT(yes)
433else
434  AC_DEFINE_UNQUOTED(OM_INLINE_DECL, extern)
435  AC_DEFINE_UNQUOTED(OM_INLINE_IMPL,)
436  AC_DEFINE_UNQUOTED(OM_INLINE_LOCAL, static)
437  AC_MSG_RESULT(no)
438fi
439
440dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
441dnl backtrace business
442dnl
443AC_MSG_CHECKING(whether GET_RET_ADDR works)
444AC_CACHE_VAL(ac_cv_get_return_addr_works,
445AC_TRY_RUN([
446#include "omReturn.h"
447int test_return_addr()
448{
449  char* f;
450  GET_RET_ADDR(f);
451  return (int) f;
452}
453int main()
454{
455   exit(! test_return_addr());
456}
457], ac_cv_get_return_addr_works=yes, 
458   ac_cv_get_return_addr_works=no,
459   ac_cv_get_return_addr_works=no))
460AC_MSG_RESULT($ac_cv_get_return_addr_works)
461if test "$ac_cv_get_return_addr_works" = yes; then
462AC_DEFINE(OM_GET_RETURN_ADDR_WORKS)
463fi
464
465AC_MSG_CHECKING(whether omGetBackTrace works)
466AC_CACHE_VAL(ac_cv_get_backtrace_works,
467AC_TRY_RUN([
468#include "omGetBackTrace.c"
469#include <stdio.h>
470int test_backtrace()
471{
472  void* bt;
473  int i = omGetBackTrace(&bt, 0, 10);
474  return i;
475}
476int main()
477{
478   int i;       
479   omInitGetBackTrace();
480   i = test_backtrace();
481   if (i == 1) exit(0);
482   else exit(i+1);
483}
484], ac_cv_get_backtrace_works=yes, 
485   ac_cv_get_backtrace_works=no,
486   ac_cv_get_backtrace_works=no))
487AC_MSG_RESULT($ac_cv_get_backtrace_works)
488if test "$ac_cv_get_backtrace_works" = yes; then
489AC_DEFINE(OM_GET_BACKTRACE_WORKS)
490fi
491
492AC_MSG_CHECKING(whether addr2line works)
493AC_CACHE_VAL(ac_cv_prog_addr2line_works,
494AC_TRY_RUN([
495#undef OM_GET_BACKTRACE_WORKS
496#include "omReturn.h"
497#include "omStructs.h"
498#include "omGetBackTrace.h"
499#include "omRet2Info.c"
500#include "omFindExec.c"
501
502
503int test_Ret_2_Info()
504{
505  void* bt;
506  int i;
507  struct omRetInfo_s info;
508 
509  GET_RET_ADDR(bt);
510  i = omBackTrace_2_RetInfo(&bt, &info, 1);
511  return i;
512}
513
514 
515int main(int argc, char** argv)
516{
517  int i;
518  omInitRet_2_Info(*argv);
519  i = test_Ret_2_Info();
520  if (i==1) exit(0);
521  else exit (i+10);
522}
523], ac_cv_prog_addr2line_works=yes, 
524   ac_cv_prog_addr2line_works=no,
525   ac_cv_prog_addr2line_works=no))
526AC_MSG_RESULT($ac_cv_prog_addr2line_works)
527 
528AC_MSG_CHECKING(whether to track return addresses)
529if test "$with_track_return" = no || test "$ac_cv_get_return_addr_works" = no || test "$ac_cv_prog_addr2line_works" != yes; then
530  with_track_return=no
531else
532  AC_DEFINE(OM_TRACK_RETURN)
533  with_track_return=yes
534fi
535AC_MSG_RESULT($with_track_return)
536
537AC_MSG_CHECKING(whether to track files and line numbers)
538if test "$with_track_fl" = no && test "$with_track_return" = no; then
539  with_track_fl=yes
540fi
541if test "${with_track_fl+set}" != set; then
542  if test "$with_track_return" = yes; then
543    with_track_fl=no
544  else
545    with_track_fl=yes
546  fi
547fi
548AC_MSG_RESULT($with_track_fl)
549if test "$with_track_fl" = yes; then
550  AC_DEFINE(OM_TRACK_FILE_LINE)
551fi
552
553AC_MSG_CHECKING(whether to track stack backtraces)
554if test "$with_track" != no && test "$ac_cv_get_backtrace_works" = yes && test "$with_track_backtrace" != no && test "$ac_cv_prog_addr2line_works" = yes; then
555  with_track_backtrace=yes
556  AC_DEFINE(OM_TRACK_BACKTRACE)
557else
558  with_track_backtrace=no
559fi
560AC_MSG_RESULT($with_track_backtrace)
561
562AC_MSG_CHECKING(whether to track custom values) 
563if test "$with_track" != no && test "$with_track_custom" = yes; then
564  AC_DEFINE(OM_TRACK_CUSTOM)
565else
566  with_track_custom=no
567fi
568AC_MSG_RESULT($with_track_custom)
569
570dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
571dnl wrap it up
572dnl
573AC_CONFIG_HEADER(omConfig.h omMalloc.h:${OM_MALLOC_HEADER})
574
575
576AC_OUTPUT(Makefile, \
577 if test "$CONFIG_HEADERS"; then echo timestamp > stamp-h; fi)
578
579
580
581
Note: See TracBrowser for help on using the repository browser.