File Makefile.linux.suse of Package squeezeplay

################################################################################
# Squeezeplay makefile for Linux
# Copyright 2007 Logitech
################################################################################

#
# Absolute path to top of SQUEEZEPLAY directories
#

SRC_DIR = $(realpath ${PWD})
BASE_DIR = $(dir ${SRC_DIR})

export BUILD_TOP=${RPM_BUILD_ROOT}/opt/squeezeplay

export DESTDIR=${BUILD_TOP}
export PREFIX=${DESTDIR}

export CFLAGS=-I${PREFIX}/include -I${PREFIX}/include/SDL -I${PREFIX}/include/freetype2 -g -fPIC
export LDFLAGS=-L${PREFIX}/lib

export TOOLPATH = $(shell dirname `which gcc`)

export SDL_CONFIG = ${BUILD_TOP}/bin/sdl-config

ENABLE_PROFILING=--enable-profiling --disable-static --disable-rpath
# --disable-shared
USE_MMX=--disable-mmx

# Override to yes to build closed source squeezeplay libraries 
SPPRIVATE=no

ifeq ($(SPPRIVATE),yes)
	ENABLE_SPPRIVATE=--with-spprivate
	SPPRIVATE_TARGETS=axtls squeezeplay_private
endif


#
# Top level targets
#
.PHONY: all
all: sdl-all lua-all app



#####
# SDL
#####

.PHONY: sdl-all freetype sdl sdl-image sdl-tff sdl-gfx c-ares
sdl-all: freetype sdl sdl-ttf png sdl-image sdl-gfx

generated:
	mkdir -p generated


# freetype
freetype-2.1.10/config.mk:
	cd freetype-2.1.10; ./configure --enable-shared ${ENABLE_PROFILING} --target=${TARGET} --prefix=

freetype: freetype-2.1.10/config.mk
	cd freetype-2.1.10; make && make install

# sdl
SDL-1.2.13/Makefile:
	cd SDL-1.2.13; ./configure  ${ENABLE_PROFILING} --target=${TARGET} --prefix=${PREFIX}

sdl: SDL-1.2.13/Makefile
	cd SDL-1.2.13; make && make install

# png
libpng-1.2.32/Makefile:
	cd libpng-1.2.32; ./configure ${ENABLE_PROFILING} --target=${TARGET} --prefix=

png:	libpng-1.2.32/Makefile
	cd libpng-1.2.32; make && make install

# sdl_image (requires jpeg tiff png)
SDL_image-1.2.5/Makefile:
	cd SDL_image-1.2.5; SDL_CONFIG=${PREFIX}/bin/sdl-config ./configure --disable-tif  --target=${TARGET} ${ENABLE_PROFILING} --prefix= ${LIBPNG} ${LIBJPEG}

sdl-image: SDL_image-1.2.5/Makefile
	cd SDL_image-1.2.5; make && make install
	perl -pi -e s"|/lib/libpng.la|${PREFIX}/lib/libpng.la|" ${PREFIX}/lib/libSDL_image.la

# sdl_ttf
SDL_ttf-2.0.8/Makefile:
	cd SDL_ttf-2.0.8; SDL_CONFIG=${PREFIX}/bin/sdl-config ./configure  ${ENABLE_PROFILING} --target=${TARGET} --prefix= --with-freetype-prefix=${PREFIX} --without-opengl

sdl-ttf: SDL_ttf-2.0.8/Makefile
	cd SDL_ttf-2.0.8; make && make install
	perl -pi -e s"|/lib/libfreetype.la|${PREFIX}/lib/libfreetype.la|" ${PREFIX}/lib/libSDL_ttf.la

# sdl_gfx
SDL_gfx-2.0.15/Makefile:
	cd SDL_gfx-2.0.15; ./configure ${ENABLE_PROFILING} ${USE_MMX} --target=${TARGET} --prefix=

sdl-gfx: SDL_gfx-2.0.15/Makefile
	cd SDL_gfx-2.0.15; make && make install


#####
# lua
#####

.PHONY: lua-all lua luasocket slnunicode luajson loop luaexpat luafilesystem luaprofiler luazipfilter luamd5

lua-all: lua tolua++ luasocket slnunicode luajson loop luaexpat luafilesystem luaprofiler luazipfilter luamd5

# lua (requires readline ncurses)
lua:
	cd lua-5.1.1; make linux INSTALL_TOP=${PREFIX} && make install INSTALL_TOP=${PREFIX}

# luasocket (requires lua)
luasocket: lua
	cd luasocket-2.0.2; make install LD="gcc -shared" INSTALL_TOP=${PREFIX} TARGET=$(TARGET) PLATFORM=linux

slnunicode: lua
	cd slnunicode-1.1; make install INSTALL_TOP=${PREFIX} TARGET=$(TARGET) PLATFORM=linux

luajson/Makefile:
	cd luajson; ./configure --target=${TARGET} --prefix=${PREFIX}

luajson: luajson/Makefile
	cd luajson; make && cp .libs/json.so ${PREFIX}/lib/lua/5.1/json.so

luazipfilter/Makefile:
	cd luazipfilter; ./configure --target=${TARGET} --prefix=${PREFIX}

luazipfilter: luazipfilter/Makefile
	cd luazipfilter; make && cp .libs/zipfilter.so ${PREFIX}/lib/lua/5.1/zipfilter.so

luamd5:
	cd luamd5; make LUA=${PREFIX} MYNAME=sha1
	cd luamd5; make LUA=${PREFIX} MYNAME=md5
	cp luamd5/md5.so ${PREFIX}/lib/lua/5.1/md5.so
	cp luamd5/sha1.so ${PREFIX}/lib/lua/5.1/sha1.so

loop:
	-mkdir ${PREFIX}/share/lua/5.1/loop
	-mkdir ${PREFIX}/share/lua/5.1/loop/collection
	-mkdir ${PREFIX}/share/lua/5.1/loop/debug
	cd loop-2.2-alpha; install loop/base.lua ${PREFIX}/share/lua/5.1/loop/.
	cd loop-2.2-alpha; install loop/simple.lua ${PREFIX}/share/lua/5.1/loop/.
	cd loop-2.2-alpha; install loop/table.lua ${PREFIX}/share/lua/5.1/loop/.
	cd loop-2.2-alpha; install loop/collection/ObjectCache.lua ${PREFIX}/share/lua/5.1/loop/collection/.
	cd loop-2.2-alpha; install loop/debug/Viewer.lua ${PREFIX}/share/lua/5.1/loop/debug/.

luaexpat: lua
	cd luaexpat-1.0.2; make PREFIX=${PREFIX} PLATFORM=linux && make install PREFIX=${PREFIX} PLATFORM=linux

luafilesystem:
	cd luafilesystem-1.2 && make install PREFIX=${PREFIX} PLATFORM=linux

luaprofiler:
	cd luaprofiler-2.0 && make -f Makefile.linux install

# just compile the library for to tolua++
.PHONY: tolua++
tolua++: lua
	cd tolua++-1.0.92/src/lib; ${CC} -shared -fPIC -o libtolua++.so -I../../include -I${PREFIX}/include *.c
	mkdir -p ${PREFIX}/lib
	install tolua++-1.0.92/include/tolua++.h ${PREFIX}/include
	install tolua++-1.0.92/src/lib/libtolua++.so ${PREFIX}/lib


#
# squeezeplay
#

.PHONY: app portaudio libmad tremor squeezeplay squeezeplay_desktop squeezeplay_contrib squeezeplay_private freefont freefont-debian axtls rtmp
app: portaudio libmad tremor ${SPPRIVATE_TARGETS} squeezeplay squeezeplay_desktop squeezeplay_contrib freefont rtmp

# portaudio
portaudio_v19_1360/Makefile:
	cd portaudio_v19_1360; ./configure --target=${TARGET} --prefix=

portaudio: portaudio_v19_1360/Makefile
	cd portaudio_v19_1360; make && make install

# flac
flac-1.2.1/Makefile:
	cd flac-1.2.1; ./configure --disable-xmms-plugin --target=${TARGET} --prefix=

flac: flac-1.2.1/Makefile
	cd flac-1.2.1; make && make install

#libmad
LIBMAD_DIR=libmad-0.15.1b
generated/${LIBMAD_DIR}/Makefile: generated/${LIBMAD_DIR}/Makefile.am
	cd generated/${LIBMAD_DIR}; ./configure --target=${TARGET} --prefix=

libmad: generated/${LIBMAD_DIR}/Makefile.am generated/${LIBMAD_DIR}/Makefile
	cd generated/${LIBMAD_DIR}; make && make install


# ogg
Tremor/Makefile:
	cd Tremor; ./autogen.sh; CFLAGS="-DSQUEEZEPLAY" ./configure --target=${TARGET} --prefix=

tremor: Tremor/Makefile
	cd Tremor; make && make install
	# ugly hack to get tremor in the good place
	mv -vf ${BUILD_TOP}/home/*/*/*/include/tremor ${BUILD_TOP}/include
	mv -vf ${BUILD_TOP}/home/*/*/*/lib/* ${BUILD_TOP}/lib
	rm -rvf ${BUILD_TOP}/home


rtmp: squeezeplay
	cd luartmp-squeezeplay; make
	cp luartmp-squeezeplay/rtmp.so ${PREFIX}/lib/lua/5.1/rtmp.so 


# squeezeplay
squeezeplay/Makefile:
	cd squeezeplay; SDL_CONFIG=${SDL_CONFIG} ./configure ${ENABLE_SPPRIVATE} ${ENABLE_PROFILING} --target=${TARGET} --prefix=

squeezeplay: squeezeplay/Makefile
	cd squeezeplay; make && make install

squeezeplay_desktop/Makefile:
	cd squeezeplay_desktop; SDL_CONFIG=${SDL_CONFIG} ./configure --target=${TARGET} --prefix=

squeezeplay_desktop: squeezeplay_desktop/Makefile
	cd squeezeplay_desktop; make install
	cp -af ${PREFIX}/home/*/build/linux/share/jive/applets/* ${PREFIX}/share/jive/applets/
	cp squeezeplay_desktop/squeezeplay.sh ${PREFIX}/bin/
	chmod +x ${PREFIX}/bin/squeezeplay.sh
	rm -rf ${PREFIX}/home/

squeezeplay_contrib: squeezeplay/Makefile
	cd squeezeplay_contrib; make

squeezeplay_private/Makefile:
	cd squeezeplay_private; SDL_CONFIG=${SDL_CONFIG} ./configure --target=${TARGET} --prefix=${PREFIX} --enable-wma --enable-aac

squeezeplay_private: squeezeplay_private/Makefile
	cd squeezeplay_private; make PREFIX= install

# freefont
freefont:
	mkdir -p ${PREFIX}/share/jive/fonts
	cp freefont-20090104/FreeSans.ttf ${PREFIX}/share/jive/fonts
	cp freefont-20090104/FreeSansBold.ttf ${PREFIX}/share/jive/fonts

# 
# This builds the .tarball. It's called by 'all' so no need to run it manually
# 
squeezeplay-tgz: squeezeplay/Makefile
	cd squeezeplay; make squeezeplay-tgz


.PHONY: clean_generated
clean_generated:
	@echo "----------------------------------------------------------"
	@echo "Cleaning: generated dir"
	-rm -rf generated


#
# clean
#

.PHONY: clean
clean:
	-rm -rf generated
	-cd freetype-2.1.10; make distclean
	-cd SDL-1.2.13; make distclean; rm -f include/SDL_config.h;
	-cd SDL_image-1.2.5; make distclean
	-cd SDL_ttf-2.0.8; make distclean
	-cd SDL_gfx-2.0.15; make distclean
	-cd lua-5.1.1; make clean
	-cd luasocket-2.0.2; make clean PLATFORM=linux
	-cd slnunicode-1.1; make clean PLATFORM=linux
	-cd luaexpat-1.0.2; make clean PLATFORM=linux
	-cd luafilesystem-1.2; make clean PLATFORM=linux
	-cd luajson; make distclean
	-cd luazipfilter; make distclean
	-cd luaprofiler-2.0; make -f Makefile.linux clean
	-cd luamd5; make MYNAME=sha1 clean
	-cd luamd5; make MYNAME=md5 clean
	-cd tolua++-1.0.92/src/lib; rm libtolua++.so; rm *.o
	-cd squeezeplay; make distclean
	-cd squeezeplay_private; make distclean
	-rm -rf generated