aboutsummaryrefslogtreecommitdiffstats
path: root/configure
blob: 5facfc01c6a5b06fd56a24d2c2ea8ea57745f7a0 (plain)
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
#!/bin/sh

cd `dirname "$0"`
. 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:
  --libdir=DIR                  service and source directories [PREFIX/lib/$package]
  --bindir=BINDIR               user executables [EPREFIX/bin]

Binaries
  --shebangdir=SHEBANGDIR       dir used to find interpreters for scripts [PREFIX/bin]

Logging
  --syslogdir=LOGDIR            system logdir [PREFIX/var/log/goetia]
  --usrlogdir=LOGDIR            user logdir appended to \${HOME} [.local/state/log]

  --logconfig=LOGCONFIG         directives for autogenerated s6-log scripts [n3 T]
  --loguser=LOGUSER             user running all system s6-log processes [logger]
  --logdep=LOGDEP               dependencies for autogenerated system s6-log processes [mount]

Other
  --sysconfdir=CONFIGDIR        systemtree configdir [PREFIX/etc/goetia/system]
  --usrconfdir=CONFIGDIR        usertree configdir appended to \${HOME} [.config/goetia]

  --tmpfsdir=TMPFSDIR           tmpfs dir used for supervision trees [/run]
  --sysrundir=SYSRUNDIR         systemtree runtime dir appended to TMPFSDIR [system]
  --usrrundir=USRRUNDIR         usertree runtime dir appended to TMPFSDIR [user]

  --timeout=TIMEOUT             Timeout in ms for s6-rc invocations in init and shutdown scripts [60000]

Optional features:
  --enable-slashpackage[=ROOT]  assume /package installation at ROOT [disabled]

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 () {
  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"
}

stripdir () {
  while eval "fnmatch '*/' \"\${$1}\"" ; do
    eval "$1=\${$1%/}"
  done
}

escapeslash () {
	echo "$1" | sed -e 's/\//\\\//g'
}

# Actual script

prefix=
exec_prefix='$prefix'
bindir='$exec_prefix/bin'
libdir='$prefix/lib/$package'

shebangdir='$prefix/bin'

syslogdir='$prefix/var/log/goetia'
usrlogdir='.local/state/log'

logconfig='n3 T'
loguser='logger'
logdep='mount'

sysconfdir='$prefix/etc/goetia/system'
usrconfdir='.config/goetia'

tmpfsdir='$prefix/run'
sysrundir='system'
usrrundir='user'

timeout=60000

slashpackage=false
sproot=
home=
exthome=
build=

for arg ; do
  case "$arg" in
    --help) usage ;;
    --prefix=*) prefix=${arg#*=} ;;
    --exec-prefix=*) exec_prefix=${arg#*=} ;;
    --bindir=*) bindir=${arg#*=} ;;
    --libdir=*) libdir=${arg#*=} ;;
    --shebangdir=*) shebangdir=${arg#*=} ;;
    --syslogdir=*) syslogdir=${arg#*=} ;;
    --usrlogdir=*) usrlogdir=${arg#*=} ;;
    --logconfig=*) logconfig=${arg#*=} ;;
    --loguser=*) loguser=${arg#*=} ;;
    --logdep=*) logdep=${arg#*=} ;;
    --sysconfdir=*) sysconfdir=${arg#*=} ;;
    --usrconfdir=*) usrconfdir=${arg#*=} ;;
    --tmpfsdir=*) tmpfsdir=${arg#*=} ;;
    --sysrundir=*) sysrundir=${arg#*=} ;;
    --usrrundir=*) usrrundir=${arg#*=} ;;
    --timeout=*) timeout=${arg#*=} ;;
	--enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;;
    --enable-slashpackage) sproot= ; slashpackage=true ;;
    --disable-slashpackage) sproot= ; installtype=fhs ;;
    --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
    -* ) echo "$0: unknown option $arg" ;;
    *=*) eval "${arg%%=*}=\${arg#*=}" ;;
    *) target=$arg ;;
  esac
done

# Expand installation directories
stripdir prefix
for i in exec_prefix bindir libdir shebangdir syslogdir usrlogdir sysconfdir usrconfdir tmpfsdir sysrundir usrrundir sproot ; do
  eval tmp=\${$i}
  eval $i=$tmp
  stripdir $i
done

# Set slashpackage values
if $slashpackage ; then
  home=${sproot}/package/${category}/${package}-${version}
  exthome=${sproot}/package/${category}/${package}
  extbinprefix=${exthome}/command
  bindir=${home}/command
  libdir=${home}
fi

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.

IT ::= all

package ::= $package
prefix ::= $prefix
exec_prefix ::= $exec_prefix
bindir ::= $bindir
libdir ::= $libdir
shebangdir ::= $(escapeslash "$shebangdir")
syslogdir ::= $(escapeslash "$syslogdir")
usrlogdir ::= $(escapeslash "$usrlogdir")
logconfig ::= $(escapeslash "$logconfig")
loguser ::= $(escapeslash "$loguser")
logdep ::= $(escapeslash "$logdep")
sysconfdir ::= $(escapeslash "$sysconfdir")
usrconfdir ::= $(escapeslash "$usrconfdir")
tmpfsdir ::= $(escapeslash "$tmpfsdir")
sysrundir ::= $(escapeslash "$sysrundir")
usrrundir ::= $(escapeslash "$usrrundir")
timeout ::= $timeout
slashpackage ::= $slashpackage
sproot ::= $sproot
version ::= $version
home ::= $home
exthome ::= $exthome
EOF

exec 1>&3 3>&-
echo "  ... done."