-
Notifications
You must be signed in to change notification settings - Fork 93
/
configure
executable file
·126 lines (112 loc) · 2.76 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
#!/usr/bin/env sh
set -e
BOLD="\033[1m"
RESET="\033[0m"
LIGHT_RED="\033[91m"
LIGHT_GREEN="\033[92m"
LIGHT_CYAN="\033[96m"
logging(){
local type=$1; shift
printf "${LIGHT_CYAN}${BOLD}configure${RESET} [%b] : %b\n" "$type" "$*"
}
log_info(){
logging "${LIGHT_GREEN}info${RESET}" "$@"
}
log_error(){
logging "${LIGHT_RED}error${RESET}" "$@" >&2
}
# find and print x11 header path
get_xlib_include_path(){
local result=""
for inc in \
/usr/X11/include \
/usr/X11R6/include \
/usr/X11R5/include \
/usr/X11R4/include \
\
/usr/include \
/usr/include/X11 \
/usr/include/X11R6 \
/usr/include/X11R5 \
/usr/include/X11R4 \
\
/usr/local/X11/include \
/usr/local/X11R6/include \
/usr/local/X11R5/include \
/usr/local/X11R4/include \
\
/usr/local/include/X11 \
/usr/local/include/X11R6 \
/usr/local/include/X11R5 \
/usr/local/include/X11R4 \
\
/usr/X386/include \
/usr/x386/include \
/usr/XFree86/include/X11 \
\
/usr/local/include \
/usr/athena/include \
/usr/local/x11r5/include \
/usr/lpp/Xamples/include \
\
/usr/openwin/include \
/usr/openwin/share/include
do
if [ -f "$inc/X11/Xlib.h" -a -f "$inc/X11/extensions/XShm.h" ]; then
result=$inc
break
fi
done
echo $result
}
show_help(){
cat <<EOF
Usage :
$0 Auto-configure and make MinilibX
$0 clean Execute the clean rule of both Makefile.gen
EOF
}
clean(){
log_info 'Execute "make clean" from "makefile.gen"'
${MAKE} -f Makefile.gen clean
log_info 'Execute "make clean" from "test/makefile.gen"'
${MAKE} -f Makefile.gen -C test/ --no-print-directory clean
}
parse_args(){
case "$1" in
--help | -h)
show_help
exit 0;;
clean)
clean
exit 0;;
"") return;;
*)
log_error "unknown command \"$1\"\nRun \"./configure --help\" for usage."
exit 1;;
esac
}
main(){
local xlib_inc="$(get_xlib_include_path)"
case $(uname) in
FreeBSD) MAKE=gmake ;;
*) MAKE=make ;;
esac
parse_args "$@"
if [ -z "$xlib_inc" ]; then
log_error "Can't find a suitable X11 include directory."
exit 1
fi
log_info "Found X11 include path directory: $xlib_inc"
log_info 'Generate "makefile.gen" from template "makefile.mk"'
echo "INC=$xlib_inc" > Makefile.gen
cat Makefile.mk | grep -v %%%% >> Makefile.gen
log_info 'Generate "test/makefile.gen" from template "test/makefile.mk"'
echo "INC=$xlib_inc" > test/Makefile.gen
cat test/Makefile.mk | grep -v %%%% >> test/Makefile.gen
log_info 'Execute "make all" from file "makefile.gen"'
${MAKE} -f Makefile.gen all
log_info 'Execute "make all" from file "test/makefile.gen"'
(cd test ; ${MAKE} -f Makefile.gen all )
}
main "$@"