Pregunta

I wanted to write a general makefile that fulfils most of my needs for various projects at once. But then I tumbled over the following:

%/:
    mkdir -p $@

.SECONDEXPANSION:
$(objects): $$(dir $$@)

I expected this to run just fine and create a directory whenever a dir for a target in $(objects) does need one. But somehow it didn't work. I checked and found the following: Targets can't end with '/'.

Is there a way I can avoid this?

¿Fue útil?

Solución

You just need to select an suffix that will can't be the name of a file in the folder. For example .. So the rules become the following:

%/.:
    mkdir -p $@

.SECONDEXPANSION:
$(objects): $$(dir $$@).

As . refers to the directory itself this should not create problems what-so-ever :)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top