xref: /netbsd/external/bsd/pcc/prepare-import.sh (revision 6550d01e)
1#!/bin/sh -x
2#
3#	prepare pcc distribution for import
4#
5# pcc can be built as part of the toolchain by setting
6#
7#	HAVE_PCC=yes
8#
9# and as a native binary for a release build by setting
10#
11#	MKPCC=yes
12#	MKPCCCMDS=yes
13#
14
15#
16# TODO
17# - some files only have NetBSD tags to start with, they end up with none
18
19set -e
20
21if [ ! -d work -o ! -d work/pcc -o ! -d work/pcc-libs ]; then
22	echo "checkout or unpack pcc and pcc-libs to work/ first, eg"
23	echo ""
24	echo "    cvs -d :pserver:anonymous@pcc.ludd.ltu.se:/cvsroot -f checkout -P -d work -N pcc pcc-libs"
25	echo ""
26	exit 1
27fi
28
29echo "====> Removing pcc CVS directories..."
30find work -type d -name CVS | xargs rm -Rf
31
32echo "====> Fixing file and directory permissions..."
33find work -type d -exec chmod u=rwx,go=rx {} \;
34find work -type f -exec chmod u=rw,go=r {} \;
35
36echo "====> Fixing RCS tags..."
37# fix existing RCS tags, and insert blank NetBSD tags
38for f in $(grep -RL '\$(NetBSD|Id).*\$' work); do
39    sed -e '/\$NetBSD\$/d'				\
40	-e 's,\$\(NetBSD[[:>:]].*\)\$,\1,'		\
41	-e 's,\(.*\)\$\(Id[[:>:]].*\)\$\(.*\),\1\2\3	\
42\1\$NetBSD\$\3,'					\
43	< ${f} > ${f}_tmp
44    mv ${f}_tmp ${f}
45done
46
47echo "====> Creating pcc \"config.h\" file..."
48mkdir work/tmp
49cd work/tmp
50sh ../pcc/configure
51cd ../..
52#
53# comment out items we provide at build time from Makefile.inc
54# modify the PACKAGE_STRING to include the checkout date
55# define PREPROCESSOR as pcpp to avoid conflicts with GCC
56#
57datestamp=$(cat work/pcc/DATESTAMP)
58sed -e "s,^\(#define[[:space:]]*VERSSTR[[:>:]].*\)\$,/* \1 */,"					\
59    -e "s,^\(#define[[:space:]]*HOST_BIG_ENDIAN[[:>:]].*\)\$,/* \1 */,"				\
60    -e "s,^\(#define[[:space:]]*HOST_LITTLE_ENDIAN[[:>:]].*\)\$,/* \1 */,"			\
61    -e "s,^\(#define[[:space:]]*TARGET_BIG_ENDIAN[[:>:]].*\)\$,/* \1 */,"			\
62    -e "s,^\(#define[[:space:]]*TARGET_LITTLE_ENDIAN[[:>:]].*\)\$,/* \1 */,"			\
63    -e "s,^\(#define[[:space:]]*PACKAGE_STRING[[:>:]].*\".*\)\(\".*\)\$,\1 [${datestamp}]\2,"	\
64    -e "s,^\(.*[[:<:]]PREPROCESSOR[[:>:]].*\)\$,#define PREPROCESSOR \"pcpp\","			\
65    < work/tmp/config.h > work/config.h
66
67echo "====> Replacing pcc sources..."
68rm -Rf dist/pcc dist/pcc-libs
69mv work/pcc work/pcc-libs dist
70if cmp -s work/config.h include/config.h; then :; else
71    echo "====> Updating include/config.h..."
72    mv work/config.h include/config.h
73fi
74
75echo "====> Done."
76rm -Rf work
77
78echo ""
79echo "after testing, use the following command to import from the dist directory,"
80echo ""
81echo "    cvs import src/external/bsd/pcc/dist ragge pcc-${datestamp}"
82echo ""
83echo "providing a ChangeLog in the commit message."
84