@@ -9,14 +9,20 @@ CONFIG_CXX_FLAGS := $($(CONFIG)_CXX_FLAGS)
9
9
CURRENT_OS := $(shell uname 2>/dev/null || echo Unknown)
10
10
TARGET_OS ?= $(CURRENT_OS )
11
11
12
+ Windows_RUN_PREFIX := wine
13
+ RUN_PREFIX := $($(TARGET_OS ) _RUN_PREFIX)
14
+
15
+ Windows_EXE_SUFFIX := .exe
16
+ EXE_SUFFIX := $($(TARGET_OS ) _EXE_SUFFIX)
17
+
12
18
ROOTBUILDDIR := .build
13
19
BUILDDIRPREFIX := $(ROOTBUILDDIR ) /$(CONFIG ) _Linux_
14
20
15
21
16
22
# # Default and top-level targets ##
17
23
18
24
.PHONY : all
19
- all : ophd
25
+ all : ophd$( EXE_SUFFIX )
20
26
21
27
.PHONY : test
22
28
test : testLibOPHD testLibControls
@@ -56,10 +62,14 @@ Darwin_OpenGL_LIBS := -lGLEW -framework OpenGL
56
62
Windows_OpenGL_LIBS := -lglew32 -lopengl32
57
63
OpenGL_LIBS := $($(TARGET_OS ) _OpenGL_LIBS)
58
64
65
+ SDL_CONFIG := sdl2-config
66
+ SDL_CONFIG_CFLAGS = $(shell $(SDL_CONFIG ) --cflags)
67
+ SDL_CONFIG_LIBS = $(shell $(SDL_CONFIG ) --libs)
68
+
59
69
CPPFLAGS := $(CPPFLAGS_EXTRA )
60
70
CXXFLAGS_WARN := -Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wnull-dereference -Wold-style-cast -Wcast-qual -Wcast-align -Wdouble-promotion -Wfloat-conversion -Wsign-conversion -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Wmissing-include-dirs -Winvalid-pch -Wmissing-format-attribute $(WARN_EXTRA )
61
- CXXFLAGS := $(CXXFLAGS_EXTRA ) $(CONFIG_CXX_FLAGS ) -std=c++20 $(CXXFLAGS_WARN ) -I$(NAS2DINCLUDEDIR ) $(shell sdl2-config --cflags )
62
- LDFLAGS := $(LDFLAGS_EXTRA ) $(shell sdl2-config --libs )
71
+ CXXFLAGS := $(CXXFLAGS_EXTRA ) $(CONFIG_CXX_FLAGS ) -std=c++20 $(CXXFLAGS_WARN ) -I$(NAS2DINCLUDEDIR ) $(SDL_CONFIG_CFLAGS )
72
+ LDFLAGS := $(LDFLAGS_EXTRA ) $(SDL_CONFIG_LIBS )
63
73
LDLIBS := $(LDLIBS_EXTRA ) -lSDL2_ttf -lSDL2_image -lSDL2_mixer -lSDL2 $(OpenGL_LIBS )
64
74
65
75
PROJECT_FLAGS := $(CPPFLAGS ) $(CXXFLAGS )
@@ -106,7 +116,7 @@ include $(wildcard $(patsubst %.o,%.d,$(libControls_OBJS)))
106
116
107
117
testLibOphd_SRCDIR := testLibOPHD/
108
118
testLibOphd_OBJDIR := $(BUILDDIRPREFIX )$(testLibOphd_SRCDIR ) Intermediate/
109
- testLibOphd_OUTPUT := $(BUILDDIRPREFIX )$(testLibOphd_SRCDIR ) testLibOPHD
119
+ testLibOphd_OUTPUT := $(BUILDDIRPREFIX )$(testLibOphd_SRCDIR ) testLibOPHD$( EXE_SUFFIX )
110
120
testLibOphd_SRCS := $(shell find $(testLibOphd_SRCDIR ) -name '* .cpp')
111
121
testLibOphd_OBJS := $(patsubst $(testLibOphd_SRCDIR ) % .cpp,$(testLibOphd_OBJDIR ) % .o,$(testLibOphd_SRCS ) )
112
122
@@ -121,7 +131,7 @@ testLibOPHD: $(testLibOphd_OUTPUT)
121
131
122
132
.PHONY : checkOPHD
123
133
checkOPHD : $(testLibOphd_OUTPUT )
124
- $(testLibOphd_OUTPUT )
134
+ $(RUN_PREFIX ) $( testLibOphd_OUTPUT )
125
135
126
136
$(testLibOphd_OUTPUT ) : PROJECT_LINKFLAGS := $(testLibOphd_PROJECT_LINKFLAGS )
127
137
$(testLibOphd_OUTPUT ) : $(testLibOphd_OBJS ) $(libOPHD_OUTPUT ) $(NAS2DLIB )
@@ -136,7 +146,7 @@ include $(wildcard $(patsubst %.o,%.d,$(testLibOphd_OBJS)))
136
146
137
147
testLibControls_SRCDIR := testLibControls/
138
148
testLibControls_OBJDIR := $(BUILDDIRPREFIX )$(testLibControls_SRCDIR ) Intermediate/
139
- testLibControls_OUTPUT := $(BUILDDIRPREFIX )$(testLibControls_SRCDIR ) testLibControls
149
+ testLibControls_OUTPUT := $(BUILDDIRPREFIX )$(testLibControls_SRCDIR ) testLibControls$( EXE_SUFFIX )
140
150
testLibControls_SRCS := $(shell find $(testLibControls_SRCDIR ) -name '* .cpp')
141
151
testLibControls_OBJS := $(patsubst $(testLibControls_SRCDIR ) % .cpp,$(testLibControls_OBJDIR ) % .o,$(testLibControls_SRCS ) )
142
152
@@ -151,7 +161,7 @@ testLibControls: $(testLibControls_OUTPUT)
151
161
152
162
.PHONY : checkControls
153
163
checkControls : $(testLibControls_OUTPUT )
154
- $(testLibControls_OUTPUT )
164
+ $(RUN_PREFIX ) $( testLibControls_OUTPUT )
155
165
156
166
$(testLibControls_OUTPUT ) : PROJECT_LINKFLAGS := $(testLibControls_PROJECT_LINKFLAGS )
157
167
$(testLibControls_OUTPUT ) : $(testLibControls_OBJS ) $(libControls_OUTPUT ) $(NAS2DLIB )
@@ -166,7 +176,7 @@ include $(wildcard $(patsubst %.o,%.d,$(testLibControls_OBJS)))
166
176
167
177
demoLibControls_SRCDIR := demoLibControls/
168
178
demoLibControls_OBJDIR := $(BUILDDIRPREFIX )$(demoLibControls_SRCDIR ) Intermediate/
169
- demoLibControls_OUTPUT := $(BUILDDIRPREFIX )$(demoLibControls_SRCDIR ) demoLibControls
179
+ demoLibControls_OUTPUT := $(BUILDDIRPREFIX )$(demoLibControls_SRCDIR ) demoLibControls$( EXE_SUFFIX )
170
180
demoLibControls_SRCS := $(shell find $(demoLibControls_SRCDIR ) -name '* .cpp')
171
181
demoLibControls_OBJS := $(patsubst $(demoLibControls_SRCDIR ) % .cpp,$(demoLibControls_OBJDIR ) % .o,$(demoLibControls_SRCS ) )
172
182
@@ -178,7 +188,7 @@ demoLibControls: $(demoLibControls_OUTPUT)
178
188
179
189
.PHONY : runDemoControls
180
190
runDemoControls :
181
- $(demoLibControls_OUTPUT )
191
+ $(RUN_PREFIX ) $( demoLibControls_OUTPUT )
182
192
183
193
$(demoLibControls_OUTPUT ) : $(demoLibControls_OBJS ) $(libControls_OUTPUT ) $(NAS2DLIB )
184
194
@@ -192,7 +202,7 @@ include $(wildcard $(patsubst %.o,%.d,$(demoLibControls_OBJS)))
192
202
193
203
ophd_SRCDIR := appOPHD/
194
204
ophd_OBJDIR := $(BUILDDIRPREFIX )$(ophd_SRCDIR ) Intermediate/
195
- ophd_OUTPUT := ophd
205
+ ophd_OUTPUT := ophd$( EXE_SUFFIX )
196
206
ophd_SRCS := $(shell find $(ophd_SRCDIR ) -name '* .cpp')
197
207
ophd_OBJS := $(patsubst $(ophd_SRCDIR ) % .cpp,$(ophd_OBJDIR ) % .o,$(ophd_SRCS ) )
198
208
0 commit comments