source: to-imperative/trunk/configure @ 1445

Last change on this file since 1445 was 1434, checked in by orlov, 16 years ago
  • Improved makefiles.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1#!/bin/sh
2#
3# $Id: configure 1434 2004-06-08 06:52:15Z orlov $
4#
5
6package=rfpc
7version_major=0
8version_minor=0
9version_micro=0
10version=$version_major.$version_minor.$version_micro
11
12install_dir=/usr/local
13
14test "$CXX" && cxx="$CXX" || cxx=g++
15
16wflags="-W -Wall"
17dflags="-g -DDEBUG -DPARANOIA"
18oflags="-O0"
19
20help () {
21  cat <<EOF
22Usage: configure [options]
23
24Possible options are:
25  -prefix <dir>         install directory [$install_dir]
26  -cxx <path>           path to C++ compiler [$cxx]
27  -gmp_inc <dir>        directory containing GNU MP headers
28  -gmp_lib <dir>        directory containing GNU MP library
29  -wflags <flags>       C++ compiler warning options [$wflags]
30  -dflags <flags>       debugging options [$dflags]
31  -oflags <flags>       C++ compiler optimization options [$oflags]
32  -name                 shows package name
33  -version              shows package version
34EOF
35  exit 1
36}
37
38while true; do
39  if [ -z "$1" ]; then break; fi
40  case $1 in
41  -prefix)
42    shift
43    if [ -z "$1" ]; then help; fi
44    install_dir="$1"
45    ;;
46  -cxx)
47    shift
48    if [ -z "$1" ]; then help; fi
49    cxx="$1"
50    ;;
51  -gmp_inc)
52    shift
53    if [ -z "$1" ]; then help; fi
54    gmp_inc="-I'$1'"
55    ;;
56  -gmp_lib)
57    shift
58    if [ -z "$1" ]; then help; fi
59    gmp_lib="-L'$1'"
60    ;;
61  -wflags)
62    shift
63    if [ -z "$1" ]; then help; fi
64    wflags="$1"
65    ;;
66  -dflags)
67    shift
68    if [ -z "$1" ]; then help; fi
69    dflags="$1"
70    ;;
71  -oflags)
72    shift
73    if [ -z "$1" ]; then help; fi
74    oflags="$1"
75    ;;
76  -name)
77    echo $package
78    exit 0
79    ;;
80  -version)
81    echo $version
82    exit 0
83    ;;
84  -help|*)
85    help
86    ;;
87  esac
88  shift
89done
90
91. ./config.functions
92
93config_mk=config.mk
94#subdirs_mk=subdirs.mk
95
96if [ -e "$config_mk" ] ; then
97  rm $config_mk
98fi
99
100
101case "$install_dir" in
102  /*) ;;
103  *) install_dir="`pwd`/$install_dir"
104esac
105while [ "$tmp_dir" != "$install_dir" ]; do
106  tmp_dir="$install_dir"
107  install_dir="`echo $install_dir | sed 's@/\.\?/@/@g'`"
108done
109tmp_dir=""
110while [ "$tmp_dir" != "$install_dir" ]; do
111  tmp_dir="$install_dir"
112  install_dir="`echo $install_dir | sed 's@\(.*\)/.*/\.\.\(.*\)@\1\2@'`"
113done
114
115
116echon "Checking for operating system... "
117os="`(uname | tr A-Z a-z) 2>/dev/null`"
118echo "$os"
119case "$os" in
120  linux)
121    main_dir='$(TOPDIR)'
122    rfpc='$(TOPDIR)/bootstrap/compiler/rfpc'
123    rfp='$(TOPDIR)/rfp.sh'
124    exe_suffix=''
125    ;;
126  cygwin*)
127    os='cygwin'
128    main_dir='$(TOPDIR)/cygwin/'
129    rfpc='$(TOPDIR)/bootstrap/compiler/rfpc.exe'
130    rfp='ldflags=-Wl,--stack,0x800000 $(TOPDIR)/rfp.sh'
131    exe_suffix='.exe'
132    ;;
133  *)
134    echo "***"
135    echo "*** Fatal error - your OS is not supported yet."
136    echo "*** Please contact developers at refal-devel@botik.ru"
137    echo "***"
138    exit 1
139    ;;
140esac
141
142
143echon "Checking for working C++ compiler... "
144cat >cfgtest.cc <<EOF
145class C;
146int main(void) { return 0; }
147EOF
148$cxx -o cfgtest cfgtest.cc >/dev/null 2>&1
149./cfgtest >/dev/null 2>&1
150if [ $? != 0 ]; then
151  echo
152  echo "***"
153  echo "*** Fatal error - $cxx is not working C++ compiler."
154  echo "*** Specify other one with -cxx option."
155  echo "***"
156  exit 1
157fi
158echo $cxx
159rm -f cfgtest*
160
161
162echon "Checking for gmp library... "
163cat >cfgtest.cc <<EOF
164#include <stdio.h>
165#include <gmp.h>
166int main(void) { printf("%d\n", __GNU_MP_VERSION); }
167EOF
168$cxx $gmp_inc $gmp_lib -o cfgtest cfgtest.cc -lgmp >/dev/null 2>&1
169./cfgtest >/dev/null 2>&1
170if [ $? != 0 ]; then
171  echo
172  echo "***"
173  echo "*** Fatal error - GNU MP not found, see http://swox.com/gmp"
174  echo "*** If it has been installed to a non-standard location"
175  echo "*** then use -gmp_inc and -gmp_lib options."
176  echo "***"
177  exit 1
178fi
179echo OK
180rm -f cfgtest*
181
182
183cat >>$config_mk <<EOF
184TARGET = $os
185INSTALL_DIR = $install_dir
186
187EXE_SUFFIX = $exe_suffix
188
189CXX = $cxx
190CC  = $cxx
191CPPFLAGS += $wflags
192CPPFLAGS += $dflags
193CPPFLAGS += -DALL_INLINE
194CFLAGS += $oflags
195LDLIBS += -static-libgcc
196
197RFPC = $rfpc
198RFLAGS += -I ${main_dir}/library/include/refal-plus
199
200CPPFALGS += $gmp_inc
201RFRTLIB_CFLAGS = -I${main_dir}/runtime -I${main_dir}/libp++
202RFLIB_CFLAGS = -I${main_dir}/library/include
203
204LIBRF = ${main_dir}/library/librf.a
205LIBRFRT = ${main_dir}/runtime/librfrt.a
206LIBPXX = ${main_dir}/libp++/libp++.a
207
208LDFLAGS += $gmp_lib
209LDLIBS += -lsupc++ -lgmp
210EOF
211
212
213cat >rfp.sh <<EOF
214#!/bin/bash
215
216[ -z "\$cxx" ] && cxx="$cxx"
217[ -z "\$rfpc" ] && rfpc="$install_dir/bin/rfpc"
218
219cflags="\$cflags -I'$install_dir/include' -I'$install_dir/include/rfrt'"
220cflags="\$cflags -I'$install_dir/include/libp++' $gmp_inc"
221cflags="\$cflags $wflags $dflags -DALL_INLINE $oflags -c"
222ldflags="\$ldflags -L'$install_dir/lib' $gmp_lib"
223ldlibs="\$ldlibs -lrf -lrfrt -lp++ -lsupc++ -lgmp"
224EOF
225
226cat >>rfp.sh <rfp.in
227
Note: See TracBrowser for help on using the repository browser.