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
|
#!/bin/sh
config_mk="config.mk"
enable_asan=f
prefix="/usr/local"
with_xfce4_panel_applet=f
with_gtktheme=f
with_lx=f
with_pmenu=f
usage_message="Usage: ./configure
Produce a config.mk file to be sourced by Makefile
--with-xfce4-panel-applet Include xfce4-panel-applet. This has quite different
runtime dependencies, so consider building
separately.
--with-gtktheme Include gtktheme module
--with-lx Include lx module
--with-pmenu Include pmenu module
--all, -a Include all contrib/ packages above
--dev, -d Same as --all, but also with ASAN and prefix=\$HOME
--enable-asan Enable address sanitizer (only during development)
--disable-svg Disable SVG icon support
--prefix=<dir> Install architecture-independent files in \$prefix
(e.g. --prefix=\$HOME')
--libdir=<dir> Specify libdir (\$prefix/lib by default)
--libexecdir=<dir> Specify libexecdir (\$prefix/lib by default)
"
print_ok_fail () {
# Usage: print_ok_fail <status> <message>...
# <status> 0=ok; 1-127=fail
status=$1
shift
if [ "$status" = "0" ]; then
printf '%b\n' "[ OK ] $*"
else
printf '%b\n' "[FAIL] $*"
exit 1
fi
}
check_bin () {
type "$*" >/dev/null 2>&1
print_ok_fail $? $*
}
check_lib () {
pkg-config "$*" >/dev/null 2>&1
print_ok_fail $? $*
}
check_core_dependencies () {
for b in "pkg-config" "xml2-config"; do
check_bin "$b"
done
for l in "x11" "xrandr" "cairo" "pango" "pangocairo" "glib-2.0"; do
check_lib "$l"
done
if [ "$disable_svg" != "t" ]; then
check_lib "librsvg-2.0"
fi
}
add () {
printf '%b\n' "$*" >>"$config_mk"
}
add_modules () {
add "prefix = $prefix"
test -z "$libdir" || add "libdir = $libdir"
test -z "$libexecdir" || add "libexecdir = $libexecdir"
if [ "$disable_svg" != "t" ]; then
add "RSVG=1"
fi
if [ "$enable_asan" = "t" ]; then
add "ASAN=1"
fi
if [ "$with_xfce4_panel_applet" = "t" ]; then
check_lib "libxfce4panel-2.0"
add "CONTRIB_DIRS += xfce4-panel"
fi
if [ "$with_gtktheme" = "t" ]; then
add "CONTRIB_DIRS += gtktheme"
fi
if [ "$with_lx" = "t" ]; then
check_lib "libmenu-cache >= 1.1.0"
add "CONTRIB_DIRS += lx"
fi
if [ "$with_pmenu" = "t" ]; then
add "CONTRIB_DIRS += pmenu"
fi
}
with_all () {
with_xfce4_panel_applet=t
with_gtktheme=t
with_lx=t
with_pmenu=t
}
main () {
for arg
do
opt=${arg%%=*}
var=${arg#*=}
case "$opt" in
--prefix)
prefix="$var" ;;
--libdir)
libdir="$var" ;;
--libexecdir)
libexecdir="$var" ;;
--with-xfce4-panel-applet)
with_xfce4_panel_applet=t ;;
--with-gtktheme)
with_gtktheme=t ;;
--with-lx)
with_lx=t ;;
--with-pmenu)
with_pmenu=t ;;
--enable-asan)
enable_asan=t ;;
--disable-svg)
disable_svg=t ;;
-a|--all)
with_all ;;
-d|--dev)
with_all
enable_asan=t
prefix=${HOME}
;;
-h|--help)
printf '%b' "$usage_message"; exit 1 ;;
*)
printf '%b\n' "warn: unknown option $opt" >&2 ;;
esac
done
rm -rf $config_mk
add "# Generated by configure script"
check_core_dependencies
add_modules
}
main "$@"
|