chiark / gitweb /
resolve: add more record types and convert to gperf table
[elogind.git] / Makefile.am
index 30b2589086288256f36878aec53306c11696d3ee..45d2e58bf5569566a8451613e73295e1e8a23da1 100644 (file)
@@ -201,6 +201,7 @@ AM_CPPFLAGS = \
        -I $(top_srcdir)/src/timedate \
        -I $(top_srcdir)/src/timesync \
        -I $(top_srcdir)/src/resolve \
+       -I $(top_builddir)/src/resolve \
        -I $(top_srcdir)/src/systemd \
        -I $(top_builddir)/src/core \
        -I $(top_srcdir)/src/core \
@@ -1148,45 +1149,50 @@ CLEANFILES += \
        src/shared/errno-list.txt \
        src/shared/errno-from-name.gperf \
        src/shared/af-list.txt \
-       src/shared/af-from-name.gperf
+       src/shared/af-from-name.gperf \
+       src/shared/dns_type-list.txt \
+       src/shared/dns_type-from-name.gperf
 
 BUILT_SOURCES += \
        src/shared/errno-from-name.h \
        src/shared/errno-to-name.h \
        src/shared/af-from-name.h \
-       src/shared/af-to-name.h
+       src/shared/af-to-name.h \
+       src/resolve/dns_type-from-name.h \
+       src/resolve/dns_type-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; }'  > $@
+%-from-name.gperf: %-list.txt
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_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 }' < $< > $@
+%-from-name.h: %-from-name.gperf
+       $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
 
-src/shared/errno-from-name.h: src/shared/errno-from-name.gperf
+
+src/shared/errno-list.txt:
        $(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 < $< > $@
+       $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - </dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }'  >$@
 
 src/shared/errno-to-name.h: 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)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
+
 
 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; }'  > $@
+       $(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/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-to-name.h: src/shared/af-list.txt
+       $(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 "};"}' <$< >$@
 
-src/shared/af-from-name.h: src/shared/af-from-name.gperf
-       $(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 < $< > $@
 
-src/shared/af-to-name.h: src/shared/af-list.txt
+src/resolve/dns_type-list.txt: src/resolve/dns-type.h
        $(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)$(SED) -n -r 's/.* DNS_TYPE_(\w+).*/\1/p' <$< >$@
+
+src/resolve/dns_type-to-name.h: src/resolve/dns_type-list.txt
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "const char *dns_type_to_string(uint16_t type) {\n\tswitch(type) {" } {printf "        case DNS_TYPE_%s: return ", $$1; sub(/_/, "-"); printf "\"%s\";\n", $$1 } END{ print "\ndefault: return NULL;\n\t}\n}\n" }' <$< >$@
+
+src/resolve/dns_type-from-name.gperf: src/resolve/dns_type-list.txt
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct dns_type_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { s=$$1; sub(/_/, "-", s); printf "%s, ", $$s; printf "DNS_TYPE_%s\n", $$1 }' <$< >$@
 
 # ------------------------------------------------------------------------------
 systemd_SOURCES = \
@@ -4764,13 +4770,18 @@ systemd_resolved_SOURCES = \
        src/resolve/resolved-dns-zone.h \
        src/resolve/resolved-dns-zone.c \
        src/resolve/resolved-dns-stream.h \
-       src/resolve/resolved-dns-stream.c
+       src/resolve/resolved-dns-stream.c \
+       src/resolve/dns-type.c \
+       src/resolve/dns-type.h \
+       src/resolve/dns_type-from-name.h \
+       src/resolve/dns_type-to-name.h
 
 nodist_systemd_resolved_SOURCES = \
        src/resolve/resolved-gperf.c
 
 EXTRA_DIST += \
-       src/resolve/resolved-gperf.gperf
+       src/resolve/resolved-gperf.gperf \
+       src/resolve/dns_type-from-name.gperf
 
 CLEANFILES += \
        src/resolve/resolved-gperf.c
@@ -4867,7 +4878,11 @@ systemd_resolve_host_SOURCES = \
        src/resolve/resolved-dns-question.c \
        src/resolve/resolved-dns-question.h \
        src/resolve/resolved-dns-domain.c \
-       src/resolve/resolved-dns-domain.h
+       src/resolve/resolved-dns-domain.h \
+       src/resolve/dns-type.c \
+       src/resolve/dns-type.h \
+       src/resolve/dns_type-from-name.h \
+       src/resolve/dns_type-to-name.h
 
 systemd_resolve_host_LDADD = \
        libsystemd-internal.la \