From: Zbigniew Jędrzejewski-Szmek Date: Fri, 1 Aug 2014 23:36:48 +0000 (-0400) Subject: build-sys: use a common rule for some gperf commands X-Git-Tag: v216~279 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=fd00a088216f6d6a6c502faf6b46c1e2ae7cbc54;hp=23432a1c249b9c513e438bffe9778a7ce2ee74fe build-sys: use a common rule for some gperf commands --- diff --git a/Makefile.am b/Makefile.am index 30b258908..73aa4209c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1156,37 +1156,27 @@ BUILT_SOURCES += \ src/shared/af-from-name.h \ src/shared/af-to-name.h -src/shared/errno-list.txt: - $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - < /dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' > $@ +src/shared/%-from-name.gperf: src/shared/%-list.txt + $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $*_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@ -src/shared/errno-from-name.gperf: src/shared/errno-list.txt - $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct errno_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' < $< > $@ +src/shared/%-from-name.h: src/shared/%-from-name.gperf + $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$* -H hash_$*_name -p -C <$< >$@ -src/shared/errno-from-name.h: src/shared/errno-from-name.gperf - $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_errno -H hash_errno_name -p -C < $< > $@ -src/shared/errno-to-name.h: src/shared/errno-list.txt +src/shared/errno-list.txt: $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@ + $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - $@ -src/shared/af-list.txt: - $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include sys/socket.h - < /dev/null | grep -v AF_UNSPEC | grep -v AF_MAX | $(AWK) '/^#define[ \t]+AF_[^ \t]+[ \t]+PF_[^ \t]/ { print $$2; }' > $@ +src/shared/errno-to-name.h: src/shared/errno-list.txt + $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@ -src/shared/af-from-name.gperf: src/shared/af-list.txt - $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct af_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' < $< > $@ -src/shared/af-from-name.h: src/shared/af-from-name.gperf +src/shared/af-list.txt: $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_af -H hash_af_name -p -C < $< > $@ + $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include sys/socket.h - $@ src/shared/af-to-name.h: src/shared/af-list.txt - $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const af_names[] = { "} !/AF_FILE/ && !/AF_ROUTE/ && !/AF_LOCAL/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@ + $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const af_names[] = { "} !/AF_FILE/ && !/AF_ROUTE/ && !/AF_LOCAL/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@ # ------------------------------------------------------------------------------ systemd_SOURCES = \