1 | #!/bin/sh |
---|
2 | |
---|
3 | set -e |
---|
4 | |
---|
5 | # Script to compile the Ampl Solver Library on Unix systems. Why this approach? |
---|
6 | # Well, we don't want to get into the business of creating (and maintaining) |
---|
7 | # the full set of autotools source files for the ASL. This approach tries to |
---|
8 | # leverage makefile.u, which comes with ASL. |
---|
9 | |
---|
10 | # To support VPATH builds, the strategy is to copy the sources to the build |
---|
11 | # directory, build, and then erase the sources when we're done. Start by |
---|
12 | # copying the sources. |
---|
13 | |
---|
14 | # set -x |
---|
15 | mkinstalldirs="@install_sh@ -d" |
---|
16 | abs_source_dir=@abs_source_dir@ |
---|
17 | compdir=compdir |
---|
18 | |
---|
19 | # Remove the old compilation directory, if present, and create a new one. Then |
---|
20 | # copy the sources. The wildcards given to ls will produce duplicates, which |
---|
21 | # may result in a warning as the files are linked or copied. |
---|
22 | |
---|
23 | rm -rf $compdir |
---|
24 | $mkinstalldirs $compdir |
---|
25 | files=`cd $abs_source_dir/solvers ; ls *.[chs] *.[ch]0 *.hd arith.* makefile* *.bat amplsolv.lbc` |
---|
26 | |
---|
27 | cd $compdir |
---|
28 | for file in $files ; do |
---|
29 | rm -f $file |
---|
30 | @LN_S@ $abs_source_dir/solvers/$file $file |
---|
31 | done |
---|
32 | |
---|
33 | # Acquire the system details. On some systems (Cygwin, for example), this |
---|
34 | # string will contain '/' characters, so escape them properly. |
---|
35 | |
---|
36 | sys_details=`uname -sr | sed -e 's/\\//\\\\\\//g'` |
---|
37 | |
---|
38 | sed -e "/sysdetails_ASL/s/System_details/$sys_details/" details.c0 > details.c |
---|
39 | |
---|
40 | # Adjust solvers/makefile.u for the system at hand. Really all we're doing |
---|
41 | # is trying to automate the instructions in makefile.u. If you have build |
---|
42 | # problems, a good thing to do is compare the shell code here with makefile.u, |
---|
43 | # to see if it contains instructions that are not automated here. The final |
---|
44 | # result is left in makefile.coin |
---|
45 | |
---|
46 | # Allow make to decide the name of the archive program and the appropriate |
---|
47 | # flags. makefile.u hardwires `ar' and sets ARFLAGS = ruv. Since we trash the |
---|
48 | # entire build and start from scratch, the `u' in ruv stands for `useless'. |
---|
49 | |
---|
50 | sed -e 's/ ar / @AR@ /g' \ |
---|
51 | -e 's/^ARFLAGS =/# ARFLAGS =/' < makefile.u > makefile.coin |
---|
52 | |
---|
53 | # If we're in a fake unix environment on a Windows box, the default compiler |
---|
54 | # output file is a.exe, not a.out. |
---|
55 | |
---|
56 | if test "x@EXEEXT@" = "x.exe" ; then |
---|
57 | sed -e 's/a\.out/a.exe/' < makefile.coin > makefile.coin.tmp |
---|
58 | mv makefile.coin.tmp makefile.coin |
---|
59 | fi |
---|
60 | |
---|
61 | # System-specific tweaks. On Solaris x86, we need to build fpsetprec.s |
---|
62 | # (fpsetprec64.s for 64-bit builds). Add it to the dependency list for |
---|
63 | # amplsolver.a. The 64-bit question here is how to reliably recognise a 64-bit |
---|
64 | # build. For GCC, -m64 should do it. For Sun Studio, it's more difficult. |
---|
65 | # Studio 12 and later recognises -m64. Earlier versions require |
---|
66 | # -xarch=<something>, where something can be any of generic64, native64, amd64, |
---|
67 | # or amd64a (and perhaps others). So ... let's go out on a limb and hope that |
---|
68 | # -xarch=*64* will not pick up anything it shouldn't. Force leading and |
---|
69 | # trailing spaces in the string we're matching, in case the 64-bit flag is the |
---|
70 | # only content in CFLAGS. |
---|
71 | |
---|
72 | case "@build@" in |
---|
73 | *86-*-solaris*) |
---|
74 | case " @CFLAGS@ " in |
---|
75 | *" "-m64" "* | *" "-xarch=*64*" "*) |
---|
76 | sed -e 's/^amplsolver.a:/amplsolver.a: fpsetprec64.s/' \ |
---|
77 | < makefile.coin > makefile.coin.tmp |
---|
78 | ;; |
---|
79 | *) |
---|
80 | sed -e 's/^amplsolver.a:/amplsolver.a: fpsetprec.s/' \ |
---|
81 | < makefile.coin > makefile.coin.tmp |
---|
82 | ;; |
---|
83 | esac |
---|
84 | mv makefile.coin.tmp makefile.coin |
---|
85 | ;; |
---|
86 | esac |
---|
87 | |
---|
88 | # That's it, we can do the build. |
---|
89 | # A last detail: makefile.u will try to force CC=cc. We need to make sure |
---|
90 | # that we stay with our chosen compiler. It will try and force CFLAGS, too, but |
---|
91 | # configure has already put the appropriate information into ASLMAKEFLAGS. |
---|
92 | |
---|
93 | libampl=@AMPLSOLVER_A@ |
---|
94 | make -f makefile.coin @ASLMAKEFLAGS@ CC="@CC@" |
---|
95 | mv amplsolver.a ../$libampl |
---|
96 | mv stdio1.h arith.h funcadd0.@OBJEXT@ .. |
---|
97 | cd .. |
---|
98 | rm -rf $compdir |
---|
99 | |
---|