Files
RetroArch/Makefile.win
T
LibretroAdmin e9d708f269 Makefile.win: definitions and objects agree, and imm32 links
Two kinds of drift a direct mingw build tripped over, found while
building the audit lane. DEFINES has carried -DHAVE_OVERLAY since
before the object list moved to Makefile.common, which keys off the
make variables: the define without the variable compiled overlay
callers against overlay objects that were never built, and
screenshots without HAVE_RPNG could not encode - both surfacing as
undefined references at link. The variables are now set where the
other HAVE_ ones are, so definitions and objects agree again.

And win32_common.c pulls imm32 with #pragma comment(lib), which
MSVC honours and GNU ld silently ignores, leaving the IME
composition calls undefined; the library is now on LIBS explicitly.

The audit lane script drops both of its compensations - the
variable overrides and the manual relink that appended imm32 - and
its plain make now compiles and links the audit subject in one
step, which is the fix demonstrating itself.

Verified: a clean cross build linking through the makefile's own
rule, and the PE audit at its standing zero findings.
2026-09-16 13:28:35 +02:00

190 lines
4.2 KiB
Makefile

TARGET = retroarch.exe
HAVE_SCREENSHOTS = 1
# DEFINES below has carried -DHAVE_OVERLAY since before the object
# list moved to Makefile.common, which keys off these variables: the
# define without the variable compiled overlay callers against
# overlay objects that were never built, and screenshots without
# rpng could not encode. Set the variables so definitions and
# objects agree again.
HAVE_OVERLAY = 1
HAVE_RPNG = 1
HAVE_AUDIOMIXER = 1
HAVE_RWAV = 1
HAVE_DINPUT = 1
HAVE_XAUDIO = 1
HAVE_DSOUND = 1
HAVE_WASAPI = 1
HAVE_OPENGL = 1
HAVE_DYLIB = 1
HAVE_D3D9 = 1
HAVE_NETWORKING = 1
HAVE_IFINFO = 1
HAVE_NETPLAYDISCOVERY = 1
HAVE_STDIN_CMD = 1
HAVE_COMMAND = 1
HAVE_THREADS = 1
HAVE_MENU = 1
HAVE_CONFIGFILE = 1
HAVE_PATCH = 1
HAVE_REWIND = 1
HAVE_CHEATS = 1
HAVE_RGUI = 1
HAVE_MATERIALUI = 1
HAVE_DSP_FILTER = 1
HAVE_VIDEO_FILTER = 1
HAVE_7ZIP = 1
DYNAMIC = 1
HAVE_CORE_INFO_CACHE = 1
HAVE_XINPUT = 1
HAVE_WINMM = 1
HAVE_SDL := 0
HAVE_SDL2 := 0
HAVE_SDL3 := 0
HAVE_RSOUND := 0
HAVE_FREETYPE := 1
HAVE_FFMPEG := 0
HAVE_CG := 1
HAVE_CC_RESAMPLER := 1
ifeq ($(HAVE_CG), 1)
CG_LIBS := -lcg -lcgGL
endif
ifeq ($(HAVE_FREETYPE), 1)
FREETYPE_CFLAGS := -DHAVE_FREETYPE -Ifreetype2
FREETYPE_LIBS := -lfreetype
endif
ifeq ($(HAVE_SDL), 1)
SDL_LIBS := -lSDL
SDL_CFLAGS := -ISDL -DHAVE_SDL
BSD_LOCAL_INC :=
endif
ifeq ($(HAVE_SDL2), 1)
SDL2_LIBS := -lSDL2
SDL2_CFLAGS := -ISDL2 -DHAVE_SDL2
endif
ifeq ($(HAVE_SDL3), 1)
SDL3_LIBS := -lSDL3
SDL3_CFLAGS := -ISDL3 -DHAVE_SDL3
endif
ifeq ($(HAVE_D3D8), 1)
D3D8_LIBS := -ld3d8
endif
ifeq ($(HAVE_D3D9), 1)
D3D9_LIBS := -ld3d9
endif
ifeq ($(HAVE_RSOUND), 1)
RSOUND_CFLAGS := -DHAVE_RSOUND
RSOUND_LIBS := -lrsound
endif
ifeq ($(HAVE_FFMPEG), 1)
AVCODEC_LIBS := -lavcodec
AVUTIL_LIBS := -lavutil
SWSCALE_LIBS := -lswscale
AVFORMAT_LIBS := -lavformat
SWRESAMPLE_LIBS := -lswresample
AVDEVICE_LIBS := -lavdevice
FFMPEG_LIBS := -lws2_32 -lz
endif
OBJDIR := obj-w32
OS := Win32
OBJ :=
# imm32: win32_common.c pulls it with #pragma comment(lib), which
# MSVC honours and GNU ld silently ignores - link it explicitly or
# the IME composition calls are undefined under mingw.
LIBS := -lm -limm32
DEFINES :=
DEFINES += -I. -Ilibretro-common/include -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_OVERLAY
LDFLAGS := -L. -static-libgcc
include Makefile.common
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
ifneq ($(HOST_PREFIX),)
CC = $(HOST_PREFIX)gcc
CXX = $(HOST_PREFIX)g++
WINDRES = $(HOST_PREFIX)windres
else
CC = gcc
CXX = g++
WINDRES = windres
endif
libretro ?= -lretro
ifeq ($(DYNAMIC), 1)
DEFINES += -DHAVE_DYNAMIC
else
LIBS += $(libretro)
endif
ifneq ($(V), 1)
Q := @
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
CXXFLAGS += -O0 -g
else
CFLAGS += -O3
CXXFLAGS += -O3
endif
CFLAGS += $(DEF_FLAGS) -Wall -Wno-unused-result -Wno-unused-variable -I. -Ideps
CXXFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. -Ideps -std=c++98 -D__STDC_CONSTANT_MACROS
ifeq ($(CXX_BUILD), 1)
CFLAGS += -std=c++98 -xc++ -D__STDC_CONSTANT_MACROS
else
ifneq ($(GNU90_BUILD), 1)
CFLAGS += -std=gnu99
endif
endif
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
all: $(TARGET)
-include $(RARCH_OBJ:.o=.d)
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(CXX) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LDCXXFLAGS)
#those mkdir shenanigans are really ugly, but I can't find any better solution
$(OBJDIR)/%.o: %.c
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.cpp | $(dir $@)
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.rc $(HEADERS)
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo WINDRES $<),)
$(Q)$(WINDRES) $(DEFINES) -o $@ $<
clean:
rm -rf $(OBJDIR)
rm -f $(TARGET)
rm -f *.d
.PHONY: all install uninstall clean