chiark / gitweb /
build-sys: use C preprocessor for key list, too
[elogind.git] / Makefile.am
index a48e05bd8750c0ada0feed7f8594b40a6872fca3..ec50f408bce3e486ef6410de88bde0f1810544bd 100644 (file)
@@ -668,8 +668,8 @@ noinst_DATA += \
 CLEANFILES += \
        man/index.html
 
-man/index.html: $(XML_FILES)
-       $(AM_V_GEN)$(PYTHON) $(top_srcdir)/make-man-index.py $(XML_FILES) > $@
+man/index.html: $(XML_FILES) $(top_srcdir)/make-man-index.py
+       $(AM_V_GEN)$(PYTHON) $(top_srcdir)/make-man-index.py $(XML_FILES) > $@ || rm $@
 endif
 
 endif
@@ -961,11 +961,15 @@ libsystemd_core_la_SOURCES = \
        src/core/switch-root.h \
        src/core/switch-root.c \
        src/core/killall.h \
-       src/core/killall.c
+       src/core/killall.c \
+       src/core/syscall-list.c \
+       src/core/syscall-list.h
 
 nodist_libsystemd_core_la_SOURCES = \
        src/core/load-fragment-gperf.c \
-       src/core/load-fragment-gperf-nulstr.c
+       src/core/load-fragment-gperf-nulstr.c \
+       src/core/syscall-from-name.h \
+       src/core/syscall-to-name.h
 
 libsystemd_core_la_CFLAGS = \
        $(AM_CFLAGS) \
@@ -998,7 +1002,27 @@ EXTRA_DIST += \
 CLEANFILES += \
        src/core/load-fragment-gperf.gperf \
        src/core/load-fragment-gperf.c \
-       src/core/load-fragment-gperf-nulstr.c
+       src/core/load-fragment-gperf-nulstr.c \
+       src/core/syscall-list.txt \
+       src/core/syscall-from-name.gperf \
+       src/core/syscall-from-name.h \
+       src/core/syscall-to-name.h
+
+BUILT_SOURCES += \
+       src/core/syscall-from-name.h \
+       src/core/syscall-to-name.h
+
+src/core/syscall-list.txt: Makefile
+       $(AM_V_GEN)cpp $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include sys/syscall.h < /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[ \t]+[0-9]/ { sub(/__NR_/, "", $$2); print $$2; }' > $@ || rm $@
+
+src/core/syscall-from-name.gperf: src/core/syscall-list.txt Makefile
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct syscall_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, __NR_%s\n", $$1, $$1 }' < $< > $@ || rm $@
+
+src/core/syscall-from-name.h: src/core/syscall-from-name.gperf Makefile
+       $(AM_V_GEN)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_syscall -H hash_syscall_name -p -C < $< > $@ || rm $@
+
+src/core/syscall-to-name.h: src/core/syscall-list.txt Makefile
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "const char* const syscall_names[] = { "} { printf "[__NR_%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@ || rm $@
 
 # ------------------------------------------------------------------------------
 systemd_SOURCES = \
@@ -2163,18 +2187,18 @@ dist_udevkeymapforcerel_DATA = \
        keymaps-force-release/samsung-90x3a \
        keymaps-force-release/common-volume-keys
 
-src/udev/keymap/keys.txt: $(INCLUDE_PREFIX)/linux/input.h
+src/udev/keymap/keys.txt: Makefile
        $(AM_V_at)mkdir -p src/udev/keymap
-       $(AM_V_GEN)$(AWK) '/^#define.*KEY_[^ ]+[ \t]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' < $< | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+       $(AM_V_GEN)cpp $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/input.h < /dev/null | $(AWK) '/^#define[ \t]+KEY_[^ ]+[ \t]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@ || rm $@
 
-src/udev/keymap/keys-from-name.gperf: src/udev/keymap/keys.txt
-       $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct key { const char* name; unsigned short id; };"; print "%null-strings"; print "%%";} { print $$1 ", " $$1 }' < $< > $@
+src/udev/keymap/keys-from-name.gperf: src/udev/keymap/keys.txt Makefile
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct key { const char* name; unsigned short id; };"; print "%null-strings"; print "%%";} { print $$1 ", " $$1 }' < $< > $@ || rm $@
 
 src/udev/keymap/keys-from-name.h: src/udev/keymap/keys-from-name.gperf Makefile
-       $(AM_V_GEN)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_key -H hash_key_name -p -C < $< > $@
+       $(AM_V_GEN)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_key -H hash_key_name -p -C < $< > $@ || rm $@
 
 src/udev/keymap/keys-to-name.h: src/udev/keymap/keys.txt Makefile
-       $(AM_V_GEN)$(AWK) 'BEGIN{ print "const char* const key_names[KEY_CNT] = { "} { print "[" $$1 "] = \"" $$1 "\"," } END{print "};"}' < $< > $@
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "const char* const key_names[KEY_CNT] = { "} { print "[" $$1 "] = \"" $$1 "\"," } END{print "};"}' < $< > $@ || rm $@
 endif
 
 # ------------------------------------------------------------------------------