|
...
|
...
|
@@ -1,66 +1,101 @@
|
|
1
|
|
-#SOURCES= IN_XSF IN_2SF IN_GSF IN_SNSF IN_NCSF TMP
|
|
2
|
|
-SOURCES= IN_XSF IN_2SF IN_GSF IN_SNSF IN_NCSF
|
|
|
1
|
+UNAME:= $(shell uname -s)
|
|
3
|
2
|
|
|
4
|
|
-IN_XSF_SRCS = ./in_xsf.cpp $(shell find . \! -name . -prune \( -iname \*.cpp -o -iname \*.c \) \! -iname tmp.cpp \! -iname XSFConfig_\*.cpp \! -iname XSFPlayer_\*.cpp \! -iname in_\*sf.cpp)
|
|
5
|
|
-IN_2SF_SRCS = ./XSFConfig_2SF.cpp ./XSFConfig_Winamp.cpp ./XSFPlayer_2SF.cpp $(shell find ./desmume \( -iname \*.cpp -o -iname \*.c \) \! -iname cpu_detect_x86_win.cpp \! -iname debug.cpp)
|
|
6
|
|
-IN_GSF_SRCS = ./XSFConfig_GSF.cpp ./XSFConfig_Winamp.cpp ./XSFPlayer_GSF.cpp $(shell find ./vbam \( -iname \*.cpp -o -iname \*.c \))
|
|
7
|
|
-IN_SNSF_SRCS = ./XSFConfig_SNSF.cpp ./XSFConfig_Winamp.cpp ./XSFPlayer_SNSF.cpp $(shell find ./snes9x \( -iname \*.cpp -o -iname \*.c \))
|
|
8
|
|
-IN_NCSF_SRCS = ./XSFConfig_NCSF.cpp ./XSFConfig_Winamp.cpp ./XSFPlayer_NCSF.cpp $(shell find ./SSEQPlayer \( -iname \*.cpp -o -iname \*.c \))
|
|
9
|
|
-#TMP_SRCS = ./tmp.cpp
|
|
|
3
|
+SRCDIR:= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
10
|
4
|
|
|
11
|
|
-$(foreach SOURCE,$(SOURCES),$(eval $(SOURCE)_OBJS = $(addprefix obj/,$(patsubst %.cpp,%.o,$($(SOURCE)_SRCS:.c=.o)))))
|
|
12
|
|
-$(foreach SOURCE,$(SOURCES),$(eval ALL_OBJS += $($(SOURCE)_OBJS)))
|
|
|
5
|
+FRAMEWORK_SRCS:= $(sort $(wildcard $(SRCDIR)in_xsf_framework/*.cpp))
|
|
|
6
|
+FRAMEWORK_OBJS:= $(subst $(SRCDIR),,$(FRAMEWORK_SRCS:%.cpp=%.o))
|
|
13
|
7
|
|
|
14
|
|
-#DLLS = in_2sf.dll in_gsf.dll in_snsf.dll in_ncsf.dll tmp.exe
|
|
15
|
|
-DLLS = in_2sf.dll in_gsf.dll in_snsf.dll in_ncsf.dll
|
|
|
8
|
+in_2sf_SRCS:= $(wildcard $(SRCDIR)in_2sf/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/addons/*.cpp) \
|
|
|
9
|
+ $(wildcard $(SRCDIR)in_2sf/desmume/metaspu/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/metaspu/SoundTouch/*.cpp) \
|
|
|
10
|
+ $(wildcard $(SRCDIR)in_2sf/desmume/utils/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/utils/AsmJit/*.cpp) \
|
|
|
11
|
+ $(wildcard $(SRCDIR)in_2sf/desmume/utils/AsmJit/base/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/utils/AsmJit/x86/*.cpp)
|
|
|
12
|
+in_2sf_SRCS:= $(filter-out $(SRCDIR)in_2sf/desmume/debug.cpp $(SRCDIR)in_2sf/desmume/metaspu/SoundTouch/cpu_detect_x86_win.cpp,$(in_2sf_SRCS))
|
|
|
13
|
+in_gsf_SRCS:= $(wildcard $(SRCDIR)in_gsf/*.cpp) $(wildcard $(SRCDIR)in_gsf/vbam/apu/*.cpp) $(wildcard $(SRCDIR)in_gsf/vbam/gba/*.cpp)
|
|
|
14
|
+in_ncsf_SRCS:= $(wildcard $(SRCDIR)in_ncsf/*.cpp) $(wildcard $(SRCDIR)in_ncsf/SSEQPlayer/*.cpp)
|
|
|
15
|
+in_snsf_SRCS:= $(wildcard $(SRCDIR)in_snsf/*.cpp) $(wildcard $(SRCDIR)in_snsf/snes9x/*.cpp) $(wildcard $(SRCDIR)in_snsf/snes9x/apu/*.cpp)
|
|
16
|
16
|
|
|
17
|
|
-$(foreach FILE,$(ALL_OBJS),$(shell mkdir -p $(dir $(FILE))))
|
|
|
17
|
+DLLS= in_2sf in_gsf in_ncsf in_snsf
|
|
|
18
|
+DLLS:= $(sort $(addsuffix .dll,$(DLLS)))
|
|
18
|
19
|
|
|
19
|
|
-CXX ?= g++
|
|
20
|
|
-CFLAGS ?= -pipe -pedantic -Wall -Wextra -Winit-self -Wfloat-equal -Wshadow -Wcast-qual -Wlogical-op -Wunreachable-code -Wabi -Wno-unused-parameter -Wno-variadic-macros -Wno-strict-aliasing
|
|
21
|
|
-CXXFLAGS ?= -Woverloaded-virtual
|
|
|
20
|
+COMPILER:= $(shell $(CXX) -v 2>/dev/stdout)
|
|
22
|
21
|
|
|
23
|
|
-obj/%.o : %.c
|
|
24
|
|
- @echo "Compiling $^..."
|
|
25
|
|
- @$(CC) -std=gnu99 $(CFLAGS) -Wc++-compat -DWINAMP_PLUGIN -D_WINDOWS -I. $(EXTRA_INCLUDES) -I/c/Program\ Files/Winamp\ SDK -o $@ -c $^
|
|
|
22
|
+CPPFLAGS+= -std=gnu++11 -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
|
|
|
23
|
+CXXFLAGS+= -std=gnu++11 -pipe -Wall -Wctor-dtor-privacy -Wold-style-cast -Wextra -Wno-div-by-zero -Wfloat-equal -Wshadow -Winit-self -Wcast-qual -Wunreachable-code -Wabi -Woverloaded-virtual -Wno-long-long -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
|
|
|
24
|
+ifeq (,$(findstring clang,$(COMPILER)))
|
|
|
25
|
+CXXFLAGS+= -Wlogical-op
|
|
|
26
|
+endif
|
|
|
27
|
+LDFLAGS+= -lz
|
|
26
|
28
|
|
|
27
|
|
-obj/%.o : %.cpp
|
|
28
|
|
- @echo "Compiling $^..."
|
|
29
|
|
- @$(CXX) -std=gnu++98 $(CFLAGS) $(CXXFLAGS) -DWINAMP_PLUGIN -D_WINDOWS -I. $(EXTRA_INCLUDES) -I/c/Program\ Files/Winamp\ SDK -o $@ -c $^
|
|
|
29
|
+ifneq (,$(findstring MINGW,$(UNAME)))
|
|
|
30
|
+ifeq (,$(findstring clang,$(COMPILER)))
|
|
|
31
|
+LDFLAGS+= -static-libgcc -static-libstdc++
|
|
|
32
|
+endif
|
|
|
33
|
+endif
|
|
30
|
34
|
|
|
31
|
|
-.PHONY: clean all profile debug optimized
|
|
|
35
|
+DLL_SRCS_template= $(1)_SRCS:= $$(sort $$($(1)_SRCS))
|
|
|
36
|
+DLL_OBJS_template= $(1)_OBJS:= $$(subst $(SRCDIR),,$$($(1)_SRCS:%.cpp=%.o))
|
|
|
37
|
+
|
|
|
38
|
+$(foreach dll,$(DLLS),$(eval $(call DLL_SRCS_template,$(basename $(notdir $(dll))))))
|
|
|
39
|
+$(foreach dll,$(DLLS),$(eval $(call DLL_OBJS_template,$(basename $(notdir $(dll))))))
|
|
|
40
|
+
|
|
|
41
|
+SRCS:= $(sort $(FRAMEWORK_SRCS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_SRCS)))
|
|
|
42
|
+OBJS:= $(sort $(FRAMEWORK_OBJS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_OBJS)))
|
|
|
43
|
+DEPS:= $(OBJS:%.o=%.d)
|
|
|
44
|
+
|
|
|
45
|
+.PHONY: all debug clean
|
|
|
46
|
+
|
|
|
47
|
+.SUFFIXES:
|
|
|
48
|
+.SUFFIXES: .cpp .o .d .a .dll
|
|
32
|
49
|
|
|
33
|
50
|
all: $(DLLS)
|
|
34
|
|
-profile: CFLAGS += -g -pg
|
|
35
|
|
-profile: all
|
|
36
|
|
-debug: CFLAGS += -g
|
|
|
51
|
+debug: CXXFLAGS+= -g -D_DEBUG
|
|
37
|
52
|
debug: all
|
|
38
|
|
-optimized: CFLAGS += -O3
|
|
39
|
|
-optimized: all
|
|
40
|
|
-
|
|
41
|
|
-$(IN_XSF_OBJS): CXXFLAGS += -Weffc++
|
|
42
|
|
-$(IN_2SF_OBJS): EXTRA_INCLUDES = -Idesmume
|
|
43
|
|
-$(IN_2SF_OBJS): CFLAGS += -DHAVE_LIBZ
|
|
44
|
|
-in_2sf.dll: $(IN_XSF_OBJS) $(IN_2SF_OBJS)
|
|
45
|
|
- @echo "Linking $@..."
|
|
46
|
|
- @$(CXX) $(CFLAGS) -static-libgcc -static-libstdc++ -shared -o $@ $^ -lz -lgdi32
|
|
47
|
|
-$(IN_GSF_OBJS): EXTRA_INCLUDES = -Ivbam
|
|
48
|
|
-$(IN_GSF_OBJS): CFLAGS += -DNO_DEBUGGER -DFINAL_VERSION
|
|
49
|
|
-in_gsf.dll: $(IN_XSF_OBJS) $(IN_GSF_OBJS)
|
|
50
|
|
- @echo "Linking $@..."
|
|
51
|
|
- @$(CXX) $(CFLAGS) -static-libgcc -static-libstdc++ -shared -o $@ $^ -lz -lgdi32
|
|
52
|
|
-$(IN_SNSF_OBJS): EXTRA_INCLUDES = -Isnes9x
|
|
53
|
|
-in_snsf.dll: $(IN_XSF_OBJS) $(IN_SNSF_OBJS)
|
|
54
|
|
- @echo "Linking $@..."
|
|
55
|
|
- @$(CXX) $(CFLAGS) -static-libgcc -static-libstdc++ -shared -o $@ $^ -lz -lgdi32
|
|
56
|
|
-$(IN_NCSF_OBJS): EXTRA_INCLUDES = -ISSEQPlayer
|
|
57
|
|
-in_snsf.dll: $(IN_XSF_OBJS) $(IN_NCSF_OBJS)
|
|
58
|
|
- @echo "Linking $@..."
|
|
59
|
|
- @$(CXX) $(CFLAGS) -static-libgcc -static-libstdc++ -shared -o $@ $^ -lz -lgdi32
|
|
60
|
|
-tmp.exe: $(IN_XSF_OBJS) $(IN_2SF_OBJS) $(TMP_OBJS)
|
|
61
|
|
- @echo "Linking $@..."
|
|
62
|
|
- @$(CXX) $(CFLAGS) -static-libgcc -static-libstdc++ -o $@ $^ -lz -lgdi32
|
|
|
53
|
+
|
|
|
54
|
+define DLL_template
|
|
|
55
|
+$(1): $$(FRAMEWORK_OBJS) $$($$(basename $$(notdir $(1)))_OBJS)
|
|
|
56
|
+ @echo "Linking $$@..."
|
|
|
57
|
+ @$$(CXX) -shared -fPIC $$(CXXFLAGS) -o $$@ $$^ $$(LDFLAGS)
|
|
|
58
|
+endef
|
|
|
59
|
+define SRC_template
|
|
|
60
|
+$$(subst $(SRCDIR),,$(1:%.cpp=%.o)): $(1)
|
|
|
61
|
+ @echo "Compiling $$<..."
|
|
|
62
|
+ @$$(CXX) $$(CXXFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
|
|
|
63
|
+endef
|
|
|
64
|
+define DEP_template
|
|
|
65
|
+$$(subst $(SRCDIR),,$(1:%.cpp=%.d)): $(1)
|
|
|
66
|
+ @echo "Calculating depends for $$<..."
|
|
|
67
|
+ -@mkdir -p $$(@D)
|
|
|
68
|
+ @$$(CXX) $$(CPPFLAGS) -MM -MF $$(subst $(SRCDIR),,$$@).tmp $$<
|
|
|
69
|
+ @sed 's,$$(notdir $$*)\.o[ :]*,$$(subst /,\/,$$*).o $$(subst /,\/,$$@): ,g' < $$(subst $(SRCDIR),,$$@).tmp > $$(subst $(SRCDIR),,$$@)
|
|
|
70
|
+ @rm $$(subst $(SRCDIR),,$$@).tmp
|
|
|
71
|
+endef
|
|
|
72
|
+
|
|
|
73
|
+$(foreach dll,$(DLLS),$(eval $(call DLL_template,$(dll))))
|
|
|
74
|
+$(foreach src,$(SRCS),$(eval $(call SRC_template,$(src))))
|
|
|
75
|
+$(foreach src,$(SRCS),$(eval $(call DEP_template,$(src))))
|
|
|
76
|
+
|
|
|
77
|
+$(subst $(SRCDIR),,$(in_2sf_SRCS:%.cpp=%.d)): CPPFLAGS+= -msse
|
|
|
78
|
+$(in_2sf_OBJS): CXXFLAGS+= -msse -DHAVE_LIBZ
|
|
|
79
|
+
|
|
|
80
|
+in_2sf/desmume/MMU.o: CXXFLAGS+= -Wno-shadow
|
|
|
81
|
+in_2sf/desmume/utils/AsmJit/base/codegen.o: CXXFLAGS+= -Wno-unused-value
|
|
|
82
|
+in_2sf/desmume/utils/AsmJit/base/runtime.o: CXXFLAGS+= -Wno-unused-parameter
|
|
|
83
|
+in_2sf/desmume/utils/AsmJit/base/vmem.o: CXXFLAGS+= -Wno-missing-field-initializers -Wno-unused-function
|
|
|
84
|
+ifneq (,$(findstring clang,$(COMPILER)))
|
|
|
85
|
+in_2sf/desmume/utils/AsmJit/base/vmem.o: CXXFLAGS+= -Wno-missing-braces
|
|
|
86
|
+endif
|
|
|
87
|
+in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: CXXFLAGS+= -Wno-unused-variable
|
|
|
88
|
+ifneq (,$(findstring clang,$(COMPILER)))
|
|
|
89
|
+in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: CXXFLAGS+= -Wno-missing-braces
|
|
|
90
|
+endif
|
|
|
91
|
+in_2sf/desmume/utils/AsmJit/x86/x86context.o: CXXFLAGS+= -Wno-unused-parameter -Wno-unused-value -Wno-unused-variable
|
|
|
92
|
+in_gsf/vbam/gba/GBA-arm.o: CXXFLAGS+= -Wno-unused-variable
|
|
|
93
|
+ifeq (,$(findstring clang,$(COMPILER)))
|
|
|
94
|
+in_gsf/vbam/gba/GBA-arm.o: CXXFLAGS+= -Wno-unused-but-set-variable
|
|
|
95
|
+endif
|
|
63
|
96
|
|
|
64
|
97
|
clean:
|
|
65
|
|
- @echo "Cleaning DLLs and OBJs..."
|
|
66
|
|
- @-rm -f $(DLLS) $(ALL_OBJS)
|
|
|
98
|
+ @echo "Cleaning OBJs and DLLs..."
|
|
|
99
|
+ -@rm $(OBJS) $(DLLS)
|
|
|
100
|
+
|
|
|
101
|
+-include $(DEPS)
|