xref: /freebsd/sys/contrib/dev/acpica/acpica_prep.sh (revision 3c4ba5f55438f7afd4f4b0b56f88f2bb505fd6a6)
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 parsers preprocessor tests tools"
21stripfiles="Makefile README aslcompiler.y accygwin.h acdragonfly.h	\
22	acdragonflyex.h acefi.h acefiex.h achaiku.h acintel.h aclinux.h	\
23	aclinuxex.h acmacosx.h acmsvc.h acmsvcex.h acnetbsd.h acos2.h	\
24	acqnx.h acwin.h acwin64.h acwinex.h new_table.txt osbsdtbl.c	\
25	osefitbl.c osefixf.c osfreebsdtbl.c oslinuxtbl.c osunixdir.c	\
26	osunixmap.c oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c	\
27	utprint.c"
28
29# include files to canonify
30src_headers="acapps.h acbuffer.h acclib.h accommon.h acconfig.h		\
31	acconvert.h acdebug.h acdisasm.h acdispat.h acevents.h		\
32	acexcep.h acglobal.h achware.h acinterp.h aclocal.h acmacros.h	\
33	acnames.h acnamesp.h acobject.h acopcode.h acoutput.h		\
34	acparser.h acpi.h acpiosxf.h acpixf.h acpredef.h acresrc.h	\
35	acrestyp.h acstruct.h actables.h actbinfo.h actbl.h actbl1.h	\
36	actbl2.h actbl3.h actypes.h acutils.h acuuid.h amlcode.h	\
37	amlresrc.h platform/acenv.h platform/acenvex.h			\
38	platform/acfreebsd.h platform/acgcc.h"
39comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h	\
40	aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h"
41platform_headers="acfreebsd.h acgcc.h"
42
43# pre-clean
44echo pre-clean
45rm -rf ${wrk} ${dst}
46mkdir -p ${wrk}
47mkdir -p ${dst}
48
49# unpack
50echo unpack
51tar -x -z -f ${src} -C ${wrk}
52
53# strip files
54echo strip
55for i in ${stripdirs}; do
56	find ${wrk} -name ${i} -type d -print | xargs rm -r
57done
58for i in ${stripfiles}; do
59	find ${wrk} -name ${i} -type f -delete
60done
61
62# copy files
63echo copying full dirs
64for i in ${fulldirs}; do
65	find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst}
66done
67echo copying remaining files
68find ${wrk} -type f -print | xargs -J % mv % ${dst}
69
70# canonify include paths
71for H in ${src_headers}; do
72	find ${dst} -name "*.[chly]" -type f -print |	\
73	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g"
74done
75for H in ${comp_headers}; do
76	find ${dst}/common ${dst}/compiler ${dst}/components \
77	    -name "*.[chly]" -type f |	\
78	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g"
79done
80for H in ${platform_headers}; do
81	find ${dst}/include/platform -name "*.h" -type f -print |	\
82	xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g"
83done
84
85# post-clean
86echo post-clean
87rm -rf ${wrk}
88
89# assist the developer in generating a diff
90echo "Directories you may want to 'svn diff':"
91echo "    sys/contrib/dev/acpica sys/dev/acpica \\"
92echo "    sys/amd64/acpica sys/arm64/acpica sys/i386/acpica sys/x86/acpica \\"
93echo "    sys/amd64/include sys/arm64/include sys/i386/include include \\"
94echo "    stand sys/conf sys/modules/acpi usr.sbin/acpi"
95