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