Newer
Older
#!/bin/sh
. package/info
usage () {
cat <<EOF
Usage: $0 [OPTION]... [TARGET]
Defaults for the options are specified in brackets.
Installation directories:
--prefix=PREFIX main installation prefix [/]
--exec-prefix=EPREFIX installation prefix for executable files [PREFIX]
Fine tuning of the installation directories:
--bindir=BINDIR user executables [EPREFIX/bin]
--datarootdir=DATAROOTDIR read-only architecture-independent data root [PREFIX/share]
--with-system-service=DIR 66 service intallation directory [DATAROOTDIR/$package_macro_dir/service]

Eric Vidal
committed
--with-system-seed=DIR system trees default configuration[DATAROOTDIR/$package_macro_dir/seed]
--execlinedir=DIR absolute path of execline binaries [BINDIR]
Fine tunning of boot-user configuration:
--DISPLAY_MANAGER=VALUE display manager to use []
--CONSOLE_TRACKER=VALUE console tracker to use []
--XDG_RUNTIME=BOOLEAN create and mount the XDG_RUNTIME directory [!yes]
--DESKTOP_CMDLINE=VALUE commandline to use in the .xinitrc file [!jwm]

Eric Vidal
committed
--version=VALUE version of the service[0.0.1]
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
Empty value is a commented one and not used at all.
An exclamation mark '!' at the begin of the value unexport the variable
for the environment after the use. This is avoid to poluate the environment
with tempory variables. You need to single-quote the options as
follow:
./configure --XDG_RUNTIME='!yes'
EOF
exit 0
}
# Helper functions
# If your system does not have printf, you can comment this, but it is
# generally not a good idea to use echo.
# See http://www.etalabs.net/sh_tricks.html
echo () {
IFS=" "
printf %s\\n "$*"
}
quote () {
tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; }
$1
EOF
echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g"
}
fail () {
echo "$*"
exit 1
}
fnmatch () {
eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac"
}
cmdexists () {
type "$1" >/dev/null 2>&1
}
stripdir () {
while eval "fnmatch '*/' \"\${$1}\"" ; do
eval "$1=\${$1%/}"
done
}
testval () {
if test -z ${1}; then
return 0 ;
else
return 1 ;
fi
}
# Actual script
prefix=
exec_prefix='$prefix'
bindir='$exec_prefix/bin'
datarootdir='$prefix/share'
service_directory='$datarootdir/$package_macro_dir/service'

Eric Vidal
committed
seed_directory='$datarootdir/$package_macro_dir/seed'
DISPLAY_MANAGER=
CONSOLE_TRACKER=
XDG_RUNTIME='!yes'
DESKTOP_CMDLINE='!jwm'
for arg ; do
case "$arg" in
--help) usage ;;
--prefix=*) prefix=${arg#*=} ;;
--exec-prefix=*) exec_prefix=${arg#*=} ;;
--bindir=*) bindir=${arg#*=} ;;
--datarootdir=*) datarootdir=${arg#*=} ;;
--with-system-service=*) service_directory=${arg#*=} ;;

Eric Vidal
committed
--with-system-seed=*) seed_directory=${arg#*=} ;;
--execlinedir=*) execlinedir=${arg#*=} ;;
--DISPLAY_MANAGER=*) DISPLAY_MANAGER=${arg#*=} ;;
--CONSOLE_TRACKER=*) CONSOLE_TRACKER=${arg#*=} ;;
--XDG_RUNTIME=*) XDG_RUNTIME=${arg#*=} ;;
--DESKTOP_CMDLINE=*) DESKTOP_CMDLINE=${arg#*=} ;;

Eric Vidal
committed
--version=*) version=${arg#*=} ;;
-* ) echo "$0: unknown option $arg" ;;
*=*) ;;
*) target=$arg ;;
esac
done
# Add /usr in the default case
if test -z "$prefix" ; then
if test "$datarootdir" = '$prefix/share'; then
datarootdir=/usr/share
fi
fi
# Expand installation directories
stripdir prefix
for i in exec_prefix bindir datarootdir \
seed_directory service_directory execlinedir; do
eval tmp=\${$i}
eval $i=$tmp
stripdir $i
done
stripdir datarootdir

Eric Vidal
committed
for i in service_directory seed_directory; do
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
eval tmp=\${$i}
eval $i=$tmp
stripdir $i
done
for i in DISPLAY_MANAGER CONSOLE_TRACKER XDG_RUNTIME DESKTOP_CMDLINE; do
eval tmp=\${$i}
if testval $tmp; then
if [ "${i}" = "DISPLAY_MANAGER" ]; then
eval $i='${i}=\"\\#${i}=sddm\"'
elif [ "${i}" = "CONSOLE_TRACKER" ]; then
eval $i='${i}=\"\\#${i}=consolekit\"'
else
eval $i='${i}=\"\\#${i}=\"'
fi
else
eval $i='$i=$i=$tmp'
fi
done
# Get usable temp filenames
i=0
set -C
while : ; do
i=$(($i+1))
tmpc="./tmp-configure-$$-$PPID-$i.c"
tmpe="./tmp-configure-$$-$PPID-$i.tmp"
2>|/dev/null > "$tmpc" && break
2>|/dev/null > "$tmpe" && break
test "$i" -gt 50 && fail "$0: cannot create temporary files"
done
set +C
trap 'rm -f "$tmpc" "$tmpe"' EXIT ABRT INT QUIT TERM HUP
echo "creating config.mak..."
cmdline=$(quote "$0")
for i ; do cmdline="$cmdline $(quote "$i")" ; done
exec 3>&1 1>config.mak
cat << EOF
# This file was generated by:
# $cmdline
# Any changes made here will be lost if configure is re-run.
version := $version

Eric Vidal
committed
package := $package
prefix := $prefix
exec_prefix := $exec_prefix
bindir := $bindir
datarootdir := $datarootdir
service_directory := $service_directory

Eric Vidal
committed
seed_directory := $seed_directory
$DISPLAY_MANAGER
$CONSOLE_TRACKER
$XDG_RUNTIME
$DESKTOP_CMDLINE
EOF
exec 1>&3 3>&-
echo " ... done."