Skip to content

Commit 53f10fc

Browse files
authored
Merge pull request #1557 from OutpostUniverse/makefileMingwWineUpgrades
Upgrade `makefile` support for Mingw and Wine
2 parents 8df2265 + d668cc8 commit 53f10fc

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

makefile

+20-10
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ CONFIG_CXX_FLAGS := $($(CONFIG)_CXX_FLAGS)
99
CURRENT_OS := $(shell uname 2>/dev/null || echo Unknown)
1010
TARGET_OS ?= $(CURRENT_OS)
1111

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+
1218
ROOTBUILDDIR := .build
1319
BUILDDIRPREFIX := $(ROOTBUILDDIR)/$(CONFIG)_Linux_
1420

1521

1622
## Default and top-level targets ##
1723

1824
.PHONY: all
19-
all: ophd
25+
all: ophd$(EXE_SUFFIX)
2026

2127
.PHONY: test
2228
test: testLibOPHD testLibControls
@@ -56,10 +62,14 @@ Darwin_OpenGL_LIBS := -lGLEW -framework OpenGL
5662
Windows_OpenGL_LIBS := -lglew32 -lopengl32
5763
OpenGL_LIBS := $($(TARGET_OS)_OpenGL_LIBS)
5864

65+
SDL_CONFIG := sdl2-config
66+
SDL_CONFIG_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
67+
SDL_CONFIG_LIBS = $(shell $(SDL_CONFIG) --libs)
68+
5969
CPPFLAGS := $(CPPFLAGS_EXTRA)
6070
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)
6373
LDLIBS := $(LDLIBS_EXTRA) -lSDL2_ttf -lSDL2_image -lSDL2_mixer -lSDL2 $(OpenGL_LIBS)
6474

6575
PROJECT_FLAGS := $(CPPFLAGS) $(CXXFLAGS)
@@ -106,7 +116,7 @@ include $(wildcard $(patsubst %.o,%.d,$(libControls_OBJS)))
106116

107117
testLibOphd_SRCDIR := testLibOPHD/
108118
testLibOphd_OBJDIR := $(BUILDDIRPREFIX)$(testLibOphd_SRCDIR)Intermediate/
109-
testLibOphd_OUTPUT := $(BUILDDIRPREFIX)$(testLibOphd_SRCDIR)testLibOPHD
119+
testLibOphd_OUTPUT := $(BUILDDIRPREFIX)$(testLibOphd_SRCDIR)testLibOPHD$(EXE_SUFFIX)
110120
testLibOphd_SRCS := $(shell find $(testLibOphd_SRCDIR) -name '*.cpp')
111121
testLibOphd_OBJS := $(patsubst $(testLibOphd_SRCDIR)%.cpp,$(testLibOphd_OBJDIR)%.o,$(testLibOphd_SRCS))
112122

@@ -121,7 +131,7 @@ testLibOPHD: $(testLibOphd_OUTPUT)
121131

122132
.PHONY: checkOPHD
123133
checkOPHD: $(testLibOphd_OUTPUT)
124-
$(testLibOphd_OUTPUT)
134+
$(RUN_PREFIX) $(testLibOphd_OUTPUT)
125135

126136
$(testLibOphd_OUTPUT): PROJECT_LINKFLAGS := $(testLibOphd_PROJECT_LINKFLAGS)
127137
$(testLibOphd_OUTPUT): $(testLibOphd_OBJS) $(libOPHD_OUTPUT) $(NAS2DLIB)
@@ -136,7 +146,7 @@ include $(wildcard $(patsubst %.o,%.d,$(testLibOphd_OBJS)))
136146

137147
testLibControls_SRCDIR := testLibControls/
138148
testLibControls_OBJDIR := $(BUILDDIRPREFIX)$(testLibControls_SRCDIR)Intermediate/
139-
testLibControls_OUTPUT := $(BUILDDIRPREFIX)$(testLibControls_SRCDIR)testLibControls
149+
testLibControls_OUTPUT := $(BUILDDIRPREFIX)$(testLibControls_SRCDIR)testLibControls$(EXE_SUFFIX)
140150
testLibControls_SRCS := $(shell find $(testLibControls_SRCDIR) -name '*.cpp')
141151
testLibControls_OBJS := $(patsubst $(testLibControls_SRCDIR)%.cpp,$(testLibControls_OBJDIR)%.o,$(testLibControls_SRCS))
142152

@@ -151,7 +161,7 @@ testLibControls: $(testLibControls_OUTPUT)
151161

152162
.PHONY: checkControls
153163
checkControls: $(testLibControls_OUTPUT)
154-
$(testLibControls_OUTPUT)
164+
$(RUN_PREFIX) $(testLibControls_OUTPUT)
155165

156166
$(testLibControls_OUTPUT): PROJECT_LINKFLAGS := $(testLibControls_PROJECT_LINKFLAGS)
157167
$(testLibControls_OUTPUT): $(testLibControls_OBJS) $(libControls_OUTPUT) $(NAS2DLIB)
@@ -166,7 +176,7 @@ include $(wildcard $(patsubst %.o,%.d,$(testLibControls_OBJS)))
166176

167177
demoLibControls_SRCDIR := demoLibControls/
168178
demoLibControls_OBJDIR := $(BUILDDIRPREFIX)$(demoLibControls_SRCDIR)Intermediate/
169-
demoLibControls_OUTPUT := $(BUILDDIRPREFIX)$(demoLibControls_SRCDIR)demoLibControls
179+
demoLibControls_OUTPUT := $(BUILDDIRPREFIX)$(demoLibControls_SRCDIR)demoLibControls$(EXE_SUFFIX)
170180
demoLibControls_SRCS := $(shell find $(demoLibControls_SRCDIR) -name '*.cpp')
171181
demoLibControls_OBJS := $(patsubst $(demoLibControls_SRCDIR)%.cpp,$(demoLibControls_OBJDIR)%.o,$(demoLibControls_SRCS))
172182

@@ -178,7 +188,7 @@ demoLibControls: $(demoLibControls_OUTPUT)
178188

179189
.PHONY: runDemoControls
180190
runDemoControls:
181-
$(demoLibControls_OUTPUT)
191+
$(RUN_PREFIX) $(demoLibControls_OUTPUT)
182192

183193
$(demoLibControls_OUTPUT): $(demoLibControls_OBJS) $(libControls_OUTPUT) $(NAS2DLIB)
184194

@@ -192,7 +202,7 @@ include $(wildcard $(patsubst %.o,%.d,$(demoLibControls_OBJS)))
192202

193203
ophd_SRCDIR := appOPHD/
194204
ophd_OBJDIR := $(BUILDDIRPREFIX)$(ophd_SRCDIR)Intermediate/
195-
ophd_OUTPUT := ophd
205+
ophd_OUTPUT := ophd$(EXE_SUFFIX)
196206
ophd_SRCS := $(shell find $(ophd_SRCDIR) -name '*.cpp')
197207
ophd_OBJS := $(patsubst $(ophd_SRCDIR)%.cpp,$(ophd_OBJDIR)%.o,$(ophd_SRCS))
198208

0 commit comments

Comments
 (0)