Codebase list cppad / upstream/2014.03.28 configure.ac
upstream/2014.03.28

Tree @upstream/2014.03.28 (Download .tar.gz)

configure.ac @upstream/2014.03.28raw · history · blame

  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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
dnl $Id: configure.ac 3145 2014-03-03 12:28:04Z bradbell $
dnl ---------------------------------------------------------------------------
dnl CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
dnl
dnl CppAD is distributed under multiple licenses. This distribution is under
dnl the terms of the
dnl                     GNU General Public License Version 3.
dnl 
dnl A copy of this license is included in the COPYING file of this distribution.
dnl Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
dnl ---------------------------------------------------------------------------
dnl
dnl Process this file with autoconf to produce a configure script.
dnl   package   version              bug-report
AC_INIT(cppad, 20140328, cppad@list.coin-or.org)
AM_SILENT_RULES([yes])

dnl By defalut disable maintainer mode when running configure;
dnl --enable-maintainer-mode will enable it.
dnl This avoids the autoconf and automake tools being launched by make
AM_MAINTAINER_MODE

dnl Set the default install prefix to the installers home directory
dnl cygwin begin delete:
AC_PREFIX_DEFAULT(${HOME})
dnl cygwin end delete:
dnl cygwin replace: AC_PREFIX_DEFAULT(/usr)

dnl --------------------------------------------------------------------------
dnl Check for programs

AC_CHECK_PROG(have_pkg_config, [pkg-config], [yes], [no])
AM_CONDITIONAL(CppAD_PKG_CONFIG, test "$have_pkg_config" = "yes")

AC_CHECK_PROG(have_ar, [ar], [yes], [no])
AM_CONDITIONAL(CppAD_HAVE_AR, test "$have_ar" = "yes")
if test "$have_ar" = "no"; then
	AC_MSG_WARN(
	[cannot build any libraries because ar is missing, speed/* is not used] 
	)
fi

dnl ----------------------------------------------------------------------
AC_MSG_NOTICE([*** Check command line arguments that are longer used ****])

if test "$CPP_ERROR_WARN" != "" ; then
    AC_MSG_ERROR([The CPP_ERROR_WARN configure option is now CXX_FLAGS])
fi
dnl
AC_ARG_WITH(SpeedExample, AC_HELP_STRING(
	[--with-SpeedExample], [is not necessary, see install instructions.]),
	[SpeedExample="yes"], [SpeedExample="no"]
)
if test "$SpeedExample" = "yes" ; then
    AC_MSG_ERROR([--with-SpeedExample not necessary, see install instructions.])
fi
dnl
AC_ARG_WITH(profiling, AC_HELP_STRING(
	[--with-profiling], [is not necessary, see install instructions.]),
	[profiling="yes"], [profiling="no"]
)
if test "$profiling" = "yes" ; then
    AC_MSG_ERROR([--with-profiling not necessary, see install instructions.])
fi
dnl 
AC_ARG_WITH(Speed, AC_HELP_STRING(
	[--with-Speed], [is not necessary, see install instructions.]),
	[Speed="yes"], [Speed="no"]
)
if test "$Speed" = "yes" ; then
    AC_MSG_ERROR([--with-Speed not necessary, see install instructions.])
fi
dnl 
AC_ARG_WITH(Introduction, AC_HELP_STRING(
	[--with-Introduction], [is not necessary, see install instructions.]),
	[Introduction="yes"], [Introduction="no"]
)
if test "$Introduction" = "yes" ; then
    AC_MSG_ERROR([--with-Introduction not necessary, see install instructions.])
fi
dnl 
AC_ARG_WITH(Example, AC_HELP_STRING(
	[--with-Example], [is not necessary, see install instructions.]),
	[Example="yes"], [Example="no"]
)
if test "$Example" = "yes" ; then
    AC_MSG_ERROR([--with-Example not necessary, see install instructions.])
fi
dnl 
AC_ARG_WITH(TestMore, AC_HELP_STRING(
	[--with-TestMore], [is not necessary, see install instructions.]),
	[TestMore="yes"], [TestMore="no"]
)
if test "$TestMore" = "yes" ; then
    AC_MSG_ERROR([--with-TestMore not necessary, see install instructions.])
fi
dnl 
AC_ARG_WITH(PrintFor, AC_HELP_STRING(
	[--with-PrintFor], [is not necessary, see install instructions.]),
	[PrintFor="yes"], [PrintFor="no"]
)
if test "$PrintFor" = "yes" ; then
    AC_MSG_ERROR([--with-PrintFor not necessary, see install instructions.])
fi
dnl --------------------------------------------------------------------------
AC_MSG_NOTICE([******  Check command line arguments that are used ***********])
dnl the prefix directory corresponding to CppAD -------------------------
dnl The following seems to work but NONE is not in autoconf specifications
AC_MSG_CHECKING([--prefix])
if test "$prefix" = "NONE" ; then
	AC_MSG_RESULT([$HOME])
else
	AC_MSG_RESULT([$prefix])
fi

dnl Are we installing the documentation -----------------------------------
dnl cygwin begin delete:
AC_MSG_CHECKING([--with-Documentation])
AC_ARG_WITH(Documentation, 
	AC_HELP_STRING([--with-Documentation], [default is no]),
	[Documentation="yes"],
	[Documentation="no"]
)
AM_CONDITIONAL(CppAD_DOCUMENTATION, test "$Documentation" = "yes")
AC_MSG_RESULT([$Documentation])
dnl cygwin end delete:
dnl cygwin replace: AM_CONDITIONAL(CppAD_DOCUMENTATION, test "yes" = "yes")

dnl Are we using standard vectors ----------------------------------------
AC_MSG_CHECKING([--with-stdvector])
AC_ARG_WITH(stdvector, 
	AC_HELP_STRING([--with-stdvector], [default is no]),
	[stdvector="yes"],
	[stdvector="no"]
)
if test "$stdvector" = "yes" ; then
	AC_SUBST(cppad_stdvector, 1)
else
	AC_SUBST(cppad_stdvector, 0)
fi
AC_MSG_RESULT([$stdvector])

dnl Are we using boost vectors ----------------------------------------
AC_MSG_CHECKING([--with-boostvector])
AC_ARG_WITH(boostvector, 
	AC_HELP_STRING([--with-boostvector], [default is no]),
	[boostvector="yes"],
	[boostvector="no"]
)
AC_MSG_RESULT([$boostvector])
if test "$boostvector" = "yes" ; then
	if test "$stdvector" != "no" ; then
		AC_MSG_ERROR([cannot --with both stdvector and boostvector])
	fi
	AC_SUBST(cppad_boostvector, 1)
else
	AC_SUBST(cppad_boostvector, 0)
fi

dnl Are we using eigen vectors ----------------------------------------
AC_MSG_CHECKING([--with-eigenvector])
AC_ARG_WITH(eigenvector, 
	AC_HELP_STRING([--with-eigenvector], [default is no]),
	[eigenvector="yes"],
	[eigenvector="no"]
)
AC_MSG_RESULT([$eigenvector])
if test "$eigenvector" = "yes" ; then
	if test "$stdvector" != "no" ; then
		AC_MSG_ERROR([cannot --with both stdvector and eigenvector])
	fi
	if test "$boostvector" != "no" ; then
		AC_MSG_ERROR([cannot --with both boostvector and eigenvector])
	fi
	AC_SUBST(cppad_eigenvector, 1)
else
	AC_SUBST(cppad_eigenvector, 0)
fi

dnl Are we using sparse_set or sparse_list ----------------------------
AC_MSG_CHECKING([--with-sparse_set])
AC_ARG_WITH(sparse_set, 
	AC_HELP_STRING([--with-sparse_set], [default is not specified]),
	[sparse_set="yes"],
	[sparse_set="no"]
)
AC_MSG_RESULT([$sparse_set])
dnl
AC_MSG_CHECKING([--with-sparse_list])
AC_ARG_WITH(sparse_list, 
	AC_HELP_STRING([--with-sparse_list], [default is not specified]),
	[sparse_list="yes"],
	[sparse_list="no"]
)
AC_MSG_RESULT([$sparse_list])
if test "$sparse_set" = "yes" ; then
	if test "$sparse_list" == "yes" ; then
		AC_MSG_ERROR([cannot --with both sparse_set and sparse_list])
	fi
	AC_SUBST(cppad_internal_sparse_set, sparse_set)
else
	AC_SUBST(cppad_internal_sparse_set, sparse_list)
fi


dnl Are we including an implicit constructor from any type -----------
AC_MSG_CHECKING([--with-implicit_ctor])
AC_ARG_WITH(implicit_ctor, 
	AC_HELP_STRING(
		[--with-implicit_ctor], 
		[include an implicit AD<Base> constructor from any type]
	),
	[implicit_ctor="yes"],
	[implicit_ctor="no"]
)
AC_MSG_RESULT([$implicit_ctor])
if test "$implicit_ctor" = "yes" ; then
	AC_SUBST(cppad_implicit_ctor_from_any_type, "1")
else
	AC_SUBST(cppad_implicit_ctor_from_any_type, "0")
fi

dnl The postfix directiory corresponding to CppAD ------------------------
AC_MSG_CHECKING([POSTFIX_DIR])
AC_ARG_VAR(POSTFIX_DIR, 
	[postfix directory for CppAD installation]
)
AM_CONDITIONAL(CppAD_POSTFIX, test "$POSTFIX_DIR" != "")
if test "$POSTFIX_DIR" != "" ; then
	AC_MSG_RESULT([$POSTFIX_DIR])
else
	AC_MSG_RESULT([no])
fi

dnl The prefix corresponding to the installation of Adolc ---------------
AC_MSG_CHECKING([ADOLC_DIR])
AC_ARG_VAR(ADOLC_DIR, 
	[value of configure prefix directory during Adolc install]
)
AM_CONDITIONAL(CppAD_ADOLC, test "$ADOLC_DIR" != "")
if test "$ADOLC_DIR" != "" ; then
	AC_MSG_RESULT([$ADOLC_DIR])
	if test "$have_ar" = "no"; then
		AC_MSG_ERROR([ar is missing and ADOLC_DIR is present])
	fi
else
	AC_MSG_RESULT([no])
fi

dnl The prefix corresponding to the installation of Eigen ---------------
AC_MSG_CHECKING([EIGEN_DIR])
AC_ARG_VAR(EIGEN_DIR, 
	[value of configure prefix directory during Eigen install]
)
AM_CONDITIONAL(CppAD_EIGEN_DIR, test "$EIGEN_DIR" != "")
if test "$EIGEN_DIR" != "" ; then
	AC_MSG_RESULT([$EIGEN_DIR])
	AC_SUBST(EIGEN_INCLUDE, [-I$EIGEN_DIR/include])
else
	AC_MSG_RESULT([no])
	AC_SUBST(EIGEN_INCLUDE, [])
fi

dnl The directory corresponding to the installation of FADBAD -----------
AC_MSG_CHECKING([FADBAD_DIR])
AC_ARG_VAR(FADBAD_DIR,
	[parent directory directly above FADBAD++ directory]
)
AM_CONDITIONAL(CppAD_FADBAD, test "$FADBAD_DIR" != "")
if test "$FADBAD_DIR" != "" ; then
	AC_MSG_RESULT([$FADBAD_DIR])
	if test "$have_ar" = "no"; then
		AC_MSG_ERROR([ar is missing and FADBAD_DIR is present])
	fi
else
	AC_MSG_RESULT([no])
fi

dnl The directory corresponding to the installation of SACADO -----------
AC_MSG_CHECKING([SACADO_DIR])
AC_ARG_VAR(SACADO_DIR,
	[value of the configure prefix directory during Sacado install]
)
AM_CONDITIONAL(CppAD_SACADO, test "$SACADO_DIR" != "")
if test "$SACADO_DIR" != "" ; then
	AC_MSG_RESULT([$SACADO_DIR])
	if test "$have_ar" = "no"; then
		AC_MSG_ERROR([ar is missing and SACADO_DIR is present])
	fi
else
	AC_MSG_RESULT([no])
fi

dnl The directory corresponding to the installation of IPOPT -----------
AC_MSG_CHECKING([IPOPT_DIR])
AC_ARG_VAR(IPOPT_DIR,
	[value of the configure prefix directory during Ipopt install]
)
AM_CONDITIONAL(CppAD_IPOPT, test "$IPOPT_DIR" != "")
if test "$IPOPT_DIR" != "" ; then
	AC_MSG_RESULT([$IPOPT_DIR])
	if test "$have_ar" = "no"; then
		AC_MSG_ERROR([ar is missing and IPOPT_DIR is present])
	fi
else
	AC_MSG_RESULT([no])
fi

dnl The directory corresponding to the installation of BOOST ------------
AC_MSG_CHECKING([BOOST_DIR])
AC_ARG_VAR(BOOST_DIR,
	[parent directory directly above boost directory]
)
AM_CONDITIONAL(CppAD_BOOST_DIR, test "$BOOST_DIR" != "")
if test "$BOOST_DIR" != "" ; then
	AC_MSG_RESULT([$BOOST_DIR])
	AC_SUBST(BOOST_INCLUDE, [-I$BOOST_DIR/include])
else
	AC_MSG_RESULT([no])
	AC_SUBST(BOOST_INCLUDE,[])
fi

dnl The C++ compiler flags CXX_FLAGS -------------------------------------
dnl see AC_SUBST(CXXFLAGS, "") next to AC_PROG_CXX
#
AC_MSG_CHECKING([CXX_FLAGS])
AC_ARG_VAR(CXX_FLAGS,
	[ CXXFLAGS is ignored, use CXX_FLAGS for compiler flags]
)
# cxx_flags for fadbad and eigen
if test "$CXX_FLAGS" != "" ; then
	AC_MSG_RESULT([$CXX_FLAGS]) 
	cxx_flags_fadbad=`echo "$CXX_FLAGS" | sed -e 's|-Wshadow||'`
	cxx_flags_eigen="$cxx_flags_fadbda -Wno-long-long" 
else
	AC_MSG_RESULT([no])
	cxx_flags_fadbad=""
	cxx_flags_eigen=""
fi 
AC_SUBST(CXX_FLAGS_FADBAD, "$cxx_flags_fadbad")
AC_SUBST(CXX_FLAGS_EIGEN,  "$cxx_flags_eigen")

dnl The compiler OpenMP flags OPENMP_FLAGS ----------------------------------
AC_MSG_CHECKING([OPENMP_FLAGS])
AC_ARG_VAR(OPENMP_FLAGS,
	[ flags that instruct compiler to interpret OpenMP directrives ]
)
if test "$OPENMP_FLAGS" != "" ; then
	AC_MSG_RESULT([$OPENMP_FLAGS]) 
else
	AC_MSG_RESULT([no])
fi 
AM_CONDITIONAL(CppAD_OPENMP, test "$OPENMP_FLAGS" != "")

dnl The compiler OpenMP flags MAX_NUM_THREADS -------------------------------
AC_MSG_CHECKING([MAX_NUM_THREADS])
AC_ARG_VAR(MAX_NUM_THREADS,
	[ maximum number of threads that can be used with CppAD ]
)
if test "$MAX_NUM_THREADS" != "" ; then
	AC_MSG_RESULT([$MAX_NUM_THREADS]) 
  	if test "$MAX_NUM_THREADS" -lt "4" ; then
		AC_MSG_ERROR(
			[ MAX_NUM_THREADS=$MAX_NUM_THREADS is less than 4 ]
		)
	fi
	max_num_threads="$MAX_NUM_THREADS"
else
	max_num_threads="48"
	AC_MSG_RESULT([no, using default value $max_num_threads])
fi 
AC_SUBST(cppad_max_num_threads, [$max_num_threads])

dnl type used for addresses in AD tapes [ default = unsigned int ] -----------
AC_MSG_CHECKING([TAPE_ADDR_TYPE])
AC_ARG_VAR(TAPE_ADDR_TYPE, [type used for addresses in AD tapes])
if test "$TAPE_ADDR_TYPE" == "" ; then
	addr_t="unsigned int"
else
	addr_t="$TAPE_ADDR_TYPE"
fi
AC_SUBST(cppad_tape_addr_type, [$addr_t])
AC_MSG_RESULT([$addr_t])
ok="no"
if test "$addr_t" == "size_t" ; then
	ok="yes"
fi
if test "$addr_t" == "int" ; then
	AC_MSG_WARN(
		[TAPE_ADDR_TYPE=int is for CppAD developers (not users)]
	)
	ok="yes"
fi
if test "$addr_t" == "unsigned int" ; then
	ok="yes"
fi
if test "$addr_t" == "unsigned short int" ; then
	ok="yes"
fi
if test "$ok" == "no" ; then
  	AC_MSG_ERROR(
		[$addr_t is not a valid choice for TAPE_ADDR_TYPE]
	)
fi

dnl type used for tape identifier [ default = unsigned int ] -----------
AC_MSG_CHECKING([TAPE_ID_TYPE])
AC_ARG_VAR(TAPE_ID_TYPE, [type used for addresses in AD tapes])
if test "$TAPE_ID_TYPE" == "" ; then
	tape_id_t="unsigned int"
else
	tape_id_t="$TAPE_ID_TYPE"
fi
AC_SUBST(cppad_tape_id_type, [$tape_id_t])
AC_MSG_RESULT([$tape_id_t])
ok="no"
if test "$tape_id_t" == "size_t" ; then
	ok="yes"
fi
if test "$tape_id_t" == "int" ; then
	AC_MSG_WARN(
		[TAPE_ID_TYPE=int is for CppAD developers (not users)]
	)
	ok="yes"
fi
if test "$tape_id_t" == "unsigned int" ; then
	ok="yes"
fi
if test "$tape_id_t" == "unsigned short int" ; then
	ok="yes"
fi
if test "$ok" == "no" ; then
  	AC_MSG_ERROR(
		[$tape_id_t is not a valid choice for TAPE_ID_TYPE]
	)
fi
AC_MSG_NOTICE([********** End Checking Command Line arguments ***************])

dnl auto-tools version does not support ColPack coloring 
AC_SUBST(cppad_has_colpack, 0)

dnl auto-tools version cannot use c++11 compiler
dnl so supress corresponding features
AC_SUBST(cppad_has_nullptr, 0)
AC_SUBST(cppad_has_rvalue, 0)

dnl Determine if size_t has same size as unsigned int 
AC_CHECK_SIZEOF([size_t])
AC_CHECK_SIZEOF([unsigned int])
if test "$ac_cv_size_t" == "$ac_cv_unsigned_int" ; then
	AC_SUBST(cppad_size_t_same_unsigned_int, 1)
else
	AC_SUBST(cppad_size_t_same_unsigned_int, 0)
fi

dnl Determine which definition we are using for CPPAD_TESTVECTOR
if test "$stdvector$boostvector$eigenvector" = "nonono" ; then
	AC_SUBST(cppad_cppadvector, 1)
else 
	AC_SUBST(cppad_cppadvector, 0)
fi

dnl the gettimeofday check automatically generates a yes / no configure msg
AC_CHECK_FUNC(
	gettimeofday,
	[gettimeofday="yes"],
	[gettimeofday="no"]
)
if test "$gettimeofday" = "yes" ; then
	AC_SUBST(cppad_has_gettimeofday, 1)
else
	AC_SUBST(cppad_has_gettimeofday, 0)
fi

dnl Run any macros required for proper operation of generated makefiles
dnl nostdinc: Do not define standard include directories in generated makefiles
AM_INIT_AUTOMAKE(nostdinc)

dnl Use LIBTOOL for cppad_ipopt ?
dnl AC_PROG_LIBTOOL

dnl Determine if ranlib is present and where it is if present (set RANLIB)
AC_PROG_RANLIB

dnl AC_PROG_CXX([compiler-search-list]) outputs CXX as C++ compiler to use
AC_PROG_CXX
AC_MSG_CHECKING([whether using Microsoft C++ compiler])
AM_CONDITIONAL(CppAD_MS_COMPILER, test "$CXX" == "cl" || test "$CXX" == "icl")
if test "$CXX" == "cl" || test "$CXX" == "icl"; then
	AC_MSG_RESULT([yes])
else
	AC_MSG_RESULT([no])
fi
dnl erase any setting of CXXFLAGS, see CXX_FLAGS documentation
AC_SUBST(CXXFLAGS, "")


dnl AC_PROG_CC([compiler-search-list]) outputs CC as C++ compiler to use
AC_PROG_CC
AC_MSG_CHECKING([whether using Microsoft C++ compiler])
dnl erase any setting of CFLAGS
AC_SUBST(CFLAGS, "")

dnl Have configure check source directory to see if cppad/CppAD.h is there
AC_CONFIG_SRCDIR(cppad/CppAD.h)

dnl AC_PROG_CP outputs CPP as command to run C preprocessor
AC_PROG_CPP

dnl Do nothing if complier supports inline, otherwise try to find a subsitute
dnl definition or, if cannot, define inline as empty
AC_C_INLINE

dnl determine FCLIBS, flags necessary for linking C++ with modern fortran
AC_FC_LIBRARY_LDFLAGS

dnl absolute path corresponding to top_builddig and top_srcdir in makefile.am
dnl (used by cppad-uninstalled.pc.in).
abs_top_builddir=`pwd`
AC_SUBST(ABS_TOP_BUILDDIR, "$abs_top_builddir")
abs_top_srcdir=`cd $srcdir ; pwd`
AC_SUBST(ABS_TOP_SRCDIR, "$abs_top_srcdir")
dnl --------------------------------------------------------------------------
dnl Check for C libraries

dnl check for pthread library
AC_CHECK_LIB(
	[pthread],
	[pthread_barrier_wait],
	[pthread="yes"],
	[pthread="no"]
)
AM_CONDITIONAL(CppAD_PTHREAD, test "$pthread" = "yes")
if test "$pthread" == "yes" ; then
	AC_SUBST(PTHREAD_LIB,"-lpthread")
else
	AC_SUBST(PTHREAD_LIB,"")
fi

dnl check for dl library
AC_SUBST(DL_LIB, "")
AC_CHECK_LIB(
	[dl],
	[dlopen],
	[DL_LIB="-ldl"],
	[DL_LIB=""]
)
dnl --------------------------------------------------------------------------
dnl check for boost thread library
AC_LANG_PUSH([C++])
LDFLAGS_save=$LDFLAGS
CXXFLAGS_save=$CXXFLAGS
boost_thread_found='no'
if test "$BOOST_DIR" != '' ; then
	CXXFLAGS="-I$BOOST_DIR/include $CXXFLAGS"
fi
if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then
	bthread_lib='-lboost_thread-mt'
	LDFLAGS="$LDFLAGS_save $bthread_lib"
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[# include <boost/thread.hpp>],
			[boost::barrier wait(1);]
		)],
		[boost_thread_found='yes'],
		[boost_thread_found='no']
	)
fi
if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
	bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.so"
	LDFLAGS="$LDFLAGS_save $bthread_lib"
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[# include <boost/thread.hpp>],
			[boost::barrier wait(1);]
		)],
		[boost_thread_found='yes'],
		[boost_thread_found='no']
	)
fi
if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
	bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.a"
	LDFLAGS="$LDFLAGS_save $bthread_lib"
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[# include <boost/thread.hpp>],
			[boost::barrier wait(1);]
		)],
		[boost_thread_found='yes'],
		[boost_thread_found='no']
	)
fi
if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then
	bthread_lib='-lboost_thread'
	LDFLAGS="$LDFLAGS_save $bthread_lib"
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[# include <boost/thread.hpp>],
			[boost::barrier wait(1);]
		)],
		[boost_thread_found='yes'],
		[boost_thread_found='no']
	)
fi
if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
	bthread_lib="$BOOST_DIR/lib/libboost_thread.so"
	LDFLAGS="$LDFLAGS_save $bthread_lib"
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[# include <boost/thread.hpp>],
			[boost::barrier wait(1);]
		)],
		[boost_thread_found='yes'],
		[boost_thread_found='no']
	)
fi
if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then
	bthread_lib="$BOOST_DIR/lib/libboost_thread.a"
	LDFLAGS="$LDFLAGS_save $bthread_lib"
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[# include <boost/thread.hpp>],
			[boost::barrier wait(1);]
		)],
		[boost_thread_found='yes'],
		[boost_thread_found='no']
	)
fi
AM_CONDITIONAL(CppAD_BTHREAD, test "$boost_thread_found" = 'yes')
if test "$boost_thread_found" == 'yes' ; then
	AC_SUBST(BTHREAD_LIB,"$bthread_lib")
	AC_MSG_RESULT([boost::thread library... yes])
else
	AC_SUBST(BTHREAD_LIB,'')
	AC_MSG_RESULT([boost::thread library... no])
fi
LDFLAGS=$LDFLAGS_save
CXXFLAGS=$CXXFLAGS_save
AC_LANG_POP([C++])
#
dnl --------------------------------------------------------------------------
dnl Library directories
if test -e $IPOPT_DIR/lib/coin ; then
	IPOPT_LIBS="-L $IPOPT_DIR/lib/coin -L $IPOPT_DIR/lib/coin/ThirdParty"
	IPOPT_LD_PATH="$IPOPT_DIR/lib/coin:$IPOPT_DIR/lib/coin/ThirdParty"
else
	IPOPT_LIBS="-L $IPOPT_DIR/lib"
	IPOPT_LD_PATH="$IPOPT_DIR/lib"
fi
AC_SUBST(CPPAD_IPOPT_LD_PATH, "$IPOPT_LD_PATH")
#
AC_SUBST(CPPAD_IPOPT_LIBS, "$IPOPT_LIBS -lipopt")
if test "$have_pkg_config" == "yes"; then
	dnl set CPPAD_IPOPT_LIBS
	PKG_CONFIG_PATH="$IPOPT_DIR/lib/pkgconfig:$IPOPT_DIR/share/pkgconfig"
	PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$IPOPT_DIR/lib64/pkgconfig"
	export PKG_CONFIG_PATH
	if pkg-config --libs ipopt >& /dev/null ; then
		CPPAD_IPOPT_LIBS=`pkg-config --libs ipopt`
	else
		dnl check for blas library
		AC_LANG_PUSH([Fortran])
		AC_CHECK_LIB(
			[blas],
			[ddot],
			[CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas"],
		)
		dnl check for lapack library
		AC_CHECK_LIB(
			[lapack],
			[dgesv],
			[CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack"],
		)
		AC_LANG_POP([Fortran])
	fi
else
	dnl check for blas library
	AC_LANG_PUSH([Fortran])
	AC_CHECK_LIB(
		[blas],
		[ddot],
		[CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas"],
	)
	dnl check for lapack library
	AC_CHECK_LIB(
		[lapack],
		[dgesv],
		[CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack"],
	)
	AC_LANG_POP([Fortran])
fi
AC_MSG_RESULT([cppad_ipopt_nlp libraries: $CPPAD_IPOPT_LIBS])
dnl --------------------------------------------------------------------------
dnl names set here so same cppad.pc.in works for both with cmake and autoconf.
dnl
AC_SUBST(cppad_description, "Differentiation of C++ Algorithms")
AC_SUBST(cppad_version, ${PACKAGE_VERSION} )
AC_SUBST(cppad_url, "http://www.coin-or.org/CppAD")
if test "$prefix" == "NONE" ; then
	cppad_cflags_value="-I$HOME/include"
	cppad_libs_value="-L$HOME/lib"
else
	cppad_cflags_value="-I$prefix/include"
	cppad_libs_value="-L$prefix/lib"
fi
if test "$POSTFIX_DIR" != "" ; then
	cppad_cflags_value="$cppad_cflags_value/$POSTFIX_DIR"
	cppad_libs_value="$cppad_libs_value/$POSTFIX_DIR"
fi
if test "$IPOPT_DIR" == "" ; then
	cppad_libs_value=""
	cppad_requires_value=""
else
	cppad_libs_value="$cppad_libs_value -lcppad_ipopt"
	cppad_requires_value="ipopt"
fi
AC_SUBST(cppad_cflags,   "$cppad_cflags_value")
AC_SUBST(cppad_libs,     "$cppad_libs_value")
AC_SUBST(cppad_requires, "$cppad_requires_value")
dnl
dnl names set here so cppad.pc-uninstalled works both with cmake and autoconf 
AC_SUBST(cppad_SOURCE_DIR,  ${ABS_TOP_SRCDIR} )
dnl
dnl names set here so */test_one.sh.in works both with cmake and autoconf 
AC_SUBST(adolc_prefix,      ${ADOLC_DIR} )
AC_SUBST(eigen_prefix,      ${EIGEN_DIR} )
AC_SUBST(ipopt_prefix,      ${IPOPT_DIR} )
dnl
dnl -----------------------------------------------------------------------
dnl AC_CONFIG_FILES(file-list) for each file in the list, configure will 
dnl read file.in, do its substitutions, and create file
AC_CONFIG_FILES([ 
	cppad/configure.hpp
	cppad_ipopt/example/test.sh
	cppad_ipopt/speed/test.sh
	cppad_ipopt/test/test.sh
	example/ipopt_solve/test.sh
	example/test_one.sh
	pkgconfig/cppad.pc
	pkgconfig/cppad-uninstalled.pc
	test_more/test_one.sh

	makefile
	compare_c/makefile 
	cppad_ipopt/src/makefile
	cppad_ipopt/example/makefile
	cppad_ipopt/speed/makefile
	cppad_ipopt/test/makefile
	example/makefile 
	example/atomic/makefile 
	example/ipopt_solve/makefile 
	introduction/get_started/makefile 
	introduction/exp_apx/makefile
	multi_thread/makefile
	multi_thread/test_multi/makefile
	print_for/makefile
	speed/adolc/makefile
	speed/cppad/makefile 
	speed/double/makefile 
	speed/example/makefile
	speed/fadbad/makefile
	speed/profile/makefile
	speed/profile/gprof.sed
	speed/sacado/makefile
	speed/src/makefile
	test_more/makefile 
])
dnl END AC_CONFIG_FILES 
dnl the comment line above is used by ./new_stable.sh

AC_CONFIG_COMMANDS(
	[example_ipopt_solve_test.sh],
	[chmod +x example/ipopt_solve/test.sh],
)	[]
AC_CONFIG_COMMANDS(
	[cppad_ipopt_example_test.sh],
	[chmod +x cppad_ipopt/example/test.sh],
)	[]
AC_CONFIG_COMMANDS(
	[cppad_ipopt_speed_test.sh],
	[chmod +x cppad_ipopt/speed/test.sh],
	[]
)
AC_CONFIG_COMMANDS(
	[cppad_ipopt_test_test.sh],
	[chmod +x cppad_ipopt/test/test.sh],
	[]
)
AC_CONFIG_COMMANDS(
	[example_test_one.sh],
	[chmod +x example/test_one.sh],
	[]
)
AC_CONFIG_COMMANDS(
	[test_more_test_one.sh],
	[chmod +x test_more/test_one.sh],
	[]
)

dnl create all the requested output files
AC_OUTPUT