3
我想用libswscale.so
(分別稱爲$(SLIBNAME_WITH_MAJOR)
和$(SLIBNAME)
的變量)替換字符串libswscale.so.2
。這是我在Makefile嘗試:Makefile中的簡單字符串替換
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
[...]
@echo SHFLAGS=$(SHFLAGS)
@echo SLIBNAME_WITH_MAJOR=$(SLIBNAME_WITH_MAJOR)
@echo SLIBNAME=$(SLIBNAME)
@echo A $(patsubst $(SLIBNAME_WITH_MAJOR),$(SLIBNAME),$(SHFLAGS))
@echo B $(SHFLAGS:$(SLIBNAME_WITH_MAJOR)=$(SLIBNAME))
@echo C $($(SHFLAGS):$(SLIBNAME_WITH_MAJOR)=$(SLIBNAME))
@echo D $(SHFLAGS:$(SLIBNAME_WITH_MAJOR)=$(SLIBNAME))
@echo E $(subst $(SLIBNAME_WITH_MAJOR),$(SLIBNAME),$(SHFLAGS))
@echo F $(subst l,L,$(SHFLAGS))
輸出是
SHFLAGS=-shared -Wl,-soname,libswscale.so.2 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver
SLIBNAME_WITH_MAJOR=libswscale.so.2
SLIBNAME=libswscale.so
A -shared -Wl,-soname,libswscale.so.2 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver
B -shared -Wl,-soname,libswscale.so.2 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver
C
D -shared -Wl,-soname,libswscale.so.2 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver
E -shared -Wl,-soname,libswscale.so.2 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver
F -shared -WL,-soname,libswscale.so.2 -WL,-BsymboLic -WL,--version-script,LibswscaLe/LibswscaLe.ver
最後一個(F)特別可笑。這裏有什麼問題?是否因爲$(SHFLAGS)
也由變量組成?