Rewrite Makefile to be modular as well as more automated

Some key points for programmers:
- Source code files are mostly listed in a 'Sourcefile'.
  So you no longer directly edit the object list. There
  can be multiple Sourcefiles and they can even live in
  subdirectories--the directory name will be prepended to
  every filename in the list. Of course, the Makefile
  still needs to be edited to read from each Sourcefile.
- Different rules are no longer required for source code
  files that live in subdirectories (such as sdl/ or
  hardware/). Subdirectories Just Work so go ham!

In addition to those points, another important change is
that the bin directory is no longer divided into platform
subdirectories (Linux64, Mingw, etc). Executables now go
directly into bin. If you use DEBUGMODE or target 64-bit,
then subdirectories for 'debug' and '64' will be made
though.

Oh by the way, I don't think make clean actually removed
files before on Windows. It should now. I also fixed as
many little inconsistencies like that as I noticed.

And now just an overview of the technical aspects that
shouldn't affect anyone who doesn't REALLY care about the
Makefile...

objs and dep directories have been moved to a make
directory. Makefile.cfg and its variants have been moved
out of their various subdirectories to src/Makefile.d
make distclean removes the bin and make directories
entirely, but make clean and cleandep still only affect
the current build target.

When I say automation, I mean that a lot of copy pasting
in the Makefile has been reduced.
This commit is contained in:
James R 2021-05-02 02:54:51 -07:00
parent f637e28d0c
commit b31056c7d9
16 changed files with 1017 additions and 1414 deletions

4
.gitignore vendored
View file

@ -13,11 +13,11 @@ Win32_LIB_ASM_Release
*.dgb
*.debug
*.debug.txt
/bin/VC10/
/objs/VC10/
*.user
*.db
*.opendb
/.vs
/debian
/assets/debian
/make
/bin

View file

@ -119,7 +119,7 @@ set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
add_subdirectory(src)
add_subdirectory(assets)
#add_subdirectory(assets)
## config.h generation

File diff suppressed because it is too large Load diff

104
src/Makefile.d/detect.mk Normal file
View file

@ -0,0 +1,104 @@
#
# Detect the host system and compiler version.
#
# Previously featured:\
PANDORA\
HAIKU\
DUMMY\
DJGPPDOS\
SOLARIS\
MACOSX\
all_systems:=\
LINUX64\
MINGW64\
MINGW\
UNIX\
LINUX\
FREEBSD\
SDL\
# check for user specified system
ifeq (,$(filter $(all_systems),$(.VARIABLES)))
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
_m=Detected a Windows system,\
compiling for 32-bit MinGW SDL...)
$(call Print,$(_m))
# go for a 32-bit sdl mingw exe by default
MINGW:=1
WINDOWSHELL:=1
else # if you on the *nix
system:=$(shell uname -s)
ifeq ($(system),Linux)
new_system:=LINUX
else
$(error \
Could not automatically detect your system,\
try specifying a system manually)
endif
ifeq ($(shell getconf LONG_BIT),64)
system+=64-bit
new_system:=$(new_system)64
endif
$(call Print,Detected $(system) ($(new_system))...)
$(new_system):=1
endif
endif
# This must have high to low order.
gcc_versions:=\
102 101\
93 92 91\
84 83 82 81\
75 74 73 72 71\
64 63 62 61\
55 54 53 52 51\
49 48 47 46 45 44 43 42 41 40
latest_gcc_version:=10.2
# Automatically set version flag, but not if one was
# manually set. And don't bother if this is a clean only
# run.
ifeq (,$(call Wildvar,GCC% destructive))
version:=$(shell $(CC) --version)
# check if this is in fact GCC
ifneq (,$(or $(findstring gcc,$(version)),\
$(findstring GCC,$(version))))
version:=$(shell $(CC) -dumpversion)
# Turn version into words of major, minor
v:=$(subst ., ,$(version))
# concat. major minor
v:=$(word 1,$(v))$(word 2,$(v))
# If this version is not in the list,
# default to the latest supported
ifeq (,$(filter $(v),$(gcc_versions)))
define line =
Your compiler version, GCC $(version), \
is not supported by the Makefile.
The Makefile will assume GCC $(latest_gcc_version).))
endef
$(call Print,$(line))
GCC$(subst .,,$(latest_gcc_version)):=1
else
$(call Print,Detected GCC $(version) (GCC$(v)))
GCC$(v):=1
endif
endif
endif

View file

@ -0,0 +1,76 @@
#
# Makefile for feature flags.
#
passthru_opts+=\
NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\
MOBJCONSISTANCY PACKETDROP ZDEBUG\
HAVE_MINIUPNPC\
# build with debugging information
ifdef DEBUGMODE
MOBJCONSISTANCY=1
PACKETDROP=1
opts+=-DPARANOIA -DRANGECHECK
endif
ifndef NOHW
opts+=-DHWRENDER
sources+=$(call List,hardware/Sourcefile)
endif
ifndef NOASM
ifndef NONX86
sources+=tmap.nas tmap_mmx.nas
opts+=-DUSEASM
endif
endif
ifndef NOMD5
sources+=md5.c
endif
ifndef NOZLIB
ifndef NOPNG
ifdef PNG_PKGCONFIG
$(eval $(call Use_pkg_config,PNG_PKGCONFIG))
else
PNG_CONFIG?=$(call Prefix,libpng-config)
$(eval $(call Configure,PNG,$(PNG_CONFIG) \
$(if $(PNG_STATIC),--static),,--ldflags))
endif
ifdef LINUX
opts+=-D_LARGFILE64_SOURCE
endif
opts+=-DHAVE_PNG
sources+=apng.c
endif
endif
ifndef NONET
ifndef NOCURL
CURLCONFIG?=curl-config
$(eval $(call Configure,CURL,$(CURLCONFIG)))
opts+=-DHAVE_CURL
endif
endif
ifdef HAVE_MINIUPNPC
libs+=-lminiupnpc
endif
# (Valgrind is a memory debugger.)
ifdef VALGRIND
VALGRIND_PKGCONFIG?=valgrind
$(eval $(call Use_pkg_config,VALGRIND))
ZDEBUG=1
opts+=-DHAVE_VALGRIND
endif
default_packages:=\
GME/libgme/LIBGME\
OPENMPT/libopenmpt/LIBOPENMPT\
ZLIB/zlib\
$(foreach p,$(default_packages),\
$(eval $(call Check_pkg_config,$(p))))

View file

@ -1,51 +0,0 @@
ifdef UNIXCOMMON
LUA_CFLAGS+=-DLUA_USE_POSIX
endif
ifdef LINUX
LUA_CFLAGS+=-DLUA_USE_POSIX
endif
ifdef GCC43
ifndef GCC44
WFLAGS+=-Wno-logical-op
endif
endif
OBJS:=$(OBJS) \
$(OBJDIR)/lapi.o \
$(OBJDIR)/lbaselib.o \
$(OBJDIR)/ldo.o \
$(OBJDIR)/lfunc.o \
$(OBJDIR)/linit.o \
$(OBJDIR)/liolib.o \
$(OBJDIR)/llex.o \
$(OBJDIR)/lmem.o \
$(OBJDIR)/lobject.o \
$(OBJDIR)/lstate.o \
$(OBJDIR)/lstrlib.o \
$(OBJDIR)/ltablib.o \
$(OBJDIR)/lundump.o \
$(OBJDIR)/lzio.o \
$(OBJDIR)/lauxlib.o \
$(OBJDIR)/lcode.o \
$(OBJDIR)/ldebug.o \
$(OBJDIR)/ldump.o \
$(OBJDIR)/lgc.o \
$(OBJDIR)/lopcodes.o \
$(OBJDIR)/lparser.o \
$(OBJDIR)/lstring.o \
$(OBJDIR)/ltable.o \
$(OBJDIR)/ltm.o \
$(OBJDIR)/lvm.o \
$(OBJDIR)/lua_script.o \
$(OBJDIR)/lua_baselib.o \
$(OBJDIR)/lua_mathlib.o \
$(OBJDIR)/lua_hooklib.o \
$(OBJDIR)/lua_consolelib.o \
$(OBJDIR)/lua_infolib.o \
$(OBJDIR)/lua_mobjlib.o \
$(OBJDIR)/lua_playerlib.o \
$(OBJDIR)/lua_skinlib.o \
$(OBJDIR)/lua_thinkerlib.o \
$(OBJDIR)/lua_maplib.o \
$(OBJDIR)/lua_blockmaplib.o \
$(OBJDIR)/lua_hudlib.o

View file

@ -1,74 +1,40 @@
#
# sdl/makeNIX.cfg for SRB2/?nix
# Makefile options for unices (linux, bsd...)
#
#Valgrind support
ifdef VALGRIND
VALGRIND_PKGCONFIG?=valgrind
VALGRIND_CFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --cflags)
VALGRIND_LDFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --libs)
ZDEBUG=1
LIBS+=$(VALGRIND_LDFLAGS)
ifdef GCC46
WFLAGS+=-Wno-error=unused-but-set-variable
WFLAGS+=-Wno-unused-but-set-variable
endif
endif
EXENAME?=lsdl2srb2
#
#here is GNU/Linux and other
#
opts+=-DUNIXCOMMON -DLUA_USE_POSIX
libs+=-lm
OPTS=-DUNIXCOMMON
#LDFLAGS = -L/usr/local/lib
LIBS=-lm
ifdef LINUX
LIBS+=-lrt
ifdef NOTERMIOS
OPTS+=-DNOTERMIOS
endif
endif
ifdef LINUX64
OPTS+=-DLINUX64
endif
#
#here is Solaris
#
ifdef SOLARIS
NOIPX=1
NOASM=1
OPTS+=-DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
OPTS+=-I/usr/local/include -I/opt/sfw/include
LDFLAGS+=-L/opt/sfw/lib
LIBS+=-lsocket -lnsl
endif
#
#here is FreeBSD
#
ifdef FREEBSD
OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include
SDL_CONFIG?=sdl11-config
LDFLAGS+=-L/usr/X11R6/lib
LIBS+=-lipx -lkvm
endif
#
#here is Mac OS X
#
ifdef MACOSX
OBJS+=$(OBJDIR)/mac_resources.o
OBJS+=$(OBJDIR)/mac_alert.o
LIBS+=-framework CoreFoundation
ifndef nasm_format
nasm_format:=elf -DLINUX
endif
ifndef NOHW
OPTS+=-I/usr/X11R6/include
LDFLAGS+=-L/usr/X11R6/lib
opts+=-I/usr/X11R6/include
libs+=-L/usr/X11R6/lib
endif
# name of the exefile
EXENAME?=lsdl2srb2
SDL=1
# In common usage.
ifdef LINUX
libs+=-lrt
passthru_opts+=NOTERMIOS
endif
# Tested by Steel, as of release 2.2.8.
ifdef FREEBSD
opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD
libs+=-L/usr/X11R6/lib -lipx -lkvm
endif
# FIXME
#ifdef SOLARIS
#NOIPX=1
#NOASM=1
#opts+=-I/usr/local/include -I/opt/sfw/include \
# -DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
#libs+=-L/opt/sfw/lib -lsocket -lnsl
#endif

View file

@ -0,0 +1,67 @@
#
# Platform specific options.
#
PKG_CONFIG?=pkg-config
ifdef WINDOWSHELL
rmrf?=DEL /S /Q
mkdir?=MD
else
rmrf?=rm -rf
mkdir?=mkdir -p
endif
ifdef LINUX64
LINUX=1
endif
ifdef MINGW64
MINGW=1
endif
ifdef LINUX
UNIX=1
ifdef LINUX64
NONX86=1
# LINUX64 does not imply X86_64=1;
# could mean ARM64 or Itanium
platform=linux/64
else
platform=linux
endif
else ifdef FREEBSD
UNIX=1
platform=freebsd
else ifdef SOLARIS # FIXME
UNIX=1
platform=solaris
else ifdef CYGWIN32 # FIXME
nasm_format=win32
platform=cygwin
else ifdef MINGW
ifdef MINGW64
NONX86=1
NOASM=1
# MINGW64 should not necessarily imply X86_64=1,
# but we make that assumption elsewhere
# Once that changes, remove this
X86_64=1
platform=mingw
else
platform=mingw/64
endif
include Makefile.d/win32.mk
endif
ifdef platform
makedir:=$(makedir)/$(platform)
endif
ifdef UNIX
include Makefile.d/nix.mk
endif
ifdef SDL
include Makefile.d/sdl.mk
endif

View file

@ -1,125 +1,98 @@
#
# sdl/makefile.cfg for SRB2/SDL
# Makefile options for SDL2 backend.
#
#
#SDL...., *looks at Alam*, THIS IS A MESS!
# SDL...., *looks at Alam*, THIS IS A MESS!
#
# ...a little bird flexes its muscles...
#
ifdef UNIXCOMMON
include sdl/MakeNIX.cfg
endif
makedir:=$(makedir)/SDL
ifdef PANDORA
include sdl/SRB2Pandora/Makefile.cfg
endif #ifdef PANDORA
sources+=$(call List,sdl/Sourcefile)
opts+=-DDIRECTFULLSCREEN -DHAVE_SDL
ifdef CYGWIN32
include sdl/MakeCYG.cfg
endif #ifdef CYGWIN32
# FIXME
#ifdef PANDORA
#include sdl/SRB2Pandora/Makefile.cfg
#endif #ifdef PANDORA
ifdef SDL_PKGCONFIG
SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs)
else
ifdef PREFIX
SDL_CONFIG?=$(PREFIX)-sdl2-config
else
SDL_CONFIG?=sdl2-config
endif
ifdef STATIC
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --static-libs)
else
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --libs)
endif
endif
#use the x86 asm code
ifndef CYGWIN32
ifndef NOASM
USEASM=1
endif
endif
OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o
OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL
# FIXME
#ifdef CYGWIN32
#include sdl/MakeCYG.cfg
#endif #ifdef CYGWIN32
ifndef NOHW
OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o
sources+=sdl/ogl_sdl.c
endif
ifdef NOMIXER
i_sound_o=$(OBJDIR)/sdl_sound.o
sources+=sdl/sdl_sound.c
else
i_sound_o=$(OBJDIR)/mixer_sound.o
OPTS+=-DHAVE_MIXER
ifdef HAVE_MIXERX
OPTS+=-DHAVE_MIXERX
SDL_LDFLAGS+=-lSDL2_mixer_ext
else
SDL_LDFLAGS+=-lSDL2_mixer
endif
opts+=-DHAVE_MIXER
sources+=sdl/mixer_sound.c
ifdef HAVE_MIXERX
opts+=-DHAVE_MIXERX
libs+=-lSDL2_mixer_ext
else
libs+=-lSDL2_mixer
endif
endif
ifndef NOTHREADS
OPTS+=-DHAVE_THREADS
OBJS+=$(OBJDIR)/i_threads.o
opts+=-DHAVE_THREADS
sources+=sdl/i_threads.c
endif
ifdef SDL_TTF
OPTS+=-DHAVE_TTF
SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz
OBJS+=$(OBJDIR)/i_ttf.o
ifdef SDL_PKGCONFIG
$(eval $(call Use_pkg_config,SDL))
else
SDL_CONFIG?=$(call Prefix,sdl2-config)
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
$(if $(STATIC),--static-libs,--libs))
$(eval $(call Propogate_flags,SDL))
endif
ifdef SDL_IMAGE
OPTS+=-DHAVE_IMAGE
SDL_LDFLAGS+=-lSDL2_image
# use the x86 asm code
ifndef CYGWIN32
ifndef NOASM
USEASM=1
endif
endif
ifdef SDL_NET
OPTS+=-DHAVE_SDLNET
SDL_LDFLAGS+=-lSDL2_net
endif
# FIXME
#ifdef SDL_TTF
# OPTS+=-DHAVE_TTF
# SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz
# OBJS+=$(OBJDIR)/i_ttf.o
#endif
# FIXME
#ifdef SDL_IMAGE
# OPTS+=-DHAVE_IMAGE
# SDL_LDFLAGS+=-lSDL2_image
#endif
# FIXME
#ifdef SDL_NET
# OPTS+=-DHAVE_SDLNET
# SDL_LDFLAGS+=-lSDL2_net
#endif
ifdef MINGW
ifndef NOSDLMAIN
SDLMAIN=1
SDLMAIN=1
endif
endif
ifdef SDLMAIN
OPTS+=-DSDLMAIN
opts+=-DSDLMAIN
else
ifdef MINGW
SDL_CFLAGS+=-Umain
SDL_LDFLAGS+=-mconsole
opts+=-Umain
libs+=-mconsole
endif
endif
ifndef NOHW
ifdef OPENAL
ifdef MINGW
LIBS:=-lopenal32 $(LIBS)
else
LIBS:=-lopenal $(LIBS)
endif
else
ifdef MINGW
ifdef DS3D
LIBS:=-ldsound -luuid $(LIBS)
endif
endif
endif
endif
CFLAGS+=$(SDL_CFLAGS)
LIBS:=$(SDL_LDFLAGS) $(LIBS)
ifdef STATIC
LIBS+=$(shell $(SDL_CONFIG) --static-libs)
endif

89
src/Makefile.d/util.mk Normal file
View file

@ -0,0 +1,89 @@
#
# Utility macros for the rest of the Makefiles.
#
Ifnot=$(if $(1),$(3),$(2))
Ifndef=$(call Ifnot,$($(1)),$(2),$(3))
# Match and expand a list of variables by pattern.
Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v)))
# Read a list of words from file and prepend each with the
# directory of the file.
List=$(addprefix $(dir $(1)),$(file < $(1)))
define Propogate_flags =
opts+=$$($(1)_CFLAGS)
libs+=$$($(1)_LDFLAGS)
endef
# Set library's _CFLAGS and _LDFLAGS from some command.
# Automatically propogates the flags too.
# 1: variable prefix (e.g. CURL)
# 2: start of command (e.g. curl-config)
# --- optional ----
# 3: CFLAGS command arguments, default '--cflags'
# 4: LDFLAGS command arguments, default '--libs'
# 5: common command arguments at the end of command
define Configure =
$(1)_CFLAGS?=$$(shell $(2) $(or $(3),--cflags) $(5))
$(1)_LDFLAGS?=$$(shell $(2) $(or $(4),--libs) $(5))
$(call Propogate_flags,$(1))
endef
# Configure library with pkg-config. The package name is
# taken from a _PKGCONFIG variable.
# 1: variable prefix
#
# LIBGME_PKGCONFIG=libgme
# $(eval $(call Use_pkg_config,LIBGME))
define Use_pkg_config =
$(call Configure,$(1),$(PKG_CONFIG),,,$($(1)_PKGCONFIG))
endef
# Check disabling flag and configure package in one step
# according to delimited argument.
# (There is only one argument, but it split by slash.)
# 1/: short form library name (uppercase). This is
# prefixed with 'NO' and 'HAVE_'. E.g. NOGME, HAVE_GME
# /2: package name (e.g. libgme)
# /3: variable prefix
#
# The following example would check if NOGME is not
# defined before attempting to define LIBGME_CFLAGS and
# LIBGME_LDFLAGS as with Use_pkg_config.
#
# $(eval $(call Check_pkg_config,GME/libgme/LIBGME))
define Check_pkg_config =
_p:=$(subst /, ,$(1))
_v1:=$$(word 1,$$(_p))
_v2:=$$(or $$(word 3,$$(_p)),$$(_v1))
ifndef NO$$(_v1)
$$(_v2)_PKGCONFIG?=$$(word 2,$$(_p))
$$(eval $$(call Use_pkg_config,$$(_v2)))
opts+=-DHAVE_$$(_v1)
endif
endef
# $(call Prefix,gcc)
Prefix=$(if $(PREFIX),$(PREFIX)-)$(1)
Echo=
Echo_name=
Print=
ifndef SILENT
Echo=@echo "$(1)"
ifndef ECHO
ifndef NOECHOFILENAMES
Echo_name=$(call Echo,-- $(1) ...)
endif
endif
ifndef MAKE_RESTARTS
ifndef destructive
Print=$(info $(1))
endif
endif
endif
.=$(call Ifndef,ECHO,@)

View file

@ -1,215 +1,23 @@
# vim: ft=make
#
# Makefile.cfg for SRB2
# Flags to put a sock in GCC!
#
#
# GNU compiler & tools' flags
# and other things
#
# See the following variable don't start with 'GCC'. This is
# to avoid a false positive with the version detection...
SUPPORTED_GCC_VERSIONS:=\
101 102\
91 92 93\
81 82 83 84\
71 72 73 74 75\
61 62 63 64\
51 52 53 54 55\
40 41 42 43 44 45 46 47 48 49
LATEST_GCC_VERSION=10.2
# gcc or g++
ifdef PREFIX
CC=$(PREFIX)-gcc
CXX=$(PREFIX)-g++
OBJCOPY=$(PREFIX)-objcopy
OBJDUMP=$(PREFIX)-objdump
STRIP=$(PREFIX)-strip
WINDRES=$(PREFIX)-windres
else
OBJCOPY=objcopy
OBJDUMP=objdump
STRIP=strip
WINDRES=windres
# See the versions list in detect.mk
# This will define all version flags going backward.
# Yes, it's magic.
define _predecessor =
ifdef GCC$(firstword $(1))
GCC$(lastword $(1)):=1
endif
endef
_n:=$(words $(gcc_versions))
$(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
$(addprefix =,$(wordlist 2,$(_n),$(gcc_versions)))),\
$(and $(findstring =,$(v)),\
$(eval $(call _predecessor,$(subst =, ,$(v))))))
# because Apple screws with us on this
# need to get bintools from homebrew
ifdef MACOSX
CC=clang
CXX=clang
OBJCOPY=gobjcopy
OBJDUMP=gobjdump
endif
# Automatically set version flag, but not if one was manually set
# And don't bother if this is a clean only run
ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES)))
version:=$(shell $(CC) --version)
# check if this is in fact GCC
ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))
version:=$(shell $(CC) -dumpversion)
# Turn version into words of major, minor
v:=$(subst ., ,$(version))
# concat. major minor
v:=$(word 1,$(v))$(word 2,$(v))
# If this version is not in the list, default to the latest supported
ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS)))
define line =
Your compiler version, GCC $(version), is not supported by the Makefile.
The Makefile will assume GCC $(LATEST_GCC_VERSION).))
endef
$(call print,$(line))
GCC$(subst .,,$(LATEST_GCC_VERSION))=1
else
$(call print,Detected GCC $(version) (GCC$(v)))
GCC$(v)=1
endif
endif
endif
ifdef GCC102
GCC101=1
endif
ifdef GCC101
GCC93=1
endif
ifdef GCC93
GCC92=1
endif
ifdef GCC92
GCC91=1
endif
ifdef GCC91
GCC84=1
endif
ifdef GCC84
GCC83=1
endif
ifdef GCC83
GCC82=1
endif
ifdef GCC82
GCC81=1
endif
ifdef GCC81
GCC75=1
endif
ifdef GCC75
GCC74=1
endif
ifdef GCC74
GCC73=1
endif
ifdef GCC73
GCC72=1
endif
ifdef GCC72
GCC71=1
endif
ifdef GCC71
GCC64=1
endif
ifdef GCC64
GCC63=1
endif
ifdef GCC63
GCC62=1
endif
ifdef GCC62
GCC61=1
endif
ifdef GCC61
GCC55=1
endif
ifdef GCC55
GCC54=1
endif
ifdef GCC54
GCC53=1
endif
ifdef GCC53
GCC52=1
endif
ifdef GCC52
GCC51=1
endif
ifdef GCC51
GCC49=1
endif
ifdef GCC49
GCC48=1
endif
ifdef GCC48
GCC47=1
endif
ifdef GCC47
GCC46=1
endif
ifdef GCC46
GCC45=1
endif
ifdef GCC45
GCC44=1
endif
ifdef GCC44
GCC43=1
endif
ifdef GCC43
GCC42=1
endif
ifdef GCC42
GCC41=1
endif
ifdef GCC41
GCC40=1
VCHELP=1
endif
ifdef GCC295
GCC29=1
endif
OLDWFLAGS:=$(WFLAGS)
# -W -Wno-unused
WFLAGS=-Wall
WFLAGS:=-Wall
ifndef GCC295
#WFLAGS+=-Wno-packed
endif
@ -222,15 +30,13 @@ endif
#WFLAGS+=-Wsystem-headers
WFLAGS+=-Wfloat-equal
#WFLAGS+=-Wtraditional
ifdef VCHELP
WFLAGS+=-Wdeclaration-after-statement
WFLAGS+=-Wno-error=declaration-after-statement
endif
WFLAGS+=-Wundef
ifndef GCC295
WFLAGS+=-Wendif-labels
endif
ifdef GCC41
WFLAGS+=-Wdeclaration-after-statement
WFLAGS+=-Wno-error=declaration-after-statement
WFLAGS+=-Wshadow
endif
#WFLAGS+=-Wlarger-than-%len%
@ -308,8 +114,6 @@ ifdef ERRORMODE
WFLAGS+=-Werror
endif
WFLAGS+=$(OLDWFLAGS)
ifdef GCC43
#WFLAGS+=-Wno-error=clobbered
endif
@ -338,141 +142,36 @@ ifdef GCC81
WFLAGS+=-Wno-error=multistatement-macros
endif
#indicate platform and what interface use with
ifndef LINUX
ifndef FREEBSD
ifndef CYGWIN32
ifndef MINGW
ifndef MINGW64
ifndef SDL
ifndef DUMMY
$(error No interface or platform flag defined)
endif
endif
endif
endif
endif
endif
endif
#determine the interface directory (where you put all i_*.c)
i_net_o=$(OBJDIR)/i_net.o
i_system_o=$(OBJDIR)/i_system.o
i_sound_o=$(OBJDIR)/i_sound.o
i_main_o=$(OBJDIR)/i_main.o
#set OBJDIR and BIN's starting place
OBJDIR=../objs
BIN=../bin
DEPDIR=../dep
#Nasm ASM and rm
ifdef YASM
NASM?=yasm
ifdef NONX86
ifdef X86_64 # yeah that SEEMS contradictory
opts+=-march=nocona
endif
else
NASM?=nasm
endif
REMOVE?=rm -f
MKDIR?=mkdir -p
GZIP?=gzip
GZIP_OPTS?=-9 -f -n
GZIP_OPT2=$(GZIP_OPTS) --rsyncable
UPX?=upx
UPX_OPTS?=--best --preserve-build-id
ifndef ECHO
UPX_OPTS+=-q
ifndef GCC29
opts+=-msse3 -mfpmath=sse
else
opts+=-mpentium
endif
endif
#Interface Setup
ifdef DUMMY
INTERFACE=dummy
OBJDIR:=$(OBJDIR)/dummy
BIN:=$(BIN)/dummy
DEPDIR:=$(DEPDIR)/dummy
else
ifdef LINUX
NASMFORMAT=elf -DLINUX
SDL=1
ifdef LINUX64
OBJDIR:=$(OBJDIR)/Linux64
BIN:=$(BIN)/Linux64
DEPDIR:=$(DEPDIR)/Linux64
else
OBJDIR:=$(OBJDIR)/Linux
BIN:=$(BIN)/Linux
DEPDIR:=$(DEPDIR)/Linux
endif
else
ifdef FREEBSD
INTERFACE=sdl
NASMFORMAT=elf -DLINUX
SDL=1
OBJDIR:=$(OBJDIR)/FreeBSD
BIN:=$(BIN)/FreeBSD
DEPDIR:=$(DEPDIR)/Linux
else
ifdef SOLARIS
INTERFACE=sdl
NASMFORMAT=elf -DLINUX
SDL=1
OBJDIR:=$(OBJDIR)/Solaris
BIN:=$(BIN)/Solaris
DEPDIR:=$(DEPDIR)/Solaris
else
ifdef CYGWIN32
INTERFACE=sdl
NASMFORMAT=win32
SDL=1
OBJDIR:=$(OBJDIR)/cygwin
BIN:=$(BIN)/Cygwin
DEPDIR:=$(DEPDIR)/Cygwin
else
ifdef MINGW64
#NASMFORMAT=win64
SDL=1
OBJDIR:=$(OBJDIR)/Mingw64
BIN:=$(BIN)/Mingw64
DEPDIR:=$(DEPDIR)/Mingw64
else
ifdef MINGW
NASMFORMAT=win32
SDL=1
OBJDIR:=$(OBJDIR)/Mingw
BIN:=$(BIN)/Mingw
DEPDIR:=$(DEPDIR)/Mingw
endif
endif
endif
endif
endif
endif
endif
ifdef ARCHNAME
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
BIN:=$(BIN)/$(ARCHNAME)
DEPDIR:=$(DEPDIR)/$(ARCHNAME)
endif
OBJDUMP_OPTS?=--wide --source --line-numbers
LD=$(CC)
ifdef SDL
INTERFACE=sdl
OBJDIR:=$(OBJDIR)/SDL
DEPDIR:=$(DEPDIR)/SDL
endif
ifndef DUMMY
ifdef DEBUGMODE
OBJDIR:=$(OBJDIR)/Debug
BIN:=$(BIN)/Debug
DEPDIR:=$(DEPDIR)/Debug
ifdef GCC48
opts+=-Og
else
OBJDIR:=$(OBJDIR)/Release
BIN:=$(BIN)/Release
DEPDIR:=$(DEPDIR)/Release
opts+=O0
endif
endif
ifdef VALGRIND
ifdef GCC46
WFLAGS+=-Wno-error=unused-but-set-variable
WFLAGS+=-Wno-unused-but-set-variable
endif
endif
# Lua
ifdef GCC43
ifndef GCC44
WFLAGS+=-Wno-logical-op
endif
endif

View file

@ -1,136 +1,99 @@
#
# win32/Makefile.cfg for SRB2/Minwgw
# Mingw, if you don't know, that's Win32/Win64
#
#
#Mingw, if you don't know, that's Win32/Win64
#
ifndef MINGW64
EXENAME?=srb2win.exe
else
EXENAME?=srb2win64.exe
endif
sources+=win32/Srb2win.rc
opts+=-DSTDC_HEADERS
libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
nasm_format:=win32
SDL=1
ifndef NOHW
opts+=-DUSE_WGL_SWAP
endif
ifdef MINGW64
HAVE_LIBGME=1
LIBGME_CFLAGS=-I../libs/gme/include
LIBGME_LDFLAGS=-L../libs/gme/win64 -lgme
ifdef HAVE_OPENMPT
LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc
LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64/mingw -lopenmpt
endif
ifndef NOMIXERX
HAVE_MIXERX=1
SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main
SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDLMixerX/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
libs+=-lws2_32
else
SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main
SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDL2_mixer/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
endif
ifdef NO_IPV6
libs+=-lwsock32
else
HAVE_LIBGME=1
LIBGME_CFLAGS=-I../libs/gme/include
LIBGME_LDFLAGS=-L../libs/gme/win32 -lgme
ifdef HAVE_OPENMPT
LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc
LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86/mingw -lopenmpt
libs+=-lws2_32
endif
ifndef NOMIXERX
HAVE_MIXERX=1
SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main
SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDLMixerX/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
else
SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main
SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
endif
endif
ifndef NOASM
USEASM=1
endif
ifndef NONET
ifndef MINGW64 #miniupnc is broken with MINGW64
HAVE_MINIUPNPC=1
ifndef MINGW64 # miniupnc is broken with MINGW64
opts+=-I../libs -DSTATIC_MINIUPNPC
libs+=-L../libs/miniupnpc/mingw$(32) -lws2_32 -liphlpapi
endif
endif
OPTS=-DSTDC_HEADERS
ifndef GCC44
#OPTS+=-mms-bitfields
endif
LIBS+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
ifdef MINGW64
LIBS+=-lws2_32
ifndef MINGW64
32=32
x86=x86
i686=i686
else
ifdef NO_IPV6
LIBS+=-lwsock32
32=64
x86=x86_64
i686=x86_64
endif
mingw:=$(i686)-w64-mingw32
define _set =
$(1)_CFLAGS?=$($(1)_opts)
$(1)_LDFLAGS?=$($(1)_libs)
endef
lib:=../libs/gme
LIBGME_opts:=-I$(lib)/include
LIBGME_libs:=-L$(lib)/win$(32) -lgme
$(eval $(call _set,LIBGME))
lib:=../libs/libopenmpt
LIBOPENMPT_opts:=-I$(lib)/inc
LIBOPENMPT_libs:=-L$(lib)/lib/$(x86)/mingw -lopenmpt
$(eval $(call _set,LIBOPENMPT))
ifndef NOMIXERX
HAVE_MIXERX=1
lib:=../libs/SDLMixerX/$(mingw)
else
LIBS+=-lws2_32
endif
lib:=../libs/SDL2_mixer/$(mingw)
endif
# name of the exefile
EXENAME?=srb2win.exe
mixer_opts:=-I$(lib)/include/SDL2
mixer_libs:=-L$(lib)/lib
ifdef SDL
i_system_o+=$(OBJDIR)/SRB2.res
#i_main_o+=$(OBJDIR)/win_dbg.o
ifndef NOHW
OPTS+=-DUSE_WGL_SWAP
endif
endif
lib:=../libs/SDL2/$(mingw)
SDL_opts:=-I$(lib)/include/SDL2\
$(mixer_opts) -Dmain=SDL_main
SDL_libs:=-L$(lib)/lib $(mixer_libs)\
-lmingw32 -lSDL2main -lSDL2 -mwindows
$(eval $(call _set,SDL))
lib:=../libs/zlib
ZLIB_opts:=-I$(lib)
ZLIB_libs:=-L$(lib)/win32 -lz$(32)
$(eval $(call _set,ZLIB))
ZLIB_CFLAGS?=-I../libs/zlib
ifdef MINGW64
ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz64
else
ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz32
endif
ifndef NOPNG
ifndef PNG_CONFIG
PNG_CFLAGS?=-I../libs/libpng-src
ifdef MINGW64
PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng64
else
PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng32
endif #MINGW64
endif #PNG_CONFIG
endif #NOPNG
ifdef GETTEXT
ifndef CCBS
MSGFMT?=../libs/gettext/bin32/msgfmt.exe
endif
ifdef MINGW64
CPPFLAGS+=-I../libs/gettext/include64
LDFLAGS+=-L../libs/gettext/lib64
LIBS+=-lmingwex
else
CPPFLAGS+=-I../libs/gettext/include32
LDFLAGS+=-L../libs/gettext/lib32
STATIC_GETTEXT=1
endif #MINGW64
ifdef STATIC_GETTEXT
LIBS+=-lasprintf -lintl
else
LIBS+=-lintl.dll
endif #STATIC_GETTEXT
endif #GETTEXT
ifdef HAVE_MINIUPNPC
CPPFLAGS+=-I../libs/ -DSTATIC_MINIUPNPC
ifdef MINGW64
LDFLAGS+=-L../libs/miniupnpc/mingw64
else
LDFLAGS+=-L../libs/miniupnpc/mingw32
endif #MINGW64
lib:=../libs/libpng-src
PNG_opts:=-I$(lib)
PNG_libs:=-L$(lib)/projects -lpng$(32)
$(eval $(call _set,PNG))
endif
ifndef NOCURL
CURL_CFLAGS+=-I../libs/curl/include
ifdef MINGW64
CURL_LDFLAGS+=-L../libs/curl/lib64 -lcurl
else
CURL_LDFLAGS+=-L../libs/curl/lib32 -lcurl
endif #MINGW64
endif
lib:=../libs/curl
CURL_opts:=-I$(lib)/include
CURL_libs:=-L$(lib)/lib$(32) -lcurl
$(eval $(call _set,CURL))

87
src/Sourcefile Normal file
View file

@ -0,0 +1,87 @@
string.c
d_main.c
d_clisrv.c
d_net.c
d_netfil.c
d_netcmd.c
dehacked.c
z_zone.c
f_finale.c
f_wipe.c
g_demo.c
g_game.c
g_input.c
am_map.c
command.c
console.c
hu_stuff.c
y_inter.c
st_stuff.c
m_aatree.c
m_anigif.c
m_argv.c
m_bbox.c
m_cheat.c
m_cond.c
m_fixed.c
m_menu.c
m_misc.c
m_random.c
m_queue.c
info.c
p_ceilng.c
p_enemy.c
p_floor.c
p_inter.c
p_lights.c
p_map.c
p_maputl.c
p_mobj.c
p_polyobj.c
p_saveg.c
p_setup.c
p_sight.c
p_spec.c
p_telept.c
p_tick.c
p_user.c
p_slopes.c
tables.c
r_bsp.c
r_data.c
r_draw.c
r_main.c
r_plane.c
r_segs.c
r_skins.c
r_sky.c
r_splats.c
r_things.c
r_textures.c
r_picformats.c
r_portal.c
screen.c
v_video.c
s_sound.c
sounds.c
w_wad.c
filesrch.c
mserv.c
http-mserv.c
i_tcp.c
lzf.c
vid_copy.s
b_bot.c
lua_script.c
lua_baselib.c
lua_mathlib.c
lua_hooklib.c
lua_consolelib.c
lua_infolib.c
lua_mobjlib.c
lua_playerlib.c
lua_skinlib.c
lua_thinkerlib.c
lua_maplib.c
lua_blockmaplib.c
lua_hudlib.c

25
src/blua/Sourcefile Normal file
View file

@ -0,0 +1,25 @@
lapi.c
lbaselib.c
ldo.c
lfunc.c
linit.c
liolib.c
llex.c
lmem.c
lobject.c
lstate.c
lstrlib.c
ltablib.c
lundump.c
lzio.c
lauxlib.c
lcode.c
ldebug.c
ldump.c
lgc.c
lopcodes.c
lparser.c
lstring.c
ltable.c
ltm.c
lvm.c

13
src/hardware/Sourcefile Normal file
View file

@ -0,0 +1,13 @@
hw_bsp.c
hw_draw.c
hw_light.c
hw_main.c
hw_clip.c
hw_md2.c
hw_cache.c
hw_md2load.c
hw_md3load.c
hw_model.c
u_list.c
hw_batching.c
r_opengl/r_opengl.c

7
src/sdl/Sourcefile Normal file
View file

@ -0,0 +1,7 @@
i_net.c
i_system.c
i_main.c
i_video.c
dosstr.c
endtxt.c
hwsym_sdl.c