# Linux tests makefile for Glide3
#
#  Copyright (c) 2002 - Borca Daniel
#  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).
#			default = sst1
#	CPU		optimize for the given processor.
#			default = pentium
#
#    Targets:
#	<file.exe>	build a specific file
#


.PHONY: all
.SUFFIXES: .c .o .exe
.SECONDARY: tlib.o

FX_GLIDE_HW ?= sst1
ifeq ($(FX_GLIDE_HW),sst1)
HWDEF = -DSST1
else
ifeq ($(FX_GLIDE_HW),sst96)
HWDEF = -DSST96
XPATH = -L/usr/X11R6/lib
XLIBS = -lXxf86dga -lXxf86rush -lXxf86vm
endif
endif

override FX_GLIDE_HW = sst1
TOP = ../../..
CPU ?= pentium

CC = gcc
CFLAGS = -Wall -O2 -ffast-math -mcpu=$(CPU)
CFLAGS += -I$(TOP)/$(FX_GLIDE_HW)/glide3/src -I$(TOP)/$(FX_GLIDE_HW)/incsrc -I$(TOP)/$(FX_GLIDE_HW)/init
CFLAGS += -I$(TOP)/swlibs/fxmisc
CFLAGS += $(HWDEF)

LDFLAGS = -s -L$(TOP)/$(FX_GLIDE_HW)/lib $(XPATH)

LDLIBS = -lglide3x
LDLIBS += $(XLIBS) -lm

.c.o:
	$(CC) -o $@ $(CFLAGS) -c $<
%.exe: $(TOP)/swlibs/fxmisc/linutil.o tlib.o %.o
	$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)

all:
	$(error Must specify <filename.exe> to build)
