1# -----------------------------------------------------------------------------
2# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-21 Bradley M. Bell
3#
4# CppAD is distributed under the terms of the
5#              Eclipse Public License Version 2.0.
6#
7# This Source Code may also be made available under the following
8# Secondary License when the conditions for such availability set forth
9# in the Eclipse Public License, Version 2.0 are satisfied:
10#       GNU General Public License, Version 2.0 or later.
11# -----------------------------------------------------------------------------
12dnl Process this file with autoconf to produce a configure script.
13dnl   package   version              bug-report
14AC_INIT([cppad], [20210000.8], [cppad@list.coin-or.org])
15AM_SILENT_RULES([no])
16
17dnl By defalut disable maintainer mode when running configure;
18dnl --enable-maintainer-mode will enable it.
19dnl This avoids the autoconf and automake tools being launched by make
20AM_MAINTAINER_MODE
21
22dnl Set the default install prefix to the installers home directory
23AC_PREFIX_DEFAULT(${HOME})
24
25dnl Run any macros required for proper operation of generated makefiles
26dnl Note this must come before AC_PROG_CC; see
27dnl http://lists.gnu.org/archive/html/automake/2010-08/msg00113.html
28dnl
29dnl nostdinc: Do not define standard include directories in generated makefiles
30dnl subdir-objects: create objects in sub-directories, same structure source
31dnl foreign: not GNU standard; no NEWS, AUTHORS, ...
32AM_INIT_AUTOMAKE([nostdinc subdir-objects -Wall foreign])
33
34dnl Have configure check source directory for the following file:
35dnl include/cppad/cppad.hpp
36AC_CONFIG_SRCDIR(include/cppad/cppad.hpp)
37
38# check if we have ar program and abort if it is not found
39AM_PROG_AR
40
41dnl -----------------------------------------------------------------------
42dnl The case where enable_msvc != no is defined and supported by Ted Ralphs
43AC_MSG_CHECKING([--enable-msvc])
44AC_ARG_ENABLE([msvc],
45    [AC_HELP_STRING([--enable-msvc],
46    [Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin.])],
47    [enable_msvc=$enableval],
48    [enable_msvc=no]
49)
50AC_MSG_RESULT([$enable_msvc])
51
52dnl the prefix directory corresponding to CppAD -------------------------
53dnl The following seems to work but NONE is not in autoconf specifications
54AC_MSG_CHECKING([--prefix])
55if test "$prefix" = "NONE" ; then
56    AC_MSG_RESULT([$HOME])
57else
58    AC_MSG_RESULT([$prefix])
59fi
60
61dnl Are we using standard vectors ----------------------------------------
62AC_MSG_CHECKING([--with-stdvector])
63AC_ARG_WITH(stdvector,
64    AC_HELP_STRING([--with-stdvector], [default is no]),
65    [stdvector="yes"],
66    [stdvector="no"]
67)
68if test "$stdvector" = "yes" ; then
69    AC_SUBST(cppad_stdvector, 1)
70else
71    AC_SUBST(cppad_stdvector, 0)
72fi
73AC_MSG_RESULT([$stdvector])
74
75dnl Are we using boost vectors ----------------------------------------
76AC_MSG_CHECKING([--with-boostvector])
77AC_ARG_WITH(boostvector,
78    AC_HELP_STRING([--with-boostvector], [default is no]),
79    [boostvector="yes"],
80    [boostvector="no"]
81)
82AC_MSG_RESULT([$boostvector])
83if test "$boostvector" = "yes" ; then
84    if test "$stdvector" != "no" ; then
85        AC_MSG_ERROR([cannot --with both stdvector and boostvector])
86    fi
87    AC_SUBST(cppad_boostvector, 1)
88else
89    AC_SUBST(cppad_boostvector, 0)
90fi
91
92dnl Are we using eigen vectors ----------------------------------------
93AC_MSG_CHECKING([--with-eigenvector])
94AC_ARG_WITH(eigenvector,
95    AC_HELP_STRING([--with-eigenvector], [default is no]),
96    [eigenvector="yes"],
97    [eigenvector="no"]
98)
99AC_MSG_RESULT([$eigenvector])
100if test "$eigenvector" = "yes" ; then
101    if test "$stdvector" != "no" ; then
102        AC_MSG_ERROR([cannot --with both stdvector and eigenvector])
103    fi
104    if test "$boostvector" != "no" ; then
105        AC_MSG_ERROR([cannot --with both boostvector and eigenvector])
106    fi
107    AC_SUBST(cppad_eigenvector, 1)
108else
109    AC_SUBST(cppad_eigenvector, 0)
110fi
111
112dnl The postfix directiory corresponding to CppAD ------------------------
113AC_MSG_CHECKING([POSTFIX_DIR])
114AC_ARG_VAR(POSTFIX_DIR,
115    [postfix directory for CppAD installation]
116)
117AM_CONDITIONAL(CppAD_POSTFIX, test "$POSTFIX_DIR" != "")
118if test "$POSTFIX_DIR" != "" ; then
119    AC_MSG_RESULT([$POSTFIX_DIR])
120else
121    AC_MSG_RESULT([no])
122fi
123
124dnl The prefix corresponding to the installation of Adolc ---------------
125AC_MSG_CHECKING([ADOLC_DIR])
126AC_ARG_VAR(ADOLC_DIR,
127    [value of configure prefix directory during Adolc install]
128)
129AM_CONDITIONAL(CppAD_ADOLC, test "$ADOLC_DIR" != "")
130if test "$ADOLC_DIR" != "" ; then
131    AC_MSG_RESULT([$ADOLC_DIR])
132    AC_SUBST(cppad_has_adolc, 1)
133else
134    AC_MSG_RESULT([no])
135    AC_SUBST(cppad_has_adolc, 0)
136fi
137
138dnl The prefix corresponding to the installation of Eigen ---------------
139AC_MSG_CHECKING([EIGEN_DIR])
140AC_ARG_VAR(EIGEN_DIR,
141    [value of configure prefix directory during Eigen install]
142)
143AM_CONDITIONAL(CppAD_EIGEN, test "$EIGEN_DIR" != "")
144if test "$EIGEN_DIR" != "" ; then
145    AC_MSG_RESULT([$EIGEN_DIR])
146    AC_SUBST(EIGEN_INCLUDE, [-I$EIGEN_DIR/include])
147    AC_SUBST(cppad_has_eigen, 1)
148else
149    AC_MSG_RESULT([no])
150    AC_SUBST(EIGEN_INCLUDE, [])
151    AC_SUBST(cppad_has_eigen, 0)
152fi
153
154dnl The directory corresponding to the installation of FADBAD -----------
155AC_MSG_CHECKING([FADBAD_DIR])
156AC_ARG_VAR(FADBAD_DIR,
157    [parent directory directly above FADBAD++ directory]
158)
159AM_CONDITIONAL(CppAD_FADBAD, test "$FADBAD_DIR" != "")
160if test "$FADBAD_DIR" != "" ; then
161    AC_MSG_RESULT([$FADBAD_DIR])
162    AC_SUBST(cppad_has_fadbad, 1)
163else
164    AC_MSG_RESULT([no])
165    AC_SUBST(cppad_has_fadbad, 0)
166fi
167
168dnl The directory corresponding to the installation of SACADO -----------
169AC_MSG_CHECKING([SACADO_DIR])
170AC_ARG_VAR(SACADO_DIR,
171    [value of the configure prefix directory during Sacado install]
172)
173AM_CONDITIONAL(CppAD_SACADO, test "$SACADO_DIR" != "")
174if test "$SACADO_DIR" != "" ; then
175    AC_MSG_ERROR([CppAD autotools build no longer support sacado, use cmake])
176else
177    AC_MSG_RESULT([no])
178    AC_SUBST(cppad_has_sacado, 0)
179fi
180
181dnl The directory corresponding to the installation of IPOPT -----------
182AC_MSG_CHECKING([IPOPT_DIR])
183AC_ARG_VAR(IPOPT_DIR,
184    [value of the configure prefix directory during Ipopt install]
185)
186AM_CONDITIONAL(CppAD_IPOPT, test "$IPOPT_DIR" != "")
187if test "$IPOPT_DIR" != "" ; then
188    AC_MSG_RESULT([$IPOPT_DIR])
189    AC_SUBST(cppad_has_ipopt, 1)
190else
191    AC_MSG_RESULT([no])
192    AC_SUBST(cppad_has_ipopt, 0)
193fi
194
195dnl The directory corresponding to the installation of BOOST ------------
196AC_MSG_CHECKING([BOOST_DIR])
197AC_ARG_VAR(BOOST_DIR,
198    [parent directory directly above boost directory]
199)
200AM_CONDITIONAL(CppAD_BOOST_DIR, test "$BOOST_DIR" != "")
201if test "$BOOST_DIR" != "" ; then
202    AC_MSG_RESULT([$BOOST_DIR])
203    AC_SUBST(BOOST_INCLUDE, [-I$BOOST_DIR/include])
204    AC_SUBST(cppad_has_boost, 1)
205else
206    AC_MSG_RESULT([no])
207    AC_SUBST(BOOST_INCLUDE,[])
208    AC_SUBST(cppad_has_boost, 0)
209fi
210
211dnl The C++ compiler flags CXX_FLAGS -------------------------------------
212dnl see AC_SUBST(CXXFLAGS, "") next to AC_PROG_CXX
213#
214AC_MSG_CHECKING([CXX_FLAGS])
215AC_ARG_VAR(CXX_FLAGS,
216    [ CXXFLAGS is ignored, use CXX_FLAGS for compiler flags]
217)
218# cxx_flags for fadbad and eigen
219if test "$CXX_FLAGS" != "" ; then
220    AC_MSG_RESULT([$CXX_FLAGS])
221else
222    AC_MSG_RESULT([no])
223fi
224
225dnl The compiler OpenMP flags OPENMP_FLAGS ----------------------------------
226AC_MSG_CHECKING([OPENMP_FLAGS])
227AC_ARG_VAR(OPENMP_FLAGS,
228    [ flags that instruct compiler to interpret OpenMP directrives ]
229)
230if test "$OPENMP_FLAGS" != "" ; then
231    AC_MSG_RESULT([$OPENMP_FLAGS])
232else
233    AC_MSG_RESULT([no])
234fi
235AM_CONDITIONAL(CppAD_OPENMP, test "$OPENMP_FLAGS" != "")
236
237dnl The compiler OpenMP flags MAX_NUM_THREADS -------------------------------
238AC_MSG_CHECKING([MAX_NUM_THREADS])
239AC_ARG_VAR(MAX_NUM_THREADS,
240    [ maximum number of threads that can be used with CppAD ]
241)
242if test "$MAX_NUM_THREADS" != "" ; then
243    AC_MSG_RESULT([$MAX_NUM_THREADS])
244    if test "$MAX_NUM_THREADS" -lt "4" ; then
245        AC_MSG_ERROR(
246            [ MAX_NUM_THREADS=$MAX_NUM_THREADS is less than 4 ]
247        )
248    fi
249    max_num_threads="$MAX_NUM_THREADS"
250else
251    max_num_threads="48"
252    AC_MSG_RESULT([no, using default value $max_num_threads])
253fi
254AC_SUBST(cppad_max_num_threads, [$max_num_threads])
255
256dnl type used for addresses in AD tapes [ default = unsigned int ] -----------
257AC_MSG_CHECKING([TAPE_ADDR_TYPE])
258AC_ARG_VAR(TAPE_ADDR_TYPE, [type used for addresses in AD tapes])
259if test "$TAPE_ADDR_TYPE" == "" ; then
260    addr_t="unsigned int"
261else
262    addr_t="$TAPE_ADDR_TYPE"
263fi
264AC_SUBST(cppad_tape_addr_type, [$addr_t])
265AC_MSG_RESULT([$addr_t])
266ok="no"
267if test "$addr_t" == "size_t" ; then
268    ok="yes"
269fi
270if test "$addr_t" == "int" ; then
271    AC_MSG_WARN(
272        [TAPE_ADDR_TYPE=int is for CppAD developers (not users)]
273    )
274    ok="yes"
275fi
276if test "$addr_t" == "unsigned int" ; then
277    ok="yes"
278fi
279if test "$addr_t" == "unsigned short int" ; then
280    ok="yes"
281fi
282if test "$ok" == "no" ; then
283    AC_MSG_ERROR(
284        [$addr_t is not a valid choice for TAPE_ADDR_TYPE]
285    )
286fi
287
288dnl type used for tape identifier [ default = unsigned int ] -----------
289AC_MSG_CHECKING([TAPE_ID_TYPE])
290AC_ARG_VAR(TAPE_ID_TYPE, [type used for addresses in AD tapes])
291if test "$TAPE_ID_TYPE" == "" ; then
292    tape_id_t="unsigned int"
293else
294    tape_id_t="$TAPE_ID_TYPE"
295fi
296AC_SUBST(cppad_tape_id_type, [$tape_id_t])
297AC_MSG_RESULT([$tape_id_t])
298ok="no"
299if test "$tape_id_t" == "size_t" ; then
300    ok="yes"
301fi
302if test "$tape_id_t" == "int" ; then
303    AC_MSG_WARN(
304        [TAPE_ID_TYPE=int is for CppAD developers (not users)]
305    )
306    ok="yes"
307fi
308if test "$tape_id_t" == "unsigned int" ; then
309    ok="yes"
310fi
311if test "$tape_id_t" == "unsigned short int" ; then
312    ok="yes"
313fi
314if test "$ok" == "no" ; then
315    AC_MSG_ERROR(
316        [$tape_id_t is not a valid choice for TAPE_ID_TYPE]
317    )
318fi
319AC_MSG_NOTICE([********** End Checking Command Line arguments ***************])
320
321dnl --------------------------------------------------------------------------
322if test "$enable_msvc" == "no"
323then
324    cxx_list="g++ clang++ CC pgCC icpc gpp cxx cc++"
325    cc_list="gcc clang cc pgcc icc"
326    fc_list="gfortran ifort g95 fort77 f77 g77 pgf90 pgf77 ifc frt af77"
327else
328    dnl This case defined and supported by Ted Ralphs
329    cxx_list="icl cl g++"
330    cc_list="icl cl gcc"
331    fc_list="ifort gfortran"
332fi
333dnl --------------------------------------------------------------------------
334
335dnl AC_PROG_CXX([compiler-search-list]) outputs CXX as C++ compiler to use
336AC_PROG_CXX([$cxx_list])
337dnl erase any setting of CXXFLAGS, see CXX_FLAGS documentation
338AC_SUBST(CXXFLAGS, "")
339
340dnl AC_PROG_CC([compiler-search-list]) outputs CC as C++ compiler to use
341AC_PROG_CC([$cc_list])
342dnl erase any setting of CFLAGS
343AC_SUBST(CFLAGS, "")
344
345dnl AC_PROG_FC ([compiler-search-list], [dialect])
346AC_PROG_FC([$fc_list])
347dnl not compiling any fortran so no need to touch flags
348
349dnl Check for pkgconfig
350AC_CHECK_PROG(have_pkg_config, [pkg-config], [yes], [no])
351AM_CONDITIONAL(CppAD_PKG_CONFIG, test "$have_pkg_config" = "yes")
352dnl --------------------------------------------------------------------------
353dnl If the compiler does not support -c -o, wrap it with the compile script.
354AC_PROG_CXX_C_O
355if test $ac_cv_prog_cxx_c_o = no ; then
356   CXX="$am_aux_dir/compile $CXX"
357fi
358dnl -------------------------------------------------------------------------
359dnl Setting that cmake finds but autotools not kept up to date on
360AC_SUBST(cppad_cxx_flags, "")
361AC_SUBST(cppad_has_colpack, 0)
362AC_SUBST(cppad_has_mkstemp, 0)
363AC_SUBST(cppad_has_tmpnam_s, 0)
364AC_SUBST(cppad_cplusplus_201100_ok, 0)
365AC_SUBST(compiler_has_conversion_warn, 0)
366
367dnl -------------------------------------------------------------------------
368dnl Determine which definition we are using for CPPAD_TESTVECTOR
369if test "$stdvector$boostvector$eigenvector" = "nonono" ; then
370    AC_SUBST(cppad_cppadvector, 1)
371else
372    AC_SUBST(cppad_cppadvector, 0)
373fi
374
375dnl the gettimeofday check automatically generates a yes / no configure msg
376AC_CHECK_FUNC(
377    gettimeofday,
378    [gettimeofday="yes"],
379    [gettimeofday="no"]
380)
381if test "$gettimeofday" = "yes" ; then
382    AC_SUBST(cppad_has_gettimeofday, 1)
383else
384    AC_SUBST(cppad_has_gettimeofday, 0)
385fi
386
387dnl Use LIBTOOL for cppad_ipopt ?
388dnl AC_PROG_LIBTOOL
389
390dnl Determine if ranlib is present and where it is if present (set RANLIB)
391AC_PROG_RANLIB
392
393AC_MSG_CHECKING([whether using Microsoft C++ compiler])
394AM_CONDITIONAL(CppAD_MS_COMPILER, test "$CXX" == "cl" || test "$CXX" == "icl")
395if test "$CXX" == "cl" || test "$CXX" == "icl"; then
396    AC_MSG_RESULT([yes])
397else
398    AC_MSG_RESULT([no])
399fi
400
401dnl AC_PROG_CP outputs CPP as command to run C preprocessor
402AC_PROG_CPP
403
404dnl Do nothing if complier supports inline, otherwise try to find a subsitute
405dnl definition or, if cannot, define inline as empty
406AC_C_INLINE
407
408dnl determine FCLIBS, flags necessary for linking C++ with modern fortran
409AC_FC_LIBRARY_LDFLAGS
410
411dnl absolute path corresponding to top_builddig and top_srcdir in makefile.am
412dnl (used by cppad-uninstalled.pc.in).
413abs_top_builddir=`pwd`
414AC_SUBST(ABS_TOP_BUILDDIR, "$abs_top_builddir")
415abs_top_srcdir=`cd $srcdir ; pwd`
416AC_SUBST(ABS_TOP_SRCDIR, "$abs_top_srcdir")
417dnl --------------------------------------------------------------------------
418dnl Check for C libraries
419
420dnl check for pthread library
421AC_CHECK_LIB(
422    [pthread],
423    [pthread_barrier_wait],
424    [pthread="yes"],
425    [pthread="no"]
426)
427AM_CONDITIONAL(CppAD_PTHREAD, test "$pthread" = "yes")
428if test "$pthread" == "yes" ; then
429    AC_SUBST(PTHREAD_LIB,"-lpthread")
430else
431    AC_SUBST(PTHREAD_LIB,"")
432fi
433
434dnl check for dl library
435AC_SUBST(DL_LIB, "")
436AC_CHECK_LIB(
437    [dl],
438    [dlopen],
439    [DL_LIB="-ldl"],
440    [DL_LIB=""]
441)
442dnl --------------------------------------------------------------------------
443dnl check for boost thread library
444AC_LANG_PUSH([C++])
445LDFLAGS_save=$LDFLAGS
446CXXFLAGS_save=$CXXFLAGS
447boost_thread_found='no'
448if test "$BOOST_DIR" != '' ; then
449    CXXFLAGS="-I$BOOST_DIR/include $CXXFLAGS"
450fi
451if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then
452    bthread_lib='-lboost_thread-mt'
453    LDFLAGS="$LDFLAGS_save $bthread_lib"
454    AC_LINK_IFELSE(
455        [AC_LANG_PROGRAM(
456            [# include <boost/thread.hpp>],
457            [boost::barrier wait(1);]
458        )],
459        [boost_thread_found='yes'],
460        [boost_thread_found='no']
461    )
462fi
463if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
464    bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.so"
465    LDFLAGS="$LDFLAGS_save $bthread_lib"
466    AC_LINK_IFELSE(
467        [AC_LANG_PROGRAM(
468            [# include <boost/thread.hpp>],
469            [boost::barrier wait(1);]
470        )],
471        [boost_thread_found='yes'],
472        [boost_thread_found='no']
473    )
474fi
475if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
476    bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.a"
477    LDFLAGS="$LDFLAGS_save $bthread_lib"
478    AC_LINK_IFELSE(
479        [AC_LANG_PROGRAM(
480            [# include <boost/thread.hpp>],
481            [boost::barrier wait(1);]
482        )],
483        [boost_thread_found='yes'],
484        [boost_thread_found='no']
485    )
486fi
487if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then
488    bthread_lib='-lboost_thread'
489    LDFLAGS="$LDFLAGS_save $bthread_lib"
490    AC_LINK_IFELSE(
491        [AC_LANG_PROGRAM(
492            [# include <boost/thread.hpp>],
493            [boost::barrier wait(1);]
494        )],
495        [boost_thread_found='yes'],
496        [boost_thread_found='no']
497    )
498fi
499if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
500    bthread_lib="$BOOST_DIR/lib/libboost_thread.so"
501    LDFLAGS="$LDFLAGS_save $bthread_lib"
502    AC_LINK_IFELSE(
503        [AC_LANG_PROGRAM(
504            [# include <boost/thread.hpp>],
505            [boost::barrier wait(1);]
506        )],
507        [boost_thread_found='yes'],
508        [boost_thread_found='no']
509    )
510fi
511if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
512    bthread_lib="$BOOST_DIR/lib/libboost_thread.a"
513    LDFLAGS="$LDFLAGS_save $bthread_lib"
514    AC_LINK_IFELSE(
515        [AC_LANG_PROGRAM(
516            [# include <boost/thread.hpp>],
517            [boost::barrier wait(1);]
518        )],
519        [boost_thread_found='yes'],
520        [boost_thread_found='no']
521    )
522fi
523AM_CONDITIONAL(CppAD_BTHREAD, test "$boost_thread_found" = 'yes')
524if test "$boost_thread_found" == 'yes' ; then
525    AC_SUBST(BTHREAD_LIB,"$bthread_lib")
526    AC_MSG_RESULT([boost::thread library... yes])
527else
528    AC_SUBST(BTHREAD_LIB,'')
529    AC_MSG_RESULT([boost::thread library... no])
530fi
531LDFLAGS=$LDFLAGS_save
532CXXFLAGS=$CXXFLAGS_save
533AC_LANG_POP([C++])
534#
535dnl --------------------------------------------------------------------------
536dnl Library directories
537if test -e $IPOPT_DIR/lib/coin ; then
538    IPOPT_LIBS="-L $IPOPT_DIR/lib/coin -L $IPOPT_DIR/lib/coin-or/ThirdParty"
539    IPOPT_LD_PATH="$IPOPT_DIR/lib/coin:$IPOPT_DIR/lib/coin-or/ThirdParty"
540else
541    IPOPT_LIBS="-L $IPOPT_DIR/lib"
542    IPOPT_LD_PATH="$IPOPT_DIR/lib"
543fi
544AC_SUBST(CPPAD_IPOPT_LD_PATH, "$IPOPT_LD_PATH")
545#
546AC_SUBST(CPPAD_IPOPT_LIBS, "$IPOPT_LIBS -lipopt")
547if test "$have_pkg_config" == "yes"; then
548    dnl set CPPAD_IPOPT_LIBS
549    PKG_CONFIG_PATH="$IPOPT_DIR/lib/pkgconfig:$IPOPT_DIR/share/pkgconfig"
550    PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$IPOPT_DIR/lib64/pkgconfig"
551    export PKG_CONFIG_PATH
552    if pkg-config --libs ipopt >& /dev/null ; then
553        CPPAD_IPOPT_LIBS=`pkg-config --libs ipopt`
554    else
555        dnl check for blas library
556        AC_LANG_PUSH([Fortran])
557        AC_CHECK_LIB(
558            [blas],
559            [ddot],
560            [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas"],
561        )
562        dnl check for lapack library
563        AC_CHECK_LIB(
564            [lapack],
565            [dgesv],
566            [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack"],
567        )
568        AC_LANG_POP([Fortran])
569    fi
570else
571    dnl check for blas library
572    AC_LANG_PUSH([Fortran])
573    AC_CHECK_LIB(
574        [blas],
575        [ddot],
576        [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas"],
577    )
578    dnl check for lapack library
579    AC_CHECK_LIB(
580        [lapack],
581        [dgesv],
582        [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack"],
583    )
584    AC_LANG_POP([Fortran])
585fi
586AC_MSG_RESULT([cppad_ipopt_nlp libraries: $CPPAD_IPOPT_LIBS])
587dnl --------------------------------------------------------------------------
588dnl Set the values of the names needed by the files
589dnl pkgconfig/cppad.pc.in and pkgconfig/cppad-uninstalled.pc.in.
590dnl
591dnl These settings are an attempt to be the same as in CMakeLists.txt
592dnl and pkgconfig/CMakeLists.txt with the following restrictions:
593dnl 1. The default prefix for the autoconf install is $HOME.
594dnl 2. autoconf configuration does not allow for Colpack.
595dnl 3. Assume that libraries are being installed in prefix/lib.
596dnl 4. Only install pkgconfig files below prefix/lib (not in datadir).
597dnl
598dnl cppad_description
599AC_SUBST(cppad_description, "Differentiation of C++ Algorithms")
600dnl
601dnl cppad_version
602AC_SUBST(cppad_version, ${PACKAGE_VERSION} )
603dnl
604dnl cppad_url
605AC_SUBST(cppad_url, "http://www.coin-or.org/CppAD")
606dnl
607dnl cppad_pkgconfig_cflags_uninstalled
608AC_SUBST(cppad_pkgconfig_cflags_uninstalled, "-I$abs_top_srcdir")
609dnl
610dnl cppad_pkgconfig_cflags
611if test "$prefix" == "NONE" ; then
612    value="-I$HOME/include"
613else
614    value="-I$prefix/include"
615fi
616if test "$POSTFIX_DIR" != "" ; then
617    value="$value/$POSTFIX_DIR"
618fi
619AC_SUBST(cppad_pkgconfig_cflags, "$value")
620dnl
621dnl cppad_pkgconfig_libs_uninstalled
622if test "$IPOPT_DIR" == "" ; then
623    value=""
624else
625    value="-L$abs_top_builddir/cppad_ipopt/src -lcppad_ipopt"
626fi
627AC_SUBST(cppad_pkgconfig_libs_uninstalled, "$value")
628dnl
629dnl cppad_pkgconfig_libs
630if test "$prefix" == "NONE" ; then
631    value="-L$HOME/lib"
632else
633    value="-L$prefix/lib"
634fi
635if test "$POSTFIX_DIR" != "" ; then
636    value="$value/$POSTFIX_DIR"
637fi
638if test "$IPOPT_DIR" == "" ; then
639    value=""
640else
641    value="$value -lcppad_ipopt"
642fi
643AC_SUBST(cppad_pkgconfig_libs, "$value")
644dnl
645dnl cppad_pkgconfig_requires
646dnl cppad_pkgconfig_requires_uninstalled
647if test "$IPOPT_DIR" == "" ; then
648    value=""
649else
650    value="ipopt"
651fi
652AC_SUBST(cppad_pkgconfig_requires, "$value")
653AC_SUBST(cppad_pkgconfig_requires_uninstalled, "$value")
654dnl
655dnl -------------------------------------------------------------------------
656dnl names set here so */test_one.sh.in works both with cmake and autoconf
657dnl (no longer used ?)
658AC_SUBST(adolc_prefix,      ${ADOLC_DIR} )
659AC_SUBST(eigen_prefix,      ${EIGEN_DIR} )
660AC_SUBST(ipopt_prefix,      ${IPOPT_DIR} )
661dnl
662dnl -----------------------------------------------------------------------
663dnl AC_CONFIG_FILES(file-list) for each file in the list, configure will
664dnl read file.in, do its substitutions, and create file
665AC_CONFIG_FILES([
666    include/cppad/configure.hpp
667    cppad_ipopt/example/test.sh
668    cppad_ipopt/speed/test.sh
669    cppad_ipopt/test/test.sh
670    example/ipopt_solve/test.sh
671    pkgconfig/cppad.pc
672    pkgconfig/cppad-uninstalled.pc
673
674    makefile
675    cppad_ipopt/src/makefile
676    cppad_ipopt/example/makefile
677    cppad_ipopt/speed/makefile
678    cppad_ipopt/test/makefile
679    cppad_lib/makefile
680    example/general/makefile
681    example/abs_normal/makefile
682    example/atomic_two/makefile
683    example/atomic_three/makefile
684    example/chkpoint_two/makefile
685    example/ipopt_solve/makefile
686    example/optimize/makefile
687    example/sparse/makefile
688    example/utility/makefile
689    example/get_started/makefile
690    include/makefile
691    introduction/makefile
692    example/multi_thread/makefile
693    example/print_for/makefile
694    speed/adolc/makefile
695    speed/cppad/makefile
696    speed/double/makefile
697    speed/example/makefile
698    speed/fadbad/makefile
699    speed/sacado/makefile
700    speed/src/makefile
701    test_more/compare_c/makefile
702    test_more/general/makefile
703    test_more/deprecated/makefile
704    test_more/deprecated/atomic_two/makefile
705    test_more/deprecated/chkpoint_one/makefile
706])
707dnl END AC_CONFIG_FILES
708
709dnl copy config.hpp to source directory
710AC_CONFIG_COMMANDS(
711    [configure.hpp],
712    [cp include/cppad/configure.hpp  \
713        $abs_top_srcdir/include/cppad/configure.hpp],
714[abs_top_srcdir=$abs_top_srcdir]
715)
716dnl scripts that set library path before running test
717AC_CONFIG_COMMANDS(
718    [example_ipopt_solve_test.sh],
719    [chmod +x example/ipopt_solve/test.sh],
720    []
721)
722AC_CONFIG_COMMANDS(
723    [cppad_ipopt_example_test.sh],
724    [chmod +x cppad_ipopt/example/test.sh],
725    []
726)
727AC_CONFIG_COMMANDS(
728    [cppad_ipopt_speed_test.sh],
729    [chmod +x cppad_ipopt/speed/test.sh],
730    []
731)
732AC_CONFIG_COMMANDS(
733    [cppad_ipopt_test_test.sh],
734    [chmod +x cppad_ipopt/test/test.sh],
735    []
736)
737
738dnl create all the requested output files
739AC_OUTPUT
740