I assume that you mean the fact that you can do
make hello.o
and make will automatically know how to make .o from a .c file (or even from .f or .p , if one exists) - but you want to do this for custom file types (say, build a .bar from .foo .
The most portable way to do this is the following (in your Makefile):
.SUFFIXES: .foo .bar .foo.bar: foo2bar -in $> -out $@
The first line ( .SUFFIXES ) warns that you will treat them as special suffixes; the second line says "here is the recipe for creating .bar from .foo . The third line gives the command for this - $> and $@ get the changed make to the input and output file names.
NOTE. The indentation for the third line MUST be a tab character.
A more flexible method that only works with GNU make is to use its implicit rules . If you can guarantee that you will use GNU make, then this is probably recommended.
source share