-
Notifications
You must be signed in to change notification settings - Fork 51
/
configure
executable file
·197 lines (180 loc) · 4.05 KB
/
configure
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
#!/usr/bin/env bash
#
# Copyright © 2014 Jesse 'Jeaye' Wilkerson
# See licensing in LICENSE file, or at:
# http://www.opensource.org/licenses/MIT
#
# File: configure
# Author: Jesse 'Jeaye' Wilkerson
# Re-invoke the configure script
# and keep the output at bay.
if [ "$1" != "quiet" ];
then
"$0" "quiet" "$@" > /dev/null
exit $?
fi
shift
set -o errexit
set -o nounset
# Determine system
UNAME_LINUX=0
UNAME_CYGWIN=0
UNAME_OSX=0
UNAME_FREEBSD=0
UNAME="$(uname)"
if [ "$UNAME" = "Linux" ];
then
UNAME_LINUX=1
elif [ "$UNAME" = "Darwin" ];
then
UNAME_OSX=1
elif [ "$(uname -o)" = "Cygwin" ];
then
UNAME_CYGWIN=1
elif [ "$UNAME" = "FreeBSD" ];
then
UNAME_FREEBSD=1
else
echo "Invalid uname ($UNAME): Unsuppported platform" 1>&2
exit 1
fi
log() { echo "$@" 1>&2; }
PROJECT=stdman
log "Configuring ${PROJECT}"
PROJECTDIR="${BASH_SOURCE[0]%/*}"
REAL_PROJECTDIR="$(cd "$PROJECTDIR" && pwd)"
PREFIX=/usr/local
DATAROOTDIR="$PREFIX/share"
MANDIR="$DATAROOTDIR/man"
REFERENCE=$REAL_PROJECTDIR/reference/en/cpp
TMP_MAN=$REAL_PROJECTDIR/man
THREADS=8
CXX_PLATFORM_FLAGS=
LD_PLATFORM_LIBS=
if [ "1" -eq "$UNAME_LINUX" ];
then
log "Platform: Linux"
elif [ "1" -eq "$UNAME_OSX" ];
then
log "Platform: OS X"
CXX_PLATFORM_FLAGS="-stdlib=libc++ -I /opt/local/include"
LD_PLATFORM_LIBS="-lc++"
elif [ "1" -eq "$UNAME_CYGWIN" ];
then
log "Platform: Cygwin (NOT TESTED)"
elif [ "1" -eq "$UNAME_FREEBSD" ];
then
log "Platform: FreeBSD"
CXX_PLATFORM_FLAGS="-I/usr/local/include"
LD_PLATFORM_LIBS="-L/usr/local/lib"
fi
# Parse params
for i in "$@"
do
case "$i" in
--prefix)
shift
PREFIX="$1"
DATAROOTDIR="$PREFIX/share"
MANDIR="$DATAROOTDIR/man"
shift
;;
--prefix=*)
PREFIX="${i#*=}"
DATAROOTDIR="$PREFIX/share"
MANDIR="$DATAROOTDIR/man"
shift
;;
--datarootdir)
shift
DATAROOTDIR="$1"
MANDIR="$DATAROOTDIR/man"
shift
;;
--datarootdir=*)
DATAROOTDIR="${i#*=}"
MANDIR="$DATAROOTDIR/man"
shift
;;
--mandir)
shift
MANDIR="$1"
shift
;;
--mandir=*)
MANDIR="${i#*=}"
shift
;;
--reference)
shift
REFERENCE="$1"
shift
;;
--reference=*)
REFERENCE="${i#*=}"
shift
;;
--tmp-man)
shift
TMP_MAN="$1"
shift
;;
--tmp-man=*)
TMP_MAN="${i#*=}"
shift
;;
--threads)
shift
THREADS="$1"
shift
;;
--threads=*)
THREADS="${i#*=}"
shift
;;
--help*)
log "Usage: ./configure [OPTION...]"
log
log " --help Show this help message"
log " --prefix=[/usr/local] Set installation prefix"
log " --datarootdir=[<prefix>/share] Set data root prefix"
log " --mandir=[<prefix>/share/man] Set man prefix"
log " --reference=[./reference/en/cpp] Set input prefix"
log " --tmp-man=[./man] Set temporary output prefix"
log " --threads=[8] Set number of threads to use"
log
exit 0
;;
*)
# Unknown option
;;
esac
done
# Update after params
log
log "Reference location: $REFERENCE"
log "Install prefix: $PREFIX"
log "Install data prefix: $DATAROOTDIR"
log "Install man prefix: $MANDIR"
log "Temporary man location: $TMP_MAN"
log "Generation will be on $THREADS threads"
log
# Configure the makefile
log "Populating Makefile"
rm -f $PROJECTDIR/Makefile
sed "s#%CXX_PLATFORM_FLAGS%#${CXX_PLATFORM_FLAGS}#" "$PROJECTDIR/Makefile.in" |\
sed "s#%LD_PLATFORM_LIBS%#${LD_PLATFORM_LIBS}#" |\
sed "s#%PREFIX%#${PREFIX}#" |\
sed "s#%DATAROOTDIR%#${DATAROOTDIR}#" |\
sed "s#%MANDIR%#${MANDIR}#" |\
sed "s#%REFERENCE%#${REFERENCE}#" |\
sed "s#%TMP_MAN%#${TMP_MAN}#" |\
sed "s#%THREADS%#${THREADS}#" > "$PROJECTDIR/Makefile"
MAKE_C=
if [[ "$PROJECTDIR" != . ]];
then
MAKE_C=" -C ${PROJECTDIR/#$HOME/~}"
fi
log "Done configuring ${PROJECT}"
log
log "To install, use \`make$MAKE_C install\` with the appropriate permissions for your prefix"