-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
69 lines (53 loc) · 1.82 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
TARGET := ymfmidi
BUILD := obj
SOURCES := src ymfm/src
INCLUDES := $(SOURCES) include
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cpp))
CFLAGS := -Wall \
`pkg-config --cflags sdl2` \
-Wno-sign-compare
CXXFLAGS = $(CFLAGS) -std=c++14
ASFLAGS := $(ARCH)
LDFLAGS := `pkg-config --libs sdl2` \
-Wl,-rpath=.
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g
LDFLAGS += -g
else
CFLAGS += -O2
LDFLAGS += -s
endif
ifeq ($(OS),Windows_NT)
LDFLAGS += -mconsole
endif
OUTPUT := $(CURDIR)/$(TARGET)
OFILES := $(addprefix $(BUILD)/, $(CPPFILES:.cpp=.o) $(CFILES:.c=.o))
INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir))
CFLAGS += $(INCLUDE)
CXXFLAGS += $(INCLUDE)
.PHONY: clean
#---------------------------------------------------------------------------------
$(OUTPUT): $(OFILES)
#---------------------------------------------------------------------------------
@echo linking $(notdir $@)
@$(CXX) -o $@ $^ $(LDFLAGS)
#---------------------------------------------------------------------------------
$(BUILD)/%.o: %.cpp
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@mkdir -p $(dir $@)
@$(CXX) $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
$(BUILD)/%.o: %.c
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET) $(OFILES)