From a413ad7de22601e59e7a89f19e4986eaf70c8fbb Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Sun, 6 Apr 2008 19:18:44 +0300 Subject: [PATCH] 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... --- rpmdb/Makefile.am | 17 +++--------- rpmdb/gentagtbl.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 14 deletions(-) create mode 100755 rpmdb/gentagtbl.sh diff --git a/rpmdb/Makefile.am b/rpmdb/Makefile.am index c423a48..0a97144 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 ' >> $@ - @echo '#include ' >> $@ - @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 0000000..a4d6744 --- /dev/null +++ b/rpmdb/gentagtbl.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +cat << EOF +#include "system.h" +#include +#include +#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 + -- 2.7.4