Makefile: read input variable and set several variables -


i have makefile want read file name input , make other names based on it`s name. have tried following code

mlext = .ml testext = test.ml nativeext = test.native  test:      @read -p "enter file name: " file; \     echo $$file$(mlext); \     echo $$file$(testext); \     echo $$file$(nativeext) 

for example:

if type: foo

then want foo.ml, footest.ml, footest.native

however, can foo.ml. rest 2 .ml , .native

how can fix this?

first, let see exact recipe given shell removing @ in makefile:

read -p "enter file name: " file; \ echo $file.ml; \ echo $filetest.ml; \ echo $filetest.native;

the issue content of $(testext) gets appended $$file, creating shell variable $filetest, (very probably) not exist, resulting in empty string in end. not occur $(mlext), initial dot cannot part of variable name.

to overcome this, use $${file} instead of $$file in makefile rule.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -