File: configure

package info (click to toggle)
xstrp4 1.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 128 kB
  • sloc: ml: 249; makefile: 119
file content (237 lines) | stat: -rwxr-xr-x 5,670 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# $Id$

#######################################################################
# Helpers:

# Split $PATH into words:
oldifs="$IFS"
IFS="   :"
spacepath=`echo $PATH`
IFS="$oldifs"


in_path () {
    # Does $1 exist in $PATH?
    for d in $spacepath; do
        if test -x "$d/$1"; then
            return 0
        fi
    done
    return 1
}


get_path () {
    for d in $spacepath; do
        if test -x "$d/$1"; then
            echo "$d/$1"
            return
        fi
    done
}

#######################################################################
# Defaults

#--- Options ---
# value 0: off
# value 1: on
# defaults:

set_defaults () {
	# enable_FOO=XXX
	# with_FOO=XXX
    :
}

ocamlc=`get_path ocamlc`
set_defaults

version="1.8.2"
exec_suffix=""

#######################################################################
# Option parsing

#ehelp_FOO="XXX"
#whelp_FOO="XXX"

# Which options exist? eoptions for enable/disable, woptions for with/without:
eoptions=""
woptions=""

# Packages to include anyway:
requires=""

print_options () {
        for opt in $eoptions; do
                e="o=\$enable_$opt"
                eval "$e"
                uopt=`echo $opt | sed -e 's/_/-/g'`
                if [ $o -gt 0 ]; then
                        echo "    -enable-$uopt"
                else
                        echo "    -disable-$uopt"
                fi
        done
        for opt in $woptions; do
                e="o=\$with_$opt"
                eval "$e"
                uopt=`echo $opt | sed -e 's/_/-/g'`
                if [ $o -gt 0 ]; then
                        echo "    -with-$uopt"
                else
                        echo "    -without-$uopt"
                fi
        done
}


usage () {
        set_defaults
        cat <<_EOF_ >&2
usage: ./configure [ options ]

_EOF_
        for opt in $eoptions; do
                e="help=\$ehelp_$opt"
                eval "$e"
                uopt=`echo $opt | sed -e 's/_/-/g'`
                echo "-enable-$uopt:" >&2
                echo "-disable-$uopt:" >&2
                echo "        $help" >&2
        done
        for opt in $woptions; do
                e="help=\$whelp_$opt"
                eval "$e"
                uopt=`echo $opt | sed -e 's/_/-/g'`
                echo "-with-$uopt:" >&2
                echo "-without-$uopt:" >&2
                echo "        $help" >&2
        done
}




while [ "$#" -gt 0 ]; do
        case "$1" in
                -enable-*)
                        opt=`echo "$1" | sed -e 's/-enable-//' -e 's/-/_/g'`
                        check_eopt "$opt"
                        eval "enable_$opt=2"
                        shift
                        ;;
                -disable-*)
                        opt=`echo "$1" | sed -e 's/-disable-//' -e 's/-/_/g'`
                        check_eopt "$opt"
                        eval "enable_$opt=-1"
                        shift
                        ;;
                -with-*)
                        opt=`echo "$1" | sed -e 's/-with-//' -e 's/-/_/g'`
                        check_wopt "$opt"
                        eval "with_$opt=2"
                        shift
                        ;;
                -without-*)
                        opt=`echo "$1" | sed -e 's/-without-//' -e 's/-/_/g'`
                        check_wopt "$opt"
                        eval "with_$opt=-1"
                        shift
                        ;;
                -version)
                        echo "$version"
                        exit 0
                        ;;
                *)
                        usage
        esac
done

echo "Welcome to Xstrp4 version $version" >&2

######################################################################
# Check ocamlfind

printf "%s" "Checking for findlib... "
if ocamlfind query stdlib >/dev/null 2>/dev/null; then
    echo "found"
else
    echo "not found"
    echo "Make sure that ocamlfind is in your PATH, or download findlib"
    echo "from www.ocaml-programming.de"
    echo "ERROR"
    exit 1
fi

######################################################################
# immutable strings

printf "%s" "Checking for -safe-string... "

string_opts=""
if ocamlc -safe-string >/dev/null 2>/dev/null; then
    echo "yes"
    string_opts="-safe-string"
else
    echo "no"
fi


######################################################################
# Check camlp4 version


printf "%s" "Checking for camlp4... "
if camlp4; then
    if camlp4 -loaded-modules >/dev/null 2>/dev/null; then
	echo "3.10 style"
	camlp4_style="310"
	camlp4_opts="-package camlp4 -syntax camlp4o -ppopt pa_extend.cmo -ppopt q_MLast.cmo"
    else
	echo "3.09 style"
	echo "This is no longer supported. Upgrade to at least O'Caml 3.10"
	echo "ERROR"
	exit 1
    fi
else
    echo "not found"
    echo "Make sure the camlp4 command is in your PATH"
    echo "ERROR"
    exit 1
fi


######################################################################
# Write Makefile.conf

echo "Writing Makefile.conf"
cat <<_EOF_ >Makefile.conf
# The Xstrp4 version:
VERSION = $version

# whether to enable -safe-string
STRING_OPTS = $string_opts

# Camlp4 style:
CAMLP4_STYLE = $camlp4_style

# Camlp4 options:
CAMLP4_OPTS = $camlp4_opts
_EOF_

######################################################################
# Finish

echo
echo "Please check Makefile.conf."
echo
echo "You can now compile Xstrp4 by invoking"
echo "   make all"
echo "for the bytecode compiler, and optionally by invoking"
echo "   make opt"
echo "for the native-code compiler (if supported on your architecture)."
echo "Finally, a"
echo "   make install"
echo "will install the package(s)."