File: configure.ac

package info (click to toggle)
ctsim 4.3.1-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,460 kB
  • ctags: 3,722
  • sloc: cpp: 26,759; sh: 3,518; ansic: 1,254; perl: 296; makefile: 265
file content (464 lines) | stat: -rw-r--r-- 14,514 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
dnl Process this file with autoconf to produce a configure script.

dnl Must reset CDPATH so that bash's cd does not print to stdout
dnl CDPATH=

AC_INIT
AC_CONFIG_SRCDIR([src/ctsim.cpp])
AM_MAINTAINER_MODE
AM_INIT_AUTOMAKE(ctsim,4.3.1)
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AC_PROG_CC
AC_PROG_CXX
AC_C_BIGENDIAN

AC_PATH_PROG(wxconfig,wx-config)

dnl Check for C operation
AC_CANONICAL_HOST 
AC_C_INLINE
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)

dnl Add define templates

dnl Checks for libraries.
AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ;  AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
AC_CHECK_LIB(m, sin)
AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
AC_CHECK_LIB(readline, main, [readline=true; 
                 AC_DEFINE([HAVE_READLINE],1,[Readline library])],
		 [readline=false], [-lcurses])	
wxwin=false
AC_CHECK_LIB(wx_gtk-2.4, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])], [], [-L/usr/lib64 -L/usr/lib `gtk-config --libs` `glib-config --libs glib gmodule gthread` ])
AC_CHECK_LIB(wx_mac-2.4, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
AC_CHECK_LIB(fftw3, fftw_malloc, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false], [-L/usr/lib64 -L/usr/lib])
AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -L/usr/X11R6/lib64 -lXt -lXext])
AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])

if test "$zlib" = "true" ; then
  AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false], [-lz -lm])
fi

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h sys/fcntl.h setjmp.h stdarg.h stddef.h sys/types.h sys/stat.h string.h ctype.h math.h stdio.h netinet/in.h inttypes.h sys/param.h stdint.h stdlib.h assert.h sys/time.h sys/resource.h sys/time.h readline.h readline/readline.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_TM

dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf basename setjmp setpriority time gettimeofday getenv)
AC_CHECK_FUNC(basename)
AC_CHECK_FUNC(setjmp)
AC_CHECK_FUNC(setpriority)
AC_CHECK_FUNC(time)
AC_CHECK_FUNC(gettimeofday)
AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])

if test "${OSTYPE}" = "cygwin" ; then
  getopt_long=false
else
  AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
fi

if test "${getopt_long}" = "false" ; then
  my_includes="$my_includes -I../getopt"
  AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
  ctlibs_base="$ctlibs_base -lgetopt"
  LDFLAGS="$LDFLAGS -L../getopt"
  GETOPTLONG=1
fi
AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test "$GETOPTLONG"="1")

if test "${readline}" = "true" ; then
  ctlibs_base="$ctlibs_base -lreadline"
  if test "${ncurses}" = "true"; then
    ctlibs_base="$ctlibs_base -lncurses"
  elif test "${curses}" = "true"; then
    ctlibs_base="$ctlibs_base -lcurses"
  fi
fi

dnl Check for debug mode
AC_MSG_CHECKING([debug])
AC_ARG_ENABLE(debug,
[  --enable-debug          Turn on debugging],
[case "${enableval}" in
  yes) debug=true 
       AC_MSG_RESULT(yes)
       ;;
  no)  debug=false 
       AC_MSG_RESULT(no)
       ;;
  *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug]) 
       ;;
esac],
[debug=false; AC_MSG_RESULT(no)])
AM_CONDITIONAL(DEBUG, test "$debug" = "true")

if test "$datadir" != "" ; then
  CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
fi
dnl CFLAGS="$CFLAGS -I/usr/local/include"
dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"

if test "$debug" = "true" ; then
  CFLAGS="$CFLAGS -g -DDEBUG"
  AC_DEFINE(DEBUG,1,[turn on debugging])
else
  CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
  AC_DEFINE(NDEBUG,1,[no debugging])
fi

if test "${pthread}" = "true" ; then
dnl  CFLAGS="$CFLAGS -D_REENTRANT"
  AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
fi

AC_MSG_CHECKING(sstream)
 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
     test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
     test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
   AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
   AC_MSG_RESULT(yes)
  else
   AC_MSG_RESULT(no)
 fi


CFLAGS="$CFLAGS -Wall"
AC_MSG_CHECKING(whether to enable verbose warnings)
AC_ARG_ENABLE(verbose-warnings,
[  --enable-verbose-warnings
                          Enable verbose compiler warnings.],
[ case "$enableval" in
  yes)
    AC_MSG_RESULT(yes)
    CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ], AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(static executables)
AC_ARG_ENABLE(static,
[  --enable-static
                            Enable static executables.],
[ case "$enableval" in
  yes)
    AC_MSG_RESULT(yes)
    CFLAGS="$CFLAGS --static"
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ], AC_MSG_RESULT(no)
)

dnl Set LAM path
AC_ARG_WITH(lam,
[  --with-lam[=PATH]         Set path of LAM MPI ],
[    if test "$withval" != "no" ; then
         trylamdir=$withval
     fi ]
)

if test "$withval" != "no" ; then
  if test "$prefix" != "NONE" ; then
     trylamdir="$trylamdir $prefix"
  fi

  AC_MSG_CHECKING([for LAM MPI installation])
  for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
    if test -x "$testlamdir/bin/hcp" ; then
      if test "$testlamdir" != "/usr"; then 	
        LDFLAGS="$LDFLAGS -L$testlamdir/lib"
        CFLAGS="$CFLAGS -I$testlamdir/include"
      fi
      CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
      lamdir="$testlamdir"
      AC_SUBST(lamdir)
      mpienable="true"
      AC_SUBST(mpienable)
      break
    fi
  done
  AC_MSG_RESULT($lamdir)
else
  AC_MSG_RESULT([no])
fi


dnl Set CTN path
AC_ARG_WITH(ctn,
[  --with-ctn[=PATH]         Set path of CTN DICOM library ],
[    if test "$withval" != "no" ; then
         tryctndir=$withval
     fi ]
)

if test "$withval" == "no" -o "$withval" == "NONE" ; then
  AC_MSG_CHECKING([for CTN DICOM installation])
  AC_MSG_RESULT([disabled])
else
  AC_MSG_CHECKING([for CTN DICOM installation])
  for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
    if test -f "$testctndir/libctn.a" ; then
      LDFLAGS="$LDFLAGS -L$testctndir"
      ctnlib="true"
      break
    fi
  done
  for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
    if test -f "$testctndir/ctn_os.h" ; then
      CFLAGS="$CFLAGS -I$testctndir"
      ctninclude="true"
      break
    fi
  done
  if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
      ctn="true"
      AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
      AC_MSG_RESULT([yes])
  else
    AC_MSG_RESULT([no])
  fi
fi

dnl Set CPU
AC_MSG_CHECKING([for CPU specification])
AC_ARG_WITH(mcpu,
[  --with-mcpu[=CPU]         Set name of CPU for gcc -mcpu])

if test "$withval" == "no" -o "$withval" == "yes" -o "$withval" == ""; then
  AC_MSG_RESULT([no])
else
  AC_MSG_RESULT([$withval])
  CFLAGS="$CFLAGS -mcpu=$withval"
fi

AC_MSG_CHECKING([for web access])
dnl Set cgi-bin directory
AC_ARG_WITH(cgibin-dir, [  --with-cgibin-dir=PATH  Set path of CGI binaries directory ], 
[ cgibindir=$withval ; AC_SUBST(cgibindir) ] )

AC_ARG_WITH(cgibin-url, [  --with-cgibin-url=PATH  Set URL path of CGI binaries ], 
[ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )

AC_ARG_WITH(webdata-dir, [  --with-webdata-dir=PATH Set path of webdata], 
[ webdatadir=$withval ; AC_SUBST(webdatadir)  ] )

AC_ARG_WITH(webdata-url, [  --with-webdata-url=PATH Set URL path of webdata], 
[ webdataurl=$withval ; AC_SUBST(webdataurl) ] )

AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files], 
[ htmldir=$withval ; AC_SUBST(htmldir) ] )

if test -n "$cgibindir" -o -n "$cgibinurl" ; then
  cgiprograms="ctsim.cgi ctsim.conf"
  AC_SUBST(cgiprograms)
fi

if test -n "$htmldir" ; then
  htmldata=simulate.html
  AC_SUBST(htmldata)
fi
AM_CONDITIONAL(USE_HTML, test -n "$htmldir")

if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
  webenabled=true
  AC_SUBST(webenabled)
  AC_MSG_RESULT([yes])
  if test -z "$cgibindir" ; then
    AC_MSG_ERROR([--with-cgibin-dir not set for web access])
  elif test -z "$cgibinurl" ; then
    AC_MSG_ERROR([--with-cgibin-url not set for web access])
  elif test -z "$webdatadir" ; then
    AC_MSG_ERROR([--with-webdata-dir not set for web access])
  elif test -z "$webdataurl" ; then
    AC_MSG_ERROR([--with-webdata-url not set for web access])
  elif test -z "$htmldir" ; then
    AC_MSG_ERROR([--with-html-dir not set for web access])
  fi
else
  AC_MSG_RESULT([no])
fi

AM_CONDITIONAL(USE_LAM, test -n "$lamdir")

dnl Prepare to support X.  If the user gave the command-line option
dnl --without-x, AC_PATH_XTRA will set no_x to "yes".  Otherwise, it will
dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
dnl flags to X_LIBS.  It also checks for system-specific X libraries, and
dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate.  (The former
dnl is where "-lSM -lICE" goes, in X11R6.)  We define the X_TOOLKIT_LIBS
dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
dnl supported, we'll concatenate the whole lot of these into a command line
dnl for libtool.  See, e.g., the libplot_la_LIBADD line in
dnl libplot/Makefile.am.

AC_PATH_XTRA
AC_SUBST(X_CFLAGS)
dnl Following five are concatenated together into a linker specification.
AC_SUBST(X_LIBS)
AC_SUBST(X_TOOLKIT_LIBS)
AC_SUBST(X_PRE_LIBS)
AC_SUBST(X_BASIC_LIBS)
AC_SUBST(X_EXTRA_LIBS)

X_TOOLKIT_LIBS="-lXt"
X_BASIC_LIBS="-lXext -lX11 -lXmu"

dnl Check whether libXt has thread support.  Some platforms may have
dnl pthread support in libc, but no thread support in libXt/libX11.
our_saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$X_LIBS $LDFLAGS"
AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT,1,[x thread supported]), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
LDFLAGS="$our_saved_LDFLAGS"

dnl Our Makefile.am files test the automake variable NO_X to determine
dnl whether X should be supported.
AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")

my_includes="$my_includes -I../include -I.. -I/usr/local/include"
AC_SUBST(my_includes)

LDFLAGS="$LDFLAGS -L/usr/local/lib"

AC_MSG_CHECKING([for X])
if test "$no_x" != "yes" ; then
  AC_DEFINE(HAVE_X11,1,[X11 system])
  LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib -L/usr/X11R6/lib64"
  my_includes="$my_includes -I/usr/X11R6/include"
  ctlib_graphics="$ctlibs_base -lctgraphics"
  AC_MSG_RESULT(yes)
  ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
  if test "$libgl" = "true" ; then
    # Removed "-lglut" for Mac OS X compilation
    ctlib_graphics="$ctlib_graphics -lGL -lGLU"
    if test "$wxwin" = "true" ; then
      if [ "$wx_gtk" ]; then 
        ctlib_graphics="$ctlib_graphics `wx-config --libs` -lwx_gtk_gl-2.4 `gtk-config --libs` `glib-config --libs glib gmodule gthread`"
      elif [ "$wx_mac" ]; then
        ctlib_graphics="$ctlib_graphics -lwx_mac_gl-2.4"
      fi
    fi
  fi
  if test "$wxwin" = "true" ; then
    AC_DEFINE(HAVE_SGP,1,[use sgp library])
  fi
else
  AC_MSG_RESULT(no)
fi

AM_CONDITIONAL(HAVE_SGP, test "$wxwin" = "true")

if test "$png" = "true" ; then
  ctlibs_tools="$ctlibs_tools -lpng"
fi
if test "$zlib" = "true" ; then
  ctlibs_tools="$ctlibs_tools -lz"
fi
if test "$fftw" = "true" ; then
  ctlibs_tools="$ctlibs_tools -lfftw3"
fi
if test "$ctn" = "true"; then
  ctlibs_tools="$ctlibs_tools -lctn"
fi

dnl Check for dmalloc
AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
AC_MSG_CHECKING([for enable-dmalloc])
AC_ARG_ENABLE(dmalloc,
[  --enable-dmalloc        Use dmalloc memory allocation],
[case "${enableval}" in
  yes) usedmalloc=true 
       AC_MSG_RESULT(yes)
       ;;
  no)  usedmalloc=false 
       AC_MSG_RESULT(no)
       ;;
  *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc]) 
       ;;
esac],
[usedmalloc=false; AC_MSG_RESULT(no)])

if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
  ctlibs_tools="$ctlibs_tools -ldmallocxx"
  AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
  AC_MSG_RESULT(Using dmalloc)
fi

dnl Check for efence
AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
AC_MSG_CHECKING([for enable-efence])
AC_ARG_ENABLE(efence,
[  --enable-efence        Use ElectricFence memory allocation],
[case "${enableval}" in
  yes) useefence=true 
       AC_MSG_RESULT(yes)
       ;;
  no)  useefence=false 
       AC_MSG_RESULT(no)
       ;;
  *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence]) 
       ;;
esac],
[useefence=false; AC_MSG_RESULT(no)])

if test "$efence" = "true" -a "$useefence" = "true" ; then
  ctlibs_tools="$ctlibs_tools -lefence"
  AC_DEFINE(HAVE_EFENCE,1,[efence library])
  AC_MSG_RESULT(Using efence)
fi

if test "$wxwin" = "true" ; then
  if [ "$wx_gtk" = "true" ] || [ "$wx_mac" == "true" ] ; then	
    wxcflags=`$wxconfig --cflags`
    wxlibs=`$wxconfig --libs`
  else
	wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
        wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
  fi
  CFLAGS="$CFLAGS -I../include $wxcflags"
  ctlib_graphics="$ctlib_graphics $wxlibs"
fi
AC_SUBST(wxcflags)
AC_SUBST(wxlibs)
AM_CONDITIONAL(HAVE_WXWINDOWS, test "$wxwin"="true")

dnl Setting projet libraries and includes
LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim" 
ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
AC_SUBST(ctlibs)

if test -n "$lamdir" ; then
  lamprograms="ctsimtext-lam"
  AC_SUBST(lamprograms)
  lamdefs="$CFLAGS"
  AC_SUBST(lamdefs)
fi

CXXFLAGS="$CFLAGS"

AC_CONFIG_FILES([Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile helical/Makefile helical/sample-helical.sh])

AC_OUTPUT