3 # Copyright (c) 2006 "David Kirchner" <dpk@dpk.net>. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # Generates tables_linux.h
33 LC_ALL=C; export LC_ALL
37 echo "usage: sh $0 include-dir [output-file]"
43 output_tmp=$(mktemp -u)
49 # Generate a table C #definitions. The including file can define the
50 # TABLE_NAME(n), TABLE_ENTRY(x), and TABLE_END macros to define what
55 local name grep file excl filter
61 if [ -z "$excl" ]; then
69 if [ -e "${include_dir}/${file}" ]; then
70 all_headers="${all_headers:+${all_headers} }${file}"
71 egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
72 $include_dir/$file | ${filter} ${excl} | \
73 awk '{ for (i = 1; i <= NF; i++) \
77 sub(/LINUX_/, "", $i); \
78 printf "TABLE_ENTRY(LINUX_%s, %s)\n", $i, $i }'
87 /* This file is auto-generated. */
91 gen_table "atflags" "LINUX_AT_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_file.h"
92 gen_table "clockids" "LINUX_CLOCK_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_timer.h"
93 gen_table "clockflags" "LINUX_TIMER_[A-Z_]+[[:space:]]+0x[0-9]+" "compat/linux/linux_timer.h"
94 gen_table "clockcpuids" "LINUX_CPUCLOCK_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_timer.h" "_MASK|_MAX"
95 gen_table "openflags" "LINUX_O_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_file.h" "O_RDONLY|O_RDWR|O_WRONLY|O_ACCMODE"
96 gen_table "sigprocmaskhow" "LINUX_SIG_[A-Z]+[[:space:]]+[0-9]+" "compat/linux/linux.h"
98 # Generate a .depend file for our output file
99 if [ -n "$output_file" ]; then
100 depend_tmp=$(mktemp -u)
102 echo "$output_file: \\"
103 echo "$all_headers" | tr ' ' '\n' | sort -u |
104 sed -e "s,^, $include_dir/," -e 's,$, \\,'
107 if cmp -s "$output_tmp" "$output_file"; then
108 rm -f "$output_tmp" "$depend_tmp"
110 mv -f "$depend_tmp" ".depend.${output_file}"
111 mv -f "$output_tmp" "$output_file"