ifeq ($(OS),Windows_NT) OS = Windows MICROGLUT = MicroGlut.c else ifeq ($(shell uname),Linux) OS = Linux MICROGLUT = MicroGlut.c else ifeq ($(shell uname),Darwin) OS = Mac MICROGLUT = MicroGlut.m endif PROG = tsbk07 COMMON = \ common/GL_utilities.c \ common/LoadTGA.c \ common/$(OS)/$(MICROGLUT) CPPFLAGS += \ -Icommon \ -Icommon/$(OS) CXXFLAGS += \ -g \ -Wall \ -Wextra \ -Wpedantic \ -Wshadow LDLIBS_Windows += \ -lopengl32 LDLIBS_Linux += \ -lX11 \ -lGL LDLIBS_Mac += \ -framework Cocoa \ -framework OpenGL LDLIBS += \ $(LDLIBS_$(OS)) # The below is equivalent to the GNU Make implicit rule for # $(PROG): $(COMMON) $(PROG): $(PROG).cpp $(COMMON) g++ $(CXXFLAGS) $(CPPFLAGS) $(PROG).cpp $(COMMON) $(LDLIBS) -o $(PROG) .PHONY: clean clean: rm $(PROG) .PHONY: run run: $(PROG) ./$(PROG)