From d2d6d8d537a01921ff5c653420bfe8add5b746b7 Mon Sep 17 00:00:00 2001 From: Giorgos Keramidas Date: Fri, 1 Dec 2006 07:01:19 +0000 Subject: [PATCH] The sigconv.awk script generates a sigdesc.h header file, which contains a sigdec[] vector of structures, but the generated output is missing braces around the initializer of each struct, which triggers warnings in WARNS=3: src/usr.bin/top/sigdesc.h:10: warning: missing braces around initializer src/usr.bin/top/sigdesc.h:10: warning: (near initialization for `sigdesc[0]') * Fix the sigconv.awk script to generate a header with initializers which look better. * Add rules to usr.bin/top/Makefile that rebuilds a new sigconv.h header which matches the correct signal set from the build-time version of `${DESTDIR}/usr/include/signal.h' (so sigconv.h doesn't get stale once changes are made to the header). * Remove the old sigconv.h header, now that it is autoupdated at build time. * Various Makefile style fixes (the committed Makefile was kindly submitted by Ruslan): - Reorder .PATH, PROG, SRCS and CFLAGS to match style.Makefile(5) - Split off the generated sources (sigdesc.h top.local.h) in an SRCS+= line of their own. - Add entries to CLEANFILES near the rules that generate the respective files. - Move the explicit rule which builds top.1 after the implicit rules which generate its dependencies. Reviewed by: ru, bde Submitted by: ru (Makefile) MFC after: 2 weeks --- contrib/top/sigconv.awk | 16 +++++++++------- usr.bin/top/Makefile | 33 +++++++++++++++++++------------- usr.bin/top/sigdesc.h | 42 ----------------------------------------- 3 files changed, 29 insertions(+), 62 deletions(-) delete mode 100644 usr.bin/top/sigdesc.h diff --git a/contrib/top/sigconv.awk b/contrib/top/sigconv.awk index 8c90d8dc749e..8e065fa1a355 100644 --- a/contrib/top/sigconv.awk +++ b/contrib/top/sigconv.awk @@ -1,3 +1,5 @@ +# $FreeBSD$ + BEGIN { nsig = 0; j = 0; @@ -10,7 +12,7 @@ BEGIN { print "struct sigdesc sigdesc[] = {" } -/^#define[ \t][ \t]*SIG[A-Z]/ { +/^#define[ \t][ \t]*SIG[A-Z]+[0-9]*[ \t]/ { j = sprintf("%d", $3); str = $2; @@ -18,10 +20,10 @@ BEGIN { if (nsig < j) nsig = j; - siglist[j] = sprintf("\"%s\",\t%2d,", \ + siglist[j] = sprintf("{ \"%s\",\t%2d },", \ substr(str, 4), j); } -/^#[ \t]*define[ \t][ \t]*SIG[A-Z]/ { +/^#[ \t]*define[ \t][ \t]*SIG[A-Z]+[0-9]*[ \t]/ { j = sprintf("%d", $4); str = $3; @@ -29,10 +31,10 @@ BEGIN { if (nsig < j) nsig = j; - siglist[j] = sprintf("\"%s\",\t%2d,", \ + siglist[j] = sprintf("{ \"%s\",\t%2d },", \ substr(str, 4), j); } -/^#[ \t]*define[ \t][ \t]*_SIG[A-Z]/ { +/^#[ \t]*define[ \t][ \t]*_SIG[A-Z]+[0-9]*[ \t]/ { j = sprintf("%d", $4); str = $3; @@ -40,7 +42,7 @@ BEGIN { if (nsig < j) nsig = j; - siglist[j] = sprintf("\"%s\",\t%2d,", \ + siglist[j] = sprintf("{ \"%s\",\t%2d },", \ substr(str, 5), j); } @@ -49,5 +51,5 @@ END { if (siglist[n] != "") printf(" %s\n", siglist[n]); - printf(" NULL,\t 0\n};\n"); + printf(" { NULL,\t 0 }\n};\n"); } diff --git a/usr.bin/top/Makefile b/usr.bin/top/Makefile index 08343da66f8b..182714aa7021 100644 --- a/usr.bin/top/Makefile +++ b/usr.bin/top/Makefile @@ -1,32 +1,35 @@ # $FreeBSD$ -PROG= top TOPDIR= ${.CURDIR}/../../contrib/top -.PATH: ${TOPDIR} +.PATH: ${TOPDIR} -CFLAGS+= -DHAVE_GETOPT -DHAVE_STRERROR -I${.CURDIR} -I${TOPDIR} -I. -DORDER +PROG= top +SRCS= commands.c display.c machine.c screen.c top.c \ + username.c utils.c version.c +SRCS+= sigdesc.h top.local.h +CFLAGS+= -DHAVE_GETOPT -DHAVE_STRERROR -DORDER +CFLAGS+= -I${.CURDIR} -I${TOPDIR} -I. # # The table size should be a prime number approximately twice as # large as the number of lines in /etc/passwd. The default number -# is 20011, use /etc/make.conf to override this. +# is 20011; use /etc/make.conf to override this. # .if defined(TOP_TABLE_SIZE) CFLAGS+= -D"Table_size=${TOP_TABLE_SIZE}" .endif -SRCS= commands.c display.c machine.c screen.c top.c \ - username.c utils.c version.c top.local.h +DPADD= ${LIBTERMCAP} ${LIBM} ${LIBKVM} +LDADD= -ltermcap -lm -lkvm -CLEANFILES+= top.local.h top.x top.1 -DPADD= ${LIBTERMCAP} ${LIBM} ${LIBKVM} -LDADD= -ltermcap -lm -lkvm - -top.1: top.x top.local.1 - cat ${.ALLSRC} > top.1 +CLEANFILES= sigdesc.h +SIGCONV_AWK= ${.CURDIR}/../../contrib/top/sigconv.awk +SIGNAL_H= ${DESTDIR}/usr/include/sys/signal.h +sigdesc.h: ${SIGCONV_AWK} ${SIGNAL_H} + awk -f ${SIGCONV_AWK} < ${SIGNAL_H} > ${.TARGET} +CLEANFILES+= top.local.h top.x .SUFFIXES: .X .x .H .h - .X.x .H.h: @${ECHO} Making ${.TARGET} from ${.IMPSRC} @sed -e's,%LoadMax%,5.0,g' \ @@ -37,4 +40,8 @@ top.1: top.x top.local.1 -e's,%random%,1,g' \ ${.IMPSRC} > ${.TARGET} +CLEANFILES+= top.1 +top.1: top.x top.local.1 + cat ${.ALLSRC} > ${.TARGET} + .include diff --git a/usr.bin/top/sigdesc.h b/usr.bin/top/sigdesc.h deleted file mode 100644 index 75bc9d7b2ff4..000000000000 --- a/usr.bin/top/sigdesc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* This file was automatically generated */ -/* by the awk script "sigconv.awk". */ - -struct sigdesc { - char *name; - int number; -}; - -struct sigdesc sigdesc[] = { - "HUP", 1, - "INT", 2, - "QUIT", 3, - "ILL", 4, - "TRAP", 5, - "ABRT", 6, - "EMT", 7, - "FPE", 8, - "KILL", 9, - "BUS", 10, - "SEGV", 11, - "SYS", 12, - "PIPE", 13, - "ALRM", 14, - "TERM", 15, - "URG", 16, - "STOP", 17, - "TSTP", 18, - "CONT", 19, - "CHLD", 20, - "TTIN", 21, - "TTOU", 22, - "IO", 23, - "XCPU", 24, - "XFSZ", 25, - "VTALRM", 26, - "PROF", 27, - "WINCH", 28, - "INFO", 29, - "USR1", 30, - "USR2", 31, - NULL, 0 -};