-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfigure.in
965 lines (847 loc) · 27.8 KB
/
configure.in
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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
dnl Process this file with the GNU "autoconf" to produce a configure script
dnl for HQP/Omuses
AC_INIT
AC_CONFIG_SRCDIR([hqp/Hqp.h])
MAJOR_VERSION=1
MINOR_VERSION=9
PATCHLEVEL_BASE=9
DEVELOPMENT_VERSION=yes
# note: PATCHLEVEL is formed by appending to PATCHLEVEL_BASE the
# modification date of ChangeLog if DEVELOPMENT_VERSION = yes
# collect defines for compilation
# Note: don't use AC_DEFINE(_UNQUOTED) to avoid default DEFS,
# like PACKAGE_TAR, etc.
ALL_DEFS=""
MES_DEFS=""
IF_DEFS=""
HQP_DEFS=""
OMU_DEFS=""
ODC_DEFS=""
# collect machine objects required for linking
HQP_MACH_OBJS=""
HQP_DOCP_MACH_OBJS=""
OMU_MACH_OBJS=""
ODC_MACH_OBJS=""
# -----------------------------------------------------------------------
# Check for Tcl 8
# -----------------------------------------------------------------------
# first try --with-tcl (as defined for TEA)
AC_MSG_CHECKING([--with-tcl])
AC_ARG_WITH(tcl,
[ --with-tcl directory containing tcl configuration (tclConfig.sh)],
[with_tcl=$withval])
AC_MSG_RESULT([$with_tcl])
if test ! -z "${with_tcl}"; then
AC_MSG_CHECKING([for existence of ${with_tcl}/tclConfig.sh])
if test -f "${with_tcl}/tclConfig.sh" ; then
AC_MSG_RESULT([loading])
. ${with_tcl}/tclConfig.sh
else
AC_MSG_RESULT([file not found])
AC_MSG_ERROR([wrong --with-tcl specification])
fi
# apply eval to vars used from tclConfig.h
# (this documents and it is partly required for substituitions)
eval TCL_VERSION=${TCL_VERSION}
eval TCL_MAJOR_VERSION=${TCL_MAJOR_VERSION}
eval TCL_MINOR_VERSION=${TCL_MINOR_VERSION}
eval TCL_PREFIX=${TCL_PREFIX}
eval TCL_EXEC_PREFIX=${TCL_EXEC_PREFIX}
eval TCL_LIB_FILE=${TCL_LIB_FILE}
# TCL_LIB/INCLUDE_SPEC override TCL_LIBS/INCLUDE as defined below
eval TCL_LIB_SPEC='${TCL_LIB_SPEC}'
eval TCL_INCLUDE_SPEC='${TCL_INCLUDE_SPEC}'
# guess tclsh
TCLSH=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}
if test ! -f "${TCLSH}"; then
TCLSH=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION}
fi
else
# check for tclsh in PATH (only if no --with-tcl given)
AC_PATH_PROG(TCLSH, tclsh)
if test -z "$TCLSH"; then
AC_MSG_ERROR([Please specify --with-tcl (directory of tclConfig.sh).])
fi
AC_MSG_CHECKING([for tclsh version])
TCL_VERSION=`echo 'puts -nonewline $tcl_version' | $TCLSH`
AC_MSG_RESULT([$TCL_VERSION])
if test -z "$TCL_VERSION"; then
AC_MSG_ERROR([Require Tcl 8.1 or greater. Specify --with-tcl.])
fi
TCL_MAJOR_VERSION=`echo 'scan $tcl_version %d.%d ma mi; puts -nonewline $ma' | $TCLSH`
TCL_MINOR_VERSION=`echo 'scan $tcl_version %d.%d ma mi; puts -nonewline $mi' | $TCLSH`
# guess Tcl prefix
TCL_PREFIX=`dirname ${TCLSH}`
TCL_PREFIX=`dirname ${TCL_PREFIX}`
TCL_EXEC_PREFIX=${TCL_PREFIX}
# guess Tcl library file
TCL_LIB_FILE=`ls ${TCL_EXEC_PREFIX}/lib/libtcl${TCL_MAJOR_VERSION}*.*`
TCL_LIB_FILE=`basename "${TCL_LIB_FILE}"`
fi
if test $TCL_MAJOR_VERSION$TCL_MINOR_VERSION -lt 81; then
AC_MSG_ERROR("Require Tcl version 8.1 or greater.")
fi
# -----------------------------------------------------------------------
# Define version
# -----------------------------------------------------------------------
if test "${DEVELOPMENT_VERSION}" = yes; then
PATCHLEVEL_EXT=`echo 'puts -nonewline [[clock format [file mtime ChangeLog] -format .%y.%m.%d]]' | $TCLSH`
else
PATCHLEVEL_EXT=""
fi
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${PATCHLEVEL_BASE}${PATCHLEVEL_EXT}
ALL_DEFS="${ALL_DEFS} -DVERSION=\\\"${VERSION}\\\""
AC_SUBST(VERSION)
# -----------------------------------------------------------------------
# Compiler and flags
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-symbols])
AC_ARG_ENABLE(symbols,
[ --enable-symbols enable symbols for debugging],
[hqp_symbols=$enableval], [hqp_symbols=no])
AC_MSG_RESULT($hqp_symbols)
AC_PROG_CC
AC_PROG_CXX
if test "$CC" = "gcc -mno-cygwin"; then
CXX="$CXX -mno-cygwin"
fi
WFLAG="-W"
CFLAGS="-O2"
CXXFLAGS="-O2 -std=c++11"
if test "$hqp_symbols" = yes; then
CFLAGS="-g -DDEBUG"
CXXFLAGS="-g -std=c++11 -DDEBUG"
fi
if test "$CC" = cl; then
CC="cl -nologo"
fi
if test "$CC" = "cl -nologo"; then
WFLAG="-W2"
if test "$hqp_symbols" = yes; then
CFLAGS="-ZI -DDEBUG"
CXXFLAGS="-ZI -DDEBUG"
fi
CXX=$CC
# note: -TP to enable C++
# -EHsc to enable exception handling for Std C++ lib, e.g. iostream
CXXFLAGS="-TP -EHsc $CXXFLAGS"
fi
AC_SUBST(WFLAG)
AC_MSG_CHECKING([for u_int used by Meschach])
AC_LANG([C])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]], [[
u_int ui;
]])],[have_u_int=yes],[have_u_int=no])
AC_MSG_RESULT(${have_u_int})
if test $have_u_int = yes; then
U_INT_DEF="-DU_INT_DEF=1"
else
U_INT_DEF=""
fi
AC_SUBST(U_INT_DEF)
if test "$GXX" = yes; then
AC_MSG_CHECKING([for g++ compiler bug])
AC_LANG([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
class A { void realloc() {} void mymethod() { realloc(); } };
]])],[gcc_bug=no],[gcc_bug=yes])
AC_MSG_RESULT(${gcc_bug})
if test $gcc_bug = yes; then
AC_MSG_ERROR("Your $CXX is buggy -- please install a newer version.")
fi
fi
# -----------------------------------------------------------------------
# Check for includes
# -----------------------------------------------------------------------
#AC_CHECK_HEADERS(ieeefp.h)
# -----------------------------------------------------------------------
# Linker, machine specific settings
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--disable-shared])
AC_ARG_ENABLE(shared,
[ --disable-shared disable dynamic loading of HQP/Omuses],
[hqp_shared=$enableval], [hqp_shared=yes])
if test "$hqp_shared" = yes; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
# linking a library might require to resolve all symbols (default: no)
hqp_libs_resolved="no"
# default configuration
PICFLAG="-fPIC"
OBJ_SUFFIX=".o"
LIB_PREFIX="lib"
SHLIB_SUFFIX=".so"
LIB_SUFFIX="$SHLIB_SUFFIX"
LDLIB_PREFIX="-l"
LDLIB_SUFFIX=""
EXE_SUFFIX=""
SHLD="$CXX -shared -o "
LD="$SHLD"
LDFLAGS_START=""
LFLAG="-L"
RFLAG="-Wl,-rpath,"
# Suffix used for making a library
# (will be set to LIB_SUFFIX if not specified differently)
MKLIB_SUFFIX=""
# default Tcl libraries
if test ! -z "$TCL_LIB_SPEC"; then
# take from tclConfig.sh
TCL_LIBS=$TCL_LIB_SPEC
else
TCL_LIBS="${LDLIB_PREFIX}tcl${TCL_VERSION}${LDLIB_SUFFIX}"
fi
TCL_STUB_LIB="${LDLIB_PREFIX}tclstub${TCL_VERSION}${LDLIB_SUFFIX}"
# default OpenMP flags
OMP_CFLAG="-fopenmp"
OMP_LFLAG="-fopenmp"
# default PARDISO settings
PARDISO_DEFS=""
PARDISO_MACH_OBJS=""
AC_CHECK_PROG([uname_found],[uname],[yes],[no])
if test $uname_found = "yes" ; then
if test "$CC" != "cl -nologo"; then
target=`uname -s`
else
target="CL"
fi
case "$target" in
Linux*)
if test "$hqp_shared" = "yes"; then
hqp_libs_resolved="yes"
# guess Tcl libs if no tclConfig.sh available
if test -z "$TCL_LIB_SPEC"; then
AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
if test $have_dl = "yes"; then
TCL_LIBS="$TCL_LIBS -ldl"
else
AC_CHECK_HEADER(dld.h, [
LD="ld -shared -o "
TCL_LIBS="$TCL_LIBS -ldld"])
fi
fi
SHLD="$LD"
else
PICFLAG=""
LD="ar -cr "
LIB_SUFFIX=".a"
ALL_DEFS="${ALL_DEFS} -DIF_CLASS_STATIC=1"
RFLAG="-L"
AC_PROG_RANLIB
fi
PARDISO_DEFS="$OMP_CFLAG"
PARDISO_MACH_OBJS="$OMP_LFLAG -Wl,--no-undefined -Wl,--start-group /opt/intel/compilers_and_libraries/linux/mkl/lib/intel64_lin/libmkl_gnu_thread.a /opt/intel/compilers_and_libraries/linux/mkl/lib/intel64_lin/libmkl_core.a -Wl,--end-group -ldl"
;;
SunOS*)
RFLAG="-R"
;;
OSF1*)
LD="$CC -shared -Wl,-expect_unresolved,\"*\" -o "
SHLD="$LD"
MES_CC="cc"
MES_CFLAGS="-O"
# no automatic concatenation of multiple rflags
RFLAG="-Wl,-rpath,../lib:"
;;
IRIX*)
MES_CC="cc"
MES_CFLAGS="-O -KPIC"
;;
HP-UX*)
PICFLAG=""
LD="ar -cr "
LIB_SUFFIX=".a"
ALL_DEFS="${ALL_DEFS} -DIF_CLASS_STATIC=1"
RFLAG="-Wl,+b,"
AC_PROG_RANLIB
;;
Darwin*)
if test "$hqp_shared" = "yes"; then
hqp_libs_resolved="yes"
# configure RANLIB to call install_name_tool
RANLIB="../install_name"
fi
;;
CYGWIN*|MSYS*|MINGW*)
PICFLAG=""
if test "$hqp_shared" = "yes"; then
hqp_libs_resolved="bake-in"
LIB_PREFIX=""
LIB_SUFFIX=".dll"
else
LD="ar -cr "
LIB_SUFFIX=".a"
ALL_DEFS="${ALL_DEFS} -DIF_CLASS_STATIC=1"
RFLAG="-L"
AC_PROG_RANLIB
fi
SHLIB_SUFFIX=".dll"
EXE_SUFFIX=".exe"
;;
CL)
# note: -nodefaultlib:msvcrt is required when using Tcl stubs
SHLD="link -dll -nologo -nodefaultlib:msvcrt"
if test "$hqp_shared" = "yes"; then
hqp_libs_resolved="bake-in"
MKLIB_SUFFIX=".dll"
LD="$SHLD"
LIB_SUFFIX=".dll"
MES_DEFS="$MES_DEFS -DMESCH_API=__declspec\(dllexport\)"
IF_DEFS="$IF_DEFS -DIF_API=__declspec\(dllexport\)"
HQP_DEFS="$HQP_DEFS -DHQP_API=__declspec\(dllexport\)"
OMU_DEFS="$OMU_DEFS -DOMU_API=__declspec\(dllexport\)"
ODC_DEFS="$ODC_DEFS -DMESCH_API=__declspec\(dllimport\)"
ODC_DEFS="$ODC_DEFS -DIF_API=__declspec\(dllimport\)"
ODC_DEFS="$ODC_DEFS -DHQP_API=__declspec\(dllimport\)"
ODC_DEFS="$ODC_DEFS -DOMU_API=__declspec\(dllimport\)"
else
LD="link -lib -nologo -nodefaultlib:msvcrt"
LIB_SUFFIX=".lib"
fi
ALL_DEFS="${ALL_DEFS} -DIF_CLASS_STATIC=1"
LDFLAGS_START="-link -nodefaultlib:msvcrt"
OBJ_SUFFIX=".obj"
LIB_PREFIX=""
SHLIB_SUFFIX=".dll"
LDLIB_PREFIX=""
LDLIB_SUFFIX=".lib"
EXE_SUFFIX=".exe"
PICFLAG=""
LFLAG="-LIBPATH:"
RFLAG="-LIBPATH:"
if test "$hqp_symbols" = "yes"; then
LD="$LD -debug"
LDFLAGS_START="$LDFLAGS_START -debug"
fi
SHLD="$SHLD -out:"
LD="$LD -out:"
OMP_CFLAG="-openmp"
OMP_LFLAG=""
PARDISO_DEFS="$OMP_CFLAG -DPARDISO_API=__declspec\(dllexport\)"
PARDISO_MACH_OBJS="-LIBPATH:\"c:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/lib/ia32_win\" mkl_intel_thread.lib mkl_core.lib -LIBPATH:\"c:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/compiler/lib/ia32_win\" libiomp5md.lib"
;;
esac
fi
ALL_DEFS="${ALL_DEFS} -DSHLIB_SUFFIX=\\\"${SHLIB_SUFFIX}\\\""
AC_SUBST(PARDISO_DEFS)
AC_SUBST(PARDISO_MACH_OBJS)
case "$target" in
CYGWIN*|MSYS*|MINGW*|CL)
# Don't use TCL_LIB_SPEC under Windows, as different compilers
# require different syntax, like -ltcl or tcl.lib.
# Furthermore, take "." out of TCL_VERSION in case of no tclConfig.sh
TCL_VERSION="${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}"
TCL_LIBS="${LDLIB_PREFIX}tcl${TCL_VERSION}${LDLIB_SUFFIX}"
TCL_STUB_LIB="${LDLIB_PREFIX}tclstub${TCL_VERSION}${LDLIB_SUFFIX}"
;;
esac
CFLAGS="$CFLAGS $PICFLAG"
CXXFLAGS="$CXXFLAGS $PICFLAG"
if test -z "$MKLIB_SUFFIX"; then
MKLIB_SUFFIX="$LIB_SUFFIX"
fi
if test -z "$RANLIB"; then
RANLIB=":"
fi
if test -z "$MES_CC"; then
MES_CC="$CC"
MES_CFLAGS="$CFLAGS"
fi
AC_SUBST(OBJ_SUFFIX)
AC_SUBST(LIB_PREFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(MKLIB_SUFFIX)
AC_SUBST(LDLIB_PREFIX)
AC_SUBST(LDLIB_SUFFIX)
AC_SUBST(EXE_SUFFIX)
AC_SUBST(LD)
AC_SUBST(SHLD)
AC_SUBST(LDFLAGS_START)
AC_SUBST(LFLAG)
AC_SUBST(RFLAG)
AC_SUBST(TCL_LIBS)
AC_SUBST(TCL_STUB_LIB)
AC_SUBST(RANLIB)
AC_SUBST(MES_CC)
AC_SUBST(MES_CFLAGS)
# HQP/Omuses libs as required for a stand-alone application
HQP_LIBS="${LDLIB_PREFIX}hqp${LDLIB_SUFFIX}"
OMU_LIBS="${LDLIB_PREFIX}omu${LDLIB_SUFFIX}"
# add Hqp to Omuses machine objects or to libs required for using Omuses
if test "$hqp_libs_resolved" = "bake-in"; then
# directly link Hqp objects into an Omuses DLL
OMU_MACH_OBJS="../hqp/*\$O ../iftcl/*\$O ../meschach/*\$O"
else
OMU_LIBS="${OMU_LIBS} ${LDLIB_PREFIX}hqp${LDLIB_SUFFIX}"
if test "$hqp_libs_resolved" = "yes"; then
# in this mode we need -lhqp both for linking and running
OMU_MACH_OBJS="\$(HQP_LIBDIR) ${LDLIB_PREFIX}hqp${LDLIB_SUFFIX}"
fi
fi
AC_SUBST(HQP_LIBS)
AC_SUBST(OMU_LIBS)
# -----------------------------------------------------------------------
# Check for existence of install programs
# -----------------------------------------------------------------------
AC_PROG_INSTALL
# -----------------------------------------------------------------------
# OpenMP
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-omp])
AC_ARG_ENABLE(omp,
[ --enable-omp enable OpenMP],
[hqp_omp=$enableval], [hqp_omp=no])
AC_MSG_RESULT($hqp_omp)
if test "$hqp_omp" = yes; then
MES_DEFS="$MES_DEFS $OMP_CFLAG"
IF_DEFS="$IF_DEFS $OMP_CFLAG"
HQP_DEFS="$HQP_DEFS -DHQP_WITH_OMP $OMP_CFLAG"
HQP_MACH_OBJS="$HQP_MACH_OBJS $OMP_LFLAG"
OMU_DEFS="$OMU_DEFS -DHQP_WITH_OMP $OMP_CFLAG"
OMU_MACH_OBJS="$OMU_MACH_OBJS $OMP_LFLAG"
fi
# -----------------------------------------------------------------------
# Configure support for MEX
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-mex])
AC_ARG_ENABLE(mex,
[ --enable-mex include MEX S-function interface with Omuses],
[omu_mex=$enableval], [omu_mex=no])
AC_MSG_RESULT($omu_mex)
MEX_SRCS=""
MEX_INCDIR1=""
MEX_INCDIR2=""
MEX_LIBDIR="."
MEX_RLIBDIR="."
MEX_LIBS=""
if test "$omu_mex" != no; then
AC_MSG_CHECKING([--with-matlab])
AC_ARG_WITH(matlab,
[ --with-matlab directory containing Matlab installation],
[with_matlab=$withval])
AC_MSG_RESULT([$with_matlab])
AC_MSG_CHECKING([--with-matlab-libs])
AC_ARG_WITH(matlab-libs,
[ --with-matlab-libs directory containing Matlab run-time libraries],
[with_matlab_libs=$withval])
AC_MSG_RESULT([$with_matlab_libs])
# try to find Matlab automatically if nothing else was specified
# (assuming a path like: $with_matlab/bin/<platform>/matlab
# or $with_matlab/bin/matlab)
if test -z "${with_matlab}"; then
AC_PATH_PROG(MATLAB, matlab)
# follow a possible link to the actual executable
MATLAB=`echo "if {[[catch {file readlink \"$MATLAB\"} result]]} {puts \"$MATLAB\"} {puts [[set result]]}" | $TCLSH`
with_matlab=`dirname "${MATLAB}"`
with_matlab=`dirname "${with_matlab}"`
# need to go one more directory up of <platform> dir was there
if test `basename "$with_matlab"` = "bin"; then
with_matlab=`dirname "${with_matlab}"`
fi
AC_MSG_RESULT([guessing --with-matlab... $with_matlab])
fi
if test -z "${with_matlab}"; then
AC_MSG_ERROR([can't find Matlab, specify --with-matlab])
else
MEX_SRCS="Hxi_MEX_SFunction.C"
MEX_INCDIR1="$with_matlab"
MEX_INCDIR2="$with_matlab/extern/include"
MEX_LIBS="-lmx"
MEX_SCRIPT="$with_matlab/bin/mex"
MEX_EXTENSION=""
case "$target" in
Linux*)
MEX_LIBDIR="$with_matlab/extern/lib/glnx86"
MEX_RLIBDIR="$with_matlab/bin/glnx86"
MEX_EXTENSION=".mexglx"
;;
SunOS*)
MEX_LIBDIR="$with_matlab/extern/lib/sol2"
MEX_RLIBDIR="$with_matlab/bin/sol2"
MEX_EXTENSION=".mexsol"
;;
OSF1*)
MEX_LIBDIR="$with_matlab/extern/lib/alpha"
MEX_RLIBDIR="$with_matlab/bin/alpha"
MEX_EXTENSION=".mexaxp"
;;
IRIX*)
MEX_LIBDIR="$with_matlab/extern/lib/sgi"
MEX_RLIBDIR="$with_matlab/bin/sgi"
MEX_EXTENSION=".mexsg"
;;
HP-UX*)
MEX_LIBDIR="$with_matlab/extern/lib/hpux"
MEX_RLIBDIR="$with_matlab/bin/hpux"
MEX_EXTENSION=".mexhpux"
;;
CYGWIN*|MSYS*|MINGW*)
MEX_LIBDIR="$with_matlab/extern/lib/win32/microsoft/msvc60"
MEX_RLIBDIR="$with_matlab/bin/win32"
MEX_LIBS="-llibmx"
# note: might need to generate liblibmx.a from libmx.lib
# if libmx.lib does not link (e.g. older cygwin or when making a DLL)
MEX_SCRIPT="$with_matlab/bin/win32/mex.bat"
MEX_EXTENSION=".dll"
;;
CL)
MEX_LIBDIR="$with_matlab/extern/lib/win32/microsoft/msvc60"
MEX_RLIBDIR="$with_matlab/bin/win32"
MEX_LIBS="libmx.lib"
MEX_SCRIPT="$with_matlab/bin/win32/mex.bat"
MEX_EXTENSION=".dll"
;;
esac
# overwrite MEX_LIBDIR if set explicitly
if test ! -z "${with_matlab_libs}"; then
MEX_LIBDIR="$with_matlab_libs"
else
AC_MSG_RESULT([guessing --with-matlab-libs... $MEX_LIBDIR])
fi
OMU_DEFS="${OMU_DEFS} -DHXI_WITH_MEX=1"
fi
if test -z "${MEX_LIBDIR}"; then
AC_MSG_ERROR([can't find Matlab libs, specify --with-matlab and --with-matlab-libs])
fi
# MEX_RLIBDIR is the same as MEX_LIBDIR per default
if test -z "${MEX_RLIBDIR}"; then
MEX_RLIBDIR="$MEX_LIBDIR"
fi
fi
AC_SUBST(MEX_SRCS)
AC_SUBST(MEX_INCDIR1)
AC_SUBST(MEX_INCDIR2)
AC_SUBST(MEX_LIBDIR)
AC_SUBST(MEX_RLIBDIR)
AC_SUBST(MEX_LIBS)
AC_SUBST(MEX_SCRIPT)
AC_SUBST(MEX_EXTENSION)
# add MEX libs to machine objects
if test "$hqp_libs_resolved" = "bake-in"; then
OMU_MACH_OBJS="$OMU_MACH_OBJS \$(MEX_LIBDIR) \$(MEX_LIBS)"
else
ODC_MACH_OBJS="$ODC_MACH_OBJS \$(MEX_LIBDIR) \$(MEX_LIBS)"
fi
# -----------------------------------------------------------------------
# Check for location of Tcl includes and libraries
# -----------------------------------------------------------------------
# first try --with-tclinclude (as defined for TEA)
AC_MSG_CHECKING([--with-tclinclude])
AC_ARG_WITH(tclinclude,
[ --with-tclinclude directory containing include file tcl.h],
[with_tclinclude=${withval}])
AC_MSG_RESULT([$with_tclinclude])
AC_MSG_CHECKING([for tcl.h])
if test -z "${with_tclinclude}"; then
if test ! -z "$TCL_INCLUDE_SPEC"; then
# strip prefix like -I
TCL_IS=`expr index "$TCL_INCLUDE_SPEC" "$TCL_PREFIX"`
TCL_IE=`expr length "$TCL_INCLUDE_SPEC"`
with_tclinclude=`expr substr "$TCL_INCLUDE_SPEC" "$TCL_IS" "$TCL_IE"`
else
# guess location
with_tclinclude=${TCL_PREFIX}/include
if test ! -f ${with_tclinclude}/tcl.h; then
with_tclinclude=${with_tclinclude}/tcl${TCL_VERSION}
fi
fi
fi
if test -f ${with_tclinclude}/tcl.h; then
AC_MSG_RESULT([${with_tclinclude}/tcl.h])
TCL_INCDIR="${with_tclinclude}"
AC_SUBST(TCL_INCDIR)
else
AC_MSG_RESULT([file not found])
AC_MSG_ERROR([Specify path of tcl.h via --with-tclinclude])
fi
# Tcl lib
AC_MSG_CHECKING([for Tcl lib ${TCL_LIB_FILE}])
with_tcllib=${TCL_EXEC_PREFIX}/lib
if test -f ${with_tcllib}/${TCL_LIB_FILE}; then
AC_MSG_RESULT([${with_tcllib}/${TCL_LIB_FILE}])
else
AC_MSG_RESULT([file not found])
fi
TCL_LIBDIR="$with_tcllib"
AC_SUBST(TCL_LIBDIR)
# add Tcl libs to machine objects
if test "$hqp_shared" = yes; then
HQP_MACH_OBJS="$HQP_MACH_OBJS \$(TCL_LIBDIR) \$(TCL_STUB_LIB)"
OMU_MACH_OBJS="$OMU_MACH_OBJS \$(TCL_LIBDIR) \$(TCL_STUB_LIB)"
else
TCL_LIBS="$TCL_LIBS $TCL_STUB_LIB"
fi
# compile using stubs mechanism
ALL_DEFS="${ALL_DEFS} -DUSE_TCL_STUBS=1"
# only use new const's by Tcl 8.4 that are backwards compatible to Tcl 8.1
IF_DEFS="-DUSE_COMPAT_CONST=1 $IF_DEFS"
# -----------------------------------------------------------------------
# Configure ADOL-C
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-adolc])
AC_ARG_ENABLE(adolc,
[ --enable-adolc enable ADOL-C for automatic differentiation],
[omu_adolc=$enableval], [omu_adolc=no])
AC_MSG_RESULT($omu_adolc)
ASRCS=""
ADOLCDEF=""
ADOL_INCDIR="."
ADOL_LIBDIR="."
if test "$omu_adolc" != no; then
AC_MSG_CHECKING([--with-adolc])
AC_ARG_WITH(adolc,
[ --with-adolc directory containing ADOL-C installation],
[with_adolc=$withval])
AC_MSG_RESULT([$with_adolc])
# try to find ADOL-C automatically if nothing else was specified
if test -z "${with_adolc}"; then
with_adolc="/usr"
AC_MSG_RESULT([guessing --with-adolc... $with_adolc])
fi
if test -f ${with_adolc}/include/adolc/adolc.h; then
AC_MSG_RESULT([${with_adolc}/include/adolc/adolc.h])
ASRCS="\$(ASRCS)"
ADOLCDEF="-DOMU_WITH_ADOLC=1"
ADOL_INCDIR="$with_adolc/include"
if test -d ${with_adolc}/lib64; then
ADOL_LIBDIR="$with_adolc/lib64"
else
ADOL_LIBDIR="$with_adolc/lib"
fi
else
AC_MSG_RESULT([file not found])
AC_MSG_ERROR([Specify path of ADOL-C via --with-adolc])
fi
HQP_DEFS="$HQP_DEFS $ADOLCDEF"
OMU_DEFS="$OMU_DEFS $ADOLCDEF"
ODC_DEFS="$ODC_DEFS $ADOLCDEF"
OMU_MACH_OBJS="$OMU_MACH_OBJS \$(ADOL_LIBDIR) ${LDLIB_PREFIX}adolc${LDLIB_SUFFIX}"
ODC_MACH_OBJS="$ODC_MACH_OBJS \$(ADOL_LIBDIR) ${LDLIB_PREFIX}adolc${LDLIB_SUFFIX}"
else
ASRCS=""
ADOLCDEF=""
fi
AC_SUBST(ADOL_INCDIR)
AC_SUBST(ADOL_LIBDIR)
AC_SUBST(ASRCS)
# -----------------------------------------------------------------------
# Configure DASPK and RKsuite if enabled
# -----------------------------------------------------------------------
# defaults to disable Fortran
FORTRAN_COMP=""
FORTRAN_FLAGS=""
FORTRAN_LIBS=""
# defaults to disable DASPK
OMU_INTDASPK_C=""
DASPK=""
DASPK_OBJS=""
# defaults to disable RKsuite
OMU_INTRKSUITE_C=""
RKSUITE_O=""
RKSUITE_COMPILE_CMD=""
AC_MSG_CHECKING([--enable-fortran])
AC_ARG_ENABLE(fortran,
[ --enable-fortran include DASPK and RKsuite with Omuses],
[omu_fortran=$enableval], [omu_fortran=no])
AC_MSG_RESULT($omu_fortran)
if test "$omu_fortran" != no; then
AC_PATH_PROG(fortran_f77, f77)
if test ! -z "$fortran_f77"; then
fortran_ftn="f77"
else
AC_PATH_PROG(fortran_g77, g77)
if test ! -z "$fortran_g77"; then
fortran_ftn="g77"
else
AC_PATH_PROG(fortran_gfortran, gfortran)
if test ! -z "$fortran_gfortran"; then
fortran_ftn="gfortran"
else
AC_MSG_ERROR("Require f77, g77, or gfortran to enable RKsuite.")
fi
fi
fi
if test "$CC" = "gcc -mno-cygwin"; then
fortran_ftn="$fortran_ftn -mno-cygwin"
fi
# default settings to enable Fortran
# (MES_CFLAGS are assumed to be valid for machine Fortran)
OMU_DEFS="$OMU_DEFS -DOMU_WITH_FORTRAN=1"
FORTRAN_COMP="${fortran_ftn}"
FORTRAN_FLAGS="${MES_CFLAGS} -std=legacy"
# default settings for DASPK
if test -f daspk/ddaspk30.tar.gz; then
OMU_INTDASPK_C="Omu_IntDASPK.C"
DASPK="daspk"
DASPK_OBJS="../daspk/solver/*.o ../daspk/preconds/*.o"
AC_MSG_RESULT([enabling DASPK])
fi
# default settings with RKsuite
OMU_INTRKSUITE_C="Omu_IntRKsuite.C"
RKSUITE_O="`pwd`/rksuite/rksuite.o"
AC_MSG_RESULT([enabling RKsuite])
# try to figure out Fortran environment
AC_CHECK_LIB(f2c, pow_dd, fortran_lib=f2c, fortran_lib="")
AC_CHECK_LIB(g2c, pow_dd, fortran_lib=g2c)
if test "${fortran_f77}" = "f77"; then
AC_CHECK_LIB(ftn, pow_dd, fortran_lib=ftn)
fi
AC_CHECK_LIB(gfortran, sqrt, fortran_lib=gfortran)
case "$fortran_lib" in
ftn)
FORTRAN_LIBS="-lftn"
;;
g2c)
# don't use g2c.h due to name clash with ADOL-C (symbol "address")
# AC_CHECK_HEADER(g2c.h, OMU_DEFS="$OMU_DEFS -DHAVE_G2C_H=1")
FORTRAN_LIBS="-lg2c"
;;
f2c)
# don't use f2c.h due to name clash with ADOL-C (symbol "address")
# AC_CHECK_HEADER(f2c.h, OMU_DEFS="$OMU_DEFS -DHAVE_F2C_H=1")
FORTRAN_LIBS="-lf2c"
;;
gfortran)
FORTRAN_LIBS="-lgfortran"
;;
esac
fi
AC_SUBST(FORTRAN_COMP)
AC_SUBST(FORTRAN_FLAGS)
AC_SUBST(FORTRAN_LIBS)
AC_SUBST(OMU_INTDASPK_C)
AC_SUBST(DASPK)
AC_SUBST(DASPK_OBJS)
AC_SUBST(OMU_INTRKSUITE_C)
AC_SUBST(RKSUITE_O)
# add Fortran libs to machine objects
if test "$hqp_libs_resolved" = "bake-in"; then
OMU_MACH_OBJS="$OMU_MACH_OBJS \$(FORTRAN_LIBS)"
else
OMU_MACH_OBJS="$OMU_MACH_OBJS \$(FORTRAN_LIBS)"
ODC_MACH_OBJS="$ODC_MACH_OBJS \$(FORTRAN_LIBS)"
fi
# -----------------------------------------------------------------------
# Configure GNU malloc if enabled or if system malloc is buggy
# -----------------------------------------------------------------------
# defaults to disable GNU malloc
GMALLOC_O=""
AC_MSG_CHECKING([--enable-gmalloc])
AC_ARG_ENABLE(gmalloc,
[ --enable-gmalloc link ODC with GNU malloc],
[odc_gmalloc=$enableval], [odc_gmalloc=no])
AC_MSG_RESULT($odc_gmalloc)
if test "$odc_gmalloc" = no; then
AC_MSG_CHECKING([if malloc returns NULL])
AC_LANG([C])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
int main()
{
if (malloc(0) == NULL)
return 1;
return 0;
}
]])],[odc_gmalloc=no],[odc_gmalloc=yes],[odc_gmalloc=yes])
AC_MSG_RESULT($odc_gmalloc)
fi
if test "$odc_gmalloc" != no; then
GMALLOC_O="`pwd`/malloc/gmalloc.o"
fi
if test "$GMALLOC_O" != ""; then
AC_MSG_RESULT([enabling GNU malloc])
fi
AC_SUBST(GMALLOC_O)
# -----------------------------------------------------------------------
# Configure support for lp_solve
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-lpsolve])
AC_ARG_ENABLE(lpsolve,
[ --enable-lpsolve include mixed integer solver lp_solve with HQP],
[hqp_lpsolve=$enableval], [hqp_lpsolve=no])
AC_MSG_RESULT($hqp_lpsolve)
if test "$hqp_lpsolve" != no; then
LPSOLVE_SRCS="Hqp_LPSolve.C"
HQP_DEFS="$HQP_DEFS -DHQP_WITH_LPSOLVE=1"
if test "$target" = CL; then
# place into directory hqp/lp_solve_5.5 besides hqp/hqp and hqp/omu
LPSOLVE_INCDIR="-I../lp_solve_5.5"
HQP_MACH_OBJS="$HQP_MACH_OBJS -LIBPATH:../lp_solve_5.5 lpsolve55.lib"
OMU_MACH_OBJS="$OMU_MACH_OBJS -LIBPATH:../lp_solve_5.5 lpsolve55.lib"
else
# install regular package
LPSOLVE_INCDIR="-I/usr/include/lpsolve"
HQP_MACH_OBJS="$HQP_MACH_OBJS -Wl,-rpath,\"/usr/lib/lp_solve\" /usr/lib/lp_solve/liblpsolve55.so"
fi
else
LPSOLVE_INCDIR=""
LPSOLVE_SRCS=""
fi
AC_SUBST(LPSOLVE_INCDIR)
AC_SUBST(LPSOLVE_SRCS)
# -----------------------------------------------------------------------
# Configure support for CUTE
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-cute])
AC_ARG_ENABLE(cute,
[ --enable-cute include CUTE interface with HQP],
[hqp_cute=$enableval], [hqp_cute=no])
AC_MSG_RESULT($hqp_cute)
if test "$hqp_cute" != no; then
CUTE_SRCS="Hqp_CUTE_stubs_.C Hqp_CUTE_dummies.C Prg_CUTE.C Prg_CUTE_ST.C Hqp_CUTE.C"
HQP_DEFS="$HQP_DEFS -DHQP_WITH_CUTE=1"
else
CUTE_SRCS=""
fi
AC_SUBST(CUTE_SRCS)
# -----------------------------------------------------------------------
# Configure support for Ascend
# -----------------------------------------------------------------------
AC_MSG_CHECKING([--enable-ascend])
AC_ARG_ENABLE(ascend,
[ --enable-ascend include preliminary Ascend4 interface with HQP],
[hqp_ascend=$enableval], [hqp_ascend=no])
AC_MSG_RESULT($hqp_ascend)
if test "$hqp_ascend" != no; then
ASCEND_INCDIR="-I../../ascend4"
ASCEND_SRCS="Hqp_ASCEND_dummies.C Prg_ASCEND.C"
HQP_DEFS="$HQP_DEFS -DHQP_WITH_ASCEND=1"
else
ASCEND_INCDIR=""
ASCEND_SRCS=""
fi
AC_SUBST(ASCEND_INCDIR)
AC_SUBST(ASCEND_SRCS)
# -----------------------------------------------------------------------
# Substitute specific settings
# -----------------------------------------------------------------------
AC_SUBST(MES_DEFS)
AC_SUBST(IF_DEFS)
AC_SUBST(HQP_DEFS)
AC_SUBST(OMU_DEFS)
AC_SUBST(ODC_DEFS)
AC_SUBST(HQP_MACH_OBJS)
AC_SUBST(HQP_DOCP_MACH_OBJS)
AC_SUBST(OMU_MACH_OBJS)
AC_SUBST(ODC_MACH_OBJS)
# -----------------------------------------------------------------------
# Configure documentation generator
# -----------------------------------------------------------------------
# use dot tool from AT&T and Lucent Bell Labs for diagrams & graphs
# if installed (see www.graphviz.org)
AC_PATH_PROG(DOT, dot)
if test ! -z "$DOT"; then
HAVE_DOT="YES"
else
HAVE_DOT="NO"
fi
AC_SUBST(HAVE_DOT)
# -----------------------------------------------------------------------
# Produce outputs
# -----------------------------------------------------------------------
AC_SUBST(ALL_DEFS)
AC_CONFIG_FILES([makedefs makedirs hqp_docp/Makefile odc/Makefile odc/mex.tcl
lib/pkgIndex.tcl doc/Doxyfile])
AC_OUTPUT