summaryrefslogtreecommitdiff
path: root/build.sh
blob: b8daabf834fb05e6d57e275286350f8f633d0792 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash

# based on devs/seoz/build.sh

# /etc/ld.so.conf.d/efl.conf:
#   /opt/efl/lib
# /etc/profile.d/efl.sh:
#   export EFLDIR=/opt/efl
#   export PATH=$PATH:$EFLDIR/bin
#   export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$EFLDIR/lib/pkgconfig
#   #export XDG_DATA_DIRS=$XDG_DATA_DIRS:$EFLDIR/share

set -e
#set -x
shopt -s expand_aliases

unset LANG
export TERM=xterm-color
export CFLAGS=${CFLAGS:-"-O2 -march=native -ffast-math -W -Wall -Wextra"} # -Wshadow"
export CC=${CC:-"ccache clang"}
alias make='make -j4'
# export EFL_COV_LIBS="/usr/lib64/clang/3.2/lib/linux/libclang_rt.profile-x86_64.a"

if $(echo ${CC} | grep "clang" 1>/dev/null 2>&1); then
   export CFLAGS="${CFLAGS} -Qunused-arguments -Wno-array-bounds -Wno-parentheses-equality -Wno-empty-body"
fi

PREFIX=/opt/efl
export PATH=$PREFIX/bin:$PATH
export PKG_CONFIG_PATH=$PREFIX"/lib/pkgconfig:$PKG_CONFIG_PATH"

EFL_TESTS=${EFL_TESTS:-"regular"}
EFL_PROFILE=${EFL_PROFILE:-"dev"}
EFL_DBUS_DIR="/usr/share/dbus-1/services"

if [ "x$EFL_TESTS" = "xcoverage" ]; then
   if [[ $CC =~ clang ]]; then
      export EFL_COV_LIBS="/usr/lib64/clang/3.3/lib/linux/libclang_rt.profile-x86_64.a"
   fi
fi

BUILD_TREE="build"
BUILD_IN_TREE=1
CLEANLEVEL=1
for arg in $@; do
    if [ "x$arg" = "x+c" ]; then CLEANLEVEL=$((CLEANLEVEL+1)); fi
    if [ "x$arg" = "x-c" ]; then CLEANLEVEL=$(($CLEANLEVEL-1)); fi
done

PWD=`pwd`
TAGS_PATH=$HOME"/share/ctags/efl.tags"
LOG_WARN_FILE=$PWD"/warnings.txt"
LOG_WARN_TMP_FILE=$PWD"/warnings_tmp.txt"
LOCAL_PATCHES_PATH=$PWD"/local_patches"

EFL_FLAGS="--disable-doc --disable-static --with-profile=$EFL_PROFILE --with-dbus-services=$EFL_DBUS_DIR --with-tests=$EFL_TESTS" # --enable-always-build-examples"
EFL_FLAGS+=" --with-x11=xlib --disable-tslib --enable-drm --enable-fb --disable-egl --enable-systemd --enable-harfbuzz --disable-pulseaudio"
EFL_FLAGS+=" --enable-wayland"
# EFL_FLAGS+=" --enable-pixman --enable-pixman-font --enable-pixman-rect --enable-pixman-line --enable-pixman-poly --enable-pixman-image --enable-pixman-image-scale-sample"

E_FLAGS="--enable-pam --disable-device-hal --enable-device-udev --enable-mount-udisks --enable-mount-eeze --enable-elementary --enable-emotion --enable-enotify"
E_FLAGS+=" --enable-wayland-clients --enable-wayland-egl"

function create_log()
{
    rm $LOG_WARN_FILE -f
    touch $LOG_WARN_FILE
}

function get_sudo_pwd()
{
    echo -e "\n==== SUDO PASSWD"
    sudo_test=/tmp/_sudo.test
    echo -n "enter sudo-password: " && stty -echo && read SUDO_PASSWD && stty echo || exit 1
    echo "$SUDO_PASSWD" | sudo -S touch $sudo_test
    if [ ! -e $sudo_test ]; then
        echo "cmdline provided sudo password failed!"
        exit 1
    else
        sudo rm -f $sudo_test
    fi
}

function apply_local_patches()
{
    echo -e "\n==== LOCAL PATCHES"
    for patch in $(ls -1 $LOCAL_PATCHES_PATH/*.patch 2>/dev/null); do
        echo " - apply ${patch##*/}" && patch -p 1 -N -r - < $patch || true
    done
}

function clean_build_tree()
{
    [ ! -f Makefile ] && return
    if [ $CLEANLEVEL -gt 1 ]; then
        echo "* distclean ..." && make clean distclean >/dev/null || true
    elif [ $CLEANLEVEL -eq 1 ]; then
        echo "* clean ..." && make clean >/dev/null || true
    else
        echo "* leave tree AS IS ..."
    fi
}

function run_autogen()
{
    [ $CLEANLEVEL -lt 1 ] && return
    cmd="./autogen.sh"
    [ $BUILD_IN_TREE -ne 1 ] && cmd="../autogen.sh"
    echo "* $cmd ..." && NOCONFIGURE=1 $cmd >/dev/null 2>&1 || true
}

function configure_build_tree()
{
    autogen_flags=$1
    [ $CLEANLEVEL -lt 1 ] && return
    cmd="./configure"
    [ $BUILD_IN_TREE -ne 1 ] && cmd="../configure"
    echo "* $cmd $autogen_flags ..." && $cmd $autogen_flags || exit 1
}

function make_build_tree()
{
    echo "* make ..." && make 3>&1 1>&2 2>&3 | tee $LOG_WARN_TMP_FILE || exit 1
    cat $LOG_WARN_TMP_FILE >> $LOG_WARN_FILE
    rm $LOG_WARN_TMP_FILE
}

function install_component()
{
    echo "* install ..." && echo "$SUDO_PASSWD" | sudo -S make install >/dev/null 2>&1 || exit 1
    echo "$SUDO_PASSWD" | sudo -S ldconfig
}

function build()
{
    build_dir=$1
    autogen_flags=$2
    for I in $build_dir; do
        pushd $I || exit 1
        echo -e "\n==== $I"
        echo "" >> $LOG_WARN_FILE
        echo "["$I"]" >> $LOG_WARN_FILE
        [ $BUILD_IN_TREE -ne 1 ] && [ -f Makefile ] && echo "* distclean source tree ..." && make clean distclean >/dev/null || true
        run_autogen
        if [ $BUILD_IN_TREE -ne 1 ]; then
            [ $CLEANLEVEL -gt 2 ] && rm -fr $BUILD_TREE
            [ -d $BUILD_TREE ] || mkdir $BUILD_TREE
            pushd $BUILD_TREE
        fi
        clean_build_tree
        configure_build_tree "$autogen_flags"
        make_build_tree
        install_component
        [ $BUILD_IN_TREE -ne 1 ] &&  popd
        popd
    done
}

function uninstall()
{
    build_dir=$1
    for I in $build_dir; do
        pushd $I
        echo "$SUDO_PASSWD" | sudo -S make uninstall
        popd
    done
}

function update_desktop_stuff()
{
    echo -e "\n==== UPDATE DESKTOP STUFF"
    echo "$SUDO_PASSWD" | sudo -S -E update-mime-database $PREFIX/share/mime
    echo "$SUDO_PASSWD" | sudo -S -E update-desktop-database
}

function e17_restart()
{
    [ -z "$DISPLAY" ] && return
    echo -e "\n==== ENLIGHTENMENT RESTART"
    enlightenment_remote -restart
}

function efl_ctags()
{
    # efl ctags
    echo -e "\n==== TAGS"
    ex=""
    for dir in BINDINGS DEBUG E16 E-MODULES-EXTRA FORMATTING GAMES IN-EFL MARKETING MISC PROTO SCRIPTS TEST THEMES E16 web; do
        ex="$ex --exclude=$dir"
    done
    [ -e $TAGS_PATH ] && rm $TAGS_PATH
    ctags --tag-relative=yes -h ".h.x.cpp.c" --exclude="*.js" --exclude="*.pxi" --exclude="*.la" $ex -R -o $TAGS_PATH
}

build_core()
{
   echo "build core"
   build "core/efl" "--prefix=$PREFIX $EFL_FLAGS"
   build "core/evas_generic_loaders core/emotion_generic_players" "--prefix=$PREFIX"
}

build_elm()
{
   echo "build elm"
   build "libs/libeweather" "--prefix=$PREFIX" # --enable-tests (elocation only)
   build "devs/elocation" "--prefix=$PREFIX" # --enable-tests (elocation only)
   build "core/elementary" "--prefix=$PREFIX"
}

build_apps()
{
   echo "build apps"
   build "apps/terminology apps/ephoto" "--prefix=$PREFIX"
}

build_tools()
{
   echo "build tools"
   build "tools/clouseau tools/exactness tools/expedite" "--prefix=$PREFIX --disable-wayland-egl"
}

build_games()
{
   echo "build games"
   build "games/etrophy games/elemines" "--prefix=$PREFIX"
}

build_devs()
{
   echo "build devs"
   build "devs/efx devs/esskyuehl" "--prefix=$PREFIX"
}

build_e()
{
   echo "build e"
   build "core/enlightenment" "--prefix=$PREFIX --sysconfdir=/etc --libexecdir=$PREFIX/lib/enlightenment $E_FLAGS"
}

build_all()
{
   build_core
   build_elm
   build_apps
   build_tools
   build_games
   build_devs
   build_e
}

get_sudo_pwd
create_log

for arg in $@; do
   for fct in all core elm apps tools games devs e; do
      [ "x$arg" = "x$fct" ] && build_$arg
   done
done

update_desktop_stuff
e17_restart
efl_ctags

echo -e "\n==== DONE\n"