aboutsummaryrefslogtreecommitdiff
path: root/configure
blob: 7fec97284e6bf7597292dc761f34e0e712e7aa10 (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
#!/bin/sh
cd "$(dirname "$0")"

# ---
# Variables statiques et par défaut.
# ---

name="$(make -s getname)"
version="$(make -s getversion)"
maintainer="$(make -s getmaintainer)"

nologo=0
loglevel=WARN
deletescripts=1
curlhttpverbose=0
curlftpverbose=0
debugsyms=

# ---
# Message de version.
# ---

for arg ; do case "$arg" in
--version|-v)
	cat <<EOF
${name} configure script v${version}
Hand-written by Thomas « Cakeisalie5 » Touhey <thomas@touhey.fr>.

This configure script is free software.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
EOF
	exit 0
esac; done

# ---
# Message d'aide.
# ---

for arg ; do case "$arg" in
--help|-h)
	cat <<EOF
\`configure\` configures ${name} to adapt it to systems that aren't mine.
Usage: $0 [OPTION...]

Defaults for the option are specified in brackets.

General options:
  --help                    display this help message and exit
  --version                 display version information and quit

Build options:
  --maintainer              enable maintainer-related options.
  --debug-syms              add debug symbols.
  --nologo                  do not display the copyright message in the daemon
  --loglevel=LOGLEVEL       minimum log level to display the logs for,
                            among "debug", "warn", "error", "fatal", "none".
  --no-delete-scripts       do not delete the scripts after they have been
                            executed; this serves for debugging purposes.
  --libcurl-http-verbose    enable verbose on all http requests using libcurl,
                            for debugging purposes.
  --libcurl-ftp-verbose     same as previous for ftp requests using libcurl.
  --libcurl-verbose         same as previous for all requests using libcurl.

Report bugs to ${maintainer}.
EOF
	exit 0
esac; done

# ---
# Switch principal de récupération des arguments.
# ---

for arg ; do case "$arg" in
--debug-syms)
	debugsyms=1 ;;
--nologo)
	nologo=1 ;;
--loglevel=*)
	ll="${arg#*=}"
	case "$ll" in
	info|debug) loglevel=DEBUG ;;
	warn) loglevel=WARN ;;
	error) loglevel=ERROR ;;
	fatal) loglevel=FATAL ;;
	none) loglevel=NONE ;;
	*) echo "--loglevel: unknown value: $ll" ;;
	esac ;;
--no-delete-scripts)
	deletescripts=0 ;;
--libcurl-http-verbose)
	curlhttpverbose=1 ;;
--libcurl-ftp-verbose)
	curlftpverbose=1 ;;
--libcurl-verbose)
	curlhttpverbose=1
	curlftpverbose=1 ;;
--maintainer)
	nologo=1
	loglevel=DEBUG
	debugsyms=1 ;;
*) echo "'$arg': didn't read" >&2 ;;
esac; done

# ---
# Création de la configuration.
# ---
# On nettoie au préalable.

make mrproper MAKE_FULL_LOG=y 1>/dev/null 2>&1

# On crée le fichier.

exec 3>&1 1>Makefile.cfg
cat <<EOF
#!/usr/bin/make -f
# Configuration générée par ./configure

 CONFIG_VERSION = ${version}

# Options de construction.

 DEBUG_SYMS := ${debugsyms}

 NO_LOGO := ${nologo}
 LOG_LEVEL := ${loglevel}
 DELETE_SCRIPTS := ${deletescripts}
 CURL_HTTP_VERBOSE := ${curlhttpverbose}
 CURL_FTP_VERBOSE := ${curlftpverbose}

# End of file.
EOF
exec 1>&3 3>&-
chmod +x Makefile.cfg

# On affiche le message de fin.

echo "Configuration loaded, you can make now! :)"

# End of file.