prepare-import.sh revision 1.2 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
19 set -e
20
21 if [ ! -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 (at] pcc.ludd.ltu.se:/cvsroot -f checkout -P -d work -N pcc pcc-libs"
25 echo ""
26 exit 1
27 fi
28
29 echo "====> Removing pcc CVS directories..."
30 find work -type d -name CVS | xargs rm -Rf
31
32 echo "====> Fixing file and directory permissions..."
33 find work -type d -exec chmod u=rwx,go=rx {} \;
34 find work -type f -exec chmod u=rw,go=r {} \;
35
36 echo "====> Fixing RCS tags..."
37 # fix existing RCS tags, and insert blank NetBSD tags
38 for 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}
45 done
46
47 echo "====> Creating pcc \"config.h\" file..."
48 mkdir work/tmp
49 cd work/tmp
50 sh ../pcc/configure
51 cd ../..
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 #
57 datestamp=$(cat work/pcc/DATESTAMP)
58 sed -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
67 echo "====> Replacing pcc sources..."
68 rm -Rf dist/pcc dist/pcc-libs
69 mv work/pcc work/pcc-libs dist
70 if cmp -s work/config.h include/config.h; then :; else
71 echo "====> Updating include/config.h..."
72 mv work/config.h include/config.h
73 fi
74
75 echo "====> Done."
76 rm -Rf work
77
78 echo ""
79 echo "after testing, use the following command to import from the dist directory,"
80 echo ""
81 echo " cvs import src/external/bsd/pcc/dist ragge pcc-${datestamp}"
82 echo ""
83 echo "providing a ChangeLog in the commit message."
84