-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
32 lines (26 loc) · 856 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
CC := g++
SRCDIR := src
BUILDDIR := build
TARGET := app
SRCEXT := cpp
CFLAGS := -g -Wno-deprecated -std=c++17 -Wall
INC := -I .
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LIB := -lglut -lGLU -lGL
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
else
LIB := -framework OpenGL -framework GLUT
SOURCES := $(shell find -E $(SRCDIR) -type f -regex ".*\.($(SRCEXT))$$")
endif
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
$(TARGET): $(OBJECTS)
@echo " Linking..."
@echo " $(CC) -o $(TARGET) $^ $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB)
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(shell dirname $@)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)
.PHONY: clean