1 | #!/bin/sh |
---|
2 | |
---|
3 | set -e |
---|
4 | |
---|
5 | # Script to compile the Ampl Solver Library using cl/link. 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.vc, 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 | rm -rf $compdir |
---|
20 | $mkinstalldirs $compdir |
---|
21 | files=`cd $abs_source_dir/solvers; ls *.[chs] *.[ch]0 *.hd arith.* makefile* *.bat amplsolv.lbc` |
---|
22 | cd $compdir |
---|
23 | for file in $files |
---|
24 | do |
---|
25 | cp $abs_source_dir/solvers/$file $file;\ |
---|
26 | done |
---|
27 | |
---|
28 | # Acquire the cl version and create details.c |
---|
29 | # (This is not doing to right thing if we are using the Microsoft compiler) |
---|
30 | |
---|
31 | clver=`cl 2>&1 | egrep '^Microsoft' | sed -e 's/.*Version \(.*\)/\1/'` |
---|
32 | clver="Microsoft cl $clver" |
---|
33 | |
---|
34 | sed -e "s/System_details/$clver/" details.c0 > details.c |
---|
35 | |
---|
36 | # Adjust solvers/makefile.vc for the situation at hand. When building with cl |
---|
37 | # under cygwin, we can't execute comptry.bat. The sole purpose of comptry.bat |
---|
38 | # is to retry the compile with -DNO_LONG_LONG in an environment where long long |
---|
39 | # does not exist. Since we've already tested for long long in configure and set |
---|
40 | # ASLMAKEFLAGS accordingly, we can discard comptry.bat without worry. |
---|
41 | |
---|
42 | sed -e 's/comptry\.bat \$(CC)/$(CC)/' makefile.vc > makefile.coin |
---|
43 | |
---|
44 | # Do the build. CFLAGS specified on the command line (as a result of autoconf |
---|
45 | # replacing ASLMAKEFLAGS) will override the specs in makefile.vc, ensuring that |
---|
46 | # ASL is built with the same compiler flags as other code. Makefile.vc also |
---|
47 | # forces CC=cl, but since Coin only uses makefile.vc for the cl compiler, |
---|
48 | # there's no need to override it here. |
---|
49 | |
---|
50 | # It turns out that Gnu make always sets MAKEFLAGS to --unix, and nmake tries |
---|
51 | # to process this, resulting in error U1065. Clear MAKEFLAGS to fix the |
---|
52 | # problem. |
---|
53 | |
---|
54 | libampl=@AMPLSOLVER_A@ |
---|
55 | MAKEFLAGS= |
---|
56 | nmake -f makefile.coin @ASLMAKEFLAGS@ CC="@CC@" |
---|
57 | mv amplsolv.lib ../$libampl |
---|
58 | mv stdio1.h arith.h funcadd0.obj .. |
---|
59 | cd .. |
---|
60 | rm -rf $compdir |
---|