-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
152 lines (135 loc) · 2.96 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
#!/bin/sh
VERSION="0.30.0"
PREFIX="/usr/local"
SYSTEM_INCLUDE_PATH="/usr/include"
SYSTEM_LIBRARY_PATH="/usr/lib:/lib"
PC_PATH="/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig"
ENABLE_INDIRECT_DEPS=0
ENABLE_DEFINE_PREFIX=0
verbose=0
debug=0
red=31
green=32
yellow=33
blue=34
magenda=35
cyan=36
white=37
printc () {
printf "\033[%d;1m%b\033[0m" $1 "$2"
}
ok () {
printc $green "\tOK\n"
}
fail () {
printc $red "\tFAIL\n"
}
warn () {
printc $yellow "warning: "
printf "%b\n" "$1"
}
status () {
printf $2
if [ $1 = 0 ]; then
ok
else
fail
exit 1
fi
}
bin () {
type $1 >/dev/null 2>&1
# $? == 0?
status $? $1
}
lib () {
pkg-config $1 >/dev/null 2>&1
# $? == 0?
status $? $1
}
bins () {
printc $white "checking building tools..\n"
bin pkg-config
bin rm
bin mkdir
bin cp
bin chmod
bin strip
bin gzip
}
libs () {
printc $white "checking libraries..\n"
LIB_NAMES="glib-2.0"
for i in $LIB_NAMES; do
lib $i
done
}
append () {
printf "%b\n" "$*" >> config.mk
}
config () {
printc $white "creating configuration file"
append "# Generated by configure script"
append "BIN_DIR = $PREFIX/bin"
append "LIB_DIR = $PREFIX/lib"
append "SHARE_DIR = $PREFIX/share"
append "MAN_DIR = $PREFIX/share/man/man1\n"
if [ $verbose = 1 ]; then
append "QUIET_CC = "
append "QUIET_LINK = "
else
append "QUIET_CC = @echo 'CC '\$@;"
append "QUIET_LINK = @echo 'LINK '\$@;"
fi
append "\nCFLAGS = -DPKG_CONFIG_SYSTEM_INCLUDE_PATH=\\\"$SYSTEM_INCLUDE_PATH\\\" -DPKG_CONFIG_SYSTEM_LIBRARY_PATH=\\\"$SYSTEM_LIBRARY_PATH\\\" -DPKG_CONFIG_PACKAGE_PATH=\\\"$PREFIX/share/pkg-config\\\" -DPKG_CONFIG_PC_PATH=\\\"$PC_PATH\\\" -DENABLE_INDIRECT_DEPS=$ENABLE_INDIRECT_DEPS -DENABLE_DEFINE_PREFIX=$ENABLE_DEFINE_PREFIX -DVERSION=\\\"$VERSION\\\" `pkg-config --cflags $LIB_NAMES`"
append "CFLAGS += -DHAVE_PARSE_SPEW"
[ $debug = 1 ] && append "CFLAGS += -g -DDEBUG" || append "CFLAGS += -O3"
append "\nLIBS = `pkg-config --libs $LIB_NAMES`"
ok
}
printf "configure: create 'config.mk' include file\n"
for arg; do
opt=${arg%%=*}
var=${arg#*=}
case "$opt" in
--verbose)
verbose=1
;;
--debug)
debug=1
;;
--prefix)
PREFIX="$var"
;;
--system-include-path)
SYSTEM_INCLUDE_PATH="$var"
;;
--system-library-path)
SYSTEM_LIBRARY_PATH="$var"
;;
--pc-path)
PC_PATH="$var"
;;
--enable-indirect-deps)
ENABLE_INDIRECT_DEPS=1
;;
--enable-define-prefix)
ENABLE_DEFINE_PREFIX=1
;;
-h|--help)
printf "usage: ./"
printc $white "configure "
printf "[--verbose] [--debug] [--prefix=<dir>] [--system-include-path=<dir>] [--system-library-path=<dir>] [--pc-path=<dir>] [--enable-indirect-deps] [--enable-define-prefix]\n"
exit 1
;;
*)
warn "unknown option $opt" >&2
;;
esac
done
bins
libs
config
printf "type "
printc $white "make"
printf " to build the program\n"