Files
glide/glide3x/Makefile.DJ
2003-07-21 10:24:24 +00:00

341 lines
9.3 KiB
Makefile

# DOS/DJGPP makefile for Glide3
#
# Copyright (c) 2003 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# $Header$
#
#
# Available options:
#
# Environment variables:
# FX_GLIDE_HW=[h3|h5] build for the given ASIC.
# default = h5
# H4=1 tune for Avenger highspeed.
# default = no
# CPU optimize for the given processor.
# default = k6
# 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 lockups.
# default = no
# USE_MMX=1 (see USE_3DNOW)
# default = no
# USE_SSE=1 (see USE_3DNOW)
# default = no
# USE_SSE2=1 (see USE_3DNOW)
# default = no
#
# Targets:
# glid3: build glide3
# all: build everything
# clean: remove object files
# realclean: remove all generated files
#
.PHONY: glid3 all clean realclean
.INTERMEDIATE: fxgasm.exe gendate.exe
###############################################################################
# general defines (user settable?)
###############################################################################
GLIDE_LIB = libglid3.a
GLIDE_DXE = glid3.dxe
GLIDE_IMP = libg3i.a
FX_GLIDE_HW ?= h5
FX_GLIDE_SW = swlibs
GLIDE_LIBDIR = $(FX_GLIDE_HW)/lib
###############################################################################
# tools
###############################################################################
CC = gcc
AS = nasm
AR = ar
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
###############################################################################
# defines
###############################################################################
# platform
CDEFS = -D__DOS__ -D__DOS32__
# general
CDEFS += -DGLIDE3 -DGLIDE3_ALPHA -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC -DGLIDE_PACKED_RGB=0 -DGLIDE_PACKET3_TRI_SETUP=1 -DGLIDE_TRI_CULLING=1 -DH3 -DUSE_PACKET_FIFO=1
# subsystem
ifdef H4
CDEFS += -DH4
endif
ifeq ($(FX_GLIDE_HW),h5)
CDEFS += -DFX_GLIDE_H5_CSIM=1 -DFX_GLIDE_NAPALM=1
endif
# debug
ifdef DEBUG
CDEFS += -DGDBG_INFO_ON -DGLIDE_DEBUG -DGLIDE_SANITY_ASSERT -DGLIDE_SANITY_SIZE
endif
# other
CDEFS += -DGLIDE_PLUG -DGLIDE_SPLASH
#CDEFS += -DGLIDE_LIB
###############################################################################
# flags
###############################################################################
# librarian
ARFLAGS = rus
# assembler
ASFLAGS = -O2 -fcoff -D__DJGPP__ --prefix _
ASFLAGS += -I$(FX_GLIDE_HW)/glide3/src
ASFLAGS += $(CDEFS)
# compiler
CFLAGS = -Wall -W
ifdef DEBUG
CFLAGS += -O0 -gcoff
else
CPU ?= k6
CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
endif
CFLAGS += -I$(FX_GLIDE_HW)/glide3/src -I$(FX_GLIDE_HW)/incsrc -I$(FX_GLIDE_HW)/minihwc -Ih3/cinit
CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap
CFLAGS += $(CDEFS)
ifeq ($(FX_GLIDE_HW),h3)
override USE_MMX = 0
override USE_SSE = 0
override USE_SSE2 = 0
endif
ifeq ($(USE_3DNOW),1)
CFLAGS += -DGL_AMD3D
override USE_X86 = 1
endif
ifeq ($(USE_MMX),1)
CFLAGS += -DGL_MMX
override USE_X86 = 1
endif
ifeq ($(USE_SSE),1)
CFLAGS += -DGL_SSE
override USE_X86 = 1
endif
ifeq ($(USE_SSE2),1)
CFLAGS += -DGL_SSE2
override USE_X86 = 1
endif
ifneq ($(USE_X86),1)
CFLAGS += -DGLIDE_USE_C_TRISETUP
endif
###############################################################################
# objects
###############################################################################
GLIDE_OBJECTS = \
$(FX_GLIDE_HW)/glide3/src/gsplash.o \
$(FX_GLIDE_HW)/glide3/src/g3df.o \
$(FX_GLIDE_HW)/glide3/src/gu.o \
$(FX_GLIDE_HW)/glide3/src/gthread.o \
$(FX_GLIDE_HW)/glide3/src/gpci.o \
$(FX_GLIDE_HW)/glide3/src/diglide.o \
$(FX_GLIDE_HW)/glide3/src/disst.o \
$(FX_GLIDE_HW)/glide3/src/ditex.o \
$(FX_GLIDE_HW)/glide3/src/gbanner.o \
$(FX_GLIDE_HW)/glide3/src/gerror.o \
$(FX_GLIDE_HW)/glide3/src/gaa.o \
$(FX_GLIDE_HW)/glide3/src/gdraw.o \
$(FX_GLIDE_HW)/glide3/src/gglide.o \
$(FX_GLIDE_HW)/glide3/src/distate.o \
$(FX_GLIDE_HW)/glide3/src/gstrip.o \
$(FX_GLIDE_HW)/glide3/src/distrip.o \
$(FX_GLIDE_HW)/glide3/src/diget.o \
$(FX_GLIDE_HW)/glide3/src/glfb.o \
$(FX_GLIDE_HW)/glide3/src/gsst.o \
$(FX_GLIDE_HW)/glide3/src/gtex.o \
$(FX_GLIDE_HW)/glide3/src/gtexdl.o \
$(FX_GLIDE_HW)/glide3/src/fifo.o
ifeq ($(USE_X86),1)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/xdraw2_def.o \
$(FX_GLIDE_HW)/glide3/src/xdraw3_def.o
ifeq ($(USE_3DNOW),1)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/xdraw2_3dnow.o \
$(FX_GLIDE_HW)/glide3/src/xdraw3_3dnow.o \
$(FX_GLIDE_HW)/glide3/src/xtexdl_3dnow.o
endif
ifeq ($(USE_MMX),1)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/xtexdl_mmx.o
endif
ifeq ($(USE_SSE),1)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/xdraw2_sse.o \
$(FX_GLIDE_HW)/glide3/src/xdraw3_sse.o
endif
ifeq ($(USE_SSE2),1)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.o
endif
else
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/gxdraw.o
endif
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/xtexdl_def.o
ifeq ($(FX_GLIDE_HW),h5)
GLIDE_OBJECTS += \
h5/glide3/src/cpuid.o
endif
ifeq ($(FX_GLIDE_HW),h3)
GLIDE_OBJECTS += \
h3/glide3/src/cpudtect.o
endif
GLIDE_OBJECTS += \
h3/cinit/h3cinit.o \
$(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \
$(FX_GLIDE_SW)/newpci/pcilib/fxdpmi2.o \
$(FX_GLIDE_HW)/minihwc/hwcio.o \
$(FX_GLIDE_HW)/minihwc/gdebug.o \
$(FX_GLIDE_HW)/minihwc/minihwc.o \
$(FX_GLIDE_HW)/minihwc/dos_mode.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: glid3
glid3: $(GLIDE_LIBDIR)/$(GLIDE_LIB) $(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP)
$(GLIDE_LIBDIR)/$(GLIDE_LIB): $(GLIDE_OBJECTS)
$(AR) $(ARFLAGS) $@ $(GLIDE_OBJECTS)
$(GLIDE_LIBDIR)/$(GLIDE_DXE) $(GLIDE_LIBDIR)/$(GLIDE_IMP): $(GLIDE_OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLIDE_DXE))
else
-dxe3gen -o $(GLIDE_LIBDIR)/$(GLIDE_DXE) -Y $(GLIDE_LIBDIR)/$(GLIDE_IMP) -D "Glide3/$(FX_GLIDE_HW) DJGPP" -E _gr -E _gu -U $(GLIDE_OBJECTS)
endif
###############################################################################
# rules(2)
###############################################################################
h3/glide3/src/gglide.o: h3/glide3/src/gglide.c.save
$(CC) -o $@ $(CFLAGS) -x c -c $<
h3/glide3/src/glfb.o: h3/glide3/src/glfb.c.save
$(CC) -o $@ $(CFLAGS) -x c -c $<
h3/glide3/src/gsst.o: h3/glide3/src/gsst.c.save
$(CC) -o $@ $(CFLAGS) -x c -c $<
h3/glide3/src/xdraw2_def.o: h3/glide3/src/xdraw2.S
$(CC) -o $@ $(CFLAGS) -UGL_AMD3D -c $<
h3/glide3/src/xdraw3_def.o: h3/glide3/src/xdraw3.S
$(CC) -o $@ $(CFLAGS) -UGL_AMD3D -c $<
h3/glide3/src/xtexdl_3dnow.o: h3/glide3/src/xtexdl.S
$(CC) -o $@ $(CFLAGS) -c $<
h3/glide3/src/xdraw2_3dnow.o: h3/glide3/src/xdraw2.S
$(CC) -o $@ $(CFLAGS) -c $<
h3/glide3/src/xdraw3_3dnow.o: h3/glide3/src/xdraw3.S
$(CC) -o $@ $(CFLAGS) -c $<
h5/glide3/src/xdraw2_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm
$(AS) -o $@ $(ASFLAGS) $<
h5/glide3/src/xdraw3_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm
$(AS) -o $@ $(ASFLAGS) $<
h5/glide3/src/xdraw2_3dnow.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
h5/glide3/src/xdraw3_3dnow.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
h5/glide3/src/xtexdl_3dnow.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
h5/glide3/src/xtexdl_mmx.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_MMX=1 $<
h5/glide3/src/xdraw2_sse.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm
$(AS) -o $@ $(ASFLAGS) -DGL_SSE=1 $<
h5/glide3/src/xdraw3_sse.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm
$(AS) -o $@ $(ASFLAGS) -DGL_SSE=1 $<
h5/glide3/src/xtexdl_sse2.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_SSE2=1 $<
$(GLIDE_OBJECTS): $(FX_GLIDE_HW)/glide3/src/fxinline.h $(FX_GLIDE_HW)/glide3/src/fxgasm.h
$(FX_GLIDE_HW)/glide3/src/fxinline.h: fxgasm.exe
$< -inline > $@
$(FX_GLIDE_HW)/glide3/src/fxgasm.h: fxgasm.exe
$< -hex > $@
ifeq ($(FX_GLIDE_HW),h5)
GENDATE = h5/incsrc/gendate.h
endif
fxgasm.exe: $(FX_GLIDE_HW)/glide3/src/fxgasm.c $(GENDATE)
$(CC) -o $@ $(CFLAGS) $<
$(GENDATE): gendate.exe
$< > $@
gendate.exe: h5/incsrc/gendate.c
$(CC) -o $@ $(CFLAGS) $<
###############################################################################
# clean, realclean
###############################################################################
clean:
-$(call UNLINK,h3/cinit/*.o)
-$(call UNLINK,$(FX_GLIDE_HW)/glide3/src/*.o)
-$(call UNLINK,$(FX_GLIDE_HW)/minihwc/*.o)
-$(call UNLINK,$(FX_GLIDE_SW)/newpci/pcilib/*.o)
-$(call UNLINK,$(FX_GLIDE_HW)/glide3/src/fxinline.h)
-$(call UNLINK,$(FX_GLIDE_HW)/glide3/src/fxgasm.h)
ifneq ($(GENDATE),)
-$(call UNLINK,$(GENDATE))
endif
realclean: clean
-$(call UNLINK,$(GLIDE_LIBDIR)/*.a)
-$(call UNLINK,$(GLIDE_LIBDIR)/*.dxe)