1## Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2## Copyright (C) 2019 X. Andrade
3##
4## This Source Code Form is subject to the terms of the Mozilla Public
5## License, v. 2.0. If a copy of the MPL was not distributed with this
6## file, You can obtain one at http://mozilla.org/MPL/2.0/.
7##
8
9AC_INIT([libxc],[5.0.0],[libxc@tddft.org],[libxc],[http://www.tddft.org/programs/Libxc])
10AC_CONFIG_SRCDIR([src/xc.h])
11AM_INIT_AUTOMAKE
12
13AC_CONFIG_HEADERS([config.h])
14AC_CONFIG_MACRO_DIR([m4])
15
16# Library versioning (C:R:A == current:revision:age)
17# See the libtool manual for an explanation of the numbers
18#
19# libxc-2.0.0   1:0:0
20# libxc-2.0.1   1:1:0
21# libxc-2.0.2   1:2:0
22# libxc-2.0.3   1:3:0
23# libxc-2.1.0   2:0:1
24# libxc-2.1.1   2:1:1
25# libxc-2.1.2   2:2:1
26# libxc-2.1.3   2:3:1
27# libxc-2.2.0   3:0:0
28# libxc-2.2.1   3:1:0
29# libxc-2.2.3   3:3:0
30# libxc-3.0.0   4:0:0
31# libxc-3.0.1   4:1:0
32# libxc-4.0.0   5:0:0
33# libxc-4.0.1   5:1:0
34# libxc-4.0.2   5:2:0
35# libxc-4.0.3   5:3:0
36# libxc-4.0.4   5:4:0
37# libxc-4.0.5   5:5:0
38# libxc-4.1.0   6:0:1
39# libxc-4.1.1   6:1:1
40# libxc-4.2.0   7:0:2
41# libxc-4.2.1   7:1:2
42# libxc-4.2.2   7:2:2
43# libxc-4.2.3   7:3:2
44# libxc-4.3.0   8:0:3
45# libxc-4.3.2   8:1:3
46# libxc-4.3.2   8:2:3
47# libxc-4.3.3   8:3:3
48# libxc-4.3.4   8:4:3
49# libxc-5.0.0   9:0:0
50#
51# Note that libtool versioning was not used prior to libxc-2.0.
52# Because of this, we will start counting at 1.
53#
54# How to update library version number
55# ====================================
56#
57# C: increment if the interface has additions, changes, removals.
58#
59# R: increment any time the source changes; set to 0 if you
60# incremented CURRENT
61#
62# A: increment if any interfaces have been added; set to 0 if any
63# interfaces have been removed. removal has precedence over adding,
64# so set to 0 if both happened.
65
66XC_CURRENT=9
67XC_REVISION=0
68XC_AGE=0
69
70XC_LT_VERSION="${XC_CURRENT}:${XC_REVISION}:${XC_AGE}"
71AC_SUBST(XC_LT_VERSION)
72
73# Split VERSION into XC_VERSION_MAJOR and XC_VERSION_MINOR
74# Follows AX_SPLIT_VERSION macro from AC-Archive
75# Rhys Ulerich <rhys.ulerich@gmail.com>
76AC_PROG_SED
77XC_MAJOR_VERSION=`echo "$VERSION" | $SED 's/\([[^.]][[^.]]*\).*/\1/'`
78XC_MINOR_VERSION=`echo "$VERSION" | $SED 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
79XC_MICRO_VERSION=`echo "$VERSION" | $SED 's/[[^.]][[^.]]*.[[^.]][[^.]]*.\(.*\)/\1/'`
80AC_SUBST(XC_MAJOR_VERSION)
81AC_SUBST(XC_MINOR_VERSION)
82AC_SUBST(XC_MICRO_VERSION)
83
84
85# Installation prefix by default
86AC_PREFIX_DEFAULT([/opt/etsf])
87
88AC_DISABLE_SHARED
89LT_PREREQ([2.2])
90LT_INIT
91
92# enable cuda first, since this is required for the compiler selection
93AC_ARG_ENABLE(cuda, AS_HELP_STRING([--enable-cuda], [Cuda support (experimental)]))
94
95if test x"${enable_cuda}" == x"yes" ; then
96  AC_DEFINE(HAVE_CUDA, 1, [defined if cuda support is enabled])
97fi
98
99AM_CONDITIONAL([HAVE_CUDA], [test x"${enable_cuda}" == x"yes"])
100
101# Checks for programs.
102AC_PROG_CC
103
104#we may need to set the linker for the cuda case, so pass that to automake
105if test x"$CCLD" == x ; then
106   CCLD=$CC
107fi
108AC_SUBST(CCLD)
109
110AC_LANG_PREPROC
111AM_PROG_CC_C_O
112AC_C_INLINE
113
114# Checks for header files.
115AC_HEADER_STDC
116AC_FUNC_ALLOCA
117
118# Checks for typedefs, structures, and compiler characteristics.
119AC_CHECK_SIZEOF(void*)
120
121# Need BASH to run tests
122AC_CHECK_PROG([BASH_SHELL],[bash],[yes])
123
124# Check for presence of some C99 libm functions
125AC_CHECK_LIB([m],[cbrt],[AC_DEFINE([HAVE_CBRT],[1],[libm includes cbrt])])
126AC_CHECK_LIB([m],[feenableexcept],[AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
127
128AC_ARG_WITH([custom-fmoddir],
129	    [AS_HELP_STRING([--with-custom-fmoddir=DIR],
130			    [Instalation directory for Fortran module files (includedir by default)])],
131	    [AC_SUBST([FMODDIR],["$withval"])],
132	    [AC_SUBST([FMODDIR],['${includedir}'])])
133
134# Enable/disable derivatives
135AC_ARG_ENABLE([vxc],
136	      AS_HELP_STRING([--disable-vxc], [don't build first derivatives]),
137	      [ac_cv_build_vxc=$enableval],
138	      [ac_cv_build_vxc=yes])
139if test x"${ac_cv_build_vxc}" == x"no"; then
140  AC_DEFINE(XC_DONT_COMPILE_VXC, 1, [defined if first derivatives are disabled])
141  AC_DEFINE(XC_DONT_COMPILE_FXC, 1, [defined if second derivatives are disabled])
142  AC_DEFINE(XC_DONT_COMPILE_KXC, 1, [defined if third derivatives are disabled])
143  AC_DEFINE(XC_DONT_COMPILE_LXC, 1, [defined if fourth derivatives are disabled])
144fi
145
146AC_ARG_ENABLE([fxc],
147	      AS_HELP_STRING([--disable-fxc], [don't build second derivatives]),
148	      [ac_cv_build_fxc=$enableval],
149	      [ac_cv_build_fxc=yes])
150if test x"${ac_cv_build_fxc}" == x"no"; then
151  AC_DEFINE(XC_DONT_COMPILE_FXC, 1, [defined if second derivatives are disabled])
152  AC_DEFINE(XC_DONT_COMPILE_KXC, 1, [defined if third derivatives are disabled])
153  AC_DEFINE(XC_DONT_COMPILE_LXC, 1, [defined if fourth derivatives are disabled])
154fi
155
156AC_ARG_ENABLE([kxc],
157	      AS_HELP_STRING([--disable-kxc], [don't build third derivatives]),
158	      [ac_cv_build_kxc=$enableval],
159	      [ac_cv_build_kxc=no])
160if test x"${ac_cv_build_kxc}" == x"no"; then
161  AC_DEFINE(XC_DONT_COMPILE_KXC, 1, [defined if third derivatives are disabled])
162  AC_DEFINE(XC_DONT_COMPILE_LXC, 1, [defined if fourth derivatives are disabled])
163fi
164
165AC_ARG_ENABLE([lxc],
166	      AS_HELP_STRING([--disable-lxc], [don't build fourth derivatives]),
167	      [ac_cv_build_lxc=$enableval],
168	      [ac_cv_build_lxc=no])
169if test x"${ac_cv_build_lxc}" == x"no"; then
170  AC_DEFINE(XC_DONT_COMPILE_LXC, 1, [defined if fourth derivatives are disabled])
171fi
172
173# build/install fortran bits unless --disable-fortran is used
174AC_ARG_ENABLE([fortran],
175	      AS_HELP_STRING([--disable-fortran], [don't build/install fortran components]),
176	      [ac_cv_build_fortran=$enableval],
177	      [ac_cv_build_fortran=yes])
178AM_CONDITIONAL([ENABLE_FORTRAN], [test $ac_cv_build_fortran = yes])
179
180if test $ac_cv_build_fortran = yes; then
181  HAVE_FORTRAN=1
182  AC_DEFINE(HAVE_FORTRAN, [1], [Defined if libxc is compiled with fortran support])
183
184  dnl try to find out what is the default FORTRAN 90 compiler
185  acx_save_fcflags="${FCFLAGS}"
186  AC_PROG_FC([], [Fortran 90])
187  if test x"$FC" = x; then
188    AC_MSG_ERROR([could not find Fortran 90 compiler])
189  fi
190
191  AC_LANG_PUSH(Fortran)
192  AC_FC_SRCEXT(f90)
193  FCFLAGS="${acx_save_fcflags}"
194
195  dnl Fortran default flags
196  ACX_FCFLAGS
197
198  dnl libxc needs the preprocessor. The result goes to FCCPP
199  ACX_FCCPP
200
201  dnl how Fortran mangles function names
202  AC_FC_WRAPPERS
203
204  dnl check whether we have or not a compiler that allows for very long lines...
205  ACX_LONG_FORTRAN_LINES
206
207  dnl check whether the Fortran 90 compiler accepts line markers cast by the preprocessor.
208  ACX_F90_ACCEPTS_LINE_NUMBERS
209
210  AX_F90_MODULE_EXTENSION
211
212  dnl Need to know the size of a Fortran integer
213  ACX_FC_INTEGER_SIZE
214  ACX_CC_FORTRAN_INT
215
216  dnl check whether the Fortran compiler supports Fortran 2003 iso_c_binding
217  ACX_FC_ISO_C_BINDING([], [AC_MSG_ERROR([Could not find Fortran 2003 iso_c_binding. Fortran 2003 interface can not be compiled.])])
218
219AC_LANG_POP([Fortran])
220else
221  HAVE_FORTRAN=0
222fi
223AC_SUBST(ax_cv_f90_modext)
224AM_CONDITIONAL(F90_MOD_UPPERCASE, [test x$ax_f90_mod_uppercase = xyes])
225AM_CONDITIONAL(COMPILE_FORTRAN, test x${HAVE_FORTRAN} = x1)
226AM_CONDITIONAL([COMPILE_FORTRAN03], [test x$ac_cv_build_fortran03 = xyes])
227
228
229AC_CONFIG_FILES([Makefile
230  xc_version.h
231  src/Makefile
232  src/maple2c/Makefile
233  src/maple2c/lda_exc/Makefile
234  src/maple2c/lda_vxc/Makefile
235  src/maple2c/gga_exc/Makefile
236  src/maple2c/gga_vxc/Makefile
237  src/maple2c/mgga_exc/Makefile
238  src/maple2c/mgga_vxc/Makefile
239  testsuite/Makefile
240  testsuite/pytest/Makefile
241  build/Makefile
242  build/libxc.pc
243  build/libxcf90.pc
244  build/libxcf03.pc
245  build/libxc.spec
246  scripts/Makefile
247  maple/Makefile
248  maple/lda_exc/Makefile
249  maple/lda_vxc/Makefile
250  maple/gga_exc/Makefile
251  maple/gga_vxc/Makefile
252  maple/mgga_exc/Makefile
253  maple/mgga_vxc/Makefile
254  pylibxc/Makefile
255  cmake/Makefile
256])
257
258AC_OUTPUT
259
260