Catchall target with BSD's make
Asked Answered
E

1

11

In a BSD Makefile, is it possible to define a catch-all target? I'm looking for the GNU equivalent of:

%:
    @echo caught target $@

I was hoping that the preprocessor possesses enough magic to define a target on the fly, but couldn't figure out how to do so. All local variables, such as .TARGET, only work within a target but not at global scope.

Eskew answered 8/10, 2015 at 8:1 Comment(0)
T
16

I don't know if BSD make qualifies, but every POSIX-compliant version of make must support the .DEFAULT: special target which does this, even in GNU make, without the overhead of using a catch-all pattern like %:

.DEFAULT:
        @echo caught target $@
Todtoday answered 8/10, 2015 at 14:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.