Files
glide/glide3x/makefile.linux
2003-12-08 13:13:11 +00:00

469 lines
13 KiB
Plaintext

# Linux makefile for Glide3 and Texus2
#
# Copyright (c) 2003 - Borca Daniel
# Email : dborca@users.sourceforge.net
# Web : http://www.geocities.com/dborca
#
# $Header$
#
#
# Available options:
#
# Environment variables:
# FX_GLIDE_HW build for the given ASIC (cvg, h3, h5).
# default = h5
# DRI=1 Build DRI version.
# target = h3, h5
# default = no
# DGA=1 Build DGA version (experimental).
# target = h3, h5
# default = no
# XPATH specify X libraries path; needed by DRI and DGA.
# target = h3, h5
# default = /usr/X11/lib
# H4=1 Avenger/Napalm.
# target = h3, h5
# default = no
# CPU optimize for the given processor.
# target = cvg, h3, h5
# default = pentium
# DEBUG=1 disable optimizations and build for debug.
# target = cvg, h3, h5
# default = no
# USE_X86=1 use assembler triangle specializations; req by CVG
# target = cvg, h3, h5
# 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, h5
# default = no
# USE_MMX=1 (see USE_3DNOW)
# target = h5
# default = no
# USE_SSE=1 (see USE_3DNOW)
# target = h5
# default = no
# USE_SSE2=1 (see USE_3DNOW)
# target = h5
# default = no
# TEXUS2=1 embed Texus2 functions into Glide3.
# target = cvg, h3, h5
# default = no
#
# Targets:
# all: build everything
# glide3x: build Glide3x lib
# clean: remove object files
# realclean: remove all generated files
#
.PHONY: all glide3x clean realclean
.INTERMEDIATE: fxgasm gendate fxbldno
.SUFFIXES: .lo
export PATH := $(PATH):.
###############################################################################
# general defines (user settable?)
###############################################################################
GLIDE_LIB = libglide3.a
GLIDE_SO = libglide3.so
TEXUS_EXE = texus2
FX_GLIDE_HW ?= h5
FX_GLIDE_SW = swlibs
GLIDE_LIBDIR = $(FX_GLIDE_HW)/lib
TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin
###############################################################################
# tools
###############################################################################
CC = gcc
AS = nasm
AR = ar
LD = gcc
CP = cp
###############################################################################
# defines
###############################################################################
# platform
CDEFS = -D__linux__
ifneq ($(FX_GLIDE_HW),cvg)
XPATH ?= /usr/X11/lib
ifeq ($(DRI),1)
CDEFS += -DDRI_BUILD
LDFLAGS = -L$(XPATH)
LDLIBS = -lX11
endif
ifeq ($(DGA),1)
CDEFS += -DUSE_XDGA_SWITCH=1
LDFLAGS = -L$(XPATH)
LDLIBS = -lX11 -lXext -lXxf86dga
endif
endif
# 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 -DUSE_PACKET_FIFO=1
# subsystem
ifeq ($(FX_GLIDE_HW),cvg)
CDEFS += -DCVG
else
CDEFS += -DH3
ifdef H4
CDEFS += -DH4
endif
ifeq ($(FX_GLIDE_HW),h5)
CDEFS += -DFX_GLIDE_H5_CSIM=1 -DFX_GLIDE_NAPALM=1
endif
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
ifeq ($(FX_GLIDE_HW),cvg)
#CDEFS += -DGLIDE3_SCALER
CDEFS += -DGLIDE_DISPATCH_SETUP -DGLIDE_DISPATCH_DOWNLOAD
CDEFS += -DINIT_LINUX
CDEFS += -D__3Dfx_PCI_CFG__
else
#CDEFS += -DGLIDE_CHECK_CONTEXT
endif
ifeq ($(TEXUS2),1)
CDEFS += -DHAVE_TEXUS2
endif
###############################################################################
# flags
###############################################################################
# librarian
ARFLAGS = rus
# assembler
ASFLAGS = -O2 -felf -D__linux__
ASFLAGS += -I$(FX_GLIDE_HW)/glide3/src
ASFLAGS += $(CDEFS)
# compiler
CFLAGS = -Wall -W
ifdef DEBUG
CFLAGS += -O0 -g
else
CPU ?= pentium
CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
endif
CFLAGS += -I$(FX_GLIDE_HW)/glide3/src -I$(FX_GLIDE_HW)/incsrc -I$(FX_GLIDE_HW)/minihwc -I$(FX_GLIDE_HW)/cinit -I$(FX_GLIDE_HW)/init
CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap
CFLAGS += -I$(FX_GLIDE_SW)/texus2/lib
CFLAGS += $(CDEFS)
ifeq ($(FX_GLIDE_HW),cvg)
override USE_X86 = 1
else
ifeq ($(FX_GLIDE_HW),h3)
override USE_MMX = 0
override USE_SSE = 0
override USE_SSE2 = 0
endif
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/fifo.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/gsplash.o \
$(FX_GLIDE_HW)/glide3/src/g3df.o \
$(FX_GLIDE_HW)/glide3/src/gu.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/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/cpuid.o \
$(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \
$(FX_GLIDE_SW)/newpci/pcilib/fxlinux.o \
$(FX_GLIDE_SW)/fxmisc/linutil.o \
$(FX_GLIDE_HW)/glide3/src/xtexdl_def.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
ifeq ($(FX_GLIDE_HW),cvg)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/digutex.o \
$(FX_GLIDE_SW)/newpci/pcilib/fxmsr.o \
$(FX_GLIDE_HW)/init/canopus.o \
$(FX_GLIDE_HW)/init/dac.o \
$(FX_GLIDE_HW)/init/gamma.o \
$(FX_GLIDE_HW)/init/gdebug.o \
$(FX_GLIDE_HW)/init/info.o \
$(FX_GLIDE_HW)/init/parse.o \
$(FX_GLIDE_HW)/init/print.o \
$(FX_GLIDE_HW)/init/sli.o \
$(FX_GLIDE_HW)/init/sst1init.o \
$(FX_GLIDE_HW)/init/util.o \
$(FX_GLIDE_HW)/init/video.o \
$(FX_GLIDE_HW)/init/fxremap.o
else
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/glide3/src/gthread.o \
$(FX_GLIDE_HW)/minihwc/hwcio.o \
$(FX_GLIDE_HW)/minihwc/gdebug.o
ifeq ($(DRI),1)
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/minihwc/linhwc.o
else
GLIDE_OBJECTS += \
$(FX_GLIDE_HW)/minihwc/minihwc.o \
$(FX_GLIDE_HW)/minihwc/lin_mode.o \
h5/cinit/h3cinit.o
endif
endif
TEXUS_SOURCES = \
$(FX_GLIDE_SW)/texus2/lib/texuslib.c \
$(FX_GLIDE_SW)/texus2/lib/clamp.c \
$(FX_GLIDE_SW)/texus2/lib/read.c \
$(FX_GLIDE_SW)/texus2/lib/resample.c \
$(FX_GLIDE_SW)/texus2/lib/mipmap.c \
$(FX_GLIDE_SW)/texus2/lib/quantize.c \
$(FX_GLIDE_SW)/texus2/lib/ncc.c \
$(FX_GLIDE_SW)/texus2/lib/nccnnet.c \
$(FX_GLIDE_SW)/texus2/lib/pal256.c \
$(FX_GLIDE_SW)/texus2/lib/pal6666.c \
$(FX_GLIDE_SW)/texus2/lib/dequant.c \
$(FX_GLIDE_SW)/texus2/lib/view.c \
$(FX_GLIDE_SW)/texus2/lib/util.c \
$(FX_GLIDE_SW)/texus2/lib/diffuse.c \
$(FX_GLIDE_SW)/texus2/lib/write.c \
$(FX_GLIDE_SW)/texus2/lib/tga.c \
$(FX_GLIDE_SW)/texus2/lib/3df.c \
$(FX_GLIDE_SW)/texus2/lib/ppm.c \
$(FX_GLIDE_SW)/texus2/lib/rgt.c \
$(FX_GLIDE_SW)/texus2/lib/txs.c \
$(FX_GLIDE_SW)/texus2/lib/codec.c \
$(FX_GLIDE_SW)/texus2/lib/eigen.c \
$(FX_GLIDE_SW)/texus2/lib/bitcoder.c
ifeq ($(TEXUS2),1)
GLIDE_OBJECTS += $(TEXUS_SOURCES:.c=.o)
endif
###############################################################################
# rules
###############################################################################
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.S.o:
$(CC) -o $@ $(CFLAGS) -c $<
.s.o:
$(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
.c.lo:
$(CC) -o $@ $(CFLAGS) -DPIC -fPIC -c $<
###############################################################################
# main
###############################################################################
all: glide3x $(TEXUS_EXEDIR)/$(TEXUS_EXE)
glide3x: $(GLIDE_LIBDIR)/$(GLIDE_LIB) $(GLIDE_LIBDIR)/$(GLIDE_SO)
$(GLIDE_LIBDIR)/$(GLIDE_LIB): $(GLIDE_OBJECTS)
$(AR) $(ARFLAGS) $@ $^
$(GLIDE_LIBDIR)/$(GLIDE_SO): $(GLIDE_OBJECTS:.o=.lo)
$(CC) -o $@ -shared $^ $(LDFLAGS) $(LDLIBS)
$(TEXUS_EXEDIR)/$(TEXUS_EXE): $(FX_GLIDE_SW)/texus2/cmd/cmd.c $(GLIDE_LIBDIR)/$(GLIDE_LIB)
ifeq ($(TEXUS2),1)
$(CC) -o $@ -s $(CFLAGS) -L$(GLIDE_LIBDIR) $< -lglide3 -lm
else
$(warning Texus2 not enabled... Skipping $(TEXUS_EXE))
endif
###############################################################################
# rules(2)
###############################################################################
cvg/glide3/src/xtexdl_def.o: cvg/glide3/src/xtexdl.c
$(CC) -o $@ $(CFLAGS) -c $<
cvg/glide3/src/cpuid.o: cvg/glide3/src/cpudtect.asm
$(AS) -o $@ $(ASFLAGS) $<
h3/glide3/src/cpuid.o: h3/glide3/src/cpudtect.asm
$(AS) -o $@ $(ASFLAGS) $<
$(FX_GLIDE_HW)/glide3/src/xdraw2_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm
$(AS) -o $@ $(ASFLAGS) $<
$(FX_GLIDE_HW)/glide3/src/xdraw3_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm
$(AS) -o $@ $(ASFLAGS) $<
$(FX_GLIDE_HW)/glide3/src/xdraw2_3dnow.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
$(FX_GLIDE_HW)/glide3/src/xdraw3_3dnow.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
$(FX_GLIDE_HW)/glide3/src/xtexdl_3dnow.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
$(FX_GLIDE_HW)/glide3/src/xtexdl_mmx.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_MMX=1 $<
$(FX_GLIDE_HW)/glide3/src/xdraw2_sse.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm
$(AS) -o $@ $(ASFLAGS) -DGL_SSE=1 $<
$(FX_GLIDE_HW)/glide3/src/xdraw3_sse.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm
$(AS) -o $@ $(ASFLAGS) -DGL_SSE=1 $<
$(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_SSE2=1 $<
cvg/glide3/src/xtexdl_def.lo: cvg/glide3/src/xtexdl.c
$(CC) -o $@ $(CFLAGS) -DPIC -fPIC -c $<
cvg/glide3/src/cpuid.lo: cvg/glide3/src/cpuid.o
$(CP) $< $@
h3/glide3/src/cpuid.lo: h3/glide3/src/cpuid.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xdraw2_def.lo: $(FX_GLIDE_HW)/glide3/src/xdraw2_def.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xdraw3_def.lo: $(FX_GLIDE_HW)/glide3/src/xdraw3_def.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xdraw2_3dnow.lo: $(FX_GLIDE_HW)/glide3/src/xdraw2_3dnow.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xdraw3_3dnow.lo: $(FX_GLIDE_HW)/glide3/src/xdraw3_3dnow.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xtexdl_3dnow.lo: $(FX_GLIDE_HW)/glide3/src/xtexdl_3dnow.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xtexdl_mmx.lo: $(FX_GLIDE_HW)/glide3/src/xtexdl_mmx.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xdraw2_sse.lo: $(FX_GLIDE_HW)/glide3/src/xdraw2_sse.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xdraw3_sse.lo: $(FX_GLIDE_HW)/glide3/src/xdraw3_sse.o
$(CP) $< $@
$(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.lo: $(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.o
$(CP) $< $@
ifeq ($(FX_GLIDE_HW),h5)
GENDATE = $(FX_GLIDE_HW)/incsrc/gendate.h
FXBLDNO = $(FX_GLIDE_HW)/glide3/src/fxbldno.h
endif
$(GLIDE_OBJECTS): $(FX_GLIDE_HW)/glide3/src/fxinline.h $(FX_GLIDE_HW)/glide3/src/fxgasm.h $(FXBLDNO)
$(FX_GLIDE_HW)/glide3/src/fxinline.h: fxgasm
$< -inline > $@
$(FX_GLIDE_HW)/glide3/src/fxgasm.h: fxgasm
$< -hex > $@
fxgasm: $(FX_GLIDE_HW)/glide3/src/fxgasm.c $(GENDATE)
$(CC) -o $@ $(CFLAGS) $<
$(GENDATE): gendate
$< > $@
$(FXBLDNO): fxbldno
$< > $@
gendate: $(GENDATE:.h=.c)
$(CC) -o $@ $(CFLAGS) $<
fxbldno: $(FXBLDNO:.h=.c)
$(CC) -o $@ $(CFLAGS) $<
###############################################################################
# clean, realclean
###############################################################################
clean:
-$(RM) cvg/init/*.[l]o
-$(RM) h5/cinit/*.[l]o
-$(RM) $(FX_GLIDE_HW)/glide3/src/*.[l]o
-$(RM) $(FX_GLIDE_HW)/minihwc/*.[l]o
-$(RM) $(FX_GLIDE_SW)/newpci/pcilib/*.[l]o
-$(RM) $(FX_GLIDE_HW)/glide3/src/fxinline.h
-$(RM) $(FX_GLIDE_HW)/glide3/src/fxgasm.h
-$(RM) $(GENDATE)
-$(RM) $(FXBLDNO)
-$(RM) $(FX_GLIDE_SW)/fxmisc/*.[l]o
-$(RM) $(FX_GLIDE_SW)/texus2/lib/*.[l]o)
realclean: clean
-$(RM) $(GLIDE_LIBDIR)/$(GLIDE_LIB)
-$(RM) $(GLIDE_LIBDIR)/$(GLIDE_SO)
-$(RM) $(TEXUS_EXEDIR)/$(TEXUS_EXE))