1dnl Process this file with autoconf to produce configure.
2AC_INIT(libneurosim, 1.2.0, [https://github.com/INCF/libneurosim/issues])
3AM_INIT_AUTOMAKE
4AM_CONFIG_HEADER([config.h])
5AM_MAINTAINER_MODE
6
7# Obtain host system type
8AC_CANONICAL_HOST
9
10# Debug level
11# Note, $NS_debug is used in acinclude.m4
12NS_debug="set"
13# Flags depend on platform and compiler and will be set later
14NS_debugflags=""
15
16# Optimization level
17# Note, $NS_optimize is used in acinclude.m4
18NS_optimize="set"
19# Flags depend on platform and compiler and will be set later
20NS_optimizeflags=""
21
22# Warning level
23# Note, $NS_warning is used in acinclude.m4
24NS_warning="set"
25# Flags depend on platform and compiler and will be set later
26NS_warningflags=""
27
28bluegene_architecture="none"
29configure_bluegene="no"
30AC_MSG_CHECKING(whether we are configuring for Blue Gene)
31AC_ARG_ENABLE([bluegene],
32	[AS_HELP_STRING([--enable-bluegene],
33	[Configure for Blue Gene; the specific BG model must be given as argument (=L/P/Q).])],
34	[if test "x$enableval" != "xno" ; then
35	   configure_bluegene="yes"
36	   enableval_uc=`echo ${enableval} | awk {'print toupper($_)'}`
37	   if test "x$enableval_uc" = xL || test "x$enableval_uc" = xP || test "x$enableval_uc" = xQ; then
38	     bluegene_architecture="$enableval_uc"
39           else
40             echo
41	     AC_MSG_ERROR([Only L, P, or Q are valid arguments for --enable-bluegene.])
42           fi
43         fi],[])
44
45if test "x$configure_bluegene" = xno ; then
46  AC_MSG_RESULT(no)
47else
48  AC_MSG_RESULT([yes ($bluegene_architecture)])
49fi
50
51# register variable IS_BLUEGENE to be visible in Makefile.am
52AM_CONDITIONAL(IS_BLUEGENE, test "x$configure_bluegene" != xno)
53
54
55# Manually activate MPI, allow to specify directory containing MPI
56#
57# Modified from H. E. Plesser, 2007-01-05
58NS_distributed="unset"
59NS_mpi_prefix="unset"
60NS_mpi_option="no"
61
62if test "x$configure_bluegene" = xyes ; then
63  NS_distributed=set
64  NS_mpi_option=yes
65  if test "x$bluegene_architecture" = xL; then
66    AC_DEFINE(IS_BLUEGENE_L, 1, [Configuring for Blue Gene/L])
67    bluegene_dynamic_libs=no # no dynamic libs on BG/L
68  elif test "x$bluegene_architecture" = xP; then
69    AC_DEFINE(IS_BLUEGENE_P, 1, [Configuring for Blue Gene/P])
70    bluegene_dynamic_libs=yes
71  elif test "x$bluegene_architecture" = xQ ; then
72    AC_DEFINE(IS_BLUEGENE_Q, 1, [Configuring for Blue Gene/Q])
73    bluegene_dynamic_libs=yes
74  fi
75else
76  AC_ARG_WITH(mpi,[  --with-mpi[[=directory]]	Request compilation with MPI; optionally give directory with MPI installation.],
77  [
78    if test "$withval" = "yes" ; then
79      NS_distributed="set"
80      NS_mpi_option="yes"
81    elif test "$withval" != "no" ; then
82      NS_distributed="set"
83      NS_mpi_prefix=`echo ${withval} | sed 's/\/*$//'` # remove trailing slashes
84      NS_mpi_option="yes"
85    fi
86  ])
87fi
88
89# Set the platform-dependent compiler flags based on the canonical
90# host string.  These flags are placed in AM_{C,CXX}FLAGS.  If
91# {C,CXX}FLAGS are given as environment variables, then they are
92# appended to the set of automatically chosen flags.  After
93# {C,CXX}FLAGS have been read out, they must be cleared, since
94# system-dependent defaults will otherwise be placed into the
95# Makefiles.  HEP 2004-12-20.
96
97# Before we can determine the proper compiler flags, we must know
98# which compiler we are using.  Since the pertaining AC macros run the
99# compiler and set CFLAGS, CXXFLAGS to system-dependent values, we
100# need to save command line/enviroment settings of these variables
101# first. AC_AIX must run before the compiler is run, so we must run it
102# here.
103# HEP 2004-12-21
104
105# Compiler selection:
106# - C compiler is chosen using AC_PROG_CC. C code occurs only in a
107#   few files in librandom. None of that code is MPI related.
108#
109# - C++ compiler is chosen as follows if distributed simulation is
110#   chosen:
111#
112#   1. If simulation is not distributed, use AC_PROC_CXX.
113#   2. Otherwise, if no prefix is given, search for mpiCC or equivalent
114#      using AC_PROG_CXX(mpiCC).
115#      Search order can be influenced by setting PATH before calling
116#      configure.
117#   3. If distributed simulation is requested and a prefix given, use
118#      standard compiler from AC_PROG_CXX and check for libraries in
119#      prefix directory.
120#   4. Setting CXX overrides compiler selection brute force. AC_PROG_CXX
121#      handles this.
122#   5. The final configuration is tested for if it works.
123#
124# HEP 2007-01-03
125
126NS_SAVE_CFLAGS="$CFLAGS"
127NS_SAVE_CXXFLAGS="$CXXFLAGS"
128NS_SAVE_LDFLAGS="$LDFLAGS"
129
130AC_AIX
131
132AC_PROG_CC
133
134if test "$NS_distributed" = unset ; then
135
136  # no-distributed simulation
137  AC_PROG_CXX
138
139else
140
141  # Here we assume that the wrappers work. If an
142  # explicit mpi-path is given, we add its bin to PATH first, then
143  # test, and then redefine the compiler variables to full path
144  # names. This is necessary since AC_PROG_CXX internally searches
145  # through the entire PATH; since AC_PROG_CXX contains many checks
146  # in addition to the search, we cannot simply write our own
147  # absolute-path version.
148  #
149  # Search for MPI C++ compiler wrapper:
150  # 1. Search for mpicxx, since mpicc and mpiCC are the same file
151  #    on non-case-sensitive file systems (most OSX filesystems).
152  # 2. Search for mpiCC, which is MPICH standard
153
154  if test "$NS_mpi_prefix" = unset ; then
155    AC_PROG_CXX(mpicxx mpiCC)
156  else
157    NS_SAVE_PATH=$PATH
158    # add /bin, avoiding duplicate //
159    mpi_bin=${NS_mpi_prefix}/bin
160
161    PATH=${mpi_bin}:$PATH
162    AC_PROG_CXX(mpicxx mpiCC)
163
164    # If mpicxx or mpiCC are chosen, we check if they exists in the prefix
165    # path. If so, we add the prefix path. Otherwise, we leave CXX untouched.
166    if test $CXX = mpicxx -o $CXX = mpiCC ; then
167      if test -x ${mpi_bin}/$CXX ; then
168        CXX=$mpi_bin/$CXX
169        ac_ct_CXX=$CXX
170        ac_cv_prog_ac_ct_CXX=$CXX
171      fi
172    fi
173    PATH=$NS_SAVE_PATH
174  fi
175
176fi
177# further processing of distributed case below (see NS_NEW_PATH_MPI)
178
179dnl Choose Python version
180AC_ARG_WITH([python], [AS_HELP_STRING([--with-python], [python version to use 2 or 3])], [], [with_python=no])
181# default version is 2
182if test "$with_python" = yes; then
183   with_python=2
184fi
185# don't look for Python if --with-python wasn't given
186if test "$with_python" != no; then
187   AM_PATH_PYTHON(["$with_python"])
188else
189   PYTHON=":"
190fi
191AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != [:]])
192if test $PYTHON != [:]; then
193    PYTHON_INCLUDE=`$PYTHON -c 'from distutils import sysconfig;\
194        print (sysconfig.get_python_inc ())'`
195fi
196dnl set this to use in the makefile
197AM_CONDITIONAL([PY3], [test "x$with_python" = x3 ])
198
199NS_SET_CFLAGS
200CFLAGS=
201NS_SET_CXXFLAGS
202CXXFLAGS=
203NS_SET_LDFLAGS
204LDFLAGS=
205
206LT_PATH_LD
207LT_CONFIG_LTDL_DIR([libltdl])
208_LTDL_CONVENIENCE                 ## put libltdl into a convenience library
209LT_INIT([dlopen])                 ## use libtool
210m4_pattern_allow([LT_LIBEXT])     ## supress false positive message by autoconf
211
212if test "x$BUILD_SHARED" != xno ; then
213  if test "x$LIBLTDL" != x ; then
214    AC_DEFINE(HAVE_LIBLTDL, 1, [Havel libltdl, can load dynamic modules])
215  fi
216fi
217
218AC_CONFIG_SUBDIRS(libltdl)        ## also configure subdir containing libltdl
219AC_PROG_LIBTOOL
220
221#-- Set the language to C++
222AC_LANG_CPLUSPLUS
223
224# For a description of MPI detection, see comment on compiler selection.
225if test "$NS_distributed" = "set"; then
226  if test "x$configure_bluegene" = xyes ; then
227    BLUEGENE_MPI
228  else
229    NS_NEW_PATH_MPI
230  fi
231  AC_DEFINE(HAVE_MPI, 1, [Compile for MPI])
232  NEUROSIM_HAVE_MPI=1
233else
234  NEUROSIM_HAVE_MPI=0
235fi
236
237AC_SUBST(MPI_LIBS)
238AC_SUBST(MPI_INCLUDE)
239AC_SUBST(PYTHON_INCLUDE)
240AC_SUBST(INCLTDL)
241AC_SUBST(LIBLTDL)
242AC_SUBST(HAVE_LIBLTDL)
243AC_SUBST(HAVE_MPI)
244AC_SUBST(NEUROSIM_HAVE_MPI)
245AC_SUBST(LIBADD_DL)
246
247AC_CONFIG_FILES([
248  Makefile
249  neurosim/Makefile
250  neurosim/config.h
251  neurosim/version.h
252  neurosim/examples/Makefile
253  libpyneurosim/Makefile
254])
255
256AC_OUTPUT
257
258dnl Local Variables:
259dnl comment-start: "dnl "
260dnl comment-end: ""
261dnl comment-start-skip: "\\bdnl\\b\\s *"
262dnl End:
263