#!/bin/sh if test $Argc -lt 2 { echo "Usage: headers_install.sh OUTDIR SRCDIR [FILES...]" echo echo "Prepares kernel header files for use by user space, by removing" echo "all compiler.h definitions and #includes, removing any" echo "#ifdef __KERNEL__ sections, and putting __underscores__ around" echo "asm/inline/volatile keywords." echo echo "OUTDIR: directory to write each userspace header FILE to." echo "SRCDIR: source directory where files are picked." echo "FILES: list of header files to operate on." exit 1 } # Grab arguments global OUTDIR := $1 shift global SRCDIR := $1 shift # Iterate through files listed on command line global FILE := '' trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT for i in [@Argv] { global FILE := $[basename $i] sed -r \ -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \ -e 's/__attribute_const__([ \t]|$)/\1/g' \ -e 's@^#include @@' \ -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ > "$OUTDIR/$FILE" test $Status -gt 1 && exit 1 rm -f "$OUTDIR/$FILE.sed" } trap - EXIT (CommandList children: [ (If arms: [ (if_arm cond: [(C {(Lit_Other "[")} {($ VSub_Pound "$#")} {(-lt)} {(2)} {(Lit_Other "]")})] action: [ (C {(echo)} {(DQ ("Usage: headers_install.sh OUTDIR SRCDIR [FILES...]"))}) (C {(echo)}) (C {(echo)} {(DQ ("Prepares kernel header files for use by user space, by removing"))}) (C {(echo)} {(DQ ("all compiler.h definitions and #includes, removing any"))}) (C {(echo)} {(DQ ("#ifdef __KERNEL__ sections, and putting __underscores__ around"))}) (C {(echo)} {(DQ ("asm/inline/volatile keywords."))}) (C {(echo)}) (C {(echo)} {(DQ ("OUTDIR: directory to write each userspace header FILE to."))}) (C {(echo)} {(DQ ("SRCDIR: source directory where files are picked."))}) (C {(echo)} {(DQ ("FILES: list of header files to operate on."))}) (C {(exit)} {(1)}) ] spids: [-1 16] ) ] spids: [-1 86] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OUTDIR) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [93] ) ] spids: [93] ) (C {(shift)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SRCDIR) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [100] ) ] spids: [100] ) (C {(shift)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:FILE) op:Equal rhs:{(SQ )} spids:[112])] spids: [112] ) (C {(trap)} {(SQ <"rm -f \"$OUTDIR/$FILE\" \"$OUTDIR/$FILE.sed\"">)} {(EXIT)}) (ForEach iter_name: i iter_words: [{(DQ ($ VSub_At "$@"))}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FILE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(basename)} {(DQ ($ VSub_Name "$i"))})] ) left_token: spids: [137 143] ) ) } spids: [135] ) ] spids: [135] ) (AndOr children: [ (SimpleCommand words: [ {(sed)} {(-r)} {(-e)} {(SQ <"s/([ \\t(])(__user|__force|__iomem)[ \\t]/\\1/g">)} {(-e)} {(SQ <"s/__attribute_const__([ \\t]|$)/\\1/g">)} {(-e)} {(SQ <"s@^#include @@">)} {(-e)} { (SQ < "s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\\1__attribute__((packed))\\2/g" > ) } {(-e)} {(SQ <"s/(^|[ \\t(])(inline|asm|volatile)([ \\t(]|$)/\\1__\\2__\\3/g">)} {(-e)} {(SQ <"s@#(ifndef|define|endif[ \\t]*/[*])[ \\t]*_UAPI@#\\1 @">)} {(DQ ($ VSub_Name "$SRCDIR") (/) ($ VSub_Name "$i"))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$OUTDIR") (/) ($ VSub_Name "$FILE") (.sed))} spids: [207] ) ] ) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (SimpleCommand words: [ {(scripts/unifdef)} {(-U__KERNEL__)} {(-D__EXPORTED_HEADERS__)} {(DQ ($ VSub_Name "$OUTDIR") (/) ($ VSub_Name "$FILE") (.sed))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$OUTDIR") (/) ($ VSub_Name "$FILE"))} spids: [238] ) ] ) (AndOr children: [ (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-gt)} {(1)} {(Lit_Other "]")}) (C {(exit)} {(1)}) ] op_id: Op_DAmp ) (C {(rm)} {(-f)} {(DQ ($ VSub_Name "$OUTDIR") (/) ($ VSub_Name "$FILE") (.sed))}) ] spids: [132 275] ) spids: [127 -1] ) (C {(trap)} {(-)} {(EXIT)}) ] )