summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-15 14:30:03 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-15 14:30:03 +0200
commit0a64a7993b3e64e88b5bd2a7f38cdb151908b3d9 (patch)
tree2173ea232262c0ed35ad4616551d955f25a7993b
parent0d9da34b0a6320f37c67540d8a15a55b78ea7796 (diff)
build-fct: clean up CLEANLEVEL usage, build in tree if desired
-rwxr-xr-xbuild-fcts.sh110
1 files changed, 58 insertions, 52 deletions
diff --git a/build-fcts.sh b/build-fcts.sh
index c358eb7..d9d088d 100755
--- a/build-fcts.sh
+++ b/build-fcts.sh
@@ -28,6 +28,12 @@ if [ "x${PREFIX}" = "x" ]; then
28 exit 1 28 exit 1
29fi 29fi
30 30
31RESET="\033[0m"
32RED="\033[0;31m"
33GREEN="\033[0;32m"
34BROWN="\033[0;33m"
35PURPLE="\033[0;35m"
36
31export CC=${CC:-"ccache gcc"} 37export CC=${CC:-"ccache gcc"}
32export CFLAGS=${CFLAGS:-"-ggdb3 -O2 -march=native -ffast-math -W -Wall -Wextra -Wshadow"} 38export CFLAGS=${CFLAGS:-"-ggdb3 -O2 -march=native -ffast-math -W -Wall -Wextra -Wshadow"}
33 39
@@ -35,7 +41,8 @@ export PATH=$PREFIX/bin:$PATH
35export LD_LIBRARY_PATH=$PREFIX"/lib" 41export LD_LIBRARY_PATH=$PREFIX"/lib"
36export PKG_CONFIG_PATH=$PREFIX"/lib/pkgconfig" 42export PKG_CONFIG_PATH=$PREFIX"/lib/pkgconfig"
37 43
38BUILD_DIR=${BUILD_DIR:-"./build"} 44BUILD_DIR=${BUILD_DIR:-"build"}
45USE_BUILD_DIR=${USE_BUILD_DIR:-0}
39 46
40TAGS_PATH=$HOME"/share/ctags/efl.tags" 47TAGS_PATH=$HOME"/share/ctags/efl.tags"
41 48
@@ -53,32 +60,17 @@ E_FLAGS="--disable-device-hal"
53E_FLAGS+=" --enable-pam --enable-device-udev --enable-mount-udisks --enable-mount-eeze --enable-enotify" 60E_FLAGS+=" --enable-pam --enable-device-udev --enable-mount-udisks --enable-mount-eeze --enable-enotify"
54E_FLAGS+=" --enable-wayland-clients --enable-wayland-egl" 61E_FLAGS+=" --enable-wayland-clients --enable-wayland-egl"
55 62
56CLEANLEVEL=1 63CLEANLEVEL=0
57for arg in $@; do 64for arg in $@; do
58 if [ "x$arg" = "x+c" ]; then CLEANLEVEL=$((CLEANLEVEL+1)); fi 65 if [ "x$arg" = "x+c" ]; then CLEANLEVEL=$((CLEANLEVEL+1)); fi
59 if [ "x$arg" = "x-c" ]; then CLEANLEVEL=$(($CLEANLEVEL-1)); fi 66 if [ "x$arg" = "x-c" ]; then CLEANLEVEL=$(($CLEANLEVEL-1)); fi
60done 67done
61echo "clean : $CLEANLEVEL" 68echo "clean : $CLEANLEVEL"
62 69
63function get_sudo_pwd()
64{
65 echo -e "\n==== SUDO PASSWD"
66 sudo_test=/tmp/_sudo.test
67 echo -n "enter sudo-password: " && stty -echo && read SUDO_PASSWD && stty echo || exit 1
68 echo "$SUDO_PASSWD" | sudo -S touch $sudo_test
69 if [ ! -e $sudo_test ]; then
70 echo "cmdline provided sudo password failed!"
71 exit 1
72 else
73 sudo rm -f $sudo_test
74 fi
75 echo
76}
77
78function say() 70function say()
79{ 71{
80 cmd=$1 72 cmd=$1
81 echo -e " \033[0;33m* \033[0;32m$cmd\033[0m ..." 73 echo -e " $BROWN* $GREEN$cmd$RESET ..."
82} 74}
83 75
84function exec_cmd() 76function exec_cmd()
@@ -87,60 +79,74 @@ function exec_cmd()
87 say "$cmd" && $cmd 79 say "$cmd" && $cmd
88} 80}
89 81
90function prepare_src_dir() 82function fatal()
91{ 83{
92 src_dir=$1 84 cmd=$1
93 [ $CLEANLEVEL -lt 4 -a -f "$src_dir/configure" ] && return 85 echo -e "$PURPLE$cmd$RESET miserably$RED FAILED$RESET"
86 exit 1
87}
94 88
95 pushd $src_dir >/dev/null || exit 1 89function get_sudo_pwd()
96 say "./autogen.sh" && NOCONFIGURE=1 ./autogen.sh >/dev/null 2>&1 90{
97 popd 91 echo -e "\n==== $RED SUDO$RESET PASSWD"
92 sudo_test=/tmp/_sudo.test
93 echo -n "enter sudo-password: " && stty -echo && read SUDO_PASSWD && stty echo || exit 1
94 echo "$SUDO_PASSWD" | sudo -S touch $sudo_test
95 if [ ! -e $sudo_test ]; then
96 fatal "cmdline provided sudo password failed!"
97 else
98 sudo rm -f $sudo_test
99 fi
100 echo
98} 101}
99 102
100function prepare_build_dir() 103function prepare_build_install()
101{ 104{
102 src_dir=$1 105 autogen_flags=$1
103 build_dir=$2 106 configure="./configure"
104 autogen_flags=$3 107 autogen="./autogen.sh"
105 configure="$src_dir/configure"
106 108
107 [ $CLEANLEVEL -gt 2 ] && exec_cmd "rm -fr $build_dir" 2>/dev/null 109 [ $CLEANLEVEL -ge 4 -a $USE_BUILD_DIR -eq 1 ] && exec_cmd "rm -fr $BUILD_DIR" 2>/dev/null
108 110
109 [ ! -d "$build_dir" ] && mkdir -p "$build_dir" 111 if [ $CLEANLEVEL -ge 5 -o ! -f "$configure" ]; then
110 pushd "$build_dir" >/dev/null || exit 1 112 [ -f "$autogen" ] || fatal "no $autogen -> no can do !!!"
113 say "$autogen" && NOCONFIGURE=1 $autogen >/dev/null 2>&1
114 [ -f "$configure" ] || fatal "no $configure -> no can do !!!"
115 fi
111 116
112 [ -f Makefile -a $CLEANLEVEL -gt 1 ] && say "make distclean" && make distclean >/dev/null 117 if [ $USE_BUILD_DIR -eq 1 ]; then
113 [ -f Makefile -a $CLEANLEVEL -gt 0 ] && say "make clean" && make clean >/dev/null 118 [ ! -d "$BUILD_DIR" ] && ( mkdir "$BUILD_DIR" || fatal "mkdir" )
119 pushd "$BUILD_DIR" >/dev/null || fatal "pushd"
120 fi
121
122 [ $CLEANLEVEL -ge 3 -a -f Makefile ] && say "make distclean" && make distclean >/dev/null || true
123 [ $CLEANLEVEL -ge 1 -a -f Makefile ] && say "make clean" && make clean >/dev/null || true
114 124
115 if [ ! -f Makefile ]; then 125
116 exec_cmd "$configure $autogen_flags" || exit 1 126 if [ $CLEANLEVEL -ge 2 -o ! -f Makefile ]; then
127 [ $USE_BUILD_DIR -eq 1 ] && configure=".$configure"
128 exec_cmd "$configure $autogen_flags" || fatal "configure"
117 fi 129 fi
118}
119 130
120function make_build_tree() 131 exec_cmd "make" || fatal "make"
121{
122 exec_cmd "make" || exit 1
123}
124 132
125function install_component() 133 say "make install" && echo "$SUDO_PASSWD" | sudo -S make install >/dev/null 2>&1 || fatal "make install"
126{
127 say "make install" && echo "$SUDO_PASSWD" | sudo -S make install >/dev/null 2>&1 || exit 1
128 echo "$SUDO_PASSWD" | sudo -S ldconfig 134 echo "$SUDO_PASSWD" | sudo -S ldconfig
135
136 [ $USE_BUILD_DIR -eq 1 ] && popd
129} 137}
130 138
131function build() 139function build()
132{ 140{
133 src_dirs=$1 141 src_dirs=$1
134 autogen_flags=" --prefix=${PREFIX} $2" 142 autogen_flags=" --prefix=${PREFIX} $2"
135 root=$(pwd)
136 for I in $src_dirs; do 143 for I in $src_dirs; do
137 echo -e "\n==== $I" 144 src_dir="./$I"
138 src_dir="$root/$I" 145 build_dir="$src_dir"
139 build_dir="$BUILD_DIR/$I" 146 [ $USE_BUILD_DIR -eq 1 ] && build_dir="$src_dir/$BUILD_DIR/"
140 prepare_src_dir "$src_dir" 147 echo -e "\n==== build $PURPLE${src_dir##*/}$RESET in $GREEN$build_dir$RESET"
141 prepare_build_dir "$src_dir" "$build_dir" "$autogen_flags" 148 pushd $src_dir > /dev/null || fatal "pushd"
142 make_build_tree 149 prepare_build_install "$autogen_flags"
143 install_component
144 popd 150 popd
145 done 151 done
146} 152}