Skip to content

Commit

Permalink
get some better build infrastructure going
Browse files Browse the repository at this point in the history
  • Loading branch information
emmamai committed Apr 10, 2021
1 parent 9089108 commit aedd78b
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
bin/
61 changes: 52 additions & 9 deletions Makefile.dos
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,57 @@ NOARCH=noarch
SRC_DIR=$(shell pwd)
BUILDDIR ?= $(shell pwd)/build

OLEVEL=O3
OCPU=486
OLTO=yes
OASM=yes

ifeq "$(OCPU)" "386"
OARCH=i486
OTUNE=i386
else ifeq "$(OCPU)" "486"
OARCH=i486
OTUNE=i486
else ifeq "$(OCPU)" "586"
OARCH=pentium
OTUNE=pentium
else ifeq "$(OCPU)" "686"
OARCH=pentiumpro
OTUNE=pentiumpro
else
$(error unknown cpu type $(OCPU))
endif

BINNAME=$(OCPU)q$(OLEVEL)$(LTOCHAR)

ifeq "$(OLTO)" "yes"
LTOFLAGS=-flto
BINNAME:=$(BINNAME)l
endif

ifneq "$(OASM)" "yes"
ID386=0
BINNAME:=$(BINNAME)c
else
ID386=1
endif

BUILD_DEBUG_DIR=debug$(ARCH)$(GLIBC)
BUILD_RELEASE_DIR=release$(ARCH)$(GLIBC)

CC=i586-pc-msdosdjgpp-gcc

BASE_CFLAGS=-Dstricmp=strcasecmp
RELEASE_CFLAGS=$(BASE_CFLAGS) -s -Os -march=i486 -mtune=i386 -ffast-math \
CC_VERSION=$(shell $(CC) --version | head -n 1 | awk -F " " '{print $3}')

BASE_CFLAGS=-Dstricmp=strcasecmp -DSUBARCH=$(OCPU) -DOLEVEL="\"$(OLEVEL)\"" -DLTOFLAGS="\" $(LTOFLAGS)\"" -Did386=$(ID386) -DCCVERSION="\"$(CC_VERSION)\""
RELEASE_CFLAGS=$(BASE_CFLAGS) -s -$(OLEVEL) -march=$(OARCH) -mtune=$(OTUNE) -ffast-math \
-fno-unwind-tables -fno-asynchronous-unwind-tables -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations -flto \

DEBUG_CFLAGS=$(BASE_CFLAGS) -g
CFLAGS?=$(BASE_CFLAGS) $(RELEASE_CFLAGS)

LDFLAGS=-lm -flto
LDFLAGS=-lm

DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
DO_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) -o $@ -c $<
Expand All @@ -35,14 +72,14 @@ DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
# SETUP AND BUILD
#############################################################################

TARGETS=$(BUILDDIR)/486quake.exe
TARGETS=$(BUILDDIR)/$(BINNAME).exe

build_release: $(BUILDDIR)/486quake.exe
build_release: $(BUILDDIR)/$(BINNAME).exe

$(BUILDDIR)/486quake:
mkdir -p $(BUILDDIR)/486quake
mkdir -p $(BUILDDIR)/$(BINNAME)

all: $(BUILDDIR)/486quake build_release $(TARGETS)
all: $(BUILDDIR)/$(BINNAME).exe build_release $(TARGETS)

#############################################################################
# SVGALIB Quake
Expand Down Expand Up @@ -151,9 +188,15 @@ all: $(BUILDDIR)/486quake build_release $(TARGETS)
$(BUILDDIR)/486quake/r_aclipa.o \
$(BUILDDIR)/486quake/snd_mixa.o \
$(BUILDDIR)/486quake/sys_dosa.o

ifneq "$(OASM)" "yes"
486QUAKE_COBJS = \
$(BUILDDIR)/486quake/d_vars.o \

endif

$(BUILDDIR)/486quake.exe : $(486QUAKE_OBJS)
$(CC) $(RELEASE_CFLAGS) -o $@ $(486QUAKE_OBJS) $(SVGALDFLAGS) $(LDFLAGS)
$(BUILDDIR)/$(BINNAME).exe : $(486QUAKE_OBJS) $(486QUAKE_COBJS)
$(CC) $(RELEASE_CFLAGS) -o $@ $(486QUAKE_COBJS) $(486QUAKE_OBJS) $(LDFLAGS)

####

Expand Down
20 changes: 20 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -e -x

rm -rf build bin

mkdir -p build/486quake
mkdir -p bin

for cpu in 386 486 586 686; do
for olevel in Os O2 O3; do
for olto in yes no; do
for oasm in yes no; do
make -f Makefile.dos clean
make -j8 -f Makefile.dos OCPU=$cpu OLEVEL=$olevel OLTO=$olto OASM=$oasm
cp build/*.exe bin/
done
done
done
done
4 changes: 2 additions & 2 deletions cd_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ int CDAudio_Init(void)
dos_int86 (0x2f);
if (regs.x.bx == 0)
{
Con_NotifyBox (
Con_Printf (
"MSCDEX not loaded, music is\n"
"disabled. Use \"-nocdaudio\" if you\n"
"wish to avoid this message in the\n"
Expand All @@ -834,7 +834,7 @@ int CDAudio_Init(void)
dos_int86 (0x2f);
if (regs.x.bx == 0)
{
Con_NotifyBox (
Con_Printf (
"MSCDEX version 2.00 or later\n"
"required for music. See README.TXT\n"
"for help.\n"
Expand Down
6 changes: 6 additions & 0 deletions cl_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ void CL_FinishTimeDemo (void)
if (!time)
time = 1;
Con_Printf ("%i frames %5.1f seconds %5.1f fps\n", frames, time, frames/time);
#if id386
Con_Printf (" on %iQuake -%s%s v%4.2f\n", SUBARCH, OLEVEL, LTOFLAGS, VERSION);
#else
Con_Printf (" on %iQuake -%s%s noasm v%4.2f\n", SUBARCH, OLEVEL, LTOFLAGS, VERSION);
#endif
Con_Printf (" %s\n", CCVERSION);
}

/*
Expand Down
5 changes: 0 additions & 5 deletions d_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// r_vars.c: global refresh variables

#if !id386

#include "quakedef.h"

// all global and static refresh variables are collected in a contiguous block
Expand All @@ -45,6 +43,3 @@ pixel_t *d_viewbuffer;
short *d_pzbuffer;
unsigned int d_zrowbytes;
unsigned int d_zwidth;

#endif // !id386

9 changes: 6 additions & 3 deletions draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void Draw_ConsoleBackground (int lines)
unsigned short *pusdest;
int f, fstep;
qpic_t *conback;
char ver[100];
char ver[256];

conback = Draw_CachePic ("gfx/conback.lmp");

Expand All @@ -557,9 +557,12 @@ void Draw_ConsoleBackground (int lines)
#elif defined(__linux__)
sprintf (ver, "(Linux Quake %2.2f) %4.2f", (float)LINUX_VERSION, (float)VERSION);
dest = conback->data + 320*186 + 320 - 11 - 8*strlen(ver);
#elif defined(id386)
sprintf (ver, "%iquake -%s%s %4.2f", SUBARCH, OLEVEL, LTOFLAGS, VERSION);
dest = conback->data + 320*186 + 320 - 11 - 8*strlen(ver);
#else
dest = conback->data + 320 - 43 + 320*186;
sprintf (ver, "486quake %4.2f", VERSION);
sprintf (ver, "%iquake -%s%s noasm %4.2f", SUBARCH, OLEVEL, LTOFLAGS, VERSION);
dest = conback->data + 320*186 + 320 - 11 - 8*strlen(ver);
#endif

for (x=0 ; x<strlen(ver) ; x++)
Expand Down
2 changes: 1 addition & 1 deletion host.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Host_EndGame (char *message, ...)
if (cls.state == ca_dedicated)
Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit

if (cls.demonum != -1)
if ( ( cls.demonum != -1 ) && ( !cls.timedemo ) )
CL_NextDemo ();
else
CL_Disconnect ();
Expand Down
6 changes: 0 additions & 6 deletions quakeasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#endif

#ifdef __i386__
#define id386 1
#else
#define id386 0
#endif

// !!! must be kept the same as in d_iface.h !!!
#define TRANSPARENT_COLOR 255

Expand Down
8 changes: 1 addition & 7 deletions quakedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ void VID_UnlockBuffer (void);

#endif

#if defined __i386__ // && !defined __sun__
#define id386 1
#else
#define id386 0
#endif

#if id386
#if id386 || defined __i386__
#define UNALIGNED_OK 1 // set to 0 if unaligned accesses are not supported
#else
#define UNALIGNED_OK 0
Expand Down
9 changes: 4 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
486quake
========

this is an attempt at building quake in a way that allows it to be faster on 486-class machines.
this is an attempt to ressurect the original Quake DOS sources, clean up the bitrot just enough to be able
to build with modern toolchains, and try out modern compiler optimizations to see if this is sufficient
to make the game notably faster, particularly on 486-class machines.

additional changes of note:
- Win95 MPATH net driver removed
- not easy/possible to build without win95 sdk
- this means no tcp/ip networking is available without the Beame & Whiteside tcp/ip stack (QKEPPP20.ZIP)
this should build on any machine with DJGPP installed and the environment set up properly.
2 changes: 1 addition & 1 deletion sys_dos.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ int main (int c, char **v)
extern void (*dos_error_func)(char *, ...);
static char cwd[1024];

printf ("Quake v%4.2f\n", VERSION);
printf ("%iQuake -%s%s v%4.2f built with %s\n", SUBARCH, OLEVEL, LTOFLAGS, VERSION, CCVERSION);

// make sure there's an FPU
signal(SIGNOFP, Sys_NoFPUExceptionHandler);
Expand Down

0 comments on commit aedd78b

Please sign in to comment.