From 305fab36507e64252fa8c2e3065c81dbddf14f6a Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 6 Jul 2019 18:37:00 +0300 Subject: [PATCH] glide2x: initial makefiles to target DOS/DJGPP. build-tested yet, will see if they actually run later. --- glide2x/Makefile.DJ | 61 ++++++ glide2x/cvg/glide/src/Makefile.DJ | 286 +++++++++++++++++++++++++++++ glide2x/h3/glide/src/Makefile.DJ | 265 ++++++++++++++++++++++++++ glide2x/sst1/glide/src/Makefile.DJ | 283 ++++++++++++++++++++++++++++ 4 files changed, 895 insertions(+) create mode 100644 glide2x/Makefile.DJ create mode 100644 glide2x/cvg/glide/src/Makefile.DJ create mode 100644 glide2x/h3/glide/src/Makefile.DJ create mode 100644 glide2x/sst1/glide/src/Makefile.DJ diff --git a/glide2x/Makefile.DJ b/glide2x/Makefile.DJ new file mode 100644 index 0000000..ca5de22 --- /dev/null +++ b/glide2x/Makefile.DJ @@ -0,0 +1,61 @@ +# DOS / DJGPP makefile for Glide2 +# +# Copyright (c) 2003 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca +# + +# +# Available options: +# +# Environment variables: +# FX_GLIDE_HW build for the given ASIC (sst1, sst96, cvg, h3). +# default = h3 +# H4=1 High speed Avenger. +# target = h3 +# default = no +# OPTFLAGS pass given optimization flags to compiler +# target = sst1, sst96, cvg, h3 +# default = -O2 -ffast-math (+ -mcpu=pentium if USE_X86=1) +# DEBUG=1 enable debugging checks and messages +# target = sst1, sst96, cvg, h3 +# default = no +# USE_X86=1 use assembler triangle specializations; req by CVG +# target = sst1, sst96, cvg, h3 +# default = no +# USE_3DNOW=1 allow 3DNow! specializations. However, the true CPU +# capabilities are still checked at run-time to avoid +# crashes. +# target = cvg, h3 +# default = no +# USE_MMX=1 (see USE_3DNOW) +# target = cvg +# default = no +# +# Targets: +# all: build everything +# clean: remove object files +# realclean: remove all generated files +# + + +.PHONY: all clean realclean + +export BUILD_NUMBER = 40404 +export FX_GLIDE_HW ?= h3 + +ifeq ($(FX_GLIDE_HW),sst96) +G2_DIR = sst1/glide/src +else +G2_DIR = $(FX_GLIDE_HW)/glide/src +endif + +all: + make -f Makefile.DJ -C $(G2_DIR) +# USE_X86=1 USE_3DNOW=1 USE_MMX=1 USE_SSE=1 USE_SSE2=1 + +clean: + make -f Makefile.DJ -C $(G2_DIR) clean + +realclean: + make -f Makefile.DJ -C $(G2_DIR) realclean diff --git a/glide2x/cvg/glide/src/Makefile.DJ b/glide2x/cvg/glide/src/Makefile.DJ new file mode 100644 index 0000000..a479912 --- /dev/null +++ b/glide2x/cvg/glide/src/Makefile.DJ @@ -0,0 +1,286 @@ +# DOS/DJGPP makefile for Glide2/CVG +# +# Copyright (c) 2003 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca +# + +# +# Available options: +# +# Environment variables: +# CPU optimize for the given processor. +# default = -mtune=pentium +# DEBUG=1 disable optimizations and build for debug. +# default = no +# USE_X86=1 use assembler triangle specializations; req by CVG +# default = yes +# USE_3DNOW=1 allow 3DNow! specializations. However, the true CPU +# capabilities are still checked at run-time to avoid +# crashes. +# default = no +# USE_MMX=1 allow MMX specializations. +# default = no +# +# Targets: +# all: build everything +# glide2x: build Glide2x lib +# clean: remove object files +# realclean: remove all generated files +# + +.PHONY: all glide2x clean realclean +.INTERMEDIATE: fxgasm.exe + +############################################################################### +# general defines (user settable?) +############################################################################### + +GLIDE_LIB = libglide2x.a +GLIDE_DXE = glide2x.dxe +GLIDE_IMP = libglide2i.a + +FX_GLIDE_SW = ../../../swlibs +GLIDE_LIBDIR = ../../lib + +############################################################################### +# tools +############################################################################### + +CC = gcc +AS = nasm +LD = $(CC) +AR = ar +DXE3GEN = dxe3gen + +#for cross-builds +HOST_CC = gcc + +UNLINK = rm -f $(1) + +############################################################################### +# defines +############################################################################### + +# platform +CDEFS = -D__DOS__ -D__DOS32__ -DINIT_DOS -D__3Dfx_PCI_CFG__ + +# general +CDEFS += -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_PACKED_RGB=1 -DGLIDE_TRI_CULLING=1 -DGLIDE_DEFAULT_GAMMA=1.3f -DGLIDE_LIB=1 + +# workaround for CVGs with broken tsus which cannot send commands to multiple +# tmus using chipfield. chipfield will always be set to 0xf +CDEFS += -DGLIDE_CHIP_BROADCAST=1 +# special sli buffer clears +CDEFS += -DGLIDE_BLIT_CLEAR=1 + +# subsystem +CDEFS += -DCVG + +# debug +ifdef DEBUG +CDEFS += -DGDBG_INFO_ON -DGLIDE_DEBUG -DGLIDE_SANITY_ASSERT -DGLIDE_SANITY_SIZE +endif + +override USE_FIFO = 1 +#override USE_X86 = 1 + +ifeq ($(USE_X86),1) +CDEFS += -DGLIDE_DISPATCH_SETUP=1 -DGLIDE_DISPATCH_DOWNLOAD=1 +override USE_FIFO = 1 +CDEFS += -DHAVE_XDRAWTRI_ASM=1 +override USE_DRAWTRI_ASM = 1 +else +CDEFS += -DGLIDE_USE_C_TRISETUP=1 +endif + +# fifo +ifeq ($(USE_FIFO),1) +CDEFS += -DUSE_PACKET_FIFO=1 -DGLIDE_PACKET3_TRI_SETUP=1 +endif + +# shameless plug and splash screen +#CDEFS += -DGLIDE_PLUG -DGLIDE_SPLASH + +############################################################################### +# flags +############################################################################### + +# librarian +ARFLAGS = rus + +# assembler +ASFLAGS = -O2 -fcoff -D__DJGPP__ --prefix _ +ASFLAGS += $(CDEFS) + +# compiler +CFLAGS = -Wall +CFLAGS += -I. -I../../incsrc -I../../init +CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap +CFLAGS += $(CDEFS) + +# cpu optimized triangle +ifeq ($(USE_MMX),1) +CFLAGS += -DGL_MMX +override USE_X86 = 1 +endif + +ifeq ($(USE_3DNOW),1) +CFLAGS += -DGL_AMD3D +override USE_X86 = 1 +endif + +ifeq ($(USE_X86),1) +OPTFLAGS ?= -O1 -ffast-math -mtune=pentium +else +OPTFLAGS ?= -O1 -ffast-math +endif + +# optflags +CFLAGS += $(OPTFLAGS) + +# for cross-builds +HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -march=%,$(CFLAGS)) + +############################################################################### +# objects +############################################################################### + +GLIDE_OBJECTS = \ + fifo.o \ + gsplash.o \ + g3df.o \ + gu.o \ + guclip.o \ + gpci.o \ + gump.o \ + diglide.o \ + disst.o \ + ditex.o \ + gbanner.o \ + gerror.o \ + gmovie.o \ + digutex.o \ + ddgump.o \ + gaa.o \ + gdraw.o \ + gglide.o \ + glfb.o \ + gsst.o \ + gtex.o \ + gtexdl.o \ + gutex.o \ + cpuid.o \ + fpu.o \ + xtexdl_def.o + +ifeq ($(USE_DRAWTRI_ASM),1) +GLIDE_OBJECTS += xdrawtri.o +endif +ifeq ($(USE_X86),1) +GLIDE_OBJECTS += \ + xdraw2_def.o +ifeq ($(USE_MMX),1) +GLIDE_OBJECTS += \ + xtexdl_mmx.o +endif +ifeq ($(USE_3DNOW),1) +GLIDE_OBJECTS += \ + xdraw2_3dnow.o \ + xtexdl_3dnow.o +endif +else +GLIDE_OBJECTS += \ + gxdraw.o +endif + +GLIDE_OBJECTS += \ + $(FX_GLIDE_SW)/newpci/pcilib/fxmsr.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxdpmi2.o \ + ../../init/canopus.o \ + ../../init/dac.o \ + ../../init/gamma.o \ + ../../init/gdebug.o \ + ../../init/info.o \ + ../../init/parse.o \ + ../../init/print.o \ + ../../init/sli.o \ + ../../init/sst1init.o \ + ../../init/util.o \ + ../../init/video.o \ + ../../init/fxremap.o + +############################################################################### +# rules +############################################################################### + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< + +############################################################################### +# main +############################################################################### +all: glide2x + +glide2x: $(GLIDE_LIBDIR)/$(GLIDE_LIB) $(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP) + +$(GLIDE_LIBDIR)/$(GLIDE_LIB): $(GLIDE_OBJECTS) + $(AR) $(ARFLAGS) $@ $^ + +$(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP): $(GLIDE_OBJECTS) + -$(DXE3GEN) -o $(GLIDE_LIBDIR)/$(GLIDE_DXE) -Y $(GLIDE_LIBDIR)/$(GLIDE_IMP) -D "GLIDE2X.DXE^CVG^" -E _gr -E _gu -E _ConvertAndDownloadRle -U $^ + +############################################################################### +# rules(2) +############################################################################### + +#cpuid.o: cpudtect.asm +# $(AS) -o $@ $(ASFLAGS) $< +xdraw2_def.o: xdraw2.asm + $(AS) -o $@ $(ASFLAGS) $< +xtexdl_def.o: xtexdl.c + $(CC) -o $@ $(CFLAGS) -c $< +xtexdl_mmx.o: xtexdl.asm + $(AS) -o $@ $(ASFLAGS) -DGL_MMX=1 $< +xdraw2_3dnow.o: xdraw2.asm + $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $< +xtexdl_3dnow.o: xtexdl.asm + $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $< +xdrawtri.o: xdrawtri.asm + $(AS) -o $@ $(ASFLAGS) $< + +$(GLIDE_OBJECTS): fxinline.h fxgasm.h + +# cross-compile workaround: +ifneq ($(COMSPEC),) +RUN_FXGASM=fxgasm.exe +else +RUN_FXGASM=./fxgasm.exe +endif + +fxinline.h: fxgasm.exe + $(RUN_FXGASM) -inline > $@ + +fxgasm.h: fxgasm.exe + $(RUN_FXGASM) -hex > $@ + +fxgasm.exe: fxgasm.c + $(HOST_CC) -o $@ $(HOST_CFLAGS) $< + +############################################################################### +# clean, realclean +############################################################################### + +clean: + -$(call UNLINK,*.o) + -$(call UNLINK,../../init/*.o) + -$(call UNLINK,$(FX_GLIDE_SW)/newpci/pcilib/*.o) + -$(call UNLINK,fxinline.h) + -$(call UNLINK,fxgasm.h) + -$(call UNLINK,../oem/oeminit.o) + +realclean: clean + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_LIB)) + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_DXE)) + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_IMP)) diff --git a/glide2x/h3/glide/src/Makefile.DJ b/glide2x/h3/glide/src/Makefile.DJ new file mode 100644 index 0000000..f77443c --- /dev/null +++ b/glide2x/h3/glide/src/Makefile.DJ @@ -0,0 +1,265 @@ +# DOS/DJGPP makefile for Glide2/H3 +# +# Copyright (c) 2003 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca +# + +# +# Available options: +# +# Environment variables: +# H4=1 High speed Avenger. +# default = no +# CPU optimize for the given processor. +# default = -mtune=pentium +# DEBUG=1 disable optimizations and build for debug. +# default = no +# USE_X86=1 use assembler triangle specializations! +# default = no +# USE_3DNOW=1 allow 3DNow! specializations. However, the true CPU +# capabilities are still checked at run-time to avoid +# crashes. +# default = no +# +# Targets: +# all: build everything +# glide2x: build Glide2x lib +# clean: remove object files +# realclean: remove all generated files +# + +.PHONY: all glide2x clean realclean +.INTERMEDIATE: fxgasm.exe + +############################################################################### +# general defines (user settable?) +############################################################################### + +GLIDE_LIB = libglide2x.a +GLIDE_DXE = glide2x.dxe +GLIDE_IMP = libglide2i.a + +FX_GLIDE_SW = ../../../swlibs +GLIDE_LIBDIR = ../../lib + +############################################################################### +# tools +############################################################################### + +CC = gcc +AS = nasm +LD = $(CC) +AR = ar +DXE3GEN = dxe3gen + +#for cross-builds +HOST_CC = gcc + +UNLINK = rm -f $(1) + +############################################################################### +# defines +############################################################################### + +# platform +CDEFS = -D__DOS__ -D__DOS32__ -DINIT_DOS + +# general +CDEFS += -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC -DGLIDE_PACKED_RGB=0 -DGLIDE_TRI_CULLING=1 -DGLIDE_LIB=1 + +# subsystem +CDEFS += -DH3 +ifdef H4 +CDEFS += -DH4 +endif + +# debug +ifdef DEBUG +CDEFS += -DGDBG_INFO_ON -DGLIDE_DEBUG -DGLIDE_SANITY_ASSERT -DGLIDE_SANITY_SIZE +endif + +override USE_FIFO = 1 +#override USE_X86 = 1 + +ifeq ($(USE_X86),1) +CDEFS += -DGLIDE_DISPATCH_SETUP=1 +override USE_FIFO = 1 +CDEFS += -DHAVE_XDRAWTRI_ASM=1 +override USE_DRAWTRI_ASM = 1 +else +CDEFS += -DGLIDE_USE_C_TRISETUP=1 +endif + +# fifo +ifeq ($(USE_FIFO),1) +CDEFS += -DUSE_PACKET_FIFO=1 -DGLIDE_PACKET3_TRI_SETUP=1 +endif + +# shameless plug and splash screen +#CDEFS += -DGLIDE_PLUG -DGLIDE_SPLASH + +############################################################################### +# flags +############################################################################### + +# librarian +ARFLAGS = rus + +# assembler +ASFLAGS = -O2 -fcoff -D__DJGPP__ --prefix _ +ASFLAGS += $(CDEFS) + +# compiler +CFLAGS = -Wall +CFLAGS += -I. -I../../incsrc -I../../minihwc -I../../cinit +CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap +CFLAGS += $(CDEFS) + +ifeq ($(USE_3DNOW),1) +CFLAGS += -DGL_AMD3D +override USE_X86 = 1 +endif + +ifeq ($(USE_X86),1) +OPTFLAGS ?= -O1 -ffast-math +else +OPTFLAGS ?= -O1 -ffast-math +endif + +# optflags +CFLAGS += $(OPTFLAGS) + +# for cross-builds +HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -march=%,$(CFLAGS)) + +############################################################################### +# objects +############################################################################### + +GLIDE_OBJECTS = \ + fifo.o \ + gsplash.o \ + g3df.o \ + gu.o \ + guclip.o \ + gpci.o \ + gump.o \ + diglide.o \ + disst.o \ + ditex.o \ + gbanner.o \ + gerror.o \ + gmovie.o \ + digutex.o \ + ddgump.o \ + gaa.o \ + gdraw.o \ + gglide.o \ + glfb.o \ + gsst.o \ + gtex.o \ + gtexdl.o \ + gutex.o \ + cpuid.o \ + xtexdl_def.o + +ifeq ($(USE_DRAWTRI_ASM),1) +GLIDE_OBJECTS += xdrawtri.o +endif +ifeq ($(USE_X86),1) +GLIDE_OBJECTS += \ + xdraw2_def.o +ifeq ($(USE_3DNOW),1) +GLIDE_OBJECTS += \ + xdraw2_3dnow.o \ + xtexdl_3dnow.o +endif +else +GLIDE_OBJECTS += \ + gxdraw.o +endif + +GLIDE_OBJECTS += \ + $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxdpmi2.o \ + ../../minihwc/hwcio.o \ + ../../minihwc/gdebug.o \ + ../../minihwc/minihwc.o \ + ../../minihwc/dos_mode.o \ + ../../cinit/h3cinit.o + +############################################################################### +# rules +############################################################################### + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +.S.o: + $(CC) -o $@ $(CFLAGS) -c $< +.s.o: + $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $< + +############################################################################### +# main +############################################################################### +all: glide2x + +glide2x: $(GLIDE_LIBDIR)/$(GLIDE_LIB) $(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP) + +$(GLIDE_LIBDIR)/$(GLIDE_LIB): $(GLIDE_OBJECTS) + $(AR) $(ARFLAGS) $@ $^ + +$(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP): $(GLIDE_OBJECTS) + -$(DXE3GEN) -o $(GLIDE_LIBDIR)/$(GLIDE_DXE) -Y $(GLIDE_LIBDIR)/$(GLIDE_IMP) -D "GLIDE2X.DXE^H3^" -E _gr -E _gu -E _ConvertAndDownloadRle -U $^ + +############################################################################### +# rules(2) +############################################################################### + +cpuid.o: cpudtect.asm + $(AS) -o $@ $(ASFLAGS) $< +xdraw2_def.o: xdraw2.asm + $(AS) -o $@ $(ASFLAGS) $< +xdraw2_3dnow.o: xdraw2.asm + $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $< +xtexdl_3dnow.o: xtexdl.asm + $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $< +xdrawtri.o: xdrawtri.asm + $(AS) -o $@ $(ASFLAGS) $< + +$(GLIDE_OBJECTS): fxinline.h fxgasm.h + +# cross-compile workaround: +ifneq ($(COMSPEC),) +RUN_FXGASM=fxgasm.exe +else +RUN_FXGASM=./fxgasm.exe +endif + +fxinline.h: fxgasm.exe + $(RUN_FXGASM) -inline > $@ + +fxgasm.h: fxgasm.exe + $(RUN_FXGASM) -hex > $@ + +fxgasm.exe: fxgasm.c + $(HOST_CC) -o $@ $(HOST_CFLAGS) $< + +############################################################################### +# clean, realclean +############################################################################### + +clean: + -$(call UNLINK,*.o) + -$(call UNLINK,../../cinit/*.o) + -$(call UNLINK,../../minihwc/*.o) + -$(call UNLINK,$(FX_GLIDE_SW)/newpci/pcilib/*.o) + -$(call UNLINK,fxinline.h) + -$(call UNLINK,fxgasm.h) + +realclean: clean + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_LIB)) + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_DXE)) + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_IMP)) + diff --git a/glide2x/sst1/glide/src/Makefile.DJ b/glide2x/sst1/glide/src/Makefile.DJ new file mode 100644 index 0000000..56b6090 --- /dev/null +++ b/glide2x/sst1/glide/src/Makefile.DJ @@ -0,0 +1,283 @@ +# DOS/DJGPP makefile for Glide2/SST1 +# +# Copyright (c) 2003 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca +# + +# +# Available options: +# +# Environment variables: +# FX_GLIDE_HW build for the given ASIC (either sst1, or sst96). +# default = sst1 +# CPU optimize for the given processor. +# default = -mtune=pentium +# DEBUG=1 disable optimizations and build for debug. +# default = no +# USE_X86=1 use assembler triangle specializations! +# default = no +# +# Targets: +# all: build everything +# glide2x: build Glide2x lib +# clean: remove object files +# realclean: remove all generated files +# + +.PHONY: all glide2x clean realclean +.INTERMEDIATE: fxgasm.exe + +############################################################################### +# general defines (user settable?) +############################################################################### + +GLIDE_LIB = libglide2x.a +GLIDE_DXE = glide2x.dxe +GLIDE_IMP = libglide2i.a + +FX_GLIDE_HW ?= sst1 +FX_GLIDE_SW = ../../../swlibs +GLIDE_LIBDIR = ../../lib + +############################################################################### +# tools +############################################################################### + +CC = gcc +AS = nasm +LD = $(CC) +AR = ar +DXE3GEN = dxe3gen + +#for cross-builds +HOST_CC = gcc + +UNLINK = rm -f $(1) + +############################################################################### +# defines +############################################################################### + +# platform +CDEFS = -D__DOS__ -D__DOS32__ -DINIT_DOS + +# general +CDEFS += -DGLIDE_HARDWARE -DGLIDE_DEFAULT_GAMMA=1.3f -DGLIDE_LIB=1 + +# subsystem +ifeq ($(FX_GLIDE_HW),sst1) +CDEFS += -DSST1 +else +ifeq ($(FX_GLIDE_HW),sst96) +CDEFS += -DSST96 +CDEFS += -DSST96_FIFO +#CDEFS += -DSST96_ALT_FIFO_WRAP +#CDEFS += -DINIT96VGASWAP +CDEFS += -DINIT_ACCESS_DIRECT +CDEFS += -DGLIDE_USE_ALT_REGMAP +else +$(error Invalid FX_GLIDE_HW setting) +endif +endif + +# debug +ifdef DEBUG +CDEFS += -DGDBG_INFO_ON -DGLIDE_DEBUG -DGLIDE_SANITY_ASSERT -DGLIDE_SANITY_SIZE +endif + +# shameless plug and splash screen +#CDEFS += -DGLIDE_PLUG -DGLIDE_SPLASH + +############################################################################### +# flags +############################################################################### + +# librarian +ARFLAGS = rus + +# assembler +ASFLAGS = -O2 -fcoff -D__DJGPP__ --prefix _ +ASFLAGS += $(CDEFS) + +# compiler +CFLAGS = -Wall +CFLAGS += -I. -I../../incsrc -I../../init -I../../init/initvg -I../../init/init96 +CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap +CFLAGS += $(CDEFS) + +ifneq ($(USE_X86),1) +CFLAGS += -DGLIDE_USE_C_TRISETUP +endif + +ifeq ($(USE_X86),1) +OPTFLAGS ?= -O1 -ffast-math -mtune=pentium +else +OPTFLAGS ?= -O1 -ffast-math +endif + +# optflags +CFLAGS += $(OPTFLAGS) + +# for cross-builds +HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -march=%,$(CFLAGS)) + +############################################################################### +# objects +############################################################################### + +GLIDE_OBJECTS = \ + gsplash.o \ + g3df.o \ + gu.o \ + guclip.o \ + gpci.o \ + gump.o \ + diglide.o \ + disst.o \ + ditex.o \ + gbanner.o \ + gerror.o \ + gmovie.o \ + digutex.o \ + ddgump.o \ + gaa.o \ + gdraw.o \ + gglide.o \ + glfb.o \ + gsst.o \ + gtex.o \ + gtexdl.o \ + gutex.o \ + gxdraw.o + +GLIDE_OBJECTS += \ + cpuid.o + +ifeq ($(USE_X86),1) +ifeq ($(FX_GLIDE_HW),sst1) +GLIDE_OBJECTS += \ + xdraw.o +else +GLIDE_OBJECTS += \ + xdraw96.o +endif +endif + +ifeq ($(FX_GLIDE_HW),sst96) +GLIDE_OBJECTS += \ + sst96.o \ + ../../init/init96/init96.o \ + ../../init/init96/dxdrvr.o \ + ../../init/init96/initat3d.o \ + ../../init/init96/initmcrx.o +endif + +GLIDE_OBJECTS += \ + ../../init/init.o \ + ../../init/vgdrvr.o \ + ../../init/vg96drvr.o \ + ../../init/initvg/gamma.o \ + ../../init/initvg/dac.o \ + ../../init/initvg/video.o \ + ../../init/initvg/parse.o \ + ../../init/initvg/sli.o \ + ../../init/initvg/util.o \ + ../../init/initvg/info.o \ + ../../init/initvg/print.o \ + ../../init/initvg/gdebug.o \ + ../../init/initvg/sst1init.o \ + $(FX_GLIDE_SW)/newpci/pcilib/sst1_pci.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxmsr.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxdpmi2.o + +############################################################################### +# rules +############################################################################### + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< + +############################################################################### +# main +############################################################################### +all: glide2x + +glide2x: $(GLIDE_LIBDIR)/$(GLIDE_LIB) $(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP) + +$(GLIDE_LIBDIR)/$(GLIDE_LIB): $(GLIDE_OBJECTS) + $(AR) $(ARFLAGS) $@ $^ + +$(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP): $(GLIDE_OBJECTS) + -$(DXE3GEN) -o $(GLIDE_LIBDIR)/$(GLIDE_DXE) -Y $(GLIDE_LIBDIR)/$(GLIDE_IMP) -D "GLIDE2X.DXE^$(FX_GLIDE_HW)^" -E _gr -E _gu -E _ConvertAndDownloadRle -U $^ + +############################################################################### +# rules(2) +############################################################################### + +cpuid.o: cpudtect.asm + $(AS) -o $@ $(ASFLAGS) $< +xdraw.o: xdraw.asm + $(AS) -o $@ $(ASFLAGS) $< +xdraw96.o: xdraw96.asm + $(AS) -o $@ $(ASFLAGS) $< + +ifeq ($(FX_GLIDE_HW),sst96) +../../init/initvg/gamma.o: ../../init/initvg/gamma.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/dac.o: ../../init/initvg/dac.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/video.o: ../../init/initvg/video.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/parse.o: ../../init/initvg/parse.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/sli.o: ../../init/initvg/sli.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/util.o: ../../init/initvg/util.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/info.o: ../../init/initvg/info.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/print.o: ../../init/initvg/print.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/gdebug.o: ../../init/initvg/gdebug.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +../../init/initvg/sst1init.o: ../../init/initvg/sst1init.c + $(CC) -o $@ $(CFLAGS) -USST96 -c $< +endif + +$(GLIDE_OBJECTS): fxinline.h fxgasm.h + +# cross-compile workaround: +ifneq ($(COMSPEC),) +RUN_FXGASM=fxgasm.exe +else +RUN_FXGASM=./fxgasm.exe +endif + +fxinline.h: fxgasm.exe + $(RUN_FXGASM) -inline > $@ + +fxgasm.h: fxgasm.exe + $(RUN_FXGASM) -hex > $@ + +fxgasm.exe: fxgasm.c + $(HOST_CC) -o $@ $(HOST_CFLAGS) $< + +############################################################################### +# clean, realclean +############################################################################### + +clean: + -$(call UNLINK,*.o) + -$(call UNLINK,../../init/*.o) + -$(call UNLINK,../../init/initvg/*.o) + -$(call UNLINK,../../init/init96/*.o) + -$(call UNLINK,$(FX_GLIDE_SW)/newpci/pcilib/*.o) + -$(call UNLINK,fxinline.h) + -$(call UNLINK,fxgasm.h) + +realclean: clean + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_LIB)) + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_DXE)) + -$(call UNLINK,$(GLIDE_LIBDIR)/$(GLIDE_IMP))