Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yonzkon committed Mar 21, 2019
1 parent 8bfb99e commit 7869600
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
[submodule "file"]
path = file
url = git://github.com/file/file
[submodule "tcpdump"]
path = tcpdump
url = https://github.com/the-tcpdump-group/tcpdump
[submodule "libpcap"]
path = libpcap
url = https://github.com/the-tcpdump-group/libpcap
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EDT provide a bundle of develop tools run on embedded devices.
- strace
- gperftools
- file
- tcpdump

## Build

Expand Down
98 changes: 75 additions & 23 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export CPP=$HOST-cpp
export AS=$HOST-as
export LD=$HOST-ld
export STRIP=$HOST-strip
export C_INCLUDE_PATH=$PREFIX/include
export CPLUS_INCLUDE_PATH=$PREFIX/include
export LD_LIBRARY_PATH=$PREFIX/lib
RPATH='-Wl,-rpath,$$\ORIGIN:$$\ORIGIN/../lib'

do_build()
Expand All @@ -46,72 +49,120 @@ do_build()
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Finished $1\033[0m"
}

do_make()
{
local make_dir=$1
local make_jobs=$2
local make_opts=$3

if [ -z "$make_opts" ]; then
$MAKE -C $make_dir -j$make_jobs
else
$MAKE -C $make_dir -j$make_jobs "$make_opts"
fi

if [ ! $? -eq 0 ]; then
rm -rf $make_dir
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Failed to make $1\033[0m"
else
$MAKE -C $make_dir install
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Success to make $1\033[0m"
fi
}

do_build_with_configure()
{
local name=$1
local config_opts=$2
local make_opts=$3
local build=$BUILD_DIR/$name

# Skip or start
if [ -e $build ]; then
$MAKE -C $build install
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Skip $1\033[0m"
return
fi

echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Start building $1\033[0m"

# autogen & configure
if [ ! -e $SCRIPT_DIR/$name/configure ]; then
pushd $SCRIPT_DIR/$name && ./autogen.sh && popd
fi

mkdir -p $build && pushd $build &&
$SCRIPT_DIR/$name/configure $config_opts && popd

mkdir -p $build && pushd $build
$SCRIPT_DIR/$name/configure $config_opts
popd
if [ ! $? -eq 0 ]; then
rm -rf $build
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Failed to configure $1\033[0m"
return
fi

# make
if [ -z "$make_opts" ]; then
$MAKE -C $build -j$JOBS
else
$MAKE -C $build "$make_opts" -j$JOBS
do_make $build $JOBS "$make_opts"
}

do_build_with_cmake()
{
local name=$1
local config_opts=$2
local make_opts=$3
local build=$BUILD_DIR/$name

# Skip or start
if [ -e $build ]; then
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Skip $1\033[0m"
return
fi
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Start building $1\033[0m"

# cmake
mkdir -p $build && pushd $build
cmake $SCRIPT_DIR/$name "$config_opts"
popd
if [ ! $? -eq 0 ]; then
rm -rf $build
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Failed to make $1\033[0m"
else
$MAKE -C $build install
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Finished $1\033[0m"
echo -e "\033[32m($(date '+%Y-%m-%d %H:%M:%S')): Failed to configure $1\033[0m"
return
fi

# make
do_make $build $JOBS "$make_opts"
}

stage_build()
{
git submodule init
git submodule update

do_build_with_configure binutils-gdb "--prefix=$PREFIX --host=$HOST" \
# binutils & gdb
do_build_with_configure binutils-gdb \
"--prefix=$PREFIX --host=$HOST" \
"CFLAGS=-g -O2 -DHAVE_FCNTL_H -DHAVE_LIMITS_H"

do_build_with_configure valgrind "--prefix=$PREFIX --host=${HOST/arm/armv7}"
# valgrind
do_build_with_configure valgrind \
"--prefix=$PREFIX --host=${HOST/arm/armv7}"

do_build_with_configure gperftools "--prefix=$PREFIX --host=${HOST} \
--enable-libunwind"
# gperftools
do_build_with_configure gperftools \
"--prefix=$PREFIX --host=${HOST} --enable-libunwind"

# strace
[ ! -e $BUILD_DIR/strace ] && cd strace && ./bootstrap && cd -
do_build_with_configure strace "--prefix=$PREFIX --host=${HOST} \
--enable-mpers=no"
do_build_with_configure strace \
"--prefix=$PREFIX --host=${HOST} --enable-mpers=no"

# file
[ ! -e $BUILD_DIR/file ] && cd file && aclocal && autoheader && \
libtoolize --force && automake --add-missing && autoconf
do_build_with_configure file "--prefix=$PREFIX --host=${HOST} \
LDFLAGS=$RPATH --enable-static --disable-shared"
do_build_with_configure file \
"--prefix=$PREFIX --host=${HOST}" \
"LDFLAGS=$RPATH --enable-static --disable-shared"

# tcpdump
do_build_with_configure libpcap \
"--prefix=$PREFIX --host=${HOST} --with-pcap=linux"
do_build_with_cmake tcpdump "-DCMAKE_INSTALL_PREFIX=$PREFIX"
}

stage_trim()
Expand Down Expand Up @@ -151,7 +202,8 @@ stage_pack()
bin/strings \
bin/strip \
bin/valgrind* \
bin/vgdb
bin/vgdb \
sbin/tcpdump
popd
}

Expand Down
1 change: 1 addition & 0 deletions libpcap
Submodule libpcap added at 995849
1 change: 1 addition & 0 deletions tcpdump
Submodule tcpdump added at e96aba

0 comments on commit 7869600

Please sign in to comment.