mupen64plus-video-rice/projects/unix/Makefile
2009-12-12 00:21:21 -05:00

298 lines
9.1 KiB
Makefile

#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# * Mupen64plus-video-rice - Makefile *
# * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
# * Copyright (C) 2007-2009 Richard Goedeken *
# * Copyright (C) 2007-2008 DarkJeztr Tillin9 *
# * *
# * This program 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 of the License, or *
# * (at your option) any later version. *
# * *
# * This program 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 this program; if not, write to the *
# * Free Software Foundation, Inc., *
# * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# Makefile for RiceVideo plugin in Mupen64Plus
# detect operation system
UNAME = $(shell uname -s)
ifeq ("$(UNAME)","Linux")
OS = LINUX
SO_EXTENSION = so
SHARED = -shared
endif
ifeq ("$(UNAME)","linux")
OS = LINUX
SO_EXTENSION = so
SHARED = -shared
endif
ifeq ("$(UNAME)","Darwin")
OS = OSX
SO_EXTENSION = dylib
SHARED = -bundle
endif
ifeq ("$(UNAME)","FreeBSD")
OS = FREEBSD
SO_EXTENSION = so
SHARED = -shared
endif
# detect system architecture
HOST_CPU ?= $(shell uname -m)
ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
CPU := X86
ifeq ("$(BITS)", "32")
ARCH_DETECTED := 64BITS_32
else
ARCH_DETECTED := 64BITS
endif
endif
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
CPU := X86
ARCH_DETECTED := 32BITS
endif
ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 32BITS
NO_ASM := 1
endif
ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 64BITS
NO_ASM := 1
endif
# base CFLAGS, LIBS, and LDFLAGS
CFLAGS = -Wall -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -I../../src
LDFLAGS = -ldl -lpng
# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
# On 32-bit systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -fpic -DPIC -fvisibility=hidden
endif
# tweak flags for 32-bit build on 64-bit system
ifeq ($(ARCH_DETECTED), 64BITS_32)
ifeq ($(OS), FREEBSD)
$(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
endif
CFLAGS += -m32
LDFLAGS += -m32 -m elf_i386
endif
# set special flags per-system
ifeq ($(OS),FREEBSD)
LDFLAGS += -lGL
endif
ifeq ($(OS), LINUX)
LDFLAGS += -lGL
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -pipe -O3 -march=athlon64
else
CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
endif
endif
endif
ifeq ($(OS), OSX)
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -pipe -O3 -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
LDFLAGS += -bundle -framework OpenGL -arch x86_64
else
CFLAGS += -pipe -O3 -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
LDFLAGS += -bundle -framework OpenGL -arch i686
endif
endif
endif
ifeq ($(CPU), PPC)
CFLAGS += -mcpu=powerpc
endif
# test for presence of SDL
ifeq ($(shell which sdl-config 2>/dev/null),)
$(error No SDL development libraries found!)
endif
ifeq ($(OS),FREEBSD)
CFLAGS += `${SDL_CONFIG} --cflags`
LDFLAGS += `${SDL_CONFIG} --libs`
endif
ifeq ($(OS),OSX)
CFLAGS += $(shell sdl-config --cflags)
# sdl-config on mac screws up when we're trying to build a library and not an executable
# SDL 1.3 is supposed to fix that, if it's ever released
LDFLAGS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
endif
ifeq ($(OS),LINUX)
CFLAGS += $(shell sdl-config --cflags)
LDFLAGS += $(shell sdl-config --libs)
endif
# 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
# set shell function names
CC = gcc
CXX = g++
LD = g++
INSTALL = install
ifeq ($(OS),LINUX)
STRIP = strip -s
endif
ifeq ($(OS),OSX)
STRIP = strip -x
endif
# set special flags for given Makefile parameters
ifeq ($(DEBUG),1)
CFLAGS += -g
STRIP = true # disable binary strip
endif
ifeq ($(NO_ASM), 1)
CFLAGS += -DNO_ASM
endif
# set installation options
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
ifeq ($(SHAREDIR),)
SHAREDIR := $(PREFIX)/share/mupen64plus
endif
ifeq ($(LIBDIR),)
LIBDIR := $(PREFIX)/lib/mupen64plus
endif
SRCDIR = ../../src
OBJDIR = _obj
# list of source files to compile
SOURCE = \
$(SRCDIR)/liblinux/BMGImage.c \
$(SRCDIR)/liblinux/BMGUtils.cpp \
$(SRCDIR)/liblinux/bmp.c \
$(SRCDIR)/liblinux/pngrw.c \
$(SRCDIR)/osal_dynamiclib_unix.c \
$(SRCDIR)/Blender.cpp \
$(SRCDIR)/Combiner.cpp \
$(SRCDIR)/CombinerTable.cpp \
$(SRCDIR)/Config.cpp \
$(SRCDIR)/ConvertImage.cpp \
$(SRCDIR)/ConvertImage16.cpp \
$(SRCDIR)/CNvTNTCombiner.cpp \
$(SRCDIR)/Debugger.cpp \
$(SRCDIR)/DecodedMux.cpp \
$(SRCDIR)/DirectXDecodedMux.cpp \
$(SRCDIR)/DeviceBuilder.cpp \
$(SRCDIR)/FrameBuffer.cpp \
$(SRCDIR)/GeneralCombiner.cpp \
$(SRCDIR)/GraphicsContext.cpp \
$(SRCDIR)/OGLCombiner.cpp \
$(SRCDIR)/OGLCombinerNV.cpp \
$(SRCDIR)/OGLCombinerTNT2.cpp \
$(SRCDIR)/OGLDecodedMux.cpp \
$(SRCDIR)/OGLExtCombiner.cpp \
$(SRCDIR)/OGLExtRender.cpp \
$(SRCDIR)/OGLFragmentShaders.cpp \
$(SRCDIR)/OGLGraphicsContext.cpp \
$(SRCDIR)/OGLRender.cpp \
$(SRCDIR)/OGLRenderExt.cpp \
$(SRCDIR)/OGLTexture.cpp \
$(SRCDIR)/Render.cpp \
$(SRCDIR)/RenderBase.cpp \
$(SRCDIR)/RenderExt.cpp \
$(SRCDIR)/RenderTexture.cpp \
$(SRCDIR)/RSP_Parser.cpp \
$(SRCDIR)/RSP_S2DEX.cpp \
$(SRCDIR)/Texture.cpp \
$(SRCDIR)/TextureFilters.cpp \
$(SRCDIR)/TextureFilters_2xsai.cpp \
$(SRCDIR)/TextureFilters_hq2x.cpp \
$(SRCDIR)/TextureFilters_hq4x.cpp \
$(SRCDIR)/TextureManager.cpp \
$(SRCDIR)/VectorMath.cpp \
$(SRCDIR)/Video.cpp
# generate a list of object files build, make a temporary directory for them
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
OBJDIRS = $(dir $(OBJECTS))
$(shell mkdir -p $(OBJDIRS))
# build targets
TARGET = mupen64plus-video-rice.$(SO_EXTENSION)
targets:
@echo "Mupen64plus-video-rice N64 Graphics plugin makefile. "
@echo " Targets:"
@echo " all == Build Mupen64plus-video-rice plugin"
@echo " clean == remove object files"
@echo " rebuild == clean and re-build all"
@echo " install == Install Mupen64Plus-video-rice plugin"
@echo " uninstall == Uninstall Mupen64Plus-video-rice plugin"
@echo " Options:"
@echo " BITS=32 == build 32-bit binaries on 64-bit machine"
@echo " NO_ASM=1 == build without inline assembly code (x86 MMX/SSE)"
@echo " APIDIR=path == path to find Mupen64Plus Core headers"
@echo " Install Options:"
@echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
@echo " SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)"
@echo " LIBDIR=path == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
@echo " Debugging Options:"
@echo " DEBUG=1 == add debugging symbols"
all: $(TARGET)
install: $(TARGET)
$(INSTALL) -d -v "$(LIBDIR)"
$(INSTALL) -m 0644 $(TARGET) "$(LIBDIR)"
$(INSTALL) -d -v "$(SHAREDIR)"
$(INSTALL) -m 0644 "../../data/RiceVideoLinux.ini" "$(SHAREDIR)"
uninstall:
rm -f "$(LIBDIR)/$(TARGET)"
rm -f "$(SHAREDIR)/RiceVideoLinux.ini"
clean:
rm -f ./_obj/*.o ./_obj/liblinux/* $(TARGET)
rebuild: clean all
# build rules
$(TARGET): $(OBJECTS)
$(LD) $(SHARED) $^ $(LDFLAGS) -o $@
$(STRIP) $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) -o $@ $(CFLAGS) -c $<
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -o $@ $(CFLAGS) -c $<