Differences between revisions 5 and 6
Revision 5 as of 2012-06-25 20:18:48
Size: 31197
Editor: anonymous
Comment:
Revision 6 as of 2012-06-25 21:43:18
Size: 31212
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 337: Line 337:
# ============ checkout netsukuku source code ============

mkdir ~/savannahnongnu
cd ~/savannahnongnu
bzr branch bzr://bzr.savannah.nongnu.org/netsukuku/vala

Line 413: Line 406:

# ============ checkout netsukuku source code ============

mkdir ~/savannahnongnu
cd ~/savannahnongnu
bzr branch bzr://bzr.savannah.nongnu.org/netsukuku/vala
ln -s vala task

# ==============   download   =======================
# First, we prepare a directory from which to start
# with revision 31835 of OpenWRT.

mkdir -p ~/openwrt
cd ~/openwrt
svn co -r31835 svn://svn.openwrt.org/openwrt/trunk r31835
cd r31835
./scripts/feeds update -a
./scripts/feeds install -a

# ===================================================
# Then we make a working copy of that download

cd ..
cp -a r31835 r31835-eglibc
cd r31835-eglibc

# ===================================================
# We have to apply some patches to that revision of OpenWRT

vi package/base-files/files/lib/upgrade/common.sh

# We apply a patch that appears to be needed in order to build with glibc (also for eglibc)
# (https://dev.openwrt.org/ticket/9483#comment:16)
# 
# in file: package/base-files/files/lib/upgrade/common.sh
# at row 61, the following line:
# - install_file /etc/resolv.conf /etc/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
# becomes:
# + install_file /etc/resolv.conf /etc/functions.sh /lib/* /lib/upgrade/*.sh $RAMFS_COPY_DATA

vi package/gdb/Makefile

# Fix a bug:  gdbserver: error while loading shared libraries: libthread_db.so.1 noexist
# (beware: tabs are needed in a makefile, not spaces)
# package/gdb/Makefile:
# 
# define Package/gdbserver/install
# ---        $(INSTALL_DIR) $(1)/usr/bin
# +++        $(INSTALL_DIR) $(1)/usr/{bin,lib}
#         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdbserver $(1)/usr/bin/
# +++        $(CP) $(TOOLCHAIN_DIR)/lib/libthread_db* $(1)/usr/lib
# endef

# ==============   build image: first pass   =======================
# We prepare to compile a first time

make menuconfig

#      (select Target System (Atheros AR7xxx/AR9xxx) Subtarget (Generic) and Profile (TP-LINK TL-WR1043N/ND)
#      [*] Advanced configuration options (for developers)  --->
#        [*]   Toolchain Options  --->
#          [*]   eglibc 2.13
#          NOTE: 2.13 is the default. Version 2.14 would not build correctly the next pass.
#                Version 2.13 correspond to revision 15508

make defconfig
mkdir -p ~/openwrt-dl
ln -sf ~/openwrt-dl dl
make download

# BEWARE: some packages require internet connection during build. (e.g. luci)

time ionice -c 3 nice -n 20 make

#       (BEWARE: "-j 2" is prone to problems)
#       (It takes about 3.5 hours)
#       (I made a backup of r31835-eglibc in r31835-eglibc-backup)
#       NOTE: if you want to start again you have to remove r31835-eglibc
#             and rename r31835-eglibc-backup in r31835-eglibc

# ==============   build image: second pass   =======================
# We prepare to compile a second time with the packages that we need

make menuconfig

#       [*] Advanced configuration options (for developers)  --->
#         [*]   Toolchain Options  --->
#           [*]   Build gdb
#       [*] Build the OpenWrt SDK
#       [*] Build the OpenWrt based Toolchain
#       Base system  --->
#         --- libpthread
#         <*> librt
#       Libraries  --->
#         <*> glib2
#         <*> libffi
#         <*> libgcrypt
#         --- libgpg-error
#         <*> libiconv-full
#         <*> libintl-full
#         <*> libpcre
#         <*> pthsem
#         <*> zlib
#       LuCI  --->
#         Collections  --->
#           <M> luci
#       Network  --->
#         Firewall  --->
#           --- iptables  --->
#             <*>   iptables-mod-conntrack-extra
#             <*>   iptables-mod-ipopt
#         Routing and Redirection  --->
#           <*> ip
#       Kernel modules  --->
#         Netfilter Extensions  --->
#           --- kmod-ipt-core
#           ---   kmod-ipt-conntrack
#           ---   kmod-ipt-conntrack-extra
#           --- kmod-ipt-ipopt

time ionice -c 3 nice -n 20 make
#       (BEWARE: "-j 2" is prone to problems)
# The first run of 'make' will fail (after about 50 min) to make pthsem.
# After the failure (there is not the source at the beginning) modify the file
#  build_dir/target-mips_r2_eglibc-2.13/pthsem-2.0.8/configure
# so that it reads:
# case $PLATFORM in
#     *-*-linux* )
#         braindead=no
#         case "x`uname -r`" in
#             x2.[23456789]* ) ;;
#             x3.* ) ;;
#             * ) braindead=yes ;;

# The compilation of libgcrypt may fail too. If this happens edit
# build_dir/target-mips_eglibc-2.13/libgcrypt-1.5.0/ltmain.sh
# by changing the VERSION="..." line with
# VERSION=2.2
# without the ""

# Then launch the build process again.

time ionice -c 3 nice -n 20 make
#       (BEWARE: "-j 2" is prone to problems)
#       (It takes about 25 min)

# When it's over make pthsem compatible for apps that would search for pth:
ln -sf pthsem.h staging_dir/target-mips_r2_eglibc-2.13/usr/include/pth.h
ln -sf libpthsem.a staging_dir/target-mips_r2_eglibc-2.13/usr/lib/libpth.a
ln -sf libpthsem.so.20.0.28 staging_dir/target-mips_r2_eglibc-2.13/usr/lib/libpth.so
ln -sf libpthsem.so.20.0.28 staging_dir/target-mips_r2_eglibc-2.13/usr/lib/libpth.so.20
ln -sf libpthsem.so.20.0.28 staging_dir/target-mips_r2_eglibc-2.13/usr/lib/libpth.so.20.0.28

# Finally build also the toolchain
time ionice -c 3 nice -n 20 make toolchain/install
#       (BEWARE: "-j 2" is prone to problems)
#       (It takes about XXX min)

# ==============   verify   =======================
# Verify that you obtain the following results

# We should have a local copy of the files that would go into the root filesystem of the router.
# Somewhere inside ~/openwrt/r31835-eglibc we should find:
# usr/lib/libiconv.so
# for example in ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/root-ar71xx
file ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/root-ar71xx/usr/lib/libiconv.so*
# Among other symlink, we should have a shared object for the target platform (MIPS)
readelf -a ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/root-ar71xx/usr/lib/libiconv.so.2.4.0 | grep NEEDED
# This should tell us that the libc we linked against is libc.so.6
# We have confirmed that we have built against eglibc and that we built libiconv

# We also should have .h files for building against, since we opted for building the OpenWRT SDK.
# Let's look for iconv.h: we find usr/lib/libiconv-full/include/iconv.h inside
# ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13
# In there we should also find usr/lib/pkgconfig and usr/include
ls ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/lib/libiconv-full/include/iconv.h
ls ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/lib/pkgconfig/libffi.pc
ls ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/include/gcrypt.h

# We have to find the cross-build tools
# I find in ~/openwrt/r31835-eglibc/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_eglibc-2.13/bin
# the tools mips-openwrt-linux-gnu-*

# For a correct cross-build of projects that use auto-tools, we need a pkg-config that runs on the
# host and reports informations about the libraries that we can find on the target.
# OpenWRT provides this wrapper:
cat ~/openwrt/r31835-eglibc/staging_dir/host/bin/pkg-config
file ~/openwrt/r31835-eglibc/staging_dir/host/bin/pkg-config.real
# and places pc files here:
ls ~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/lib/pkgconfig
# E.g. give the command:
STAGING_PREFIX=~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr \
PKG_CONFIG_PATH=~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/lib/pkgconfig \
PATH=~/openwrt/r31835-eglibc/staging_dir/host/bin:$PATH \
pkg-config --cflags --libs libffi
# You should see in the output something like:
# -I/home/luca/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/lib/libffi-3.0.10/include  -L/home/luca/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr/lib -lffi  
# which says the include files and shared libraries will be searched for inside the staging_dir of your OpenWRT SDK.


# ==============   obtain dependencies   ========
#  libgee2: 0.6.4

mkdir ~/crossbuild
cd ~/crossbuild
wget http://ftp.gnome.org/pub/gnome/sources/libgee/0.6/libgee-0.6.4.tar.xz


# ============   cross-compile  libgee2   ==================
# You should open a new shell before issuing these commands
# and close the shell after this build is complete. Doing so
# you make sure to not make confusion with the environment
# variables that influence the build (e.g. PATH, PKG_CONFIG_PATH).

cd ~/crossbuild
rm -rf libgee-0.6.4
tar xf libgee-0.6.4.tar.xz
cd libgee-0.6.4
export NTK_TOOLCHAIN=~/openwrt/r31835-eglibc/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_eglibc-2.13
export NTK_TARGET=~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13
export NTK_SDK_HOST=~/openwrt/r31835-eglibc/staging_dir/host
# set path for executables mips-openwrt-linux-gcc and the like
export PATH=${NTK_TOOLCHAIN}/bin:${PATH}
# The following variable is necessary for this toolchain, it has to be set at configure-time and at make-time
export STAGING_DIR=~/openwrt/r31835-eglibc/staging_dir

STAGING_PREFIX=~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13/usr \
PKG_CONFIG_PATH=${NTK_TARGET}/usr/lib/pkgconfig \
PATH=${NTK_SDK_HOST}/bin:$PATH \
CPPF0="-I${NTK_TARGET}/usr/include" \
CPPF1="" \
CPPF2="" \
CPPFLAGS="-Os $CPPF0 $CPPF1 $CPPF2 $CPPFLAGS" \
CF0="-I${NTK_TARGET}/usr/include" \
CF1="" \
CF2="" \
CFLAGS="-Os $CF0 $CF1 $CF2 $CFLAGS" \
L0="-L${NTK_TARGET}/usr/lib" \
L1="" \
L2="" \
LDFLAGS="-Os $L0 $L1 $L2 $LDFLAGS" \
./configure \
     --host=mips-openwrt-linux-gnu \
     --prefix=/opt/libgee-0.6.4

make &&
make install DESTDIR=~/pre-pkg/mips-glibc

export PKG_INSTALL_DIR=~/pre-pkg/mips-glibc/opt/libgee-0.6.4
export FINAL_DIR=~/pkg/mips-glibc/libgee-0.6.4
export FINAL_DIR_DEV=~/pkg/mips-glibc/libgee-0.6.4-dev

mkdir -p ${FINAL_DIR_DEV}/include
cp -a ${PKG_INSTALL_DIR}/include/* ${FINAL_DIR_DEV}/include
mkdir -p ${FINAL_DIR_DEV}/lib/pkgconfig
cp -a ${PKG_INSTALL_DIR}/lib/*.{so*,a,la} ${FINAL_DIR_DEV}/lib
cp -a ${PKG_INSTALL_DIR}/lib/pkgconfig/*.pc ${FINAL_DIR_DEV}/lib/pkgconfig

mkdir -p ${FINAL_DIR}/lib
cp -a ${PKG_INSTALL_DIR}/lib/*.so* ${FINAL_DIR}/lib
mips-openwrt-linux-gnu-strip --strip-unneeded `file ${FINAL_DIR}/lib/* | grep ELF | cut -d: -f1`


# ============   include these results in the firmware   ==================
# Back to the directory where we build openwrt. We create a folder
# "files" to prepare files that have to be placed in the firmware.

cd ~/openwrt/r31835-eglibc
mkdir files
# Optionally, copy some files that you want to be placed in the firmware.
#    cp -a /media/snapshots/luca/test/routers/mips-glibc/install-full/files/* files

# Copy the really needed files:
mkdir -p files/opt
cp -a ~/pkg/mips-glibc/libgee-0.6.4 files/opt

# Build again the firmware

time ionice -c 3 nice -n 20 make

#        (it takes about 6 min)


# ============   flash the router   ==================
# Now you can flash your router, for example the TP-Link WR1043 has to be flashed
# with bin/ar71xx/openwrt-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin
# If you have already openwrt on it, ssh into it and do:
#   
#   root@OpenWrt:~# cd /tmp
#   root@OpenWrt:/tmp# scp luca@192.168.5.240:/home/luca/openwrt/r31835-eglibc/bin/ar71xx/openwrt-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin factory.bin
#   root@OpenWrt:/tmp# rm -r /tmp/opkg-lists/
#   root@OpenWrt:/tmp# echo 3 > /proc/sys/vm/drop_caches
#   root@OpenWrt:/tmp# free
#                total         used         free       shared      buffers
#   Mem:         29516        25236         4280            0          292
#   -/+ buffers:              24944         4572
#   Swap:            0            0            0
#   root@OpenWrt:/tmp# mtd -r write factory.bin firmware
#   


# ============   OPTIONALLY:  install luci   ==================
# This is optional. You can install the modules (that we have included in
#  make configure) in order to have the web interface of the administration of
#  your router (luci)
# NOTE: the location that you find in your router at /etc/opkg.conf will tell
#       the router to look for installable packages in a location where there
#       are binaries built for ar71xx but with uClibc, so they won't work with
#       your router, which has openwrt built with eglibc.
# Do a "ssh" into your router, copy on it the following packages (that you
#  have in  ~/openwrt/r31835-eglibc/bin/ar71xx/packages) and install them in this
#  order:
#   
#   root@OpenWrt:~# cd /tmp
#   root@OpenWrt:/tmp# mkdir pkg
#   root@OpenWrt:/tmp# cd pkg
# Copy here the files...
#   root@OpenWrt:/tmp/pkg# opkg install uhttpd_*
#   root@OpenWrt:/tmp/pkg# opkg install libiwinfo_*
#   root@OpenWrt:/tmp/pkg# opkg install liblua_*
#   root@OpenWrt:/tmp/pkg# opkg install lua_*
#   root@OpenWrt:/tmp/pkg# opkg install libiwinfo-lua_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-proto-core_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-proto-ppp_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-app-firewall_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-theme-base_*
#   root@OpenWrt:/tmp/pkg# opkg install libuci_*
#   root@OpenWrt:/tmp/pkg# opkg install libuci-lua_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-lib-core_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-lib-sys_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-lib-nixio_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-lib-lmo_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-sgi-cgi_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-lib-web_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-i18n-english_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-mod-admin-core_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-lib-ipkg_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-mod-admin-full_*
#   root@OpenWrt:/tmp/pkg# opkg install luci-theme-openwrt_*
#   root@OpenWrt:/tmp/pkg# opkg install luci_*
#   root@OpenWrt:/tmp/pkg# /etc/init.d/uhttpd enable
#   root@OpenWrt:/tmp/pkg# /etc/init.d/uhttpd start

# ============   cross-compile  a minimal tester   ==================
# This will assure that with this libc we can run Pth threads on the router.
# You should open a new shell before issuing these commands
# and close the shell after this build is complete. Doing so
# you make sure to not make confusion with the environment
# variables that influence the build (e.g. PATH, PKG_CONFIG_PATH).

cd ~/crossbuild
rm -rf tasklet_tester
mkdir tasklet_tester
cd tasklet_tester
export NTK_TOOLCHAIN=~/openwrt/r31835-eglibc/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_eglibc-2.13
export NTK_TARGET=~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13
export NTK_SDK_HOST=~/openwrt/r31835-eglibc/staging_dir/host
# set path for executables mips-openwrt-linux-gcc and the like
export PATH=${NTK_TOOLCHAIN}/bin:${PATH}
# The following variable is necessary for this toolchain, it has to be set at configure-time and at make-time
export STAGING_DIR=~/openwrt/r31835-eglibc/staging_dir

# Where we have netsukuku sources
export NTK_NTKD_SRC=${HOME}/savannahnongnu/task
# Where we have placed the build-output of dependencies
export NTK_LIBGEE_DEV=${HOME}/pkg/mips-glibc/libgee-0.6.4-dev

export NTK_GCC='mips-openwrt-linux-gnu-gcc '
export NTK_CFLAGS_GLIB20="-pthread -I${NTK_TARGET}/usr/include -I${NTK_TARGET}/usr/include/glib-2.0 "
export NTK_LIBS_GLIB20="-Wl,-rpath-link,${NTK_TARGET}/usr/lib/libintl-full/lib -Wl,-rpath-link,${NTK_TARGET}/usr/lib/libiconv-full/lib -Wl,-rpath-link,${NTK_TARGET}/usr/lib -L${NTK_TARGET}/usr/lib/libintl-full/lib -L${NTK_TARGET}/usr/lib/libiconv-full/lib -L${NTK_TARGET}/usr/lib -pthread -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 "
export NTK_CFLAGS_GEE10="-pthread -I${NTK_LIBGEE_DEV}/include/gee-1.0 "
export NTK_LIBS_GEE10="-Wl,-rpath-link,${NTK_LIBGEE_DEV}/lib -L${NTK_LIBGEE_DEV}/lib -pthread -lgee "
export NTK_CFLAGS_PTH2="-I${NTK_TARGET}/usr/include "
export NTK_LIBS_PTH2="-L${NTK_TARGET}/usr/lib -lpth "
export NTK_CFLAGS_GCRYPT="-I${NTK_TARGET}/usr/include "
export NTK_LIBS_GCRYPT="-L${NTK_TARGET}/usr/lib -lgcrypt -lgpg-error "
export NTK_VALA_DEF='-D linux -D bigendian '

ln -s ${NTK_NTKD_SRC}/*.vapi .
ln -s ${NTK_NTKD_SRC}/libwrappth.vala
ln -s ${NTK_NTKD_SRC}/tasklet.vala
ln -s ${NTK_NTKD_SRC}/use_with_libpth_vapi.vala
ln -s ${NTK_NTKD_SRC}/testsuites/tasklet_tester_1.vala

valac ${NTK_VALA_DEF} -C --main=Ntk.Test.TaskletTester.main libwrappth.vala tasklet.vala use_with_libpth_vapi.vala \
             tasklet_tester_1.vala --pkg gee-1.0 --pkg gio-2.0 --pkg posix --pkg posix_extras --pkg libpth --vapidir .

${NTK_GCC} -Os ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} -c libwrappth.c
${NTK_GCC} -Os ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} -c tasklet.c
${NTK_GCC} -Os ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} -c tasklet_tester_1.c
${NTK_GCC} -Os ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} -c use_with_libpth_vapi.c
${NTK_GCC} -Os -o tasklet_tester_1 -Wl,-z,origin,-rpath,\$ORIGIN \
  libwrappth.o \
  tasklet.o \
  use_with_libpth_vapi.o \
  tasklet_tester_1.o \
  ${NTK_LIBS_GLIB20} \
  ${NTK_LIBS_GEE10} \
  ${NTK_LIBS_PTH2}

rm -f *.vapi *.vala *.c *.o

# Now move the file in the router, place it in a directory of your choice,
# make symlinks in the very same directory to the shared objects in /opt/blabla/lib
# and run the tester.
# E.g. in the router:
#   root@OpenWrt:~# mkdir temp
#   root@OpenWrt:~# cd temp
#   root@OpenWrt:~/temp# scp your/url/to/file/tasklet_tester_1 .
#   root@OpenWrt:~/temp# ln -s /opt/libgee-0.6.4/lib/*.so* .
#   root@OpenWrt:~/temp# ./tasklet_tester_1
# And you should see a list of 'OK' messages.

# ============  checkout netsukuku source code ============

mkdir ~/savannahnongnu
cd ~/savannahnongnu
bzr branch bzr://bzr.savannah.nongnu.org/netsukuku/vala 
ln -s vala task


# ============   cross-compile  netsukuku daemon   ==================
# You should open a new shell before issuing these commands
# and close the shell after this build is complete. Doing so
# you make sure to not make confusion with the environment
# variables that influence the build (e.g. PATH, PKG_CONFIG_PATH).

cd ~/crossbuild
rm -rf ntkd
mkdir ntkd
cd ntkd
export NTK_TOOLCHAIN=~/openwrt/r31835-eglibc/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_eglibc-2.13
export NTK_TARGET=~/openwrt/r31835-eglibc/staging_dir/target-mips_r2_eglibc-2.13
export NTK_SDK_HOST=~/openwrt/r31835-eglibc/staging_dir/host
# set path for executables mips-openwrt-linux-gcc and the like
export PATH=${NTK_TOOLCHAIN}/bin:${PATH}
# The following variable is necessary for this toolchain, it has to be set at configure-time and at make-time
export STAGING_DIR=~/openwrt/r31835-eglibc/staging_dir

# Where we have netsukuku sources
export NTK_NTKD_SRC=${HOME}/savannahnongnu/task
# Where we have placed the build-output of dependencies
export NTK_LIBGEE_DEV=${HOME}/pkg/mips-glibc/libgee-0.6.4-dev

export NTK_GCC='mips-openwrt-linux-gnu-gcc '
export NTK_CFLAGS_GLIB20="-pthread -I${NTK_TARGET}/usr/include -I${NTK_TARGET}/usr/include/glib-2.0 "
export NTK_LIBS_GLIB20="-Wl,-rpath-link,${NTK_TARGET}/usr/lib/libintl-full/lib -Wl,-rpath-link,${NTK_TARGET}/usr/lib/libiconv-full/lib -Wl,-rpath-link,${NTK_TARGET}/usr/lib -L${NTK_TARGET}/usr/lib/libintl-full/lib -L${NTK_TARGET}/usr/lib/libiconv-full/lib -L${NTK_TARGET}/usr/lib -pthread -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 "
export NTK_CFLAGS_GEE10="-pthread -I${NTK_LIBGEE_DEV}/include/gee-1.0 "
export NTK_LIBS_GEE10="-Wl,-rpath-link,${NTK_LIBGEE_DEV}/lib -L${NTK_LIBGEE_DEV}/lib -pthread -lgee "
export NTK_CFLAGS_PTH2="-I${NTK_TARGET}/usr/include "
export NTK_LIBS_PTH2="-L${NTK_TARGET}/usr/lib -lpth "
export NTK_CFLAGS_GCRYPT="-I${NTK_TARGET}/usr/include "
export NTK_LIBS_GCRYPT="-L${NTK_TARGET}/usr/lib -lgcrypt -lgpg-error "
export NTK_VALA_DEF='-D linux -D bigendian '

ln -s ${NTK_NTKD_SRC}/*.vapi .
ln -s ${NTK_NTKD_SRC}/ntkd.vala
ln -s ${NTK_NTKD_SRC}/ntk_node.vala
ln -s ${NTK_NTKD_SRC}/networkinterfaces.vala
ln -s ${NTK_NTKD_SRC}/networkinterface_manager.vala
ln -s ${NTK_NTKD_SRC}/neighbour.vala
ln -s ${NTK_NTKD_SRC}/radar.vala
ln -s ${NTK_NTKD_SRC}/inet_ends.vala
ln -s ${NTK_NTKD_SRC}/tasklet_blocking_sockets.vala
ln -s ${NTK_NTKD_SRC}/nic_generic.vala
ln -s ${NTK_NTKD_SRC}/route_generic.vala
ln -s ${NTK_NTKD_SRC}/metrics.vala
ln -s ${NTK_NTKD_SRC}/rpc.vala
ln -s ${NTK_NTKD_SRC}/messages.vala
ln -s ${NTK_NTKD_SRC}/remotable_interfaces.vala
ln -s ${NTK_NTKD_SRC}/serializer.vala
ln -s ${NTK_NTKD_SRC}/settings.vala
ln -s ${NTK_NTKD_SRC}/network_linux.vala
ln -s ${NTK_NTKD_SRC}/microfunc.vala
ln -s ${NTK_NTKD_SRC}/addresses.vala
ln -s ${NTK_NTKD_SRC}/krnl_route.vala
ln -s ${NTK_NTKD_SRC}/address_manager.vala
ln -s ${NTK_NTKD_SRC}/auxiliary.vala
ln -s ${NTK_NTKD_SRC}/bnodetunneling.vala
ln -s ${NTK_NTKD_SRC}/rpc_clients.vala
ln -s ${NTK_NTKD_SRC}/tunnel.vala
ln -s ${NTK_NTKD_SRC}/border_nodes.vala
ln -s ${NTK_NTKD_SRC}/migration.vala
ln -s ${NTK_NTKD_SRC}/coord.vala
ln -s ${NTK_NTKD_SRC}/counter.vala
ln -s ${NTK_NTKD_SRC}/andna.vala
ln -s ${NTK_NTKD_SRC}/peer_to_peer.vala
ln -s ${NTK_NTKD_SRC}/qspn.vala
ln -s ${NTK_NTKD_SRC}/aggregated_neighbour.vala
ln -s ${NTK_NTKD_SRC}/maproute.vala
ln -s ${NTK_NTKD_SRC}/incoming_nodes.vala
ln -s ${NTK_NTKD_SRC}/hook.vala
ln -s ${NTK_NTKD_SRC}/networkid.vala
ln -s ${NTK_NTKD_SRC}/crypto.vala
ln -s ${NTK_NTKD_SRC}/inet_utils.vala
ln -s ${NTK_NTKD_SRC}/map.vala
ln -s ${NTK_NTKD_SRC}/topology.vala
ln -s ${NTK_NTKD_SRC}/tasklet.vala
ln -s ${NTK_NTKD_SRC}/channel.vala
ln -s ${NTK_NTKD_SRC}/time_utils.vala
ln -s ${NTK_NTKD_SRC}/logger.vala
ln -s ${NTK_NTKD_SRC}/libwrappth.vala
ln -s ${NTK_NTKD_SRC}/use_with_libpth_vapi.vala

valac ${NTK_VALA_DEF} -D log_tasklet -C --main=Ntk.Core.Ntkd.main \
         ntkd.vala \
         ntk_node.vala \
         networkinterfaces.vala \
         networkinterface_manager.vala \
         neighbour.vala \
         radar.vala \
         inet_ends.vala \
         tasklet_blocking_sockets.vala \
         nic_generic.vala \
         route_generic.vala \
         metrics.vala \
         rpc.vala \
         messages.vala \
         remotable_interfaces.vala \
         serializer.vala \
         settings.vala \
         network_linux.vala \
         microfunc.vala \
         addresses.vala \
         address_manager.vala \
         auxiliary.vala \
         bnodetunneling.vala \
         krnl_route.vala \
         rpc_clients.vala \
         tunnel.vala \
         border_nodes.vala \
         migration.vala \
         coord.vala \
         counter.vala \
         andna.vala \
         peer_to_peer.vala \
         qspn.vala \
         aggregated_neighbour.vala \
         maproute.vala \
         incoming_nodes.vala \
         hook.vala \
         networkid.vala \
         crypto.vala \
         inet_utils.vala \
         map.vala \
         topology.vala \
         tasklet.vala \
         channel.vala \
         time_utils.vala \
         logger.vala \
         libwrappth.vala \
         use_with_libpth_vapi.vala \
         --pkg gcrypt \
         --pkg gee-1.0 --pkg gio-2.0 --pkg posix --pkg posix_extras --pkg linux --pkg libpth --vapidir .

${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c ntkd.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c ntk_node.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c networkinterfaces.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c networkinterface_manager.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c neighbour.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c radar.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c inet_ends.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c tasklet_blocking_sockets.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c nic_generic.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c route_generic.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c metrics.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c rpc.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c messages.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c remotable_interfaces.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c serializer.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c settings.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c network_linux.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c microfunc.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c addresses.c
${NTK_GCC} ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c address_manager.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c auxiliary.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c bnodetunneling.c
${NTK_GCC} ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c krnl_route.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c rpc_clients.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c tunnel.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c border_nodes.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c migration.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c coord.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c counter.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c andna.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c peer_to_peer.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c qspn.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c aggregated_neighbour.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c maproute.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c incoming_nodes.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c hook.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c networkid.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c crypto.c
${NTK_GCC} ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c inet_utils.c
${NTK_GCC} ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c map.c
${NTK_GCC} ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c topology.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c tasklet.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c channel.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c time_utils.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c logger.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c libwrappth.c
${NTK_GCC} -O3 ${NTK_CFLAGS_GLIB20} ${NTK_CFLAGS_GEE10} ${NTK_CFLAGS_PTH2} ${NTK_CFLAGS_GCRYPT} -c use_with_libpth_vapi.c
${NTK_GCC} -O3 -o ntkd -Wl,-z,origin,-rpath,\$ORIGIN \
       ntkd.o \
       ntk_node.o \
       networkinterfaces.o \
       networkinterface_manager.o \
       neighbour.o \
       radar.o \
       inet_ends.o \
       tasklet_blocking_sockets.o \
       nic_generic.o \
       route_generic.o \
       metrics.o \
       rpc.o \
       messages.o \
       remotable_interfaces.o \
       serializer.o \
       settings.o \
       network_linux.o \
       microfunc.o \
       addresses.o \
       address_manager.o \
       auxiliary.o \
       bnodetunneling.o \
       krnl_route.o \
       rpc_clients.o \
       tunnel.o \
       border_nodes.o \
       migration.o \
       coord.o \
       counter.o \
       andna.o \
       peer_to_peer.o \
       qspn.o \
       aggregated_neighbour.o \
       maproute.o \
       incoming_nodes.o \
       hook.o \
       networkid.o \
       crypto.o \
       inet_utils.o \
       map.o \
       topology.o \
       tasklet.o \
       channel.o \
       time_utils.o \
       logger.o \
       libwrappth.o \
       use_with_libpth_vapi.o \
       -lm \
  ${NTK_LIBS_GLIB20} \
  ${NTK_LIBS_GEE10} \
  ${NTK_LIBS_PTH2} \
  ${NTK_LIBS_GCRYPT}

mips-openwrt-linux-gnu-strip --strip-unneeded ntkd

rm -f *.vapi *.vala *.c *.o

# Copy the ntkd file in the router, place it in a directory such as /opt/ntkd.
# Make symlinks in the very same directory to the shared objects in /opt/blabla/lib
# E.g. in the router:
#   root@OpenWrt:~# mkdir /opt/ntkd
#   root@OpenWrt:~# cd /opt/ntkd
#   root@OpenWrt:/opt/ntkd# scp your/url/to/file/ntkd .
#   root@OpenWrt:/opt/ntkd# ln -s /opt/libgee-0.6.4/lib/*.so* .
# Configure the system as instructed by INSTALL/linux/README in the netsukuku sources dir
# And you are ready to go!

# As a final note, I advice to use the following configuration:

cat >/etc/netsukuku/ntkd.ini <<EOF
[NTKD]
IGS_MODE=NONE
LOGS_ON_SCREEN=false
VERBOSE_LEVEL=2
BITS_PER_LEVEL=2
LEVELS=4
MAX_BOUQUET=3
RADAR_WAIT_TIME=15
THREAD_STACK_SIZE=30
IPROUTE_PATH=/usr/sbin/ip
IPTABLES_PATH=/usr/sbin/iptables
[andnsserver]
inetnameserver=8.8.8.8
[dnswrapper]
andnsserver=in-process
[libandns]
andnsserver=127.0.0.1
EOF

Netsukuku_Dev/vala/flashing_notes3 (last edited 2012-06-25 21:43:18 by anonymous)