acpica_prep.sh revision 213806
190380Smsmith#!/bin/sh
290380Smsmith# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 213806 2010-10-13 21:37:02Z 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
13193529Sjkimwrk=`realpath ./_acpi_ca_unpack`
14193529Sjkimdst=`realpath ./acpi_ca_destination`
1590380Smsmith
16123333Snjl# files that should keep their full directory path
17193529Sjkimfulldirs="common compiler debugger disassembler dispatcher events	\
18193529Sjkim	executer hardware include namespace parser resources tables	\
19193529Sjkim	tools utilities"
20193529Sjkim
2190380Smsmith# files to remove
22207344Sjkimstripdirs="acpisrc acpixtract examples generate os_specific tests"
23193529Sjkimstripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h	\
24197104Sjkim	acos2.h accygwin.h acefi.h acwin.h acwin64.h aeexec.c		\
25213806Sjkim	aehandlers.c aemain.c aetables.c aetables.h osunixdir.c		\
26213806Sjkim	readme.txt utclib.c"
27193529Sjkim
28151946Sjkim# include files to canonify
29193529Sjkimsrc_headers="acapps.h accommon.h acconfig.h acdebug.h acdisasm.h	\
30193529Sjkim	acdispat.h acevents.h acexcep.h acglobal.h achware.h acinterp.h	\
31193529Sjkim	aclocal.h acmacros.h acnames.h acnamesp.h acobject.h acopcode.h	\
32193529Sjkim	acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h acpredef.h	\
33193529Sjkim	acresrc.h acrestyp.h acstruct.h actables.h actbl.h actbl1.h	\
34197104Sjkim	actbl2.h actypes.h acutils.h amlcode.h amlresrc.h		\
35197104Sjkim	platform/acenv.h platform/acfreebsd.h platform/acgcc.h"
36213806Sjkimcomp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h	\
37213806Sjkim	asltypes.h dtcompiler.h dttemplate.h"
38193529Sjkimplatform_headers="acfreebsd.h acgcc.h"
3990380Smsmith
4090380Smsmith# pre-clean
4190380Smsmithecho pre-clean
42193529Sjkimrm -rf ${wrk} ${dst}
4390380Smsmithmkdir -p ${wrk}
4490380Smsmithmkdir -p ${dst}
4590380Smsmith
4690380Smsmith# unpack
4790380Smsmithecho unpack
4890380Smsmithtar -x -z -f ${src} -C ${wrk}
4990380Smsmith
5090380Smsmith# strip files
5190380Smsmithecho strip
5290380Smsmithfor i in ${stripdirs}; do
53209746Sjkim	find ${wrk} -name ${i} -type d -print | xargs rm -r
5490380Smsmithdone
5590380Smsmithfor i in ${stripfiles}; do
56151946Sjkim	find ${wrk} -name ${i} -type f -delete
5790380Smsmithdone
5890380Smsmith
59193529Sjkim# copy files
60123333Snjlecho copying full dirs
61123333Snjlfor i in ${fulldirs}; do
62209746Sjkim	find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst}
63123333Snjldone
64193529Sjkimecho copying remaining files
65209746Sjkimfind ${wrk} -type f -print | xargs -J % mv % ${dst}
6690380Smsmith
67151604Sobrien# canonify include paths
68151946Sjkimfor H in ${src_headers}; do
69209746Sjkim	find ${dst} -name "*.[chy]" -type f -print |	\
70193529Sjkim	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g"
71151946Sjkimdone
72151946Sjkimfor H in ${comp_headers}; do
73209746Sjkim	find ${dst}/common ${dst}/compiler -name "*.[chly]" -type f |	\
74151946Sjkim	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g"
75151946Sjkimdone
76193529Sjkimfor H in ${platform_headers}; do
77209746Sjkim	find ${dst}/include/platform -name "*.h" -type f -print |	\
78193529Sjkim	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g"
79193529Sjkimdone
80151604Sobrien
8190380Smsmith# post-clean
8290380Smsmithecho post-clean
8398146Siwasakirm -rf ${wrk}
84114244Snjl
85114244Snjl# assist the developer in generating a diff
86114244Snjlecho "Directories you may want to 'cvs diff':"
87151946Sjkimecho "    src/sys/contrib/dev/acpica src/sys/dev/acpica \\"
88151946Sjkimecho "    src/sys/amd64/acpica src/sys/i386/acpica src/sys/ia64/acpica \\"
89151946Sjkimecho "    src/sys/amd64/include src/sys/i386/include src/sys/ia64/include \\"
90151946Sjkimecho "    src/sys/boot src/sys/conf src/sys/modules/acpi src/usr.sbin/acpi"
91