1#!/bin/sh -
2#	$Id$
3#
4# Build the S60 files.
5
6msgc="/* DO NOT EDIT: automatically built by dist/s_s60. */"
7
8. RELEASE
9
10s=/tmp/__db_a
11t=/tmp/__db_b
12
13trap 'rm -f $s $t ; exit 0' 0
14trap 'rm -f $s $t ; exit 1' 1 2 3 13 15
15
16# Build the S60 db.h.
17cat <<ENDOFSEDTEXT > $s
18/@inttypes_h_decl@/d
19/@stdint_h_decl@/d
20s/@stddef_h_decl@/#include <stddef.h>/
21/@unistd_h_decl@/d
22s/@thread_h_decl@/#include <pthread.h>/
23/@u_int8_decl@/d
24/@int16_decl@/d
25/@u_int16_decl@/d
26/@int32_decl@/d
27/@u_int32_decl@/d
28/@int64_decl@/d
29/@u_int64_decl@/d
30/@u_char_decl@/d
31/@u_int_decl@/d
32/@u_long_decl@/d
33/@u_short_decl@/d
34s/@uintmax_t_decl@/typedef unsigned long uintmax_t;/
35/@uintptr_t_decl@/d
36/@FILE_t_decl@/d
37/@off_t_decl@/d
38/@pid_t_decl@/d
39/@size_t_decl@/d
40/@ssize_t_decl@/d
41/@time_t_decl@/d
42s/@db_seq_decl@/typedef int32_t db_seq_t;/
43s/@db_threadid_t_decl@/typedef pthread_t db_threadid_t;/
44s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/
45s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/
46s/@DB_VERSION_PATCH@/$DB_VERSION_PATCH/
47s/@DB_VERSION_STRING@/"$DB_VERSION_STRING"/
48s/@DB_VERSION_UNIQUE_NAME@//
49s/@DB_CONST@//
50s/@DB_PROTO1@/#undef __P/
51s/@DB_PROTO2@/#define	__P(protos)	protos/
52/@platform_header@/d
53/@platform_footer@/d
54ENDOFSEDTEXT
55(echo "$msgc" &&
56    sed -f $s ../dbinc/db.in &&
57    cat ../dbinc_auto/api_flags.in &&
58    cat ../dbinc_auto/ext_prot.in) > $t
59test `egrep '@.*@' $t` && {
60	egrep '@.*@' $t
61	echo 'Unexpanded autoconf variables found in S60 db.h.'
62	exit 1
63}
64f=../build_s60/db.h
65cmp $t $f > /dev/null 2>&1 ||
66    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
67
68# Build the S60 db_int.h.
69cat <<ENDOFSEDTEXT > $s
70s/@PATH_SEPARATOR@/\\\\\\\\\/:/
71s/@db_int_def@//
72ENDOFSEDTEXT
73(echo "$msgc" && sed -f $s ../dbinc/db_int.in) > $t
74test `egrep '@.*@' $t` && {
75	egrep '@.*@' $t
76	echo 'Unexpanded autoconf variables found in S60 db_int.h.'
77	exit 1
78}
79f=../build_s60/db_int.h
80cmp $t $f > /dev/null 2>&1 ||
81    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
82
83# Build the S60 db_config.h
84# We don't fail, but we complain if the s60_config.in file isn't up-to-date.
85check_config()
86{
87	egrep '^#undef' config.hin | awk '{print $2}' | sort > $s
88	(egrep '#undef' $1 | awk '{print $3}'
89	 egrep '^#define' $1 | awk '{print $2}') | sort > $t
90	cmp $s $t > /dev/null || {
91		echo "config.hin and $1 differ"
92		echo "<<< config.hin >>> $1"
93		diff $s $t
94	}
95}
96check_config s60/s60_config.in
97f=../build_s60/db_config.h
98(echo "$msgc" &&
99    sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" s60/s60_config.in) > $t
100cmp $t $f > /dev/null 2>&1 ||
101    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
102
103# Build the S60 clib_port.h.
104cat <<ENDOFSEDTEXT > $s
105/@INT64_FMT@/d
106/@UINT64_FMT@/d
107ENDOFSEDTEXT
108sed -f $s clib_port.in > $t
109test `egrep '@.*@' $t` && {
110	egrep '@.*@' $t
111	echo 'Unexpanded autoconf variables found in S60 clib_port.h.'
112	exit 1
113}
114f=../build_s60/clib_port.h
115cmp $t $f > /dev/null 2>&1 ||
116    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
117
118exit 0
119