-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·161 lines (144 loc) · 3.15 KB
/
configure
File metadata and controls
executable file
·161 lines (144 loc) · 3.15 KB
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
#!/bin/sh
# This configure script written by Brian Callahan <bcallah@openbsd.org>
# and released into the Public Domain.
Makefile() {
cat << EOF > Makefile
# This Makefile automatically generated by configure.
BINDIR = $bindir
MANDIR = $mandir
DMD = $dmd
DFLAGS = $dflags
PROG = repology
all:
\${DMD} \${DFLAGS} $oflag \${PROG}.d
install:
install -c -s -m 755 \${PROG} \${DESTDIR}\${BINDIR}
install -c -m 444 \${PROG}.1 \${DESTDIR}\${MANDIR}/man1
uninstall:
rm -f \${BINDIR}/\${PROG} \${MANDIR}/man1/\${PROG}.1
test:
@echo No tests.
clean:
rm -f \${PROG} \${PROG}.o \${PROG}.core
distclean: clean
rm -f Makefile
EOF
}
dmdcheck() {
for compiler in "$DMD" ldc2 gdc dmd ; do
cat << EOF > conftest.d
void main(){}
EOF
($compiler --version | grep -q "LDC - the LLVM D compiler") > /dev/null 2>&1
if [ $? -eq 0 ] ; then
is="ldc"
else
($compiler --version | grep -q "Free Software Foundation") > /dev/null 2>&1
if [ $? -eq 0 ] ; then
is="gdc"
else
is="dmd"
fi
fi
if [ $specifieddflags -eq 0 ] ; then
case "$is" in
"dmd")
dflags="-O -inline"
;;
"gdc")
dflags="-O2 -pipe -finline"
oflag="-o repology"
;;
"ldc")
dflags="-O"
;;
esac
fi
if [ "x$is" = "xgdc" ] ; then
$compiler $dflags -o conftest conftest.d > /dev/null 2>&1
else
$compiler $dflags conftest.d > /dev/null 2>&1
fi
if [ $? -eq 0 ] ; then
rm -f conftest conftest.o conftest.d
dmd="$compiler"
return 0
else
rm -f conftest conftest.o conftest.d
fi
done
return 1
}
# Option variables
if [ ! -z "$PREFIX" ] ; then
prefix="$PREFIX"
else
prefix="/usr/local"
fi
bindirset=0
mandirset=0
specifieddflags=0
bindir="$prefix/bin"
mandir="$prefix/share/man"
# Options
for opt
do
case "$opt" in
--prefix=*)
prefix=${opt#*=}
if [ $bindirset -eq 0 ] ; then
bindir="$prefix/bin"
fi
if [ $mandirset -eq 0 ] ; then
mandir="$prefix/share/man"
fi
;;
--bindir=*)
bindir=${opt#*=}
bindirset=1
;;
--mandir=*)
mandir=${opt#*=}
mandirset=1
;;
--dmd=*)
DMD=${opt#*=}
;;
--dflags=*)
dflags=${opt#*=}
specifieddflags=1
;;
--help|-h)
echo "Usage: configure [options]"
echo ""
echo "Options:"
printf " --help or -h "
echo "Display this help message"
printf " --prefix=PREFIX "
echo "Top level install directory is PREFIX [$prefix]"
printf " --bindir=BINDIR "
echo "Install executable to BINDIR [$bindir]"
printf " --mandir=MANDIR "
echo "Install manual pages to MANDIR [$mandir]"
printf " --dmd=DMD "
echo "Use specified D compiler [default=autodetect]"
printf " --dflags=DFLAGS "
echo "Use specified DFLAGS [default=autodetect]"
exit 1
;;
*)
;;
esac
done
printf "checking for D compiler... "
dmdcheck
if [ $? -ne 0 ] ; then
echo "not found"
echo "error: Please install a D compiler and re-run configure"
exit 1
else
echo "$dmd"
fi
printf "creating Makefile... "
Makefile
echo "done"