2
0

build.sh 1012 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. build() (
  3. local dir="$1"; shift
  4. cd "$dir"
  5. cmake -DCMAKE_INSTALL_PREFIX=$PWD/../install "$@" .
  6. make -j9
  7. make install
  8. )
  9. clone() (
  10. local dir="$1"
  11. local url="$2"
  12. if [ -d "$dir" ]; then
  13. cd "$dir"
  14. git pull --rebase
  15. else
  16. git clone "$url" "$dir"
  17. fi
  18. )
  19. UNAME="$(uname)"
  20. set -e -x
  21. rm -rf install
  22. mkdir -p install
  23. ln -s lib install/lib64
  24. clone libubox git://git.openwrt.org/project/libubox.git
  25. build libubox -DBUILD_LUA=off -DCMAKE_POSITION_INDEPENDENT_CODE=on
  26. if [ "$UNAME" = "Linux" ]; then
  27. clone libnl-tiny git://git.openwrt.org/project/libnl-tiny.git
  28. build libnl-tiny -DBUILD_LUA=off -DCMAKE_POSITION_INDEPENDENT_CODE=on
  29. clone libbpf https://github.com/libbpf/libbpf
  30. make -j9 -C libbpf/src PREFIX=$PWD/install all install
  31. fi
  32. rm -f install/lib/*.{so,dylib}
  33. if [ "$UNAME" = "Linux" ]; then
  34. mv install/include/libnl-tiny/* install/include/
  35. fi
  36. export CFLAGS=-I$PWD/install/include
  37. export LDFLAGS=-L$PWD/install/lib
  38. cmake -DCMAKE_FIND_ROOT_PATH=$PWD/install -DUBUS_SUPPORT=off .
  39. make -j9