So my goal as of now is to be able to compile my program under a flag(-D) if and only the user does make -D. If the user simply does make, then compile the program without the -D flag. The problem with this is that the macro MAKEFLAGS does not have the -D flag defined anywhere in it because this is a gcc preprocessor flag. So what can I do?
Here is how my Makefile looks
Code:
TARGET = ThreadSync
GCC = gcc
CFLAGS = -Wall -Wextra -g -std=gnu99 -pthread
SYNCTHREAD = -D PTHREAD_SYNC
all: $(TARGET)
ifneq (,$(findstring D,$(MAKEFLAGS)))
$(TARGET):
$(GCC) $(CFLAGS) [email protected] -o $@ $(SYNCTHREAD)
else
$(TARGET):
$(GCC) $(CFLAGS) [email protected] -o $@
endif
.PHONY: clean
clean:
rm -f $(TARGET)