# 
#  (c) Copyright 1996, Silicon Graphics, Inc.
#  ALL RIGHTS RESERVED
#  Permission to use, copy, modify, and distribute this software for
#  any purpose and without fee is hereby granted, provided that the above
#  copyright notice appear in all copies and that both the copyright notice
#  and this permission notice appear in supporting documentation, and that
#  the name of Silicon Graphics, Inc. not be used in advertising
#  or publicity pertaining to distribution of the software without specific,
#  written prior permission.
# 
#  THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
#  AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
#  INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
#  FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
#  GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
#  SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
#  KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
#  LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
#  THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
#  ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
#  ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
#  POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
# 
#  US Government Users Restricted Rights
#  Use, duplication, or disclosure by the Government is subject to
#  restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
#  (c)(1)(ii) of the Rights in Technical Data and Computer Software
#  clause at DFARS 252.227-7013 and/or in similar or successor
#  clauses in the FAR or the DOD or NASA FAR Supplement.
#  Unpublished-- rights reserved under the copyright laws of the
#  United States.  Contractor/manufacturer is Silicon Graphics,
#  Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
# 
#  Author: John Spitzer, SGI Desktop Performance Engineering
# 

# These control the size of your executable (and the amount of
# functionality that the size provides)
#
# FULL_VERTEX_PATHS  - Allows you to send 2d as well as 3d vertex
#                      data (without this, you'll only get 3d)
# FULL_RASTERPOS_PATHS  - Allows you to send 2d as well as 3d raster position
#                      data (without this, you'll only get 3d)
# FULL_TEXTURE_PATHS - Allows you to use 1d as well as 2d textures
#                      (without, you'll only get 2d)
# FULL_COLOR_PATHS   - Allows you to use RGBA as well as RGB data
#                      (without, you'll only get RGB)
# FULL_FUNCPTR_PATHS - Allows you to use function ptrs in the inner loop
#                      (without, you won't be able to use them)
# FULL_UNROLL_PATHS  - Allows you to unroll in the inner loop (up to 8)
#                      (without, you won't be able to unroll at all)
#

include MakeAdd

PATHS = \
    -DFULL_COLOR_PATHS \
    -DFULL_VERTEX_PATHS \
    -DFULL_RASTERPOS_PATHS \
    -DFULL_TEXTURE_PATHS

help:
	echo "Need to choose a config to compile: amiga"

amiga:
	rm -f MakeAdd
	echo "# Nothing" > MakeAdd
	make \
    MAKE="make" \
    LEX="flex -l" \
    YACC="bison -y" \
    CC="gcc -c" \
    E="" \
    O=".o" \
    LINK="gcc" \
    CCFLAGS="-s -v -O3 -m68030 -m68881 -fno-float-store -ffunction-cse -fpeephole -ffast-math -fomit-frame-pointer -fstrength-reduce -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns -fschedule-insns2 -fmove-all-movables -freg-struct-return -freduce-all-givs -fforce-addr -mbitfield" \
    AUX_DIR="" \
    AUX_LIB="" \
    ENV_C="EnvAOS.c" \
    INCLUDES="" \
    LIBS="-L/img/Mesa-3.0/lib -L. -lperf -lm -lMesaGLaux -lMesaGLtk -lMesaGLu -lMesaGL" \
    LFLAGS="-s -m68030 -m68881 -o " \
    GL_H="/ade/os-include/gl/gl.h" \
    GLU_H="/ade/os-include/gl/glu.h" \
    LEX_YY="lex.yy" \
    Y_TAB="y.tab" \
    LEX_YACC="lex.yy.c y.tab.c y.tab.h" \
    RM="rm -f" \
    CP="cp" \
    PERF_LIB="libperf.a" \
    MAKELIB="ar rv " \
    -f Makefile.aos GLperf

# Placeholder definitions (not actually used, don't worry)
PERF_LIB = libperf.a
MAKELIB = ar rv 
MAKE = make
LEX = lex
YACC = yacc
CC = cc -c
E = 
O = .o
LINK = cc
CCFLAGS = -O -DXWINDOWS
AUX_DIR = libaux
AUX_LIB = libaux.a
ENV_C = EnvSGI.c
INCLUDES = -I$(AUX_DIR) -I/usr/include/GL
LIBS = -L. -L$(AUX_DIR) -lperf -lm -laux -lGLU -lGL -lX11 -lXext
LFLAGS = $(CFLAGS) -o
GL_H = /usr/include/GL/gl.h
GLU_H = /usr/include/GL/glu.h
LEX_YY = lex.yy
Y_TAB = y.tab
LEX_YACC = lex.yy.c y.tab.c y.tab.h
RM=rm -f
COPY=cp

#
# You shouldn't have to change anything past here
#

CMDS = GLperf$E

CFLAGS = $(CCFLAGS) $(INCLUDES) $(PATHS)

include Objs

CFLAGS = $(CCFLAGS) $(INCLUDES) $(PATHS)

$(CMDS): $(PERF_LIB) $(CMDS)$O
	$(LINK) $(LFLAGS)$@ $(CMDS)$O $(LIBS)

GENERATE = Bitmap.x Clear.x CopyPix.x DrawPix.x ReadPix.x TexBind.x \
           TexCopy.x TexLoad.x Text.x Xform.x VertA11.x VertexA.x
GENEXE  = $(GENERATE:.x=G$E) VertexG$E
GENCSRC = $(GENERATE:.x=F.c) Vert??F.c
GENHDRS = $(GENERATE:.x=X.h) Vert??F.h
GENDIRT = $(GENEXE) $(GENCSRC) $(GENHDRS)

TABSTUFF = AttrTab.h PropTab.h TestTab.h ./Cat$E ./MakeTab$E
CLEANFILES = *$O GLperf$E $(LEX_YACC) $(TABSTUFF) $(GENDIRT) $(PERF_LIB)

clean:  
	$(RM) $(CLEANFILES)

#
# These rules show how the libraries are built
#

$(PERF_LIB): $(OBJS)
	$(MAKELIB) $@ $?

#
# These rules show how the generators create their files
#

#BitmapX.h BitmapF.c: BitmapG$E
#	BitmapG$E

#ClearX.h ClearF.c: ClearG$E
#	ClearG$E

#CopyPixX.h CopyPixF.c: CopyPixG$E
#	CopyPixG$E

#DrawPixX.h DrawPixF.c: DrawPixG$E
#	DrawPixG$E

#ReadPixX.h ReadPixF.c: ReadPixG$E
#	ReadPixG$E

#TexBindX.h TexBindF.c: TexBindG$E
#	TexBindG$E

#TexCopyX.h TexCopyF.c: TexCopyG$E
#	TexCopyG$E

#TexLoadX.h TexLoadF.c: TexLoadG$E
#	TexLoadG$E

#TextX.h TextF.c: TextG$E
#	TextG$E

#VertA11X.h VertA11F.c: VertA11G$E
#	VertA11G$E

#VertexAX.h VertexAF.c: VertexAG$E
#	VertexAG$E

#VertexX.h \
#Vert00F.h Vert00F.c \
#Vert01F.h Vert01F.c \
#Vert02F.h Vert02F.c \
#Vert03F.h Vert03F.c \
#Vert04F.h Vert04F.c \
#Vert05F.h Vert05F.c \
#Vert08F.h Vert08F.c \
#Vert09F.h Vert09F.c \
#Vert10F.h Vert10F.c \
#Vert11F.h Vert11F.c \
#Vert12F.h Vert12F.c \
#Vert13F.h Vert13F.c \
#Vert16F.h Vert16F.c \
#Vert17F.h Vert17F.c \
#Vert18F.h Vert18F.c \
#Vert19F.h Vert19F.c \
#Vert20F.h Vert20F.c \
#Vert21F.h Vert21F.c: VertexG$E
#	VertexG$E

#XformX.h XformF.c: XformG$E
#	XformG$E

#
# These rules show how the other source files are created
#

#Env.c:
#	$(RM) Env.c
#	$(CP) $(ENV_C) Env.c

#PropTab.h: PropName.h ./Cat$E ./MakeTab$E
#	./Cat$E PropName.h | ./MakeTab$E Properties > PropTab.h

#TestTab.h: TestName.h ./Cat$E ./MakeTab$E
#	./Cat$E TestName.h | ./MakeTab$E Tests > TestTab.h

#AttrTab.h: AttrName.h $(GL_H) $(GLU_H) ./Cat$E ./MakeTab$E
#	./Cat$E $(GL_H) $(GLU_H) AttrName.h | ./MakeTab$E Attributes > AttrTab.h

$(LEX_YY).c: Parse.l PropTab.h TestTab.h AttrTab.h
	$(LEX) Parse.l

$(Y_TAB).c $(Y_TAB).h: Parse.y $(LEX_YY).c
	$(YACC) -d Parse.y

#
# These rules show the dependencies of object files on source files
#

include Depends

#
# This rule shows how the source files are created
#

.c$O:
	$(CC) $(CFLAGS) $<

#
# This rule shows how the file generators are created
#

.c$E $(GENEXE):
	$(CC) $(CFLAGS) $@.c
	$(LINK) $(LFLAGS)$@ $@$O

