# 
# projectM -- Milkdrop-esque visualisation SDK
# Copyright (C)2003-2004 projectM Team
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library 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
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# See 'LICENSE.txt' included within this release

SUBDIRS=
RANLIB=ranlib

INCLUDES=-I. -I.. -I../include -I/usr/local/include \
         -I/System/Library/Frameworks/AGL.framework/Headers \
         -I/System/Library/Frameworks/OpenGL.framework/Headers \
         -I/Developer/Headers/FlatCarbon \
         -I$(HOME)/Desktop/iTunes\ Visual\ Plugins\ SDK/APIs

DEFINES= -DMACOS -DHAVE_OPENGL -DHAVE_CONFIG_H -D_THREAD_SAFE # -DDEBUG
CFLAGS=-O2
#CFLAGS=-g
LIBRARIES= -framework Cocoa -framework Carbon -framework AGL -framework OpenGL -lprojectM
#LD_FLAGS=-bundle -L/usr/local/lib $(LIBRARIES)
LD_FLAGS=-L/usr/local/lib -L../projectM $(LIBRARIES)

SRCS=\
macos/iTunesAPI.c \
iprojectM.c
OBJS=$(SRCS:.c=.o)

.SUFFIXES: .c

all: projectM

### Relinks the libry
projectM: $(OBJS) ../projectm/libprojectm.a
	rm -rf projectM.bundle
	cc -o projectM -bundle $(OBJS) $(LD_FLAGS)
	mkdir -p projectM.bundle/Contents
	mkdir -p projectM.bundle/Contents/MacOS
	mkdir -p projectM.bundle/Contents/Resources
	cp projectM projectM.bundle/Contents/MacOS/projectM
	cp Info.plist projectM.bundle/Contents
	cp projectM.icns projectM.bundle/Contents/Resources/projectM.icns
	cp PkgInfo projectM.bundle/Contents
	cp -r ../../fonts projectM.bundle/Contents/Resources
	cp -r ../../presets_projectM projectM.bundle/Contents/Resources/presets
	cp ../../AUTHORS.txt projectM.bundle/Contents/Resources
	cp ../../LICENSE.txt projectM.bundle/Contents/Resources
	cp ../../FAQ.txt projectM.bundle/Contents/Resources
	cp ../../INSTALL-iTunes-macos.txt projectM.bundle/Contents/Resources
	mkdir -p $(HOME)/Library/iTunes/iTunes\ Plug-ins/projectM
	cp -r projectM.bundle $(HOME)/Library/iTunes/iTunes\ Plug-ins/projectM

../projectm/libproject.a:
	( cd ../projectm ; make -f Makefile.macos )

image: projectM
	rm -f projectM.dmg
	hdiutil create -srcfolder projectM.bundle projectM.dmg

$(LIB_TOP):
	@( if [ ! -d $(LIB_TOP) ]; then \
	( mkdir $(LIB_TOP) ) \
	fi )

$(OBJS): %.o: %.c
	$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $*.c -o $*.o

clean:
	rm -f *.o
	rm -f libprojectm.a
	rm -rf projectM.bundle

distcln: cln
	rm -f config.log
	rm -f config.che
	rm -f config.stus
