How to express basic gmake pattern rule in bmake?

156 Views Asked by At

I'm trying to emulate this rule with bmake

%.o: %.c
    echo $< $@

This is valid in GNU make but I'm having a hard time to replicate it with BSD make.

Thanks in advance!

1

There are 1 best solutions below

1
On BEST ANSWER

Somewhat out of my depth here, but I think there are two things to change:

  1. Use suffix rules instead of (unsupported, GNU Make feature) pattern rules.
  2. Use the bmake names for automatic variables (bmake supports GNU Make automatic variables but are not recommended)
.SUFFIXES: .o
.c.o:
    echo ${.TARGET} ${.IMPSRC}

From netbsd wiki

BSD make (aka bmake) uses traditional suffix rules (.c.o: ...) instead of pattern rules like gmake's (%.c:%.o: ...) which are more general and flexible.

See also https://linux.die.net/man/1/bmake