Source

mupen64plus-video-glide64mk2 / Glide64 / Makefile.gcc

# This MUST be processed by GNU make
#
# Glide64 Makefile
# Version:  1.0
#
# this is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# this is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Make; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#

#
#  Available options:
#
#    Environment variables:
#	DEBUG=1		enable debugging checks and messages
#			default = no
#
#    Environment variables:
#
#    Targets:
#	all:		build dynamic module
#	clean:		remove object files
#	realclean:	remove all generated files
#
#
#  Requirements:
#
#    Compiler:
#       GCC 4.2
#
#    Libraries:
#       glide3x - build Glitch64 first, copy the result dll to 'lib' folder
#       wx-widgets 2.8 (http://www.wxwidgets.org)
#

#
# GCC does not have SEH (structured exception handling)
#

.PHONY: all clean realclean ostype

OS=$(shell uname)
ifeq ($(findstring MINGW,$(OS)),MINGW)
OS := WINDOWS
endif
ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
OS=WINDOWS
endif
ifeq ($(findstring WINNT,$(OS)),WINNT)
OS=WINDOWS
endif
ifeq ($(OS),Darwin)
OS=MACOSX
endif

ifeq ($(OS), WINDOWS)
  DLLNAME = Glide64.dll
else
  ifeq ($(OS), MACOSX)
    DLLNAME = Glide64.dylib
  else
    DLLNAME = Glide64.so
  endif
endif

EXT_INC = ./inc
EXT_LIB = ./lib

CC = g++ -m32
STRIP = strip

CFLAGS = -DBUILDING_DLL=1  -fexceptions 
LDLIBS = -L"." -L"lib" `wx-config --libs` `sdl-config --libs`
ifeq ($(OS), MACOSX)
LDLIBS += -framework OpenGL -framework GLUT
endif

ifeq ($(OS), Linux)
CC += -V 4.2
LDFLAGS = -shared -lstdc++ 
CFLAGS += -D__unix__
endif
ifeq ($(OS), MACOSX)
LDFLAGS = -dynamiclib -lstdc++ 
CFLAGS += -D__unix__ -Dmacintosh
endif
ifeq ($(OS), WINDOWS)
LDFLAGS = -shared -mwindows 
CFLAGS += -D__WIN32__ -DWIN32 -D_WIN32
endif

CFLAGS += -ffast-math -funroll-loops
#CFLAGS += -fexpensive-optimizations -march=k6
CFLAGS += -I. -I$(EXT_INC) -I"../Glitch64/"$(EXT_INC) `wx-config --cppflags` `sdl-config --cflags`

# set mupen64plus core API header path
ifneq ("$(APIDIR)","")
  CFLAGS += "-I$(APIDIR)"
else
  TRYDIR = ../../../mupen64plus-core/src/api
  ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
    CFLAGS += -I$(TRYDIR)
  else
    TRYDIR = /usr/local/include/mupen64plus
    ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
      CFLAGS += -I$(TRYDIR)
    else
      TRYDIR = /usr/include/mupen64plus
      ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
        CFLAGS += -I$(TRYDIR)
      else
        $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.)
      endif
    endif
  endif
endif

ifdef DEBUG
CFLAGS += -g -DDEBUG
endif

LD = g++ -m32

AS = nasm
ifeq ($(OS), Linux)
ASFLAGS = -O6 -felf -D__linux__ 
ASM_OBJ = \
  3dmathSIMD.o \
  FixedPoint.o \
  Texture.o
else 
  ifeq ($(OS), MACOSX)
    ASFLAGS = -O6 -fmacho --prefix _
    ASM_OBJ = \
     3dmathSIMD.o \
     FixedPoint.o \
     Texture.o
  else 
    ifeq ($(OS), WINDOWS)
      ASFLAGS = -O6 -fwin32 -D__WIN32__ --prefix _
      ASM_OBJ = \
       3dmathSIMD.obj \
       FixedPoint.obj \
       Texture.obj
    endif
  endif
endif

RM = rm

SOURCES = \
  3dmath.cpp \
  Combine.cpp \
  Config.cpp \
  CRC.cpp \
  Debugger.cpp \
  DepthBufferRender.cpp \
  Ext_TxFilter.cpp \
  FBtoScreen.cpp \
  Main.cpp \
  Keys.cpp \
  rdp.cpp \
  TexBuffer.cpp \
  TexCache.cpp \
  Util.cpp \
  osal_dynamiclib_unix.c \
  ../Glitch64/combiner.cpp \
  ../Glitch64/geometry.cpp \
  ../Glitch64/main.cpp \
  ../Glitch64/textures.cpp \
  ../Glitch64/vram.cpp

OBJECTS = $(SOURCES:.cpp=.o)

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

all: $(DLLNAME)

$(DLLNAME): $(OBJECTS) $(ASM_OBJ)
	$(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS)
ifeq ($(OS), Linux)
	$(STRIP) $@
endif

ifneq ($(OS), WINDOWS)
3dmathSIMD.o: 3dmathSIMD.asm
	$(AS) -o $@ $(ASFLAGS) $<
FixedPoint.o: FixedPoint.asm
	$(AS) -o $@ $(ASFLAGS) $<
Texture.o: Texture.asm
	$(AS) -o $@ $(ASFLAGS) $<
else
3dmathSIMD.obj: 3dmathSIMD.asm
	$(AS) -o $@ $(ASFLAGS) $<
FixedPoint.obj: FixedPoint.asm
	$(AS) -o $@ $(ASFLAGS) $<
Texture.obj: Texture.asm
	$(AS) -o $@ $(ASFLAGS) $<
endif

clean:
	-$(RM) -f *.o ../Glitch64/*.o

realclean: clean
	-$(RM) -f $(DLLNAME) 

ostype:
	echo $(OS)

-include depend