We have a project that builds one application but uses different sources depending of some parameter. Simplified example looks like this:
app1.c
int main() {
printf("1\n");
}
app2.c
int main() {
printf("2\n");
}
Makefile
ifeq ($(PARAM),true)
OBJ=app1.o
else
OBJ=app2.o
endif
all: app
app: $(OBJ)
$(CC) $< -o $@
The problem:
$ make app
cc -c -o app2.o app2.c
cc app2.o -o app
$ ./app
2
$ PARAM=true make app
cc -c -o app1.o app1.c
cc app1.o -o app
$ ./app
1
$ make app # I want 2 again
make: `app' is up to date.
$ ./app
1
Is there a sane way to properly rebuild everything without deleting the output?