xref: /freebsd/sys/contrib/dev/acpica/acpica_prep.sh (revision e8e8c939350bdf3c228a411caa9660c607c27a11)
1#!/bin/sh
2# $FreeBSD$
3#
4# Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout
5#
6
7if [ ! $# -eq 1 ]; then
8	echo "usage: $0 acpica_archive"
9	exit
10fi
11
12src=$1
13wrk="$(realpath .)/_acpi_ca_unpack"
14dst="$(realpath .)/acpi_ca_destination"
15
16# files that should keep their full directory path
17fulldirs="common compiler components include os_specific"
18
19# files to remove
20stripdirs="generate libraries tests tools"
21stripfiles="Makefile README accygwin.h acdragonfly.h acdragonflyex.h	\
22	acefi.h acefiex.h achaiku.h acintel.h aclinux.h aclinuxex.h	\
23	acmacosx.h acmsvc.h acnetbsd.h acos2.h acwin.h acwin64.h	\
24	new_table.txt osbsdtbl.c osefitbl.c osefixf.c osfreebsdtbl.c	\
25	oslinuxtbl.c osunixdir.c osunixmap.c oswindir.c oswintbl.c	\
26	oswinxf.c readme.txt utclib.c"
27
28# include files to canonify
29src_headers="acapps.h acbuffer.h acclib.h accommon.h acconfig.h		\
30	acdebug.h acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h	\
31	achware.h acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h	\
32	acobject.h acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h	\
33	acpixf.h acpredef.h acresrc.h acrestyp.h acstruct.h actables.h	\
34	actbl.h actbl1.h actbl2.h actbl3.h actypes.h acutils.h acuuid.h	\
35	amlcode.h amlresrc.h platform/acenv.h platform/acenvex.h	\
36	platform/acfreebsd.h platform/acgcc.h"
37comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h	\
38	aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h"
39platform_headers="acfreebsd.h acgcc.h"
40
41# pre-clean
42echo pre-clean
43rm -rf ${wrk} ${dst}
44mkdir -p ${wrk}
45mkdir -p ${dst}
46
47# unpack
48echo unpack
49tar -x -z -f ${src} -C ${wrk}
50
51# strip files
52echo strip
53for i in ${stripdirs}; do
54	find ${wrk} -name ${i} -type d -print | xargs rm -r
55done
56for i in ${stripfiles}; do
57	find ${wrk} -name ${i} -type f -delete
58done
59
60# copy files
61echo copying full dirs
62for i in ${fulldirs}; do
63	find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst}
64done
65echo copying remaining files
66find ${wrk} -type f -print | xargs -J % mv % ${dst}
67
68# canonify include paths
69for H in ${src_headers}; do
70	find ${dst} -name "*.[chly]" -type f -print |	\
71	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g"
72done
73for H in ${comp_headers}; do
74	find ${dst}/common ${dst}/compiler ${dst}/components \
75	    -name "*.[chly]" -type f |	\
76	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g"
77done
78for H in ${platform_headers}; do
79	find ${dst}/include/platform -name "*.h" -type f -print |	\
80	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g"
81done
82
83# post-clean
84echo post-clean
85rm -rf ${wrk}
86
87# assist the developer in generating a diff
88echo "Directories you may want to 'svn diff':"
89echo "    sys/contrib/dev/acpica sys/dev/acpica \\"
90echo "    sys/amd64/acpica sys/i386/acpica sys/x86/acpica \\"
91echo "    sys/amd64/include sys/i386/include include \\"
92echo "    sys/boot sys/conf sys/modules/acpi usr.sbin/acpi"
93