acpica_prep.sh revision 252279
11590Srgrimes#!/bin/sh
21590Srgrimes# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 252279 2013-06-27 00:16:54Z 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 accygwin.h acefi.h achaiku.h acintel.h	\
221590Srgrimes	aclinux.h acmacosx.h acmsvc.h acnetbsd.h acos2.h acwin.h	\
231590Srgrimes	acwin64.h new_table.txt osfreebsdtbl.c oslinuxtbl.c osunixdir.c	\
241590Srgrimes	oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c"
251590Srgrimes
261590Srgrimes# include files to canonify
271590Srgrimessrc_headers="acapps.h acbuffer.h accommon.h acconfig.h acdebug.h	\
281590Srgrimes	acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h achware.h	\
291590Srgrimes	acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h acobject.h	\
301590Srgrimes	acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h	\
311590Srgrimes	acpredef.h acresrc.h acrestyp.h acstruct.h actables.h actbl.h	\
321590Srgrimes	actbl1.h actbl2.h actbl3.h actypes.h acutils.h amlcode.h	\
331590Srgrimes	amlresrc.h platform/acenv.h platform/acfreebsd.h		\
341590Srgrimes	platform/acgcc.h"
3554162Scharniercomp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h	\
3654162Scharnier	aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h"
3754162Scharnierplatform_headers="acfreebsd.h acgcc.h"
381590Srgrimes
3999112Sobrien# pre-clean
4099112Sobrienecho pre-clean
411590Srgrimesrm -rf ${wrk} ${dst}
421590Srgrimesmkdir -p ${wrk}
43112212Srobertmkdir -p ${dst}
441590Srgrimes
45200462Sdelphij# unpack
461590Srgrimesecho unpack
4787212Smarkmtar -x -z -f ${src} -C ${wrk}
4887212Smarkm
491590Srgrimes# strip files
50112212Srobertecho strip
511590Srgrimesfor i in ${stripdirs}; do
52112212Srobert	find ${wrk} -name ${i} -type d -print | xargs rm -r
5387212Smarkmdone
54112212Srobertfor i in ${stripfiles}; do
5587212Smarkm	find ${wrk} -name ${i} -type f -delete
561590Srgrimesdone
571590Srgrimes
581590Srgrimes# copy files
591590Srgrimesecho copying full dirs
601590Srgrimesfor i in ${fulldirs}; do
611590Srgrimes	find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst}
621590Srgrimesdone
6387212Smarkmecho copying remaining files
641590Srgrimesfind ${wrk} -type f -print | xargs -J % mv % ${dst}
6587212Smarkm
661590Srgrimes# canonify include paths
671590Srgrimesfor H in ${src_headers}; do
6887212Smarkm	find ${dst} -name "*.[chly]" -type f -print |	\
691590Srgrimes	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g"
70112212Srobertdone
711590Srgrimesfor H in ${comp_headers}; do
7287212Smarkm	find ${dst}/common ${dst}/compiler ${dst}/components \
7387212Smarkm	    -name "*.[chly]" -type f |	\
741590Srgrimes	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g"
7587212Smarkmdone
761590Srgrimesfor H in ${platform_headers}; do
77112212Srobert	find ${dst}/include/platform -name "*.h" -type f -print |	\
781590Srgrimes	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g"
79done
80
81# post-clean
82echo post-clean
83rm -rf ${wrk}
84
85# assist the developer in generating a diff
86echo "Directories you may want to 'svn diff':"
87echo "    sys/contrib/dev/acpica sys/dev/acpica \\"
88echo "    sys/amd64/acpica sys/i386/acpica sys/ia64/acpica sys/x86/acpica \\"
89echo "    sys/amd64/include sys/i386/include sys/ia64/include \\"
90echo "    sys/boot sys/conf sys/modules/acpi usr.sbin/acpi"
91