Search notes:

make: multiple targets

Here's the c source code of a simple program that prints the value of the macro EXECUTABLE_NAME.
Because the program does not define this macro, it must be defined with the -D option when gcc is invoked.
#include <stdio.h>

int main() {
  printf("EXECUTABLE_NAME is defined as %s\n", EXECUTABLE_NAME);
}
Github repository about-Makefile, path: /target/multiple/example-1/prog.c
Here's a simple Makefile that uses the concept of multiple targets to create an arbitrary number of executables where the value of the macro EXECUTABLE_NAME is assigned dynamically depending on the name of the executable built:
executables = foo bar baz

all: $(executables)

foo bar baz: prog.c
	gcc -DEXECUTABLE_NAME=\"$@\" $< -o $@
Github repository about-Makefile, path: /target/multiple/example-1/Makefile

See also

make

Index