acpica_prep.sh revision 231844
11590Srgrimes#!/bin/sh
21590Srgrimes# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 231844 2012-02-16 22:59:29Z jkim $
31590Srgrimes#
41590Srgrimes# Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout
51590Srgrimes#
61590Srgrimes
71590Srgrimesif [ ! $# -eq 1 ]; then
81590Srgrimes	echo "usage: $0 acpica_archive"
91590Srgrimes	exit
101590Srgrimesfi
111590Srgrimes
121590Srgrimessrc=$1
131590Srgrimeswrk=`realpath ./_acpi_ca_unpack`
141590Srgrimesdst=`realpath ./acpi_ca_destination`
151590Srgrimes
161590Srgrimes# files that should keep their full directory path
171590Srgrimesfulldirs="common compiler components include os_specific"
181590Srgrimes
191590Srgrimes# files to remove
201590Srgrimesstripdirs="generate libraries tests tools"
211590Srgrimesstripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h	\
221590Srgrimes	acos2.h accygwin.h acefi.h acwin.h acwin64.h osunixdir.c	\
231590Srgrimes	oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c"
241590Srgrimes
251590Srgrimes# include files to canonify
261590Srgrimessrc_headers="acapps.h accommon.h acconfig.h acdebug.h acdisasm.h	\
271590Srgrimes	acdispat.h acevents.h acexcep.h acglobal.h achware.h acinterp.h	\
281590Srgrimes	aclocal.h acmacros.h acnames.h acnamesp.h acobject.h acopcode.h	\
291590Srgrimes	acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h acpredef.h	\
301590Srgrimes	acresrc.h acrestyp.h acstruct.h actables.h actbl.h actbl1.h	\
311590Srgrimes	actbl2.h actbl3.h actypes.h acutils.h amlcode.h amlresrc.h	\
321590Srgrimes	platform/acenv.h platform/acfreebsd.h platform/acgcc.h"
331590Srgrimescomp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h	\
3487628Sdwmalone	asltypes.h dtcompiler.h dttemplate.h"
351590Srgrimesplatform_headers="acfreebsd.h acgcc.h"
361590Srgrimes
3728625Ssteve# pre-clean
3887628Sdwmaloneecho pre-clean
391590Srgrimesrm -rf ${wrk} ${dst}
4087628Sdwmalonemkdir -p ${wrk}
4187628Sdwmalonemkdir -p ${dst}
4287628Sdwmalone
431590Srgrimes# unpack
441590Srgrimesecho unpack
451590Srgrimestar -x -z -f ${src} -C ${wrk}
461590Srgrimes
471590Srgrimes# strip files
481590Srgrimesecho strip
491590Srgrimesfor i in ${stripdirs}; do
501590Srgrimes	find ${wrk} -name ${i} -type d -print | xargs rm -r
511590Srgrimesdone
521590Srgrimesfor i in ${stripfiles}; do
531590Srgrimes	find ${wrk} -name ${i} -type f -delete
541590Srgrimesdone
551590Srgrimes
561590Srgrimes# copy files
571590Srgrimesecho copying full dirs
581590Srgrimesfor i in ${fulldirs}; do
591590Srgrimes	find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst}
601590Srgrimesdone
611590Srgrimesecho copying remaining files
621590Srgrimesfind ${wrk} -type f -print | xargs -J % mv % ${dst}
631590Srgrimes
641590Srgrimes# canonify include paths
651590Srgrimesfor H in ${src_headers}; do
661590Srgrimes	find ${dst} -name "*.[chly]" -type f -print |	\
671590Srgrimes	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g"
681590Srgrimesdone
691590Srgrimesfor H in ${comp_headers}; do
701590Srgrimes	find ${dst}/common ${dst}/compiler -name "*.[chly]" -type f |	\
711590Srgrimes	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g"
721590Srgrimesdone
731590Srgrimesfor H in ${platform_headers}; do
741590Srgrimes	find ${dst}/include/platform -name "*.h" -type f -print |	\
751590Srgrimes	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g"
761590Srgrimesdone
771590Srgrimes
781590Srgrimes# post-clean
791590Srgrimesecho post-clean
801590Srgrimesrm -rf ${wrk}
811590Srgrimes
821590Srgrimes# assist the developer in generating a diff
831590Srgrimesecho "Directories you may want to 'svn diff':"
841590Srgrimesecho "    sys/contrib/dev/acpica sys/dev/acpica \\"
851590Srgrimesecho "    sys/amd64/acpica sys/i386/acpica sys/ia64/acpica sys/x86/acpica \\"
861590Srgrimesecho "    sys/amd64/include sys/i386/include sys/ia64/include \\"
871590Srgrimesecho "    sys/boot sys/conf sys/modules/acpi usr.sbin/acpi"
881590Srgrimes