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