-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmakefile
More file actions
49 lines (37 loc) · 1.62 KB
/
makefile
File metadata and controls
49 lines (37 loc) · 1.62 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
UNAME_S := $(shell uname -s)
TARGET_EXEC ?= ../NewSonicThing/SAB2.out
BUILD_DIR ?= makebuild
SRC_DIRS ?= NewSonicThing/src
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c)
ifeq ($(UNAME_S),Darwin)
INC_FLAGS := $(shell pkg-config --cflags glfw3 ogg vorbis vorbisfile openal soil sdl2) -I./Libraries/Include/ # $(addprefix -I, $(shell find $(SRC_DIRS) -type d))
CFLAGS := -O3 -Wall -Wextra -MMD -MP
CPPFLAGS ?= $(INC_FLAGS)
ALL_LDFLAGS := -sectcreate __TEXT __info_plist Info.plist -lm -lpthread -ldl `pkg-config --static --libs glfw3 ogg vorbis vorbisfile openal soil sdl2` -framework OpenGL $(LDFLAGS)
CPPFLAGS += -D'fopen_s(pFile,filename,mode)=((*(pFile))=fopen((filename),(mode)))==NULL'
CXXFLAGS ?= -O3 -Wall -Wextra -MMD -MP -std=c++17
else
INC_FLAGS := `pkg-config --cflags glfw3 ogg vorbis vorbisfile openal gl`
#INC_FLAGS += $(shell find $(SRC_DIRS) -type d)
INC_FLAGS += -I./Libraries/Include/
CPPFLAGS ?= -O2 -Wall -Wextra $(INC_FLAGS) -MMD -MP # -D_GLIBCXX_USE_CXX11_ABI=0
ALL_LDFLAGS := -lSOIL -lSDL2 -lm -lpthread -ldl `pkg-config --static --libs glfw3 ogg vorbis vorbisfile openal gl` $(LDFLAGS)
#CPPFLAGS += -D'fopen_s(pFile,filename,mode)=((*(pFile))=fopen((filename),(mode)))==NULL'
endif
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CXX) $(OBJS) -o $@ $(ALL_LDFLAGS)
# c source
$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
-include $(DEPS)
MKDIR_P ?= mkdir -p