zdev: Makefile: deduplicate *_usage.c generation

Consolidate the duplicated sed command sequences used to generate
*_usage.c files into a shared CSTR_SED definition and a single pattern
rule:

	%_usage.c: %_usage.txt

This removes the copy/pasted rules for chzdev_usage.c and lszdev_usage.c
and keeps the Makefile easier to maintain.

Also drop the explicit chzdev.o/lszdev.o prerequisites on the generated
sources as dependencies are already tracked via the .*.o.d depfiles.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Polensky
2026-03-23 18:58:49 +01:00
committed by Jan Höppner
parent 7093a70b51
commit d8cea21e1e

View File

@@ -84,21 +84,14 @@ ifneq (${HAVE_JSONC}, 0)
LDLIBS += -ljson-c
endif
chzdev_usage.c: chzdev_usage.txt
$(SED) $< >$@ -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/g' \
-e 's/$$/\\n"/g'
CSTR_SED = -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/g' -e 's/$$/\\n"/g'
%_usage.c: %_usage.txt
$(SED) $(CSTR_SED) $< >$@
.chzdev.o.d: chzdev_usage.c
lszdev_usage.c: lszdev_usage.txt
$(SED) $< >$@ -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/g' \
-e 's/$$/\\n"/g'
.lszdev.o.d: lszdev_usage.c
chzdev.o: chzdev_usage.c
lszdev.o: lszdev_usage.c
libs = $(rootdir)/libap/libap.a \
$(rootdir)/libutil/libutil.a