forked from iSora/loginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·260 lines (222 loc) · 7.25 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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#! /bin/sh
######################################################################
# Project Configuration #
######################################################################
PKG_NAME="loginx"
PKG_VERSTR="v0.1"
MNT_NAME="Mike Sharov"
MNT_MAIL="[email protected]"
# Files that get created by this script
FILES="Config.mk config.h"
# Package options
COMPONENTS='
{
name=[with-debug]
desc=[ Compile for debugging]
seds=[s/^#\(DEBUG\)/\1/]
}';
# Header files
HEADERS="security/pam_appl.h ncurses.h"
# Libraries
LIBS="pam ncurses"
# First pair is used if nothing matches
PROGS="CC=gcc LD=ld INSTALL=install"
# Automatic vars
[ -d .git ] && PKG_VERSTR=`git describe --always`
PKG_MAJOR=`expr "$PKG_VERSTR" : 'v\([0-9]*\)\.[0-9]*'`
PKG_MINOR=`expr "$PKG_VERSTR" : 'v[0-9]*\.\([0-9]*\)'`
PKG_STRING="$PKG_NAME $PKG_VERSTR"
MNT_MAIL=`echo $MNT_MAIL|tr a-z n-za-m`
PKG_BUGREPORT="$MNT_NAME <$MNT_MAIL>"
# Miscellaneous substitutions
CUSTSUBS="s/@PKG_NAME@/$PKG_NAME/g
s/@PKG_VERSION@/"0x$PKG_MAJOR${PKG_MINOR}"/g
s/@PKG_VERSTR@/$PKG_VERSTR/g
s/@PKG_STRING@/$PKG_STRING/g
s/@PKG_UNAME@/`echo $PKG_NAME|tr a-z A-Z`/g
s/@PKG_BUGREPORT@/$PKG_BUGREPORT/g
s/@PKG_MAJOR@/$PKG_MAJOR/g
s/@PKG_MINOR@/$PKG_MINOR/g"
######################################################################
# The rest of the file is configuration code. Leave it alone. #
######################################################################
die() { rm -f config.sed; exit; }
#### Compile the configurator and generate initial config.sed ########
if [ -z "$CC" ]; then
for i in gcc clang cc; do
CC=`which $i 2>/dev/null` && break
done
fi
[ -z "$CC" ] && "No C compiler found" && die
#### Set host-dependent options ######################################
SYSNAME=`uname|tr A-Z a-z`
case "$SYSNAME" in
*solaris*| *sun*) SYSNAME="sun";;
*darwin*| *osx*) SYSNAME="mac";;
*bsd*) SYSNAME="bsd";;
*) SYSNAME="linux";;
esac
if [ "$SYSNAME" = "sun" ]; then
echo "s/-Wredundant-decls/-Wno-redundant-decls/g" >config.sed
elif [ "$SYSNAME" = "bsd" ]; then
echo 's/-Wredundant-decls/-Wno-redundant-decls/g
s/-Winline/-Wno-inline/g' >config.sed
elif [ ! "$SYSNAME" = "linux" ]; then
echo 's/-p --ignore-fail-on-non-empty//g' >config.sed
fi
if [ "$SYSNAME" = "mac" ]; then
echo 's/@SYSWARNS@/-Wno-long-double/g'
else
echo 's/ \?@SYSWARNS@//g' >>config.sed
fi
#### Printing helper functions #######################################
PrintComponents() {
local cc name desc
cc=$COMPONENTS
echo "Options:"
while [ ! -z "$cc" ]; do
name=`expr "$cc" : '[^}]*name=\[\([^]]*\)\]'`
desc=`expr "$cc" : '[^}]*desc=\[\([^]]*\)\]'`
echo " --$name $desc"
cc=`expr "$cc" : '[^}]*}\(.*\)'`
done
echo
}
PrintHelp() {
echo "This program configures $PKG_STRING
Usage: configure [OPTION]...
Configuration:
-h, --help display this help
-V, --version display version
Installation directories:
--prefix=PREFIX installation root [/usr/local]
--bindir=DIR programs [PREFIX/bin]
--sbindir=DIR admin programs [PREFIX/sbin]
--datadir=DIR data [PREFIX/share]
--sysconfdir=DIR configuration [PREFIX/etc]
--localstatedir=DIR modifiable data [PREFIX/var]
--includedir=DIR header files [PREFIX/include]
--libdir=DIR libraries [PREFIX/lib]
--infodir=DIR info docs [PREFIX/info]
--mandir=DIR man pages [PREFIX/man]
--builddir=DIR location for compiled objects [/tmp/$USER/make]
"
PrintComponents
echo "Report bugs to $PKG_BUGREPORT."
}
PrintVersion() {
echo "$PKG_NAME configure $PKG_VERSTR"
}
SubVar() {
local esc2
esc2=`echo $2 | sed 's/\//\\\&/g'`
eval ac_var_$1='$esc2';
echo "s/@$1@/$esc2/g" >>config.sed
}
SubComp() {
local cc name seds
cc=$COMPONENTS
while [ ! -z "$cc" ]; do
name=`expr "$cc" : '[^}]*name=\[\([^]]*\)\]'`
seds=`expr "$cc" : '[^}]*seds=\[\([^]]*\)\]'`
[ "$name" = "$1" ] && echo $seds >>config.sed
cc=`expr "$cc" : '[^}]*}\(.*\)'`
done
}
for i in $*; do
case $i in
--) break;;
--version |-V) PrintVersion && die;;
--help |-h |-?) PrintHelp && die;;
--*=*) SubVar `expr "$i" : '--\([^=]*\)='` `expr "$i" : '[^=]*=\(.*\)'`;;
--*) SubComp `expr "$i" : '--\(.*\)'`;;
*) echo "Error: unrecognized option \"$i\"" && die;;
esac
done
#### Set directory prefixes ##########################################
echo "s/@prefix@/${ac_var_prefix:=\/usr}/g
s/@bindir@/$ac_var_prefix\/bin/g
s/@sbindir@/\/sbin/g
s/@datarootdir@/${ac_var_datarootdir:=$ac_var_prefix\/share}/g
s/@datadir@/$ac_var_datarootdir/g
s/@sysconfdir@/\/etc/g
s/@localstatedir@/$ac_var_prefix\/var/g
s/@includedir@/${ac_var_includedir:=$ac_var_prefix\/include}/g
s/@docdir@/${ac_var_docdir:=$ac_var_datarootdir\/doc\/$PKG_NAME}/g
s/@infodir@/$ac_var_datarootdir\/info/g
s/@libdir@/${ac_var_libdir:=$ac_var_prefix\/lib}/g
s/@mandir@/$ac_var_datarootdir\/man/g
s/@builddir@/\/tmp\/$USER\/make/g
s/@customincdir@/${ac_var_customincdir:=$ac_var_prefix\/include}/g
s/@customlibdir@/${ac_var_customlibdir:=$ac_var_prefix\/lib}/g" >>config.sed
if [ "$ac_var_prefix" != "\/usr\/local" -a "$ac_var_prefix" != "\/usr" ]; then
echo "s/ \?@CUSTOMINCDIR@/ -I$ac_var_customincdir/g
s/ \?@CUSTOMLIBDIR@/ -L$ac_var_customlibdir/g" >>config.sed
else
echo "s/ \?@CUSTOMINCDIR@//g
s/ \?@CUSTOMLIBDIR@//g" >>config.sed
fi
#### Find headers, libs, programs, and subs ##########################
SubHeadLibsProgs() {
local INCPATH LIBPATH LIBSUFFIX found pname pcall esciv
INCPATH="$ac_var_includedir $ac_var_customincdir /usr/include /usr/include/x86_64-linux-gnu"
INCPATH=`echo $INCPATH | sed 's/\\\\//g'`
for i in $HEADERS; do
for p in $INCPATH; do
if [ -r "$p/$i" ]; then
echo 's/#undef \(HAVE_'`echo $i|tr a-z/.- A-Z___`'\)/#define \1 1/' >>config.sed
break
fi
done
done
LIBPATH="`echo $LD_LIBRARY_PATH | tr ':' ' '` $ac_var_libdir $ac_var_customlibdir /usr/lib /usr/local/lib /lib /usr/lib/x86_64-linux-gnu"
LIBPATH=`echo $LIBPATH | sed 's/\\\\//g'`
LIBSUFFIX="so a la dylib"
for i in $LIBS; do
found=
for p in $LIBPATH; do
for s in $LIBSUFFIX; do
if [ -r "$p/lib$i.$s" ]; then
found=" -l$i"
break
fi
done
[ -z "$found" ] || break
done
echo "s/ \?@lib$i@/$found/g" >>config.sed
done
for i in $PROGS; do
pname=`expr "$i" : '\([^=]*\)=[^=]*'`
pcall=`expr "$i" : '[^=]*=\([^=]*\)'`
esciv="`eval echo \$\{$pname\}|sed 's/\//\\\\\//g'`"
# First check if an environment variable is set
[ ! -z "$esciv" ] && echo "s/@$pname@/$esciv/g" >>config.sed
# Check if the program exists
[ -x `which $pcall 2>/dev/null` ] && echo "s/@$pname@/$pcall/g" >>config.sed
done
# If nothing found in first loop, set the first pair anyway.
for i in $PROGS; do
pname=`expr "$i" : '\([^=]*\)=[^=]*'`
pcall=`expr "$i" : '[^=]*=\([^=]*\)'`
echo "s/@$pname@/$pcall/g" >>config.sed
done
# And, finally, the environment variables
for i in $ENVIRONS; do
esciv="`eval echo '"'\$\{$i\}'"'|sed 's/\//\\\&/g'`"
[ ! -z "$esciv" ] && esciv=" $esciv"
echo "s/ \?@$i@/$esciv/g" >>config.sed
done
echo "$CUSTSUBS" >>config.sed
}
SubHeadLibsProgs
#### Apply substitutions to all files ################################
for i in $FILES; do
sed -f config.sed $i.in > $i
done
touch config.status
echo "#! /bin/sh
$0 $*
`tail -n+3 config.status`" > config.status.new
chmod u+x config.status.new
mv config.status.new config.status
die