2022年6月7日 星期二

Search and replace string in make file

 FILENAME:= mn.004.contrast-reading.html

DOT:= .
DASH:= -
# replace . with -
RESULT= $(subst $(DOT),$(DASH),$(FILENAME))

HTML_SUFFIX:= .html
RST_SUFFIX:= \%zh.rst
# replace .html with %zh.rst
RESULT2= $(subst $(HTML_SUFFIX),$(RST_SUFFIX),$(FILENAME))


default:
	@echo $(RESULT)
	@echo $(RESULT2)


from: https://siongui.github.io/2016/04/08/makefile-string-replace/

沒有留言:

wibiya widget