staticbuild 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/sh
  2. #This file is part of TubeMan
  3. #Copyright Oliver Galvin, 2018
  4. #This script builds TubeMan statically against libcurl, libsqlite and libncurses
  5. #Running this script depends on curl, tar, gunzip, mingw/musl, make, cc, sh
  6. case $2 in
  7. win32) host="i386-w64-mingw32" ;;
  8. win64) host="x86_64-w64-mingw32" ;;
  9. musl) host="x86_64-pc-linux-gnu"
  10. export CC="musl-gcc -static" ;;
  11. *) echo "Statically cross compiling TubeMan for different targets"
  12. echo "---"
  13. echo "Usage:"
  14. echo "$1 win32 - 32 bit windows cross compile"
  15. echo "$1 win64 - 64 bit windows cross compile"
  16. echo "$1 musl - linux musl build"
  17. exit ;;
  18. esac
  19. export CFLAGS="-Os"
  20. export LDFLAGS="-Wl,-s"
  21. builddir="static"
  22. curlver="7.61.0"
  23. sqlitever="3240000"
  24. ncursesver="6.1"
  25. sslver="2.4.7"
  26. ext=".tar.gz"
  27. mkdir "$builddir"
  28. cd "$builddir" || exit
  29. file="libressl-${sslver}"
  30. echo "Building $file"
  31. url="https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${file}${ext}"
  32. curl -Os "$url"
  33. tar -xzf "${file}${ext}"
  34. cd "$file" || exit
  35. ./configure --disable-shared --host="$host"
  36. make
  37. export LDFLAGS="${LDFLAGS} -L${file}/lib"
  38. export CFLAGS="${CFLAGS} -I${file}/include"
  39. cd ..
  40. exit
  41. file="curl-${curlver}"
  42. echo "Building $file"
  43. url="https://curl.haxx.se/download/${file}${ext}"
  44. curl -Os "$url"
  45. tar -xzf "${file}${ext}"
  46. cd "$file" || exit
  47. ./configure \
  48. --disable-shared --disable-verbose \
  49. --disable-versioned-symbols --disable-manual \
  50. --disable-cookies --disable-ldap \
  51. --without-librtmp --without-libidn \
  52. --without-libidn2 --without-librtsp \
  53. --without-zlib --disable-thread \
  54. --disable-ipv6 --disable-ares \
  55. --disable-ftp --disable-tftp \
  56. --disable-dict --disable-gopher \
  57. --disable-imap --disable-pop3 \
  58. --disable-rtsp --disable-smb \
  59. --disable-smts --disable-smtp \
  60. --disable-telnet --host="$host"
  61. make
  62. export LDFLAGS="${LDFLAGS} -L${file}/lib/.libs"
  63. export CFLAGS="${CFLAGS} -I${file}/include"
  64. cd ..
  65. file="sqlite-autoconf-${sqlitever}"
  66. echo "Building $file"
  67. url="https://www.sqlite.org/2018/${file}${ext}"
  68. curl -Os "$url"
  69. tar -xzf "${file}${ext}"
  70. cd "$file" || exit
  71. ./configure \
  72. --disable-shared \
  73. --disable-dynamic-extensions \
  74. --disable-fts5 \
  75. --disable-json1 \
  76. --host="$host"
  77. make libsqlite3.la
  78. export LDFLAGS="${LDFLAGS} -L${file}/.libs"
  79. export CFLAGS="${CFLAGS} -I${file}"
  80. cd ..
  81. file="ncurses-${ncursesver}"
  82. echo "Building $file"
  83. url="ftp://ftp.gnu.org/gnu/ncurses/${file}${ext}"
  84. curl -Os "$url"
  85. tar -xzf "${file}${ext}"
  86. cd "$file" || exit
  87. ./configure \
  88. --without-ada \
  89. --without-cxx \
  90. --without-cxx-binding \
  91. --without-manpages \
  92. --without-debug \
  93. --disable-big-core \
  94. --host="$host"
  95. make
  96. export LDFLAGS="${LDFLAGS} -L${file}/lib"
  97. export CFLAGS="${CFLAGS} -I${file}/include"
  98. cd ..