# TrueReality - Makefile
# Copyright (C) 1998, 1999 Niki W. Waibel
#
# This program is free software; you can redistribute it and/
# or modify it under the terms of the GNU General Public Li-
# cence as published by the Free Software Foundation; either
# version 2 of the Licence, or any later version.
#
# This program is distributed in the hope that it will be use-
# ful, but WITHOUT ANY WARRANTY; without even the implied war-
# ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public Licence for more details.
#
# You should have received a copy of the GNU General Public
# Licence along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
# USA.
#
# Information about me (the author):
#   Niki W. Waibel, Reichenau 20, 6890 Lustenau, Austria - EUROPE
#   niki.waibel@gmx.net





###############################################################################
# You shouldn't change anything in this file unless you are a developer.      #
# Changes can be done in 'Makefile.tmpl'.                                     #





.EXPORT_ALL_VARIABLES:





include Makefile.tmpl





VERSION = 1999062900
NAME    = TrueReality




CC      = $(CROSS_COMPILE)$(HOSTCC) $(HOSTCFLAGS)
CPP     = $(CROSS_COMPILE)$(HOSTCPP)
LD      = $(CROSS_COMPILE)$(HOSTLD)
AS      = $(CROSS_COMPILE)$(HOSTAS)
AR      = $(CROSS_COMPILE)$(HOSTAR)
RANLIB  = $(CROSS_COMPILE)$(HOSTRANLIB)
STRIP   = $(CROSS_COMPILE)$(HOSTSTRIP)





###############################################################################
# Machine (cpu) dependent definitions                                         #
###############################################################################
#                                                                             #
# hope that all of the following is ok - if not: email, thanks                #
#                                                                             #
###############################################################################

M_DEFS.alpha = -DALPHA -DENDIAN_IS_LITTLE
M_DEFS.i386  = -DI386 -DENDIAN_IS_LITTLE
M_DEFS.m68k  = -DM68K -DENDIAN_IS_BIG
M_DEFS.mips  = -DMIPS -DENDIAN_IS_BIG
M_DEFS.ppc   = -DPPC -DENDIAN_IS_BIG
M_DEFS.sparc = -DSPARC -DENDIAN_IS_BIG
M_DEFS.sparc64 = -DSPARC64 -DENDIAN_IS_BIG






###############################################################################
# Architecture (operating system) dependent definitions                       #
###############################################################################

# From: "Niki W. Waibel" <niki.waibel@gmx.net>
A_DEFS.linux    = -DLINUX
# From: "Umu (El Taco)" <umuj@yahoo.com>
A_DEFS.bsd      = -DBSD
A_DEFS.solaris  = -DSOLARIS
A_DEFS.aix      = -DAIX
# From: "William Sherman" <wsherman@ncsa.uiuc.edu>
A_DEFS.irix     = -DIRIX
A_DEFS.hpux     = -DHPUX
A_DEFS.ultrix   = -DULTRIX

# From: "Gil Pedersen" <gil@909mail.dk>
# Previously started by: "Richard Bannister"
A_DEFS.macos    = -DMACOS

# From: "KhTh" <explorer@websurf.pcom.de>
A_DEFS.os2      = -DOS2 -Zmtd -D__ST_MT_ERRNO__ -D__EMX__

A_DEFS.beos     = -DBEOS

A_DEFS.amigados = -DAMIGADOS

# From: "Boca Juniors (Diego Rozensztejn)" <boca_jrs@hotmail.com>
A_DEFS.msdos    = -DMSDOS
A_DEFS.win31    = -DWIN31
A_DEFS.win95    = -DWIN95
A_DEFS.win98    = -DWIN98
A_DEFS.winnt    = -DWINNT
A_DEFS.win2000  = -DWIN2000




###############################################################################
# Display dependent definitions                                               #
###############################################################################
#                                                                             #
# -DDISPLAY_SUPPORT (see 'config.h'):                                         #
#  %00000111 (binary number)                                                  #
#        |||__ local display                                                  #
#        ||___ local display process (display is a seperate thread/process)   #
#        |____ remote display (display can run on a different machine)        #
#                                                                             #
# -DDISPLAY=\"name"                                                           #
#                                                                             #
# -DCOMMAND_DEPTH                                                             #
#  you can choose the depth in the commandline -> tr_prefs.depth              #
#                                                                             #
###############################################################################

D_DEFS.                 = -DDISPLAY_SUPPORT=0x00 -DDISPLAY=\"NONE\"
D_DEFS.none             = -DDISPLAY_SUPPORT=0x00 -DDISPLAY=\"NONE\"
D_DEFS.x11              = -DDISPLAY_SUPPORT=0x01 -DDISPLAY=\"X11\" -DX11_DISPLAY
D_DEFS.fb               = -DDISPLAY_SUPPORT=0x01 -DDISPLAY=\"FrameBuffer\" -DFB_DISPLAY
D_DEFS.xf86_dga         = -DDISPLAY=\"X11 XF86_DGA\" -DXF86_DGA_DISPLAY
D_DEFS.svgalib          = -DCOMMAND_DEPTH -DDISPLAY_SUPPORT=0x01 -DDISPLAY=\"SVGALIB\" -DSVGALIB_DISPLAY
D_DEFS.ggi              = -DDISPLAY=\"GGI\" -DGGI_DISPLAY
D_DEFS.ncurses          = -DDISPLAY_SUPPORT=0x01 -DDISPLAY=\"NCURSES\" -DNCURSES_DISPLAY

D_DEFS.mesa             = -DDISPLAY=\"MESA\" -DMESA_DISPLAY
D_DEFS.glide            = -DDISPLAY=\"GLIDE\" -DGLIDE_DISPLAY

D_DEFS.macos            = -DDISPLAY=\"MACOS\" -DMACOS_DISPLAY

D_DEFS.os2              = -DDISPLAY=\"OS2\" -DOS2_DISPLAY

D_DEFS.beos             = -DDISPLAY=\"BEOS\" -DBEOS_DISPLAY

D_DEFS.amigados         = -DDISPLAY_SUPPORT=0x01 -DDISPLAY=\"AMIGADOS\" -DAMIGADOS_DISPLAY

D_DEFS.msdos            = -DCOMMAND_DEPTH -DDISPLAY_SUPPORT=0x01 -DDISPLAY=\"MSDOS\" -DMSDOS_DISPLAY
D_DEFS.win16            = -DDISPLAY=\"WIN16\" -DWIN16_DISPLAY
D_DEFS.win32            = -DDISPLAY=\"WIN32\" -DWIN32_DISPLAY
D_DEFS.directx5         = -DDISPLAY=\"DIRECTX5\" -DDIRECTX5_DISPLAY
D_DEFS.directx6         = -DDISPLAY=\"DIRECTX6\" -DDIRECTX6_DISPLAY
D_DEFS.opengl           = -DDISPLAY=\"OPENGL\" -DOPENGL_DISPLAY





###############################################################################
# Joystick definitions                                                        #
###############################################################################

J_DEFS.none    =

J_DEFS.linux20x = -DJOYSTICK
J_DEFS.linux21x = -DJOYSTICK
J_DEFS.bsd      =
J_DEFS.sunos    =
J_DEFS.solaris  =
J_DEFS.aix      =
J_DEFS.irix     =
J_DEFS.hpux     =
J_DEFS.ultrix   =

J_DEFS.macos    =

J_DEFS.os2      =

J_DEFS.beos     =

J_DEFS.amigados = -DJOYSTICK

J_DEFS.msdos    =
J_DEFS.win16    =
J_DEFS.win32    =
J_DEFS.directx5 =
J_DEFS.directx6 =





###############################################################################
# Audio definitions                                                           #
###############################################################################

S_DEFS.none    =

S_DEFS.oss_lite = -DAUDIO
S_DEFS.alsa     =
S_DEFS.sunos    =
S_DEFS.solaris  =
S_DEFS.aix      =
S_DEFS.irix     =
S_DEFS.hpux     =
S_DEFS.ultrix   =

S_DEFS.macos    =

S_DEFS.os2      =

S_DEFS.beos     =

S_DEFS.amigados = -DAUDIO

S_DEFS.msdos    = -DAUDIO
S_DEFS.win95    =
S_DEFS.win98    =
S_DEFS.winnt    =



###############################################################################
# Architecture (operating system) dependent libraries/-paths                  #
###############################################################################

A_LIBS.linux    = -lm
A_LIBS.bsd      = -lm
A_LIBS.sunos    =
A_LIBS.solaris  = -lm
A_LIBS.aix      =
A_LIBS.irix     =
A_LIBS.hpux     =
A_LIBS.ultrix   =

A_LIBS.macos    =

A_LIBS.os2      = -lm -Zmtd -D__ST_MT_ERRNO__ -D__EMX__

A_LIBS.beos     =

A_LIBS.amigados = -warpup

A_LIBS.msdos    = -lm
A_LIBS.win2000  =
A_LIBS.win95    =
A_LIBS.win98    =
A_LIBS.winnt    =





###############################################################################
# Architecture (operating system) dependent include file pathes               #
###############################################################################

A_INCL.linux    = 
A_INCL.bsd      =
A_INCL.sunos    =
A_INCL.solaris  =
A_INCL.aix      =
A_INCL.irix     =
A_INCL.hpux     =
A_INCL.ultrix   =

A_INCL.macos    =

A_INCL.os2      =

A_INCL.beos     =

A_INCL.amigados = -I GG:ppc-amigaos/os-include

A_INCL.msdos    =
A_INCL.win2000  =
A_INCL.win95    =
A_INCL.win98    =
A_INCL.winnt    =





include Makefile.objs




# disable debugging if the display is not able to support it #

ifeq ($(DISP),amigados)
DBG=
endif
ifeq ($(DISP),msdos)
DBG=
endif
ifeq ($(DISP),ncurses)
DBG=
endif
ifeq ($(DISP),svgalib)
DBG=
endif



# disable shared mem for non x11 displays and os2 architecture #

ifneq ($(DISP),x11)

SHM=

else

ifeq ($(ARCH),os2)

SHM=

endif

endif



ifdef READLINE
        CFLAGS := $(CFLAGS) -DREADLINE
        LDLIBS := $(LDLIBS) -lreadline -lncurses
endif


# os2 needs a post linking process to create TrueReality.exe
ifeq ($(ARCH),os2)
POST_LINKING=emxbind TrueReality
endif

# (ppc) convert PPC binary from elf to exe type
ifeq ($(ARCH),amigados)
POST_LINKING=elf2exe TrueReality TrueReality2D
endif

ifeq "$(findstring OPENGL,$(EXPERIMENTAL))" "OPENGL"
ifeq ($(ARCH),os2)
LDLIBS := $(LDLIBS) -lMesaGL -lMesaGLU -lglut
endif
ifeq ($(ARCH),linux)
LDLIBS := $(LDLIBS) -lMesaGL -lMesaGLU -lglut
endif
ifeq ($(ARCH),macos)
LDLIBS := $(LDLIBS) -lGL -lGLU -lglut
endif
ifeq ($(ARCH),solaris)
LDLIBS := $(LDLIBS) -lGL -lGLU -lglut
endif
ifeq ($(ARCH),amigados)
LDLIBS := $(LDLIBS) -lglppc
endif
endif





CFLAGS := $(CFLAGS) \
-I$(TR_HOME)/include \
$(OPTFLAGS) $(DBGFLAGS) \
$(INLINE) $(SHM) \
$(ZLIB) $(ZLIB_INCL) \
$(FPS) \
$(COLOR) \
$(DBG) \
$(EXPERIMENTAL) \
$(COMP) \
-DVERSION=\"$(VERSION)\" -DNAME=\"$(NAME)\" \
$(M_DEFS.$(MACH)) $(A_DEFS.$(ARCH)) $(D_DEFS.$(DISP)) $(J_DEFS.$(JOYS)) $(S_DEFS.$(AUDIO)) \
$(A_INCL.$(ARCH)) \
$(AD_CFLAGS.$(ARCH).$(DISP))

        
        
LDLIBS  := $(LDLIBS) $(A_LIBS.$(ARCH)) $(AD_LIBS.$(ARCH).$(DISP)) $(ZLIB_DYN) $(ZLIB_STAT)








all: print_info TrueReality



TrueReality: $(OBJCORE)
	$(LD) -o $@ $(OBJCORE) $(LDLIBS)
	$(POST_LINKING)





ifeq ($(ARCH),linux)

player: play

play: sound_player/linux.o
	$(LD) -o play sound_player/linux.o $(LDLIBS)

else

player:
	@$(ECHO) "Player is not supported in $(ARCH) (yet!)!!!"

endif










%.o: %.S
	$(AS) $(AFLAGS) $(M_DEFS.$(MACH)) -c -o $@ $<

#%.o: %.c
#	$(CC) $(CFLAGS) -c -o $@ $<



include Makefile.deps




clean:
	$(MAKE) -C N64 clean
	$(MAKE) -C asm clean
	$(MAKE) -C input clean
	$(MAKE) -C os clean
	$(MAKE) -C output clean
	$(MAKE) -C native clean
	$(MAKE) -C sound_player clean
	$(RM) *.o
	$(RM) play
	$(RM) TrueReality


tar tar.gz:
	$(TAR) -C $(TR_HOME)/../.. -cvzhf ../../TrueReality-$(VERSION).tar.gz TrueReality


print_info:
	@$(ECHO) "CPU:      $(MACH)"
	@$(ECHO) "Platform: $(ARCH)"
	@$(ECHO) "Display:  $(DISP)"
	@$(ECHO) "Audio:    $(AUDIO)"
	@$(ECHO) "Keyboard: $(KEYB)"
	@$(ECHO) "Joystick: $(JOYS)"
	@$(ECHO) ""
