1 | #!/bin/sh |
---|
2 | # |
---|
3 | # $Id: configure 1429 2004-06-07 05:58:21Z orlov $ |
---|
4 | # |
---|
5 | |
---|
6 | package=rfpc |
---|
7 | version_major=0 |
---|
8 | version_minor=0 |
---|
9 | version_micro=0 |
---|
10 | version=$version_major.$version_minor.$version_micro |
---|
11 | |
---|
12 | install_dir=/usr/local |
---|
13 | |
---|
14 | test "$CXX" && cxx="$CXX" || cxx=g++ |
---|
15 | |
---|
16 | wflags="-W -Wall" |
---|
17 | dflags="-g -DDEBUG -DPARANOIA" |
---|
18 | oflags="-O0" |
---|
19 | |
---|
20 | help () { |
---|
21 | cat <<EOF |
---|
22 | Usage: configure [options] |
---|
23 | |
---|
24 | Possible 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 |
---|
34 | EOF |
---|
35 | exit 1 |
---|
36 | } |
---|
37 | |
---|
38 | while 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 |
---|
89 | done |
---|
90 | |
---|
91 | . ./config.functions |
---|
92 | |
---|
93 | config_mk=config.mk |
---|
94 | #subdirs_mk=subdirs.mk |
---|
95 | |
---|
96 | if [ -e "$config_mk" ] ; then |
---|
97 | rm $config_mk |
---|
98 | fi |
---|
99 | |
---|
100 | |
---|
101 | case "$install_dir" in |
---|
102 | /*) ;; |
---|
103 | *) install_dir="`pwd`/$install_dir" |
---|
104 | esac |
---|
105 | while [ "$tmp_dir" != "$install_dir" ]; do |
---|
106 | tmp_dir="$install_dir" |
---|
107 | install_dir="`echo $install_dir | sed 's@/\.\?/@/@g'`" |
---|
108 | done |
---|
109 | tmp_dir="" |
---|
110 | while [ "$tmp_dir" != "$install_dir" ]; do |
---|
111 | tmp_dir="$install_dir" |
---|
112 | install_dir="`echo $install_dir | sed 's@\(.*\)/.*/\.\.\(.*\)@\1\2@'`" |
---|
113 | done |
---|
114 | |
---|
115 | |
---|
116 | echon "Checking for operating system... " |
---|
117 | os="`(uname | tr A-Z a-z) 2>/dev/null`" |
---|
118 | echo "$os" |
---|
119 | case "$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 | ;; |
---|
140 | esac |
---|
141 | |
---|
142 | |
---|
143 | echon "Checking for working C++ compiler... " |
---|
144 | cat >cfgtest.cc <<EOF |
---|
145 | class C; |
---|
146 | int main(void) { return 0; } |
---|
147 | EOF |
---|
148 | $cxx -o cfgtest cfgtest.cc >/dev/null 2>&1 |
---|
149 | ./cfgtest >/dev/null 2>&1 |
---|
150 | if [ $? != 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 |
---|
157 | fi |
---|
158 | echo $cxx |
---|
159 | rm -f cfgtest* |
---|
160 | |
---|
161 | |
---|
162 | echon "Checking for gmp library... " |
---|
163 | cat >cfgtest.cc <<EOF |
---|
164 | #include <stdio.h> |
---|
165 | #include <gmp.h> |
---|
166 | int main(void) { printf("%d\n", __GNU_MP_VERSION); } |
---|
167 | EOF |
---|
168 | $cxx $gmp_inc $gmp_lib -o cfgtest cfgtest.cc -lgmp >/dev/null 2>&1 |
---|
169 | ./cfgtest >/dev/null 2>&1 |
---|
170 | if [ $? != 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 |
---|
178 | fi |
---|
179 | echo OK |
---|
180 | rm -f cfgtest* |
---|
181 | |
---|
182 | |
---|
183 | cat >>$config_mk <<EOF |
---|
184 | TARGET = $os |
---|
185 | INSTALL_DIR = $install_dir |
---|
186 | |
---|
187 | EXE_SUFFIX = $exe_suffix |
---|
188 | |
---|
189 | CXX = $cxx |
---|
190 | CC = $cxx |
---|
191 | CPPFLAGS += $wflags |
---|
192 | CPPFLAGS += $dflags |
---|
193 | CPPFLAGS += -DALL_INLINE |
---|
194 | CFLAGS += $oflags |
---|
195 | LDLIBS += -static-libgcc |
---|
196 | |
---|
197 | RFPC = $rfpc |
---|
198 | RFLAGS += -I ${main_dir}/library/include/refal-plus |
---|
199 | |
---|
200 | CPPFALGS += $gmp_inc |
---|
201 | RFRTLIB_CFLAGS = -I${main_dir}/runtime -I${main_dir}/libp++ |
---|
202 | RFLIB_CFLAGS = -I${main_dir}/library/include |
---|
203 | |
---|
204 | LIBRF = ${main_dir}/library/librf.a |
---|
205 | LIBRFRT = ${main_dir}/runtime/librfrt.a |
---|
206 | LIBPXX = ${main_dir}/libp++/libp++.a |
---|
207 | |
---|
208 | LDFLAGS += $gmp_lib |
---|
209 | #RF_LDFLAGS += -L${main_dir}/library -L${main_dir}/runtime |
---|
210 | #RF_LDFLAGS += -L${main_dir}/libp++ |
---|
211 | #RF_LDLIBS += -lrf -lrfrt -lp++ -lsupc++ -lgmp |
---|
212 | LDLIBS += -lsupc++ -lgmp |
---|
213 | EOF |
---|
214 | |
---|