build 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  4. distdir=/var/tmp/dist/sqlcipher
  5. builddir=/var/tmp/build/[% project %]
  6. mkdir /var/tmp/build
  7. tar -C /var/tmp/dist -xf [% c('input_files_by_name/nss') %]
  8. export AR="[% c('var/cross_prefix') %]-ar"
  9. # XXX: Mozilla really uses the NDK_API_VERSION here, which is weird.
  10. export CC="[% c('var/cross_prefix') %][% pc('android-toolchain', 'var/android_ndk_version') %]-clang"
  11. export CXX="[% c('var/cross_prefix') %][% pc('android-toolchain', 'var/android_ndk_version') %]-clang++"
  12. export LD="[% c('var/cross_prefix') %]-ld"
  13. export RANLIB="[% c('var/cross_prefix') %]-ranlib"
  14. host=""
  15. [% IF c("var/cross_prefix") == "armv7a-linux-androideabi" -%]
  16. host="arm-linux"
  17. [% ELSIF c("var/cross_prefix") == "i686-linux-android" -%]
  18. host="i686-linux"
  19. [% ELSIF c("var/cross_prefix") == "x86_64-linux-android" -%]
  20. host="x86_64-linux"
  21. [% ELSIF c("var/cross_prefix") == "aarch64-linux-android" -%]
  22. host="arm-linux"
  23. [% END -%]
  24. SQLCIPHER_CFLAGS=" \
  25. -DSQLITE_HAS_CODEC \
  26. -DSQLITE_SOUNDEX \
  27. -DHAVE_USLEEP=1 \
  28. -DSQLITE_MAX_VARIABLE_NUMBER=99999 \
  29. -DSQLITE_THREADSAFE=1 \
  30. -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \
  31. -DNDEBUG=1 \
  32. -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \
  33. -DSQLITE_ENABLE_LOAD_EXTENSION \
  34. -DSQLITE_ENABLE_COLUMN_METADATA \
  35. -DSQLITE_ENABLE_UNLOCK_NOTIFY \
  36. -DSQLITE_ENABLE_RTREE \
  37. -DSQLITE_ENABLE_STAT3 \
  38. -DSQLITE_ENABLE_STAT4 \
  39. -DSQLITE_ENABLE_JSON1 \
  40. -DSQLITE_ENABLE_FTS3_PARENTHESIS \
  41. -DSQLITE_ENABLE_FTS4 \
  42. -DSQLITE_ENABLE_FTS5 \
  43. -DSQLCIPHER_CRYPTO_NSS \
  44. -DSQLITE_ENABLE_DBSTAT_VTAB \
  45. -DSQLITE_SECURE_DELETE \
  46. -DSQLITE_DEFAULT_PAGE_SIZE=32768 \
  47. -DSQLITE_MAX_DEFAULT_PAGE_SIZE=32768 \
  48. -I/var/tmp/dist/nss/include \
  49. "
  50. LIBS="\
  51. -lcertdb \
  52. -lcerthi \
  53. -lcryptohi \
  54. -lfreebl_static \
  55. -lnspr4 \
  56. -lnss_static \
  57. -lnssb \
  58. -lnssdev \
  59. -lnsspki \
  60. -lnssutil \
  61. -lpk11wrap_static \
  62. -lplc4 \
  63. -lplds4 \
  64. -lsoftokn_static \
  65. "
  66. [% IF c("var/cross_prefix") == "i686-linux-android" || c("var/cross_prefix") == "x86_64-linux-android"-%]
  67. LIBS="${LIBS} -lgcm-aes-x86_c_lib"
  68. [% END %]
  69. [% IF c("var/cross_prefix") == "armv7a-linux-android" || c("var/cross_prefix") == "aarch64-linux-android"-%]
  70. LIBS="${LIBS} -larmv8_c_lib"
  71. [% END %]
  72. [% IF c("var/cross_prefix") == "aarch64-linux-android" -%]
  73. LIBS="${LIBS} -lgcm-aes-aarch64_c_lib"
  74. [% END %]
  75. [% IF c("var/cross_prefix") == "armv7a-linux-androideabi" -%]
  76. LIBS="${LIBS} -lgcm-aes-arm32-neon_c_lib"
  77. [% END %]
  78. [% IF c("var/cross_prefix") == "x86_64-linux-android"-%]
  79. LIBS="${LIBS} -lintel-gcm-wrap_c_lib -lintel-gcm-s_lib -lhw-acc-crypto-avx -lhw-acc-crypto-avx2"
  80. [% END %]
  81. tar -C /var/tmp/build -xf [% c('input_files_by_name/sqlcipher') %]
  82. mv /var/tmp/build/[% project %]-[% c('version') %] $builddir
  83. cd $builddir
  84. mkdir $builddir/build
  85. cd build
  86. ../configure \
  87. --host="$host" \
  88. --with-pic \
  89. --verbose \
  90. --disable-shared \
  91. --with-crypto-lib=none \
  92. --disable-tcl \
  93. --enable-tempstore=yes \
  94. CFLAGS="${SQLCIPHER_CFLAGS}" \
  95. LDFLAGS="-L/var/tmp/dist/nss/lib" \
  96. LIBS="${LIBS} -llog -lm"
  97. make sqlite3.h
  98. make sqlite3ext.h
  99. make libsqlcipher.la
  100. mkdir -p $distdir/include/sqlcipher
  101. mkdir -p $distdir/lib
  102. cp -p "$builddir/build/sqlite3.h" "$distdir/include/sqlcipher"
  103. cp -p "$builddir/build/sqlite3ext.h" "$distdir/include/sqlcipher"
  104. cp -p "$builddir/build/.libs/libsqlcipher.a" "$distdir/lib"
  105. # Just in case, ensure that the created binaries are not -w.
  106. chmod +w "$distdir/lib/libsqlcipher.a"
  107. cd /var/tmp/dist
  108. [% c('tar', {
  109. tar_src => [ project ],
  110. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  111. }) %]