forked from troglobit/finit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·450 lines (391 loc) · 17 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
#!/bin/sh
# Simple home brew configure script, not as fancy as GNU Autotools
#
# --with-plugins="time initctl"
# --enable-static
# --disable-inetd
# --disable-plugins
#
# This creates a configuration where Finit is built statically, with the
# time and initctl plugins built-in, and no inetd support.
#
# Setup defaults if undefined
defaults()
{
heading=${heading:='"Finit v" VERSION'}
prefix=${prefix:="/usr"}
sysconfdir=${sysconfdir:="/etc"}
sbindir=${sbindir:="/sbin"}
libdir=${libdir:="/lib"}
pdir="finit/plugins"
plugindir=${plugindir:="$libdir/$pdir"}
# The initctl FIFO, should probably be in /run, not /dev
fifo=${fifo:="/dev/initctl"}
conf="finit.conf"
config=${config:="$sysconfdir/$conf"}
confdir=${confdir:="finit.d"}
rcsd=${rcsd:="$sysconfdir/$confdir"}
console=${console:='_PATH_CONSOLE'}
shell=${shell:='_PATH_BSHELL'}
defuser=${defuser:="root"}
defhost=${defhost:="noname"}
runlevel=${runlevel:=2}
debug=${debug:=0}
embedded=${embedded:=0}
dbus=${dbus:=0}
remount=${remount:=0}
inetd=${inetd:=1}
verbose=${verbose:=1}
kernel_quiet=${kernel_quiet:=1}
static=${static:=0}
disable_plugins=${disable_plugins:=0}
}
result()
{
echo
echo "Finit configuration"
echo "========================================================================"
echo "Heading : $heading"
echo "Install prefix : $prefix"
echo "System config dir : $sysconfdir"
echo "Super user bindir : $sbindir"
echo "Shared libs dir : $libdir"
echo "Plugins dir : $plugindir"
echo "FIFO : $fifo"
echo "Config file : $config"
echo "rcs.d/ directory : $rcsd"
echo "Default console : $console"
# echo "Fallback shell : $shell"
if [ x"$sysroot" != x"" ]; then
echo "Swap rootfs to : $sysroot"
fi
echo "Default username : $defuser"
echo "Default hostname : $defhost"
echo "Default runlevel : $runlevel"
if [ $debug -ne 0 ]; then
echo "Debug : ENABLED"
fi
if [ $embedded -ne 0 ]; then
echo "Embedded target : YES (BusyBox getty, and mdev instead of udev)"
fi
if [ $dbus -ne 0 ]; then
echo "D-Bus : YES, remember to install dbus.so plugin as well!"
fi
if [ $remount -ne 0 ]; then
echo "Remount ROOT fs : YES, / will be remounted as read-write at bootstrap"
fi
if [ x"$random" != x"" ]; then
echo "Random seed : $random"
fi
if [ $inetd -ne 0 ]; then
echo "Inetd : Built-in"
else
echo "Inetd : DISABLED"
fi
if [ x"$libite" = x"" ]; then
echo "Libite (LITE) : Built-in"
else
echo "Libite (LITE) : $libite + {/lib, /include}"
fi
if [ x"$libuev" = x"" ]; then
echo "LibuEv : Built-in"
else
echo "LibuEv : $libuev + {/lib, /include}"
fi
if [ $verbose -ne 1 ]; then
echo "Quiet Finit : YES"
else
echo "Quiet Finit : NO, verbose output (default)"
fi
if [ $kernel_quiet -eq 1 ]; then
echo "Kernel Quiet : YES, silent after inital boot (default)"
else
echo "Kernel Quiet : NO"
fi
if [ $static -ne 0 ]; then
echo "Static Finit : YES"
fi
if [ $disable_plugins -eq 1 ]; then
echo "Plugins : DISABLED"
else
if [ x"$plugins" = x"" ]; then
echo "Plugins : ALL"
else
echo "Plugins : $plugins"
fi
fi
echo
}
usage()
{
defaults
echo "Run this script to configure finit for your operating system."
echo
echo "Usage: $0 [ARG]"
echo
echo " --help This help text"
echo " --prefix=PREFIX Set installation prefix, default '$prefix'"
echo " --sysconfdir=CONF Set conf dir, default '$sysconfdir'"
echo " --sbindir=SBIN Set sbin dir, default '$sbindir'"
echo " --libdir=LIB Set lib dir, default '$libdir'"
echo " --plugindir=DIR Set plugin dir, default '\$libdir/$pdir'"
echo
echo " --with-fifo=FIFO FIFO for initctl plugin, default '$fifo'"
echo " --with-config=CONFIG Finit CONFIG file, default '\$sysconfdir/$conf'"
echo " --with-heading=GREET Display GREET instead of Finit version at boot"
echo " --with-randomseed=SEED Seed /dev/urandom from file SEED. On Debian/Ubuntu"
echo " systems, set this to /var/lib/urandom/random-seed"
echo " Default: none"
echo " --with-plugins=\"a b c\" Build plugins 'a', 'b' and 'c', either as dynamic .so"
echo " files, or as built-in if --enable-static is given,"
echo " defaults to all plugins. Exclude extension!"
echo " --with-rcsd=RCSD Finit RCSD directory, default '\$sysconfdir/$confdir'"
echo " --with-console=DEV Console to use, default: /dev/console"
# echo " --with-shell=PATH Fallback shell to use, default: /bin/sh"
echo " --with-sysroot=PATH Some distributions keep a different (writable) rootfs"
echo " that is used at runtime, usually /sysroot or /mnt"
echo " --with-username=USER User for 'startx' .conf option, default: root"
echo " --with-hostname=NAME Hostname, if /etc/hostname is missing, default: noname"
echo " --with-runlevel=LEVEL Runlevel to switch to after bootstrap (S), default: 2"
echo " --with-libite=PATH Look for libite in PATH/include and PATH/lib"
echo " This is for disabling the use of built-in libite."
echo " --with-libuev=PATH Look for libuEv in PATH/include and PATH/lib"
echo " This is for disabling the use of built-in libuEv."
echo
echo " --enable-embedded Embedded defaults, BusBox getty, mdev etc."
echo " --enable-dbus Enable D-Bus plugin. Note: install plugin as well!"
echo " --enable-rw-rootfs Remount / as read-write at bootstrap, not for embedded"
echo " --enable-debug Enable debug flags, '-O0, -g'"
echo " --enable-quiet Quiet mode, reduce screen output to absolute minimum"
echo " --enable-static Link statically. This disables a few features."
echo " --disable-inetd Disable inetd support if not needed."
echo " --disable-kernel-quiet Disable kernel cmdline quiet, default enabled."
echo " --disable-plugins Disable plugins"
echo
echo "The build system also supports external CFLAGS, CPPFLAGS, LDFLAGS, LDLIBS,"
echo "and DESTDIR, useful for packaging or cross-compiling."
echo
echo "Example:"
echo " ./configure --enable-embedded --with-plugins=\"initctl tty\""
echo
echo "Report bugs to https://github.com/troglobit/finit/issues"
echo
exit 1
}
while [ "$*" != "" ]; do
opt=`expr "$1" : "--\([^=]*\)=.*"`
arg=`expr "$1" : "--[^=]*=\(.*\)"`
if [ -z "$opt" ]; then
opt=`expr "$1" : "--\(.*\)"`
fi
shift
case $opt in
prefix)
prefix="$arg"
;;
sysconfdir)
sysconfdir="$arg"
;;
sbindir)
sbindir="$arg"
;;
libdir)
libdir="$arg"
;;
plugindir)
plugindir="$arg"
;;
with-fifo)
fifo="$arg"
;;
with-config)
config="$arg"
;;
with-heading)
heading="\"$arg\""
;;
with-randomseed)
random="$arg"
;;
with-plugins)
plugins="$arg"
;;
with-rcsd)
rcsd="$arg"
;;
with-console)
console="\"$arg\""
;;
with-shell)
shell="\"$arg\""
;;
with-sysroot)
sysroot="$arg"
;;
with-usename)
defuser="$arg"
;;
with-hostname)
defhost="$arg"
;;
with-runlevel)
runlevel="$arg"
;;
with-libite)
libite="$arg"
;;
with-libuev)
libuev="$arg"
;;
enable-debug)
debug=1
;;
enable-embedded)
embedded=1
;;
enable-dbus)
dbus=1
;;
enable-rw-rootfs)
remount=1
;;
enable-quiet)
verbose=0
;;
enable-static)
static=1
;;
disable-inetd)
inetd=0
;;
disable-kernel-quiet)
kernel_quiet=0
;;
disable-plugins)
disable_plugins=1
;;
help)
usage
;;
*)
echo "Unknown option: $opt"
usage
;;
esac
done
# If no arguments given to configure script, use defaults
defaults
result
##############################################################################
echo "# Generated by finit configure script." > config.mk
echo "prefix = $prefix" >> config.mk
echo "sysconfdir = $sysconfdir" >> config.mk
echo "sbindir = $sbindir" >> config.mk
echo "libdir = $libdir" >> config.mk
echo "plugindir = $plugindir" >> config.mk
echo "incdir = \$(prefix)/include/finit" >> config.mk
echo "datadir = \$(prefix)/share/doc/finit" >> config.mk
echo "mandir = \$(prefix)/share/man/man8" >> config.mk
echo "FINIT_RCSD = $rcsd" >> config.mk
if [ $inetd -eq 0 ]; then
echo >> config.mk
echo "OBJS := \$(filter-out inetd.o, \$(OBJS))" >> config.mk
fi
echo >> config.mk
if [ $debug -eq 1 ]; then
echo "CFLAGS += -O0 -g" >> config.mk
else
echo "CFLAGS += -O2" >> config.mk
fi
echo >> config.mk
if [ $static -ne 0 ]; then
echo "STATIC = 1" >> config.mk
echo "LDFLAGS += -static" >> config.mk
echo "CPPFLAGS += -DENABLE_STATIC" >> config.mk
echo "PLUGINS = \"\"" >> config.mk
if [ $disable_plugins -ne 1 ]; then
if [ x"$plugins" != x"" ]; then
echo "OBJS += \$(addsuffix .o, \$(addprefix plugins/, $plugins))" >> config.mk
else
echo "tmp += \$(wildcard plugins/*.c)" >> config.mk
echo "OBJS += \$(tmp:.c=.o)" >> config.mk
fi
fi
else
echo "STATIC = 0" >> config.mk
echo "LDFLAGS += -rdynamic" >> config.mk
echo "LDLIBS += -ldl" >> config.mk
if [ x"$plugins" != x"" ]; then
echo "PLUGINS = \$(addsuffix .so, $plugins)" >> config.mk
fi
fi
if [ x"$libite" != x"" ]; then
echo "LIBITE = $libite" >> config.mk
echo "CPPFLAGS += -I\$(LIBITE)/include" >> config.mk
echo "LDFLAGS += -L\$(LIBITE)/lib" >> config.mk
echo "LDLIBS += -l:libite.so.2" >> config.mk
else
echo "LDFLAGS += -L\$(TOPDIR)/libite" >> config.mk
echo "LDLIBS += -lite" >> config.mk
echo "DEPLIBS += libite/libite.a" >> config.mk
fi
if [ x"$libuev" != x"" ]; then
echo "LIBUEV = $libuev" >> config.mk
echo "CPPFLAGS += -I\$(LIBUEV)/include" >> config.mk
echo "LDFLAGS += -L\$(LIBUEV)/lib" >> config.mk
echo "LDLIBS += -l:libuev.so.1" >> config.mk
else
echo "LDFLAGS += -L\$(TOPDIR)/libuev" >> config.mk
echo "LDLIBS += -luev" >> config.mk
echo "DEPLIBS += libuev/libuev.a" >> config.mk
fi
echo >> config.mk
echo "export libdir plugindir incdir" >> config.mk
echo "export CFLAGS CPPFLAGS LDFLAGS LDLIBS STATIC" >> config.mk
##############################################################################
echo "/* Generated by finit configure script. */" > config.h
echo >> config.h
echo "#ifndef FINIT_CONFIG_H_" >> config.h
echo "#define FINIT_CONFIG_H_" >> config.h
echo >> config.h
echo "#define INIT_HEADING $heading" >> config.h
echo "#define VERBOSE_MODE $verbose" >> config.h
echo "#define KERNEL_QUIET $kernel_quiet" >> config.h
if [ $embedded -eq 1 ]; then
echo "#define EMBEDDED_SYSTEM 1" >> config.h
echo "#define SETUP_DEVFS \"/sbin/mdev -s\"" >> config.h
echo "#define GETTY \"/sbin/getty -L\"" >> config.h
echo "#define GETTY_BUSYBOX 1" >> config.h
echo "#define BAUDRATE 115200" >> config.h
else
echo "#define SETUP_DEVFS \"/sbin/udevd --daemon\"" >> config.h
echo "#define GETTY \"/sbin/getty -8\"" >> config.h
echo "#define GETTY_AGETTY 1" >> config.h
echo "#define BAUDRATE 38400" >> config.h
fi
if [ $remount -eq 1 ]; then
echo "#define REMOUNT_ROOTFS 1" >> config.h
fi
if [ $dbus -eq 1 ]; then
echo "#define HAVE_DBUS 1" >> config.h
fi
if [ $inetd -eq 0 ]; then
echo "#define INETD_DISABLED" >> config.h
fi
echo "#define FINIT_FIFO \"$fifo\"" >> config.h
echo "#define FINIT_CONF \"$config\"" >> config.h
echo "#define FINIT_RCSD \"$rcsd\"" >> config.h
echo "#define CONSOLE $console" >> config.h
echo "#define FALLBACK_SHELL $shell" >> config.h
if [ x"$sysroot" != x"" ]; then
echo "#define SYSROOT \"$sysroot\"" >> config.h
fi
echo "#define PLUGIN_PATH \"$plugindir\"" >> config.h
if [ x"$random" != x"" ]; then
echo "#define RANDOMSEED \"$random\"" >> config.h
fi
echo "#define DEFUSER \"$defuser\"" >> config.h
echo "#define DEFHOST \"$defhost\"" >> config.h
echo "#define RUNLEVEL $runlevel" >> config.h
echo >> config.h
echo "#endif /* FINIT_CONFIG_H_ */" >> config.h