From 43cf7873bee1f1bee653d298a7c5cc9dc4d94c78 Mon Sep 17 00:00:00 2001 From: Jan Polensky Date: Tue, 14 Apr 2026 12:51:01 +0200 Subject: [PATCH] zdev: generate usage text headers instead of C files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generating and then including C source files from another C file can lead to unexpected compilation errors in certain environments. Switch the usage text generation from %_usage.c to %_usage.h. The generated header provides the usage_text definition directly, and chzdev.c and lszdev.c include the corresponding *_usage.h instead. Update depfile prerequisites and the clean target to match the new generated artifacts. Reviewed-by: Jan Höppner Signed-off-by: Jan Polensky Signed-off-by: Jan Höppner --- zdev/src/Makefile | 12 +++++++----- zdev/src/chzdev.c | 6 ++---- zdev/src/lszdev.c | 6 ++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/zdev/src/Makefile b/zdev/src/Makefile index 19efe019..57e28015 100644 --- a/zdev/src/Makefile +++ b/zdev/src/Makefile @@ -86,11 +86,13 @@ endif CSTR_SED = -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/g' -e 's/$$/\\n"/g' -%_usage.c: %_usage.txt - $(SED) $(CSTR_SED) $< >$@ +%_usage.h: %_usage.txt + @echo 'static const char *usage_text =' >$@ + @$(SED) $(CSTR_SED) $< >>$@ + @echo ';' >>$@ -.chzdev.o.d: chzdev_usage.c -.lszdev.o.d: lszdev_usage.c +.chzdev.o.d: chzdev_usage.h +.lszdev.o.d: lszdev_usage.h libs = $(rootdir)/libap/libap.a \ $(rootdir)/libutil/libutil.a @@ -113,6 +115,6 @@ ifeq ($(HAVE_DRACUT),1) endif clean: - @rm -f *.o chzdev lszdev chzdev_usage.c lszdev_usage.c gmon.out *.gcda *.gcno zdev_id + @rm -f *.o chzdev lszdev chzdev_usage.h lszdev_usage.h gmon.out *.gcda *.gcno zdev_id .PHONY: all install clean diff --git a/zdev/src/chzdev.c b/zdev/src/chzdev.c index 294b126a..2c974720 100644 --- a/zdev/src/chzdev.c +++ b/zdev/src/chzdev.c @@ -111,10 +111,8 @@ struct options { unsigned int no_module_load:1; }; -/* Makefile converts chzdev_usage.txt into C file which we include here. */ -static const char *usage_text = -#include "chzdev_usage.c" - ; +/* Makefile converts chzdev_usage.txt into header file which we include here. */ +#include "chzdev_usage.h" #define OPT_ANONYMOUS_BASE 0x80 enum { diff --git a/zdev/src/lszdev.c b/zdev/src/lszdev.c index 02a98e95..63567493 100644 --- a/zdev/src/lszdev.c +++ b/zdev/src/lszdev.c @@ -76,10 +76,8 @@ struct options { unsigned int site_id; }; -/* Makefile converts lszdev_usage.txt into C file which we include here. */ -static const char *usage_text = -#include "lszdev_usage.c" - ; +/* Makefile converts lszdev_usage.txt into header file which we include here. */ +#include "lszdev_usage.h" #define OPT_ANONYMOUS_BASE 0x80 enum {