build 3.9 KB

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