Browse code

fix mingw build, clean up new warnings

Adam Higerd authored on 2021/02/11 17:42:05
Showing 1 changed files
... ...
@@ -2,14 +2,18 @@ UNAME:=	$(shell uname -s)
2 2
 
3 3
 SRCDIR:=	$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
4 4
 
5
+ZLIB_SRCS:= $(sort $(wildcard $(SRCDIR)in_xsf_framework/zlib/*.c))
6
+ZLIB_OBJS:=	$(subst $(SRCDIR),,$(ZLIB_SRCS:%.c=%.o))
5 7
 FRAMEWORK_SRCS:=	$(sort $(wildcard $(SRCDIR)in_xsf_framework/*.cpp))
6 8
 FRAMEWORK_OBJS:=	$(subst $(SRCDIR),,$(FRAMEWORK_SRCS:%.cpp=%.o))
7 9
 
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))
10
+in_2sf_SRCS:=	$(wildcard $(SRCDIR)in_2sf/*.cpp \
11
+	$(SRCDIR)in_2sf/desmume/*.cpp \
12
+	$(SRCDIR)in_2sf/desmume/*/*.cpp \
13
+	$(SRCDIR)in_2sf/desmume/*/*/*.cpp \
14
+	$(SRCDIR)in_2sf/desmume/*/*/*/*.cpp \
15
+	$(SRCDIR)in_2sf/desmume/*/*/*/*/*.cpp \
16
+	$(SRCDIR)in_2sf/spu/*.cpp)
13 17
 in_gsf_SRCS:=	$(wildcard $(SRCDIR)in_gsf/*.cpp) $(wildcard $(SRCDIR)in_gsf/vbam/apu/*.cpp) $(wildcard $(SRCDIR)in_gsf/vbam/gba/*.cpp)
14 18
 in_ncsf_SRCS:=	$(wildcard $(SRCDIR)in_ncsf/*.cpp) $(wildcard $(SRCDIR)in_ncsf/SSEQPlayer/*.cpp)
15 19
 in_snsf_SRCS:=	$(wildcard $(SRCDIR)in_snsf/*.cpp) $(wildcard $(SRCDIR)in_snsf/snes9x/*.cpp) $(wildcard $(SRCDIR)in_snsf/snes9x/apu/*.cpp)
... ...
@@ -19,12 +23,13 @@ DLLS:=	$(sort $(addsuffix .dll,$(DLLS)))
19 23
 
20 24
 COMPILER:=	$(shell $(CXX) -v 2>/dev/stdout)
21 25
 
22
-MY_CPPFLAGS=	$(CPPFLAGS) -std=gnu++11 -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
23
-MY_CXXFLAGS=	$(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 -Wno-switch -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
26
+MY_CPPFLAGS=	$(CPPFLAGS) -std=gnu++17 -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN -D_WINDOWS -I$(SRCDIR)in_xsf_framework -I$(SRCDIR)in_xsf_framework/winamp -I$(SRCDIR)in_xsf_framework/zlib -I$(SRCDIR)in_2sf/desmume
27
+MY_CXXFLAGS=	$(CXXFLAGS) -std=gnu++17 -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN -D_WINDOWS -I$(SRCDIR)in_xsf_framework -I$(SRCDIR)in_xsf_framework/winamp -I$(SRCDIR)in_xsf_framework/zlib -pipe -Wall -Wctor-dtor-privacy -Wold-style-cast -Wextra -Wno-div-by-zero -Wfloat-equal -Wshadow -Winit-self -Wcast-qual -Wunreachable-code -Woverloaded-virtual -Wno-long-long -Wno-switch
28
+MY_CFLAGS=	$(CFLAGS) -std=gnu17 -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN -D_WINDOWS -I$(SRCDIR)in_xsf_framework -I$(SRCDIR)in_xsf_framework/winamp -I$(SRCDIR)in_xsf_framework/zlib -pipe -Wall -Wextra -Wno-div-by-zero -Wfloat-equal -Wshadow -Winit-self -Wcast-qual -Wunreachable-code -Wno-long-long -Wno-switch
24 29
 ifeq (,$(findstring clang,$(COMPILER)))
25 30
 MY_CXXFLAGS+=	-Wlogical-op
26 31
 endif
27
-MY_LDFLAGS=	$(LDFLAGS) -lz
32
+MY_LDFLAGS=	$(LDFLAGS)
28 33
 
29 34
 DLL_SRCS_template=	$(1)_SRCS:=	$$(sort $$($(1)_SRCS))
30 35
 DLL_OBJS_template=	$(1)_OBJS:=	$$(subst $(SRCDIR),,$$($(1)_SRCS:%.cpp=%.o))
... ...
@@ -32,8 +37,8 @@ DLL_OBJS_template=	$(1)_OBJS:=	$$(subst $(SRCDIR),,$$($(1)_SRCS:%.cpp=%.o))
32 37
 $(foreach dll,$(DLLS),$(eval $(call DLL_SRCS_template,$(basename $(notdir $(dll))))))
33 38
 $(foreach dll,$(DLLS),$(eval $(call DLL_OBJS_template,$(basename $(notdir $(dll))))))
34 39
 
35
-SRCS:=	$(sort $(FRAMEWORK_SRCS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_SRCS)))
36
-OBJS:=	$(sort $(FRAMEWORK_OBJS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_OBJS)))
40
+SRCS:=	$(sort $(FRAMEWORK_SRCS) $(ZLIB_SRCS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_SRCS)))
41
+OBJS:=	$(sort $(FRAMEWORK_OBJS) $(ZLIB_OBJS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_OBJS)))
37 42
 DEPS:=	$(OBJS:%.o=%.d)
38 43
 
39 44
 .PHONY: all debug clean
... ...
@@ -46,17 +51,27 @@ debug: MY_CXXFLAGS+=	-g -D_DEBUG
46 51
 debug: all
47 52
 
48 53
 define DLL_template
49
-$(1): $$(FRAMEWORK_OBJS) $$($$(basename $$(notdir $(1)))_OBJS)
54
+$(1): $$(FRAMEWORK_OBJS) $$(ZLIB_OBJS) $$($$(basename $$(notdir $(1)))_OBJS)
50 55
 	@echo "Linking $$@..."
51
-	@$$(CXX) -shared -fPIC $$(MY_CXXFLAGS) -o $$@ $$^ $$(MY_LDFLAGS)
56
+	$$(CXX) -shared -fPIC $$(MY_CXXFLAGS) -o $$@ $$^ $$(MY_LDFLAGS)
52 57
 endef
53 58
 define SRC_template
59
+ifeq ($(findstring .cpp,$(1)),.cpp)
54 60
 $$(subst $(SRCDIR),,$(1:%.cpp=%.o)): $(1)
55 61
 	@echo "Compiling $$<..."
56 62
 	@$$(CXX) $$(MY_CXXFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
63
+else
64
+$$(subst $(SRCDIR),,$(1:%.c=%.o)): $(1)
65
+	@echo "Compiling $$<..."
66
+	@$$(CC) $$(MY_CFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
67
+endif
57 68
 endef
58 69
 define DEP_template
70
+ifeq ($(findstring .cpp,$(1)),.cpp)
59 71
 $$(subst $(SRCDIR),,$(1:%.cpp=%.d)): $(1)
72
+else
73
+$$(subst $(SRCDIR),,$(1:%.c=%.d)): $(1)
74
+endif
60 75
 	@echo "Calculating depends for $$<..."
61 76
 	-@mkdir -p $$(@D)
62 77
 	@$$(CXX) $$(MY_CPPFLAGS) -MM -MF $$(subst $(SRCDIR),,$$@).tmp $$<
... ...
@@ -69,20 +84,15 @@ $(foreach src,$(SRCS),$(eval $(call SRC_template,$(src))))
69 84
 $(foreach src,$(SRCS),$(eval $(call DEP_template,$(src))))
70 85
 
71 86
 $(subst $(SRCDIR),,$(in_2sf_SRCS:%.cpp=%.d)): MY_CPPFLAGS+=	-msse
72
-$(in_2sf_OBJS): MY_CXXFLAGS+=	-msse -DHAVE_LIBZ
87
+$(in_2sf_OBJS): MY_CXXFLAGS+=	-msse -DHAVE_LIBZ -I$(SRCDIR)/in_2sf/desmume
73 88
 
74
-in_2sf/desmume/MMU.o: MY_CXXFLAGS+=	-Wno-shadow
75
-in_2sf/desmume/utils/AsmJit/base/codegen.o: MY_CXXFLAGS+=	-Wno-unused-value
76
-in_2sf/desmume/utils/AsmJit/base/runtime.o: MY_CXXFLAGS+=	-Wno-unused-parameter
77
-in_2sf/desmume/utils/AsmJit/base/vmem.o: MY_CXXFLAGS+=	-Wno-missing-field-initializers -Wno-unused-function
78
-ifneq (,$(findstring clang,$(COMPILER)))
79
-in_2sf/desmume/utils/AsmJit/base/vmem.o: MY_CXXFLAGS+=	-Wno-missing-braces
80
-endif
81
-in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: MY_CXXFLAGS+=	-Wno-unused-variable
89
+in_xsf_framework/zlib/%.o: MY_CFLAGS+= -Wno-implicit-fallthrough -Wno-cast-qual
90
+in_2sf/desmume/%.o: MY_CXXFLAGS+=	-Wno-shadow -Wno-unused-parameter -Wno-unused-value -Wno-unused-variable -Wno-missing-field-initializers -Wno-unused-function -Wno-implicit-fallthrough -Wno-old-style-cast -Wno-deprecated-copy -Wno-class-memaccess -Wno-sign-compare -Wno-float-equal -Wno-unused-but-set-variable
82 91
 ifneq (,$(findstring clang,$(COMPILER)))
83
-in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: MY_CXXFLAGS+=	-Wno-missing-braces
92
+in_2sf/desmume/%.o: MY_CXXFLAGS+=	-Wno-missing-braces
84 93
 endif
85
-in_2sf/desmume/utils/AsmJit/x86/x86context.o: MY_CXXFLAGS+=	-Wno-unused-parameter -Wno-unused-value -Wno-unused-variable
94
+in_snsf/snes9x/%.o: MY_CXXFLAGS+= -Wno-implicit-fallthrough -Wno-shift-negative-value
95
+in_gsf/vbam/apu/Gb_Apu: MY_CXXFLAGS+=	-Wno-implicit-fallthrough
86 96
 in_gsf/vbam/gba/GBA-arm.o: MY_CXXFLAGS+=	-Wno-unused-variable
87 97
 ifeq (,$(findstring clang,$(COMPILER)))
88 98
 in_gsf/vbam/gba/GBA-arm.o: MY_CXXFLAGS+=	-Wno-unused-but-set-variable
... ...
@@ -90,6 +100,6 @@ endif
90 100
 
91 101
 clean:
92 102
 	@echo "Cleaning OBJs and DLLs..."
93
-	-@rm $(OBJS) $(DLLS)
103
+	-@rm -f $(OBJS) $(DLLS) $(DEPS)
94 104
 
95 105
 -include $(DEPS)
Browse code

* Small Makefile changes.

* Removed a couple files that were not being used.
* Cleanups found with clang's -Weverything (and shutting it up about a
lot of things that were ridiculous, as well as ignoring some of the
warnings still coming up).

Naram Qashat authored on 2014/09/25 12:28:21
Showing 1 changed files
... ...
@@ -19,12 +19,12 @@ DLLS:=	$(sort $(addsuffix .dll,$(DLLS)))
19 19
 
20 20
 COMPILER:=	$(shell $(CXX) -v 2>/dev/stdout)
21 21
 
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 -Wno-switch -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
22
+MY_CPPFLAGS=	$(CPPFLAGS) -std=gnu++11 -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
23
+MY_CXXFLAGS=	$(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 -Wno-switch -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
24 24
 ifeq (,$(findstring clang,$(COMPILER)))
25
-CXXFLAGS+=	-Wlogical-op
25
+MY_CXXFLAGS+=	-Wlogical-op
26 26
 endif
27
-LDFLAGS+=	-lz
27
+MY_LDFLAGS=	$(LDFLAGS) -lz
28 28
 
29 29
 DLL_SRCS_template=	$(1)_SRCS:=	$$(sort $$($(1)_SRCS))
30 30
 DLL_OBJS_template=	$(1)_OBJS:=	$$(subst $(SRCDIR),,$$($(1)_SRCS:%.cpp=%.o))
... ...
@@ -42,24 +42,24 @@ DEPS:=	$(OBJS:%.o=%.d)
42 42
 .SUFFIXES: .cpp .o .d .a .dll
43 43
 
44 44
 all: $(DLLS)
45
-debug: CXXFLAGS+=	-g -D_DEBUG
45
+debug: MY_CXXFLAGS+=	-g -D_DEBUG
46 46
 debug: all
47 47
 
48 48
 define DLL_template
49 49
 $(1): $$(FRAMEWORK_OBJS) $$($$(basename $$(notdir $(1)))_OBJS)
50 50
 	@echo "Linking $$@..."
51
-	@$$(CXX) -shared -fPIC $$(CXXFLAGS) -o $$@ $$^ $$(LDFLAGS)
51
+	@$$(CXX) -shared -fPIC $$(MY_CXXFLAGS) -o $$@ $$^ $$(MY_LDFLAGS)
52 52
 endef
53 53
 define SRC_template
54 54
 $$(subst $(SRCDIR),,$(1:%.cpp=%.o)): $(1)
55 55
 	@echo "Compiling $$<..."
56
-	@$$(CXX) $$(CXXFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
56
+	@$$(CXX) $$(MY_CXXFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
57 57
 endef
58 58
 define DEP_template
59 59
 $$(subst $(SRCDIR),,$(1:%.cpp=%.d)): $(1)
60 60
 	@echo "Calculating depends for $$<..."
61 61
 	-@mkdir -p $$(@D)
62
-	@$$(CXX) $$(CPPFLAGS) -MM -MF $$(subst $(SRCDIR),,$$@).tmp $$<
62
+	@$$(CXX) $$(MY_CPPFLAGS) -MM -MF $$(subst $(SRCDIR),,$$@).tmp $$<
63 63
 	@sed 's,$$(notdir $$*)\.o[ :]*,$$(subst /,\/,$$*).o $$(subst /,\/,$$@): ,g' < $$(subst $(SRCDIR),,$$@).tmp > $$(subst $(SRCDIR),,$$@)
64 64
 	@rm $$(subst $(SRCDIR),,$$@).tmp
65 65
 endef
... ...
@@ -68,24 +68,24 @@ $(foreach dll,$(DLLS),$(eval $(call DLL_template,$(dll))))
68 68
 $(foreach src,$(SRCS),$(eval $(call SRC_template,$(src))))
69 69
 $(foreach src,$(SRCS),$(eval $(call DEP_template,$(src))))
70 70
 
71
-$(subst $(SRCDIR),,$(in_2sf_SRCS:%.cpp=%.d)): CPPFLAGS+=	-msse
72
-$(in_2sf_OBJS): CXXFLAGS+=	-msse -DHAVE_LIBZ
71
+$(subst $(SRCDIR),,$(in_2sf_SRCS:%.cpp=%.d)): MY_CPPFLAGS+=	-msse
72
+$(in_2sf_OBJS): MY_CXXFLAGS+=	-msse -DHAVE_LIBZ
73 73
 
74
-in_2sf/desmume/MMU.o: CXXFLAGS+=	-Wno-shadow
75
-in_2sf/desmume/utils/AsmJit/base/codegen.o: CXXFLAGS+=	-Wno-unused-value
76
-in_2sf/desmume/utils/AsmJit/base/runtime.o: CXXFLAGS+=	-Wno-unused-parameter
77
-in_2sf/desmume/utils/AsmJit/base/vmem.o: CXXFLAGS+=	-Wno-missing-field-initializers -Wno-unused-function
74
+in_2sf/desmume/MMU.o: MY_CXXFLAGS+=	-Wno-shadow
75
+in_2sf/desmume/utils/AsmJit/base/codegen.o: MY_CXXFLAGS+=	-Wno-unused-value
76
+in_2sf/desmume/utils/AsmJit/base/runtime.o: MY_CXXFLAGS+=	-Wno-unused-parameter
77
+in_2sf/desmume/utils/AsmJit/base/vmem.o: MY_CXXFLAGS+=	-Wno-missing-field-initializers -Wno-unused-function
78 78
 ifneq (,$(findstring clang,$(COMPILER)))
79
-in_2sf/desmume/utils/AsmJit/base/vmem.o: CXXFLAGS+=	-Wno-missing-braces
79
+in_2sf/desmume/utils/AsmJit/base/vmem.o: MY_CXXFLAGS+=	-Wno-missing-braces
80 80
 endif
81
-in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: CXXFLAGS+=	-Wno-unused-variable
81
+in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: MY_CXXFLAGS+=	-Wno-unused-variable
82 82
 ifneq (,$(findstring clang,$(COMPILER)))
83
-in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: CXXFLAGS+=	-Wno-missing-braces
83
+in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: MY_CXXFLAGS+=	-Wno-missing-braces
84 84
 endif
85
-in_2sf/desmume/utils/AsmJit/x86/x86context.o: CXXFLAGS+=	-Wno-unused-parameter -Wno-unused-value -Wno-unused-variable
86
-in_gsf/vbam/gba/GBA-arm.o: CXXFLAGS+=	-Wno-unused-variable
85
+in_2sf/desmume/utils/AsmJit/x86/x86context.o: MY_CXXFLAGS+=	-Wno-unused-parameter -Wno-unused-value -Wno-unused-variable
86
+in_gsf/vbam/gba/GBA-arm.o: MY_CXXFLAGS+=	-Wno-unused-variable
87 87
 ifeq (,$(findstring clang,$(COMPILER)))
88
-in_gsf/vbam/gba/GBA-arm.o: CXXFLAGS+=	-Wno-unused-but-set-variable
88
+in_gsf/vbam/gba/GBA-arm.o: MY_CXXFLAGS+=	-Wno-unused-but-set-variable
89 89
 endif
90 90
 
91 91
 clean:
Browse code

Lots of changes in regards to strings, as follows:

* Removed my custom String class, as well as removed the really old
Unicode ConvertUTF, the UTF Converter, and the UTF Encode/Decode
functions.
* Replaced the above with using standard C++ std::wstring_convert and
std::codecvt_utf8.
* Added headers adapted from llvm's libc++ project for allowing the
above C++ classes to exist with GCC and Clang when libc++ isn't being
used.
* Used std::string over std::wstring whenever possible.
* Added header adapted from llvm's libc++ project to create special
versions of the ifstream and ofstream classes that would utilize _wfopen
on non-MSVC Windows compilers, so those compilers could access files on
Windows that use characters outside the current codepage.
* Removed the -static-libgcc and -static-libstdc++ flags from the
Makefile for non-MSVC builds. The generated DLLs will require extra DLLs
from either Cygwin or MinGW (whichever is used to compile), I've only
tested with MinGW and for some reason they crash Winamp on exit, I have
no idea why.

Naram Qashat authored on 2014/09/24 13:58:55
Showing 1 changed files
... ...
@@ -20,18 +20,12 @@ DLLS:=	$(sort $(addsuffix .dll,$(DLLS)))
20 20
 COMPILER:=	$(shell $(CXX) -v 2>/dev/stdout)
21 21
 
22 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
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 -Wno-switch -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
24 24
 ifeq (,$(findstring clang,$(COMPILER)))
25 25
 CXXFLAGS+=	-Wlogical-op
26 26
 endif
27 27
 LDFLAGS+=	-lz
28 28
 
29
-ifneq (,$(findstring MINGW,$(UNAME)))
30
-ifeq (,$(findstring clang,$(COMPILER)))
31
-LDFLAGS+=	-static-libgcc -static-libstdc++
32
-endif
33
-endif
34
-
35 29
 DLL_SRCS_template=	$(1)_SRCS:=	$$(sort $$($(1)_SRCS))
36 30
 DLL_OBJS_template=	$(1)_OBJS:=	$$(subst $(SRCDIR),,$$($(1)_SRCS:%.cpp=%.o))
37 31
 
Browse code

Replaced the Makefile with one that handles things better.

* g++ compiled DLLs seem to not be seen by Winamp when the
-static-libgcc and -static-libstdc++ flags are used.
* clang++ compiled DLLs seem to cause Winamp to crash on exit.

Naram Qashat authored on 2014/09/18 20:02:22
Showing 1 changed files
... ...
@@ -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)
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,66 @@
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
3
+
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
10
+
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)))
13
+
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
16
+
17
+$(foreach FILE,$(ALL_OBJS),$(shell mkdir -p $(dir $(FILE))))
18
+
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
22
+
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 $^
26
+
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 $^
30
+
31
+.PHONY: clean all profile debug optimized
32
+
33
+all: $(DLLS)
34
+profile: CFLAGS += -g -pg
35
+profile: all
36
+debug: CFLAGS += -g
37
+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
63
+
64
+clean:
65
+	@echo "Cleaning DLLs and OBJs..."
66
+	@-rm -f $(DLLS) $(ALL_OBJS)