forked from fincs/midi2sseq
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
63 lines (43 loc) · 1.26 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
# This Makefile was blatantly ripped off from the devkitPro project
.SUFFIXES:
TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source
export CC := gcc
export CXX := g++
export STRIP := strip
CFLAGS := -g0 -Wall -O2
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
LDFLAGS := -g0 -static-libgcc -static-libstdc++
ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET)
export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
.PHONY: $(BUILD) clean
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
clean:
@rm -fr $(BUILD) $(OUTPUT).exe
else
$(OUTPUT).exe: $(OFILES)
-include $(DEPSDIR)/*.d
%.exe:
@echo linking...
@$(LD) $(LDFLAGS) $(OFILES) -o $@
@$(STRIP) --strip-all $@
%.o: %.c
@echo $(notdir $<)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
%.o: %.cpp
@echo $(notdir $<)
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
endif