1

I want to declare my wildcard target as phony, but phony doesn't support wildcards:

My makefile:

%.config:
        gcc <<compile>>

I want the user to be able to use my makefile to compile the project, using a specific configuration file:

make something.config
make something_else.config

obviously, I need my target to be phony, becuase the target files exist, but simply writing:

.PHONY: %.config

doesn't work. I've seen here that makeapp supports another syntax, that would help:

$(phony %.config): ...

but I can only use make, and not makeapp.

Is there any way to do it with make?

  • "I want the user to be able to use my makefile to compile any .c file" What? That's not what make is for. – Ignacio Vazquez-Abrams Jun 20 '12 at 11:09
  • It's just an example, to show my problem. In reality, the user runs "make | and the makefile compiles the code with this coniguration – user1340472 Jun 20 '12 at 11:11
  • 1
    @user1340472: Then can you update your question to show code that more accurately reflects what you are trying to do? `make config_file` doesn't sound a lot like `make source_file.c`... – Oliver Charlesworth Jun 20 '12 at 11:13

1 Answers1

2

These are conflicting aims. A phony target is one that doesn't correspond to a real file. In your case, the file exists, but it's not really a target.

I would suggest not using the name of the config file as the target. Instead, construct a system based on one of the following:

make something_else
make CONFIG=something_else.config
Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680