Skip to contentSkip to conversation

cpupower: add checks for xgettext and msgfmt

PATCH Superseded Siddharth Menon 1 participant 1 message Oct 17, 2024 CPU power monitoring

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpupower: add checks for xgettext and msgfmt

Check whether xgettext and msgfmt are available on the system before attempting to generate the .pot and .gmo files and generate. In case of missing dependency, generate error message directing user to install the necessary package.

---
v1->v2:
- Checks for gettext tools outside the target definitions instead of inline
- Replace command with which

 tools/power/cpupower/Makefile | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
tools/power/cpupower/Makefile +13 -1
index 6c02f401069e..e178e14d4701 100644
@@ -218,29 +218,41 @@ else
 endif
 	$(QUIET) $(STRIPCMD) $@
 
+ifeq (, $(shell which xgettext))
+$(warning "Install xgettext to extract translatable strings.")
+else
 $(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
 	$(ECHO) "  GETTEXT " $@
 	$(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
 		--keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
+endif
 
+ifeq (, $(shell which msgfmt))
+$(warning "Install msgfmt to generate binary message catalogs.")
+else
 $(OUTPUT)po/%.gmo: po/%.po
 	$(ECHO) "  MSGFMT  " $@
 	$(QUIET) msgfmt -o $@ po/$*.po
+endif
 
 create-gmo: ${GMO_FILES}
 
+ifeq (, $(shell which msgmerge))
+$(warning "Install msgmerge to merge translations.")
+else
 update-po: $(OUTPUT)po/$(PACKAGE).pot
 	$(ECHO) "  MSGMRG  " $@
 	$(QUIET) @for HLANG in $(LANGUAGES); do \
 		echo -n "Updating $$HLANG "; \
 		if msgmerge po/$$HLANG.po $< -o \
-		   $(OUTPUT)po/$$HLANG.new.po; then \
+		  $(OUTPUT)po/$$HLANG.new.po; then \
 			mv -f $(OUTPUT)po/$$HLANG.new.po $(OUTPUT)po/$$HLANG.po; \
 		else \
 			echo "msgmerge for $$HLANG failed!"; \
 			rm -f $(OUTPUT)po/$$HLANG.new.po; \
 		fi; \
 	done;
+endif
 
 compile-bench: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
 	@V=$(V) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT)
Signature · 1 line
2.39.5