#!/bin/sh - # # Generate files used to build the Android platform: # Android.mk -- used as a makefile for building a drop-in version # of libsqlite for Android # db_config.h, sql/config.h -- hard-coded configuration used by the build. # # All of the above are based on hard-coding in this configuration: # --enable-smallbuild --enable-statistics # If that is to change then the files involved in this script must change to # reflect the desired configuration msgc="/* DO NOT EDIT: automatically built by dist/s_android. */" . ./RELEASE s=/tmp/__db_a t=/tmp/__db_b u=/tmp/__db_c androidfilelist=android.files makefile=Android.mk outdir=../build_android template=android/Android.mk.template # function to create Android.mk from a template createAndroidMk() { echo "# DO NOT EDIT: automatically built by dist/s_android." rm -f $u for file in `cat $androidfilelist` do # NOTE: keep the tab as the first char of the echo below echo " \$(BDB_TOP)/$file \\" >> $u done sed -e "/@SOURCE_FILES@/r$u" -e "/@SOURCE_FILES@/d" < $template rm -f $u } # Build the list of files used by the Android build sed -e '/^$/d' -e '/^[ #]/d' srcfiles.in | egrep -w android | sed 's/[ ].*//' > $androidfilelist # create Android.mk substituting relevant version strings createAndroidMk | sed -e "s/@DB_VERSION@/$DB_VERSION/g" \ -e "s/@DB_VERSION_FULL_STRING@/$DB_VERSION_FULL_STRING/g" > $t f=$outdir/Android.mk cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f) # Build other required header files usually created by configure # db.h db_config.h, sql/config.h, db_int.h and clib_port.h # These are all sed-based editing of template files that would othwerwise # be done by a configure script # Build db.h from dbinc/db.in (Android is ARM Linux) cat < $s s/@inttypes_h_decl@/#include / s/@stdint_h_decl@/#include / s/@stddef_h_decl@/#include / s/@unistd_h_decl@/#include / s/@thread_h_decl@/#include / s/@u_int8_decl@// /@int16_decl@/d s/@u_int16_decl@// /@int32_decl@/d s/@u_int32_decl@// s/@int64_decl@// s/@u_int64_decl@// /@u_char_decl@/d /@u_int_decl@/d /@u_long_decl@/d /@u_short_decl@/d s/@uintmax_t_decl@// s/@uintptr_t_decl@// /@FILE_t_decl@/d /@off_t_decl@/d /@pid_t_decl@/d /@size_t_decl@/d /@ssize_t_decl@/d /@time_t_decl@/d s/@db_seq_decl@/typedef int64_t db_seq_t;/ s/@db_threadid_t_decl@/typedef pthread_t db_threadid_t;/ s/@DB_VERSION_FAMILY@/$DB_VERSION_FAMILY/ s/@DB_VERSION_RELEASE@/$DB_VERSION_RELEASE/ s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/ s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/ s/@DB_VERSION_PATCH@/$DB_VERSION_PATCH/ s/@DB_VERSION_STRING@/"$DB_VERSION_STRING"/ s/@DB_VERSION_FULL_STRING@/"$DB_VERSION_FULL_STRING"/ s/@DB_VERSION_UNIQUE_NAME@// s/@DB_CONST@// s/@DB_PROTO1@/#undef __P/ s/@DB_PROTO2@/#define __P(protos) protos/ /@platform_header@/d /@platform_footer@/d ENDOFSEDTEXT (echo "$msgc" && sed -f $s ../src/dbinc/db.in && cat ../src/dbinc_auto/api_flags.in && cat ../src/dbinc_auto/ext_prot.in) > $t test `egrep '@.*@' $t` && { egrep '@.*@' $t echo 'Unexpanded autoconf variables found in Android db.h.' exit 1 } f=$outdir/db.h cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f) # Build db_int.h from dbinc/db_int.in cat < $s s/@PATH_SEPARATOR@/\// s/@db_int_def@// ENDOFSEDTEXT (echo "$msgc" && sed -f $s ../src/dbinc/db_int.in) > $t test `egrep '@.*@' $t` && { egrep '@.*@' $t echo 'Unexpanded autoconf variables found in Android db_int.h.' exit 1 } f=$outdir/db_int.h cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f) # Build clib_port.h from dist/clib_port.in cat < $s s/@INT64_FMT@/#define INT64_FMT "%lld"/ s/@UINT64_FMT@/#define UINT64_FMT "%llu"/ ENDOFSEDTEXT sed -f $s clib_port.in > $t test `egrep '@.*@' $t` && { egrep '@.*@' $t echo 'Unexpanded autoconf variables found in Android clib_port.h.' exit 1 } f=$outdir/clib_port.h cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f) # Build db_config.h from dist/android/android_config.in # Don't fail, but complain if the android_config.in file isn't up-to-date. check_config() { egrep '^#undef' config.hin | awk '{print $2}' | sort > $s (egrep '#undef' $1 | awk '{print $3}' egrep '^#define' $1 | awk '{print $2}') | sort > $t cmp $s $t > /dev/null || { echo "config.hin and $1 differ" echo "<<< config.hin >>> $1" diff $s $t } } check_config android/android_config.in f=$outdir/db_config.h (echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" android/android_config.in) > $t cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f) # Build sql/config.h from android/sql_config.in f=$outdir/sql/config.h sqlitever=`cat ../lang/sql/sqlite/VERSION` mkdir $outdir/sql >/dev/null 2>&1 # NOTE: the content of sql_config.in is hard-coded based on configuration # on the Android platform (echo "$msgc" && sed -e "s/@SQLITE_VERSION@/$sqlitever/g" android/sql_config.in) > $t cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f) #cleanup rm $androidfilelist rm -f $s $t $u