summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/Makefile')
-rw-r--r--sysdeps/unix/sysv/linux/Makefile107
1 files changed, 39 insertions, 68 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 1872cdb179..5573c4ebdd 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -45,75 +45,46 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
tests += tst-clone tst-clone2 tst-fanotify tst-personality tst-quota \
tst-sync_file_range test-errno-linux
-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
-
-# If there is more than one syscall list for different architecture
-# variants, the CPU/Makefile defines abi-variants to be a list of names
-# for those variants (e.g. 32 64), and, for each variant, defines
-# abi-$(variant)-options to be compiler options to cause <asm/unistd.h>
-# to define the desired list of syscalls and abi-$(variant)-condition to
-# be the condition for those options to use in a C #if condition.
-# abi-includes may be defined to a list of headers to include
-# in the generated header, if the default does not suffice.
-#
-# The generated header is compiled with `-ffreestanding' to avoid any
-# circular dependencies against the installed implementation headers.
-# Such a dependency would require the implementation header to be
-# installed before the generated header could be built (See bug 15711).
-# In current practice the generated header dependencies do not include
-# any of the implementation headers removed by the use of `-ffreestanding'.
-
-$(objpfx)bits/syscall%h $(objpfx)bits/syscall%d: ../sysdeps/unix/sysv/linux/sys/syscall.h
+# Generate the list of SYS_* macros for the system calls (__NR_*
+# macros). The file syscall-names.list contains all possible system
+# call names, and the generated header file produces SYS_* macros for
+# the __NR_* macros which are actually defined.
+
+generated += bits/syscall.h
+$(objpfx)bits/syscall.h: \
+ ../sysdeps/unix/sysv/linux/gen-syscall-h.awk \
+ ../sysdeps/unix/sysv/linux/syscall-names.list
$(make-target-directory)
- { \
- echo '/* Generated at libc build time from kernel syscall list. */';\
- echo ''; \
- echo '#ifndef _SYSCALL_H'; \
- echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
- echo '#endif'; \
- echo ''; \
- $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
- echo ''; \
- $(if $(abi-variants), \
- $(foreach v,$(abi-variants),\
- $(CC) -ffreestanding -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
- -x c $(sysincludes) $< $(abi-$(v)-options) \
- -D_LIBC -dM | \
- sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
- LC_ALL=C sort > $(@:.d=.h).new$(v); \
- $(if $(abi-$(v)-condition),\
- echo '#if $(abi-$(v)-condition)';) \
- cat $(@:.d=.h).new$(v); \
- $(if $(abi-$(v)-condition),echo '#endif';) \
- rm -f $(@:.d=.h).new$(v); \
- ), \
- $(CC) -ffreestanding -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
- -x c $(sysincludes) $< \
- -D_LIBC -dM | \
- sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
- LC_ALL=C sort;) \
- } > $(@:.d=.h).new
- mv -f $(@:.d=.h).new $(@:.d=.h)
-ifdef abi-variants
-ifneq (,$(objpfx))
- sed $(sed-remove-objpfx) \
- $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) > $(@:.h=.d)-t3
-else
- cat $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) \
- > $(@:.h=.d)-t3
-endif
- rm -f $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v))
- mv -f $(@:.h=.d)-t3 $(@:.h=.d)
-else
- mv -f $(@:.h=.d)-t $(@:.h=.d)
-endif
-
-ifndef no_deps
-# Get the generated list of dependencies (probably /usr/include/asm/unistd.h).
--include $(objpfx)bits/syscall.d
-endif
-generated += bits/syscall.h bits/syscall.d
-endif
+ $(AWK) -f $^ > $@-tmp
+ $(move-if-change) $@-tmp $@
+
+# All macros defined by <sys/syscall.h>. Include <bits/syscall.h>
+# explicitly because <sys/sycall.h> skips it if _LIBC is defined.
+$(objpfx)tst-syscall-list-macros.list: \
+ $(objpfx)bits/syscall.h ../sysdeps/unix/sysv/linux/sys/syscall.h
+ printf '#include <sys/syscall.h>\n#include <bits/syscall.h>\n' | \
+ $(CC) -E -o $@-tmp $(CFLAGS) $(CPPFLAGS) -x c - -dM
+ $(move-if-change) $@-tmp $@
+
+# __NR_* system call names. Used by the test below.
+$(objpfx)tst-syscall-list-nr.list: \
+ ../sysdeps/unix/sysv/linux/filter-nr-syscalls.awk \
+ $(objpfx)tst-syscall-list-macros.list
+ $(AWK) -f $^ > $@-tmp
+ $(move-if-change) $@-tmp $@
+
+# SYS_* system call names. Used by the test below.
+$(objpfx)tst-syscall-list-sys.list: $(objpfx)tst-syscall-list-macros.list
+ $(AWK) '/^#define SYS_/ { print substr($$2, 5) }' $< > $@-tmp
+ $(move-if-change) $@-tmp $@
+
+tests-special += $(objpfx)tst-syscall-list.out
+$(objpfx)tst-syscall-list.out: \
+ ../sysdeps/unix/sysv/linux/tst-syscall-list.sh \
+ $(objpfx)tst-syscall-list-nr.list $(objpfx)tst-syscall-list-sys.list
+ $(BASH) $^ > $@; $(evaluate-test)
+
+endif # $(subdir) == misc
ifeq ($(subdir),time)
sysdep_headers += sys/timex.h bits/timex.h