acpica_prep.sh revision 151946
190380Smsmith#!/bin/sh
290380Smsmith# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 151946 2005-11-01 22:38:50Z jkim $
390380Smsmith#
490380Smsmith# Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout
590380Smsmith#
690380Smsmith
798146Siwasakiif [ ! $# -eq 1 ]; then
898146Siwasaki	echo "usage: $0 acpica_archive"
998146Siwasaki	exit
1098146Siwasakifi
1198146Siwasaki
1290380Smsmithsrc=$1
1390380Smsmithwrk=./_acpi_ca_unpack
1490380Smsmithdst=./acpi_ca_destination
1590380Smsmith
16123333Snjl# files that should keep their full directory path
17123333Snjlfulldirs="common compiler"
1890380Smsmith# files to remove
19123333Snjlstripdirs="generate acpisrc"
20151946Sjkimstripfiles="16bit.h Makefile README a16find.c a16utils.asm		\
21151946Sjkim	a16utils.lst a16utils.obj abcompare.c abmain.c acdos16.h	\
22151946Sjkim	acintel.h aclinux.h acmsvc.h acnetbsd.h acpibin.h acwin.h	\
23151946Sjkim	acwin64.h adisasm.h aemain.c osunixdir.c readme.txt"
24151946Sjkim# include files to canonify
25151946Sjkimsrc_headers="acapps.h acconfig.h acdebug.h acdisasm.h acdispat.h	\
26151946Sjkim	acenv.h	acevents.h acexcep.h acfreebsd.h acgcc.h acglobal.h	\
27151946Sjkim	achware.h acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h	\
28151946Sjkim	acobject.h acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h	\
29151946Sjkim	acpixf.h acresrc.h acstruct.h actables.h actbl.h actbl1.h	\
30151946Sjkim	actbl2.h actypes.h acutils.h aecommon.h amlcode.h amlresrc.h	\
31151946Sjkim	mlresrc.h"
32151946Sjkimcomp_headers="aslcompiler.h asldefine.h aslglobal.h asltypes.h"
33123333Snjl	
34114244Snjl# files to update paths in
35114244Snjlsrc_update_files="acpi.h acpiosxf.h"
3690380Smsmith
3790380Smsmith# pre-clean
3890380Smsmithecho pre-clean
3990380Smsmithrm -rf ${wrk}
4090380Smsmithrm -rf ${dst}
4190380Smsmithmkdir -p ${wrk}
4290380Smsmithmkdir -p ${dst}
4390380Smsmith
4490380Smsmith# unpack
4590380Smsmithecho unpack
4690380Smsmithtar -x -z -f ${src} -C ${wrk}
4790380Smsmith
4890380Smsmith# strip files
4990380Smsmithecho strip
5090380Smsmithfor i in ${stripdirs}; do
51151946Sjkim	find ${wrk} -name ${i} -type d | xargs rm -r
5290380Smsmithdone
5390380Smsmithfor i in ${stripfiles}; do
54151946Sjkim	find ${wrk} -name ${i} -type f -delete
5590380Smsmithdone
5690380Smsmith
57123333Snjlecho copying full dirs
58123333Snjlfor i in ${fulldirs}; do
59123333Snjl    find ${wrk} -name ${i} -type d | xargs -J % mv % ${dst}
60123333Snjldone
61123333Snjl
6290380Smsmith# move files to destination
63123333Snjlecho copying flat dirs
6490380Smsmithfind ${wrk} -type f | xargs -J % mv % ${dst}
65151946Sjkimmv ${dst}/changes.txt ${dst}/CHANGES.txt
6690380Smsmith
67114244Snjl# update src/headers for appropriate paths
68114244Snjlecho updating paths
69114244Snjlfor i in ${src_update_files}; do
70151946Sjkim	i=${dst}/$i
71151946Sjkim	sed -e 's/platform\///' $i > $i.new && mv $i.new $i
72114244Snjldone
73114244Snjl
74151604Sobrien# canonify include paths
75151946Sjkimfor H in ${src_headers}; do
76151946Sjkim	find ${dst} -name "*.[chy]" -type f |	\
77151946Sjkim	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/$H\>|g"
78151946Sjkimdone
79151946Sjkimfor H in ${comp_headers}; do
80151946Sjkim	find ${dst}/compiler -name "*.[chly]" -type f |	\
81151946Sjkim	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g"
82151946Sjkimdone
83151604Sobrien
8490380Smsmith# post-clean
8590380Smsmithecho post-clean
8698146Siwasakirm -rf ${wrk}
87114244Snjl
88114244Snjl# assist the developer in generating a diff
89114244Snjlecho "Directories you may want to 'cvs diff':"
90151946Sjkimecho "    src/sys/contrib/dev/acpica src/sys/dev/acpica \\"
91151946Sjkimecho "    src/sys/amd64/acpica src/sys/i386/acpica src/sys/ia64/acpica \\"
92151946Sjkimecho "    src/sys/amd64/include src/sys/i386/include src/sys/ia64/include \\"
93151946Sjkimecho "    src/sys/boot src/sys/conf src/sys/modules/acpi src/usr.sbin/acpi"
94