diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-06 19:18:44 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-06 19:18:44 +0300 |
commit | a413ad7de22601e59e7a89f19e4986eaf70c8fbb (patch) | |
tree | 1505f4ffa02106e75318724fcf37a7177b3c8c35 | |
parent | 14dcc3034d3d252d20f80daa9b708f88cc45dbaa (diff) | |
download | rpm-a413ad7de22601e59e7a89f19e4986eaf70c8fbb.tar.gz rpm-a413ad7de22601e59e7a89f19e4986eaf70c8fbb.tar.bz2 rpm-a413ad7de22601e59e7a89f19e4986eaf70c8fbb.zip |
Move the tagtbl.c generator monster awk out of Makefile.am
- stick it into a separate script, reformat so it's possible to actually
read it...
-rw-r--r-- | rpmdb/Makefile.am | 17 | ||||
-rwxr-xr-x | rpmdb/gentagtbl.sh | 77 |
2 files changed, 80 insertions, 14 deletions
diff --git a/rpmdb/Makefile.am b/rpmdb/Makefile.am index c423a4859..0a9714404 100644 --- a/rpmdb/Makefile.am +++ b/rpmdb/Makefile.am @@ -11,6 +11,7 @@ AM_CPPFLAGS += @WITH_LIBELF_INCLUDE@ check_PROGRAMS = EXTRA_PROGRAMS = CLEANFILES = +EXTRA_DIST = gentagtbl.sh usrlibdir = $(libdir) usrlib_LTLIBRARIES = librpmdb.la @@ -36,20 +37,8 @@ else librpmdb_la_LIBADD += @WITH_DB_LIB@ endif -tagtbl.c: Makefile.am $(top_srcdir)/lib/rpmtag.h - @echo '#include "system.h"' > $@ - @echo '#include <rpm/header.h>' >> $@ - @echo '#include <rpm/rpmtag.h>' >> $@ - @echo '#include "debug.h"' >> $@ - @echo '' >> $@ - @echo 'static const struct headerTagTableEntry_s rpmTagTbl[] = {' >> $@ - ${AWK} '/[\t ](RPMTAG_[A-Z0-9]*)[ \t]+([0-9]*)/ && !/internal/ {tt = "NULL"; ta = "ANY"; if ($$5 == "c") {tt = "CHAR"; ta = "SCALAR"} if ($$5 == "c[]") {tt = "CHAR"; ta = "ARRAY"} if ($$5 == "h") {tt = "INT16"; ta = "SCALAR"} if ($$5 == "h[]") {tt = "INT16"; ta = "ARRAY"} if ($$5 == "i") {tt = "INT32"; ta = "SCALAR"} if ($$5 == "i[]") {tt = "INT32"; ta = "ARRAY"} if ($$5 == "l") {tt = "INT64"; ta = "SCALAR"} if ($$5 == "l[]") {tt = "INT64"; ta = "ARRAY"} if ($$5 == "s") {tt = "STRING"; ta = "SCALAR"} if ($$5 == "s[]") {tt = "STRING_ARRAY"; ta = "ARRAY"} if ($$5 == "s{}") {tt = "I18NSTRING"; ta = "SCALAR"} if ($$5 == "x") {tt = "BIN"; ta = "SCALAR"} if ($$2 == "=") { printf("\t{ \"%s\", %s RPM_%s_TYPE + RPM_%s_RETURN_TYPE },\n", $$1, $$3, tt, ta) } else { printf("\t{ \"%s\", %s, RPM_%s_TYPE + RPM_%s_RETURN_TYPE },\n", $$2, $$3, tt, ta) } }' < ${top_srcdir}/lib/rpmtag.h | sort >> $@ - @echo ' { NULL, 0, 0 }' >> $@ - @echo '};' >> $@ - @echo '' >> $@ - @echo 'const struct headerTagTableEntry_s * const rpmTagTable = rpmTagTbl;' >> $@ - @echo '' >> $@ - @echo 'const int rpmTagTableSize = sizeof(rpmTagTbl) / sizeof(rpmTagTbl[0]) - 1;' >> $@ +tagtbl.c: Makefile.am $(top_srcdir)/lib/rpmtag.h gentagtbl.sh + @AWK=${AWK} ${SHELL} gentagtbl.sh $(top_srcdir)/lib/rpmtag.h > $@ BUILT_SOURCES = tagtbl.c if WITH_INTERNAL_DB diff --git a/rpmdb/gentagtbl.sh b/rpmdb/gentagtbl.sh new file mode 100755 index 000000000..a4d674428 --- /dev/null +++ b/rpmdb/gentagtbl.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +cat << EOF +#include "system.h" +#include <rpm/header.h> +#include <rpm/rpmtag.h> +#include "debug.h" + +static const struct headerTagTableEntry_s rpmTagTbl[] = { +EOF + +${AWK} '/[\t ](RPMTAG_[A-Z0-9]*)[ \t]+([0-9]*)/ && !/internal/ { + tt = "NULL" + ta = "ANY" + if ($5 == "c") { + tt = "CHAR" + ta = "SCALAR" + } + if ($5 == "c[]") { + tt = "CHAR" + ta = "ARRAY" + } + if ($5 == "h") { + tt = "INT16" + ta = "SCALAR" + } + if ($5 == "h[]") { + tt = "INT16" + ta = "ARRAY" + } + if ($5 == "i") { + tt = "INT32" + ta = "SCALAR" + } + if ($5 == "i[]") { + tt = "INT32" + ta = "ARRAY" + } + if ($5 == "l") { + tt = "INT64" + ta = "SCALAR" + } + if ($5 == "l[]") { + tt = "INT64" + ta = "ARRAY" + } + if ($5 == "s") { + tt = "STRING" + ta = "SCALAR" + } + if ($5 == "s[]") { + tt = "STRING_ARRAY" + ta = "ARRAY" + } + if ($5 == "s{}") { + tt = "I18NSTRING" + ta = "SCALAR" + } + if ($5 == "x") { + tt = "BIN" + ta = "SCALAR" + } + if ($2 == "=") { + printf(" { \"%s\", %s RPM_%s_TYPE + RPM_%s_RETURN_TYPE },\n", $1, $3, tt, ta) + } else { + printf(" { \"%s\", %s, RPM_%s_TYPE + RPM_%s_RETURN_TYPE },\n", $2, $3, tt, ta) + } +}' < $1 | sort + +cat << EOF + { NULL, 0, 0 } +}; + +const struct headerTagTableEntry_s * const rpmTagTable = rpmTagTbl; +const int rpmTagTableSize = sizeof(rpmTagTbl) / sizeof(rpmTagTbl[0]) - 1; +EOF + |