xref: /freebsd/sys/contrib/dev/acpica/acpica_prep.sh (revision d6b92ffa)
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 accygwin.h acdragonfly.h acdragonflyex.h	\
22	acefi.h acefiex.h achaiku.h acintel.h aclinux.h aclinuxex.h	\
23	acmacosx.h acmsvc.h acmsvcex.h acnetbsd.h acos2.h acqnx.h	\
24	acwin.h acwin64.h acwinex.h dspkginit.c new_table.txt		\
25	osbsdtbl.c osefitbl.c osefixf.c osfreebsdtbl.c oslinuxtbl.c	\
26	osunixdir.c osunixmap.c oswindir.c oswintbl.c oswinxf.c		\
27	readme.txt utclib.c 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 actbl.h actbl1.h actbl2.h	\
36	actbl3.h actypes.h acutils.h acuuid.h amlcode.h amlresrc.h	\
37	platform/acenv.h platform/acenvex.h platform/acfreebsd.h	\
38	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 "    sys/boot sys/conf sys/modules/acpi usr.sbin/acpi"
95