| # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| # Generates a header file with a system call table made up of "name", |
| # syscall_nr entries by including the build target <asm/unistd.h> and |
| # emitting the list of defines. Use of the compiler is needed to |
| # dereference the actual provider of syscall definitions. |
| # E.g., asm/unistd_32.h or asm/unistd_64.h, etc. |
| if [ $# -ne 1 ] && [ $# -ne 2 ]; then |
| echo "Usage: $(basename "$0") OUTFILE" |
| echo "Usage: $(basename "$0") CC OUTFILE" |
| # sed expression which extracts system calls that are |
| # defined via asm/unistd.h. It converts them from: |
| SED_MULTILINE='s/#define __(ARM_)?(NR_)([[:lower:]0-9_]*) (.*)$/#ifdef __\1\2\3\ |
| cat <<-EOF > "${OUTFILE}" |
| /* GENERATED BY MAKEFILE */ |
| const struct syscall_entry syscall_table[] = { |
| $(echo '#include <asm/unistd.h>' | \ |
| ${CC} -dD - -E | sed -Ene "${SED_MULTILINE}") |