Ticket #58366: Makefile.patch

File Makefile.patch, 1.9 KB (added by jmroot (Joshua Root), 6 years ago)
  • Makefile

    old new  
    11# Taken from https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
    22
    3 CC = clang
    4 CXX = clang++
     3CC ?= clang
     4CXX ?= clang++
    55
    66BUILD_DIR ?= build
    77SRC_DIRS ?= $(shell find src -type d -not -path src) vendor/glad vendor/nanovg vendor/nanogui
     
    1010SRCS := $(shell find $(SRC_DIRS) -maxdepth 1 -name '*.cpp' -or -name '*.c')
    1111
    1212INCFLAGS := $(addprefix -I, $(SRC_DIRS)) -Ivendor
    13 CPPFLAGS ?= $(INCFLAGS) -MMD -MP -g -Wno-multichar -DNANOGUI_GLAD
    14 CXXFLAGS ?= -std=c++1y
     13CPPFLAGS := $(INCFLAGS) $(CPPFLAGS) -MMD -MP -g -Wno-multichar -DNANOGUI_GLAD
     14CXXFLAGS += -std=c++1y
    1515
    1616ifeq ($(UNAME), Darwin)
     17    SDL_FRAMEWORK_DIR ?= /Library/Frameworks
     18    ifneq ($(PKG_CONFIG),)
     19        CPPFLAGS += `$(PKG_CONFIG) --cflags SDL2` `$(PKG_CONFIG) --cflags SDL2_net`
     20        LDFLAGS += `$(PKG_CONFIG) --libs SDL2` `$(PKG_CONFIG) --libs SDL2_net`
     21    else ifneq ($(SDL_FRAMEWORK_DIR),)
     22        CPPFLAGS += -DSDL_FRAMEWORK=1 -F$(SDL_FRAMEWORK_DIR)
     23        LDFLAGS += -F$(SDL_FRAMEWORK_DIR) -framework SDL2 -framework SDL2_net
     24    else
     25        # Assume CPPFLAGS and LDFLAGS are set up with the right -I and -L flags
     26        LDFLAGS += -lSDL2 -lSDL2_net
     27    endif
    1728        SRCS += $(shell find $(SRC_DIRS) -maxdepth 1 -name '*.mm')
    18         CPPFLAGS += -F/Library/Frameworks
    19         LDFLAGS ?= -F/Library/Frameworks -lstdc++ -lm -framework SDL2 -framework SDL2_net -framework OpenGL -framework AppKit
     29        LDFLAGS += -lm -framework OpenGL -framework AppKit
    2030        POST_PROCESS ?= dsymutil
    2131else ifeq ($(UNAME), MINGW64_NT-10.0)
    2232        # Not a great conditional check for "Windows", but works for now.
     
    6575
    6676# Avara
    6777$(BUILD_DIR)/Avara: $(OBJS) $(BUILD_DIR)/src/Avara.cpp.o
    68         $(CXX) $(OBJS) $(BUILD_DIR)/src/Avara.cpp.o -o $@ $(LDFLAGS)
     78        $(CXX) $(CXXFLAGS) $(OBJS) $(BUILD_DIR)/src/Avara.cpp.o -o $@ $(LDFLAGS)
    6979        $(POST_PROCESS) $@
    7080
    7181# BSPViewer