1#!/bin/sh -
2#	$Id: s_s60_posix,v 1.2 2007/07/06 16:29:16 bostic Exp $
3#
4# Build the S60 files on a POSIX system.
5
6s=/tmp/__db_a
7t=/tmp/__db_b
8
9trap 'rm -f $s $t ; exit 0' 0
10trap 'rm -f $s $t ; exit 1' 1 2 3 13 15
11
12# Temporary directory to build in.
13test -d ../build_s60_x || mkdir ../build_s60_x
14
15# Copy in db.h.
16f=../build_s60_x/db.h
17sed -e '/typedef.*[	 ]off_t;/d' \
18    -e '/typedef.*[	 ]time_t;/d' \
19    -e '/typedef.*[	 ]uintptr_t;/d' \
20    < ../build_s60/db.h > $t
21cmp $t $f > /dev/null 2>&1 ||
22    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
23
24# Copy in common files.
25for i in clib_port.h db_config.h db_int.h; do
26	f=../build_s60_x/$i
27	cmp ../build_s60/$i $f > /dev/null 2>&1 ||
28	    (echo "Building $f" &&
29	    rm -f $f && cp ../build_s60/$i $f && chmod 444 $f)
30done
31
32# Build a Makefile for testing on a POSIX system.
33# $1 is srcfiles keyword
34# $2 is Makefile name
35build_make()
36{
37	(cat s60/s60_make.in &&
38	    echo &&
39	    echo '###################################################' &&
40	    echo '# EVERYTHING BELOW THIS LINE GENERATED BY s_s60_posix' &&
41	    echo '##################################################' &&
42	    echo 'OBJS=\' &&
43	    grep -w $1 srcfiles.in |
44	    awk '{print $1}' |
45	    sed -e 's/.*\//	/' \
46		-e 's/\.c$/.o/' \
47		-e '$!s/$/\\/' &&
48	    echo &&
49	    grep -w $1 srcfiles.in |
50	    awk '{print $1}' |
51	    sed -e 's/\.c$//' \
52		-e 's/.*/&.o: ..\/&.c/' \
53		-e 's/^[^\/]*\///' &&
54	    echo &&
55	    echo 'libdb.a: $(OBJS)' &&
56	    echo '	ar cr $@ $(OBJS)') > $t
57
58	f=../build_s60_x/$2
59	cmp $t $f > /dev/null 2>&1 ||
60	    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
61}
62
63build_make s60 Makefile
64
65exit 0
66