File: s_android

package info (click to toggle)
db5.3 5.3.28%2Bdfsg1-0.5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 158,360 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,326; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (195 lines) | stat: -rwxr-xr-x 5,780 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/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" < $mk_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

for mode in "drop-in" "jdbc"
do
    # Generate "drop-in" make file on build_android/
    # Generate "JDBC" make file on build_android/jdbc/jni. The name "jni" 
    # is required by Android ndk toolchain.
    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

    # 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=$mk_outdir/Android.mk
    cmp $t $f > /dev/null 2>&1 ||
        (echo "Building $f" && rm -f $f && cp $t $f)
done

# 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 <<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)

# Build db_int.h from dbinc/db_int.in
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)

# Build clib_port.h from dist/clib_port.in
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)

# 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