s_s60_posix   [plain text]


#!/bin/sh -
#	$Id: s_s60_posix,v 1.2 2007/07/06 16:29:16 bostic Exp $
#
# Build the S60 files on a POSIX system.

s=/tmp/__db_a
t=/tmp/__db_b

trap 'rm -f $s $t ; exit 0' 0
trap 'rm -f $s $t ; exit 1' 1 2 3 13 15

# Temporary directory to build in.
test -d ../build_s60_x || mkdir ../build_s60_x

# Copy in db.h.
f=../build_s60_x/db.h
sed -e '/typedef.*[	 ]off_t;/d' \
    -e '/typedef.*[	 ]time_t;/d' \
    -e '/typedef.*[	 ]uintptr_t;/d' \
    < ../build_s60/db.h > $t
cmp $t $f > /dev/null 2>&1 ||
    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)

# Copy in common files.
for i in clib_port.h db_config.h db_int.h; do
	f=../build_s60_x/$i
	cmp ../build_s60/$i $f > /dev/null 2>&1 ||
	    (echo "Building $f" &&
	    rm -f $f && cp ../build_s60/$i $f && chmod 444 $f)
done

# Build a Makefile for testing on a POSIX system.
# $1 is srcfiles keyword
# $2 is Makefile name
build_make()
{
	(cat s60/s60_make.in &&
	    echo &&
	    echo '###################################################' &&
	    echo '# EVERYTHING BELOW THIS LINE GENERATED BY s_s60_posix' &&
	    echo '##################################################' &&
	    echo 'OBJS=\' &&
	    grep -w $1 srcfiles.in |
	    awk '{print $1}' |
	    sed -e 's/.*\//	/' \
		-e 's/\.c$/.o/' \
		-e '$!s/$/\\/' &&
	    echo &&
	    grep -w $1 srcfiles.in |
	    awk '{print $1}' |
	    sed -e 's/\.c$//' \
		-e 's/.*/&.o: ..\/&.c/' \
		-e 's/^[^\/]*\///' &&
	    echo &&
	    echo 'libdb.a: $(OBJS)' &&
	    echo '	ar cr $@ $(OBJS)') > $t

	f=../build_s60_x/$2
	cmp $t $f > /dev/null 2>&1 ||
	    (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
}

build_make s60 Makefile

exit 0