Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Allow cross-building Windows binaries from Linux #36

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
obj/
src/dep/generated/*
gamelist.txt
fba.exe
fbad.exe
61 changes: 55 additions & 6 deletions makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ else
NAME := $(NAME)$(CPUTYPE)
endif

# determine if cross-compiling
HOST = $(shell uname)
ifeq (,$(findstring NT,$(HOST)))
CROSS = 1
endif


#
Expand Down Expand Up @@ -109,12 +114,15 @@ endif
ifdef GCC510
incdir = $(foreach dir,$(alldir),-I$(srcdir)$(dir)) -I$(objdir)dep/generated -I$(srcdir)dep/mingw/include -I$(srcdir)dep/mingw/include/directx9 -I$(srcdir)dep/mingw/include/xaudio2
endif
ifdef CROSS
incdir = $(foreach dir,$(alldir),-I$(srcdir)$(dir)) -I$(objdir)dep/generated -I$(srcdir)dep/mingw/include -I$(srcdir)dep/mingw/include/directx9 -I$(srcdir)dep/mingw/include/xaudio2
endif

ifdef UNICODE
# lib = -lunicows
endif

lib += -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 -lwinmm -lshlwapi -ladvapi32 -lsetupapi -lole32 -luuid -lwininet
lib += -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 -lwinmm -lshlwapi -ladvapi32 -lsetupapi -lole32 -luuid -lwininet -ldxguid -lxaudio2_8

ifdef INCLUDE_AVI_RECORDING
lib += -lvfw32
Expand All @@ -130,6 +138,8 @@ ifdef BUILD_A68K
a68k.o = $(objdir)cpu/a68k/a68k.o
endif



app_gnuc.rc = $(srcdir)dep/generated/app_gnuc.rc
license.rtf = $(srcdir)dep/generated/license.rtf
driverlist.h = $(srcdir)dep/generated/driverlist.h
Expand Down Expand Up @@ -178,8 +188,16 @@ autdrv := $(drvsrc:.cpp=.o)
#
#

CC = gcc
CXX = g++
ifdef CROSS
ifdef BUILD_X64_EXE
PREFIX = x86_64-w64-mingw32-
else
PREFIX = i686-w64-mingw32-
endif
endif

CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
LD = $(CXX)
AS = nasm

Expand Down Expand Up @@ -293,6 +311,29 @@ else
endif
endif

ifdef CROSS
CFLAGS = -pipe \
-std=gnu99 -O1 \
-mwindows \
-fforce-addr -finline-limit=1200 -fthread-jumps \
-fexpensive-optimizations \
-Wall -Wno-long-long -Wno-sign-compare -Wno-uninitialized -Wno-unused \
-Wno-sequence-point -Wno-pedantic \
$(DEF) $(incdir)

CXXFLAGS = -pipe \
-std=gnu++11 -O1 \
-mwindows \
-fforce-addr -finline-limit=1200 -fthread-jumps \
-fexpensive-optimizations -fcheck-new \
-Wall -W -pedantic -Wshadow -Wno-long-long -Wno-write-strings \
-Wunknown-pragmas -Wundef -Wno-conversion -Wno-missing-braces -Wno-multichar \
-Wuninitialized -Wpointer-arith -Wno-inline -Wno-address -Wno-unused-value \
-Wno-unused-but-set-variable -Wno-sequence-point -Wno-narrowing -Wno-extra \
-Wno-pedantic \
$(DEF) $(incdir)
endif

ASFLAGS = -O1 -f coff -w-orphan-labels

# D3DUtils & D3DMath need these
Expand Down Expand Up @@ -596,11 +637,12 @@ $(objdir)cpu/m68k/m68kops.o: $(objdir)cpu/m68k/m68kmake.exe $(objdir)dep/generat
@$(CC) $(CFLAGS) -c $(objdir)dep/generated/m68kops.c -o $(objdir)cpu/m68k/m68kops.o

$(objdir)dep/generated/m68kops.h: $(objdir)cpu/m68k/m68kmake.exe $(srcdir)cpu/m68k/m68k_in.c
$(objdir)/cpu/m68k/m68kmake $(objdir)dep/generated/ $(srcdir)cpu/m68k/m68k_in.c
$(objdir)/cpu/m68k/m68kmake.exe $(objdir)dep/generated/ $(srcdir)cpu/m68k/m68k_in.c

$(objdir)cpu/m68k/m68kmake.exe: $(srcdir)cpu/m68k/m68kmake.c
@echo Compiling Musashi MC680x0 core \(m68kmake.c\)...
@$(CC) $(CFLAGS) $(srcdir)cpu/m68k/m68kmake.c -o $(objdir)cpu/m68k/m68kmake.exe
# need to build using native cc to allow cross-compilations
@cc $(srcdir)cpu/m68k/m68kmake.c -o $(objdir)cpu/m68k/m68kmake.exe


#
Expand Down Expand Up @@ -687,6 +729,13 @@ endif

%.o: %.rc
@echo Compiling resource file $(<F)...
ifdef CROSS
ifdef BUILD_X64_EXE
@x86_64-w64-mingw32-windres $(DEF) $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F) $(foreach dir,$(alldir),--include-dir $(srcdir)$(dir))
else
@i686-w64-mingw32-windres $(DEF) $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F) $(foreach dir,$(alldir),--include-dir $(srcdir)$(dir))
endif
else
ifdef GCC345
@windres $(DEF) $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F) $(foreach dir,$(alldir),--include-dir $(srcdir)$(dir))
endif
Expand All @@ -707,7 +756,7 @@ else
@windres -F pe-i386 $(DEF) $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F) $(foreach dir,$(alldir),--include-dir $(srcdir)$(dir))
endif
endif

endif
#
# Generic rules for C/C++ files
#
Expand Down
Empty file modified src/dep/scripts/cave_sprite_func.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/cave_tile_func.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/fixrc.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/gamelist.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/license2rtf.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/neo_sprite_func.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/psikyo_tile_func.pl
100644 → 100755
Empty file.
Empty file modified src/dep/scripts/toa_gp9001_func.pl
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/intf/audio/win32/aud_dsound3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "aud_dsp.h"
Copy link
Collaborator

@dinkc64 dinkc64 Nov 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Yvan, we've moved the project over to fbneo - you should submit your PR there:
https://github.com/finalburnneo/FBNeo

Unfortunately, we can't accept this specific one, because we need to retain backwards compatibility with mingw gcc 3.4.5 (2 of the active devs use this one) - so a little ifdef-action will need to be used :)

best regards,

  • dink

#include <math.h>

#include <InitGuid.h>
#include <guiddef.h>
#define DIRECTSOUND_VERSION 0x0300 // Only need version from DirectX 3
#include <dsound.h>

Expand Down
3 changes: 2 additions & 1 deletion src/intf/audio/win32/aud_xaudio2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "aud_dsp.h"

//#ifdef _MSC_VER
#include <InitGuid.h>
#define INITGUID
#include <guiddef.h>
#include <xaudio2.h>
#include <xaudio2fx.h>

Expand Down
2 changes: 1 addition & 1 deletion src/intf/input/win32/inp_dinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "burner.h"
#include "inp_keys.h"

#include <InitGuid.h>
#include <guiddef.h>

#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
Expand Down
2 changes: 1 addition & 1 deletion src/intf/video/win32/vid_d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#if !defined BUILD_X64_EXE

// #include "vid_directx_support.h"
#include <InitGuid.h>
#include <guiddef.h>
#include "vid_softfx.h"

// #define ENABLE_PROFILING FBA_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/intf/video/win32/vid_ddraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "vid_directx_support.h"
#endif

#include <InitGuid.h>
#include <guiddef.h>
#define DIRECT3D_VERSION 0x0700 // Use this Direct3D version

#if defined BUILD_X64_EXE
Expand Down
2 changes: 1 addition & 1 deletion src/intf/video/win32/vid_ddrawfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "vid_softfx.h"
#endif

#include <InitGuid.h>
#include <guiddef.h>
#define DIRECT3D_VERSION 0x0700 // Use this Direct3D version

#if defined BUILD_X64_EXE
Expand Down
2 changes: 1 addition & 1 deletion src/intf/video/win32/vid_directx9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// #define ENABLE_PROFILING FBA_DEBUG
// #define LOAD_EFFECT_FROM_FILE

#include <InitGuid.h>
#include <guiddef.h>
#define DIRECT3D_VERSION 0x0900 // Use this Direct3D version
#define D3D_OVERLOADS
#include <d3d9.h>
Expand Down
2 changes: 1 addition & 1 deletion src/intf/video/win32/vid_directx_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "vid_directx_support.h"
#endif

#include <InitGuid.h>
#include <guiddef.h>
#define DIRECT3D_VERSION 0x0700 // Use this Direct3D version

#if defined BUILD_X64_EXE
Expand Down