source: ThirdParty/ASL/stable/1.0/compile_Unix_ASL.in @ 907

Last change on this file since 907 was 800, checked in by andreasw, 12 years ago

synchronized ThirdParty?/ASL/stable/0.5 with trunk rev 798

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