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
createAndroidMk()
{
echo "# DO NOT EDIT: automatically built by dist/s_android."
rm -f $u
for file in `cat $androidfilelist`
do echo " \$(BDB_TOP)/$file \\" >> $u
done
sed -e "/@SOURCE_FILES@/r$u" -e "/@SOURCE_FILES@/d" < $mk_template
rm -f $u
}
sed -e '/^$/d' -e '/^[ #]/d' srcfiles.in |
egrep -w android |
sed 's/[ ].*//' > $androidfilelist
for mode in "drop-in" "jdbc"
do
if [ "$mode" = "drop-in" ]; then
mk_outdir=../build_android
mk_template=android/Android.mk.template
elif [ "$mode" = "jdbc" ]; then
mk_outdir=../build_android/jdbc/jni
mk_template=android/jdbc/Android.mk.template
else
echo "Unknown mode $mode"
exit 1
fi
createAndroidMk | sed -e "s/@DB_VERSION@/$DB_VERSION/g" \
-e "s/@DB_VERSION_FULL_STRING@/$DB_VERSION_FULL_STRING/g" > $t
f=$mk_outdir/Android.mk
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f)
done
cat <<ENDOFSEDTEXT > $s
s/@inttypes_h_decl@/#include <inttypes.h>/
s/@stdint_h_decl@/#include <stdint.h>/
s/@stddef_h_decl@/#include <stddef.h>/
s/@unistd_h_decl@/#include <unistd.h>/
s/@thread_h_decl@/#include <pthread.h>/
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)
cat <<ENDOFSEDTEXT > $s
s/@DB_STRUCT_ALIGN8@//
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)
cat <<ENDOFSEDTEXT > $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)
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)
f=$outdir/sql/config.h
sqlitever=`cat ../lang/sql/sqlite/VERSION`
mkdir $outdir/sql >/dev/null 2>&1
(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)
rm $androidfilelist
rm -f $s $t $u