#-------------------------------------------------------
#
#	Generic Crossplatform Makefile
#
#	Author:	stephen beaulieu <hippo@be.com>
#
#	Questions, comments & concerns to <devsupport@be.com>
#
#	Copyright 1998 Be, Inc.  All Rights Reserved
#
#	Fill out the Project Specific Information section
#	Use a \ to continue information on different lines
#	example: SRCS = source1.cpp \
#					source2.cpp
#
#	When done simply cd to the directory in the terminal
#	and type make.  The objects and binary will appear
#	in an obj.x86 or obj.PPC folder.
#
#--------------------------------------------------------

	ARPROOT		= ..
	
#--------------------------------------------------------
#	High-level Project Information
#--------------------------------------------------------

#	specify the name of the project
	IMG_NAME	= Sequitur
	
#	specify the type of image to create
	IMG_TYPE	= APP

#	specify version of project
	VERSION		= 2.1.2
	
# first include the common rules for setting up all
# platform-specific information

include $(ARPROOT)/makefiles/platform

#--------------------------------------------------------
#	Project Specific Information
#--------------------------------------------------------

#	specify the list of source files
	SRCS		= $(shell echo *.cpp)
	HEADERS		= $(shell echo *.h)
	
	CFLAGS		=

ifeq ($(CPU), PPC)
	CFLAGS		= -str pool -ansi strict -bool on -requireprotos
	CFLAGS		+= -str ro -toc_data on 
	LDFLAGS		= -dead on
endif

#	specify the list of resource files
	RSRCS		:= Sequitur \
				   SequiturSkin \
				   $(ARPROOT)/ArpLib/$(OBJ_DIR)/AboutWindow
	RSRC_DIRS	:= 

#	specify how to create distribution
#	DIST_MAKES	= 
	DIST_SRCDIR	= Sequitur
	DIST_FILES	= README
	DIST_SRCS	= $(DIST_FILES)
	
#$(HEADERS) $(SRCS) $(DIST_FILES) \
#					$(shell ls 2>/dev/null -1 *.rsrc) Makefile MakeApp
	
#	specify any additional beos shared libraries needed.
	ADD_BESHLIBS	= midi midi2 translation tracker media png

#	specify additional non-beos shared libraries needed.
	ADD_SHLIBS		= $(CPPLIB) AmKernel
	ADD_STLIBS		= $(ARPROOT)/ArpLib/$(OBJ_DIR)/libSequitur.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libAmStdFactory.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libArpViews.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libArpLayout.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libArpKernel.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libArpCollections.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libBeExp.a \
					  $(ARPROOT)/ArpLib/$(OBJ_DIR)/libFFont.a

#	specify any additional beos static libraries needed.
#	ADD_BESTLIBS	= $(ARPROOT)/unknown.a

#	specify additional non-beos static libraries needed.

#	specify any additional system include paths.
	SYSTEM_INCLUDES	=
	SYSLOCAL_INCLUDES	= $(ARPROOT)/ArpHeader/

#	specify any additional local include paths.
	LOCAL_INCLUDES	=

#--------------------------------------------------------
#	Build Rules
#--------------------------------------------------------

# Special rules for copying application into public directory

	DEST_DIR	= ./
	PUBLIC_TARGET	= $(DEST_DIR)$(TARGET_NAME)

# define the actual work to be done	

default: $(PUBLIC_TARGET)
	@mkdir --parents add-ons
	@[ -e add-ons/Filters ] || ln -s ../../AmFilters/add-ons/Filters add-ons/Filters
	@[ -e lib ] || ln -s ../ArpLib/$(OBJ_DIR) lib
	
release: default

$(PUBLIC_TARGET): $(TARGET)
	mkdir --parents $(shell dirname $@)
	$(COPY) $< $@
	@[ -e $<.xSYM ] || $(COPY) $<.xSYM $@.xSYM > /dev/null 2>&1
	@[ -e $<.xMAP ] || $(COPY) $<.xMAP $@.xMAP > /dev/null 2>&1

clean:: clean_project
	rm -f $(PUBLIC_TARGET) $(PUBLIC_TARGET).xSYM $(PUBLIC_TARGET).xMAP $(PUBLIC_TARGET).dbg
	rm -rf add-ons lib
	
dist:: dist_project
	mkdir --parents $(DIST_TARGET)/add-ons/Filters
	for i in add-ons/Filters/*; do \
		$(COPY) $$i $(DIST_TARGET)/$$i; \
	done
	mkdir --parents $(DIST_TARGET)/lib
	for i in lib/*.so; do \
		$(COPY) $$i $(DIST_TARGET)/$$i; \
	done

#	mkdir --parents $(DIST_TARGET)/Devices
#	cp -r Devices/* $(DIST_TARGET)/Devices
	copyattr -r -d Devices $(DIST_TARGET)/
	mimeset -F $(DIST_TARGET)/Devices
#	mkdir --parents $(DIST_TARGET)/Motions
#	cp -r Motions/* $(DIST_TARGET)/Motions
	copyattr -r -d Motions $(DIST_TARGET)/
	mimeset -F $(DIST_TARGET)/Motions
	mkdir --parents $(DIST_TARGET)/MultiFilters
	cp -r MultiFilters/* $(DIST_TARGET)/MultiFilters
	mimeset -F $(DIST_TARGET)/MultiFilters
	mkdir --parents $(DIST_TARGET)/Tools
#	cp -r Tools/* $(DIST_TARGET)/Tools
	copyattr -r -d Tools $(DIST_TARGET)/
	mimeset -F $(DIST_TARGET)/Tools
#	mkdir --parents $(DIST_TARGET)/Skins
#	$(COPY) SequiturSkin.rsrc $(DIST_TARGET)/Skins/ExampleSkin
#	$(COPY) Skins/* $(DIST_TARGET)/Skins/
	copyattr -r -d Skins $(DIST_TARGET)/
	$(COPY) SequiturSkin.rsrc $(DIST_TARGET)/Skins/ExampleSkin
	$(COPY) Skins/* $(DIST_TARGET)/Skins/

	mkdir --parents $(DIST_TARGET)/Documentation
	cp -r docs/user/* $(DIST_TARGET)/Documentation
	mimeset -F $(DIST_TARGET)/Documentation
	mkdir --parents $(DIST_TARGET)/Examples
	cp -r Examples/* $(DIST_TARGET)/Examples
	mimeset -F $(DIST_TARGET)/Examples
#	ln -s docs/user/ReleaseNotes.html $(DIST_TARGET)/ReleaseNotes
	cp "IF SEQUITUR IMMEDIATELY CRASHES" "$(DIST_TARGET)/IF SEQUITUR IMMEDIATELY CRASHES"
	rm -rf $(DIST_TARGET)/src
	mkdir --parent $(DIST_TARGET)/DevKit/ArpHeader
	mkdir --parent $(DIST_TARGET)/DevKit/ArpLib/$(OBJ_DIR)
	mkdir --parent $(DIST_TARGET)/DevKit/ExampleFilters
	(. "$(ARPROOT)/tools/distribute.sh"; \
		distribute $(ARPROOT)/ArpHeader $(DIST_TARGET)/DevKit/ArpHeader Sequitur \
	)
	$(COPY) $(ARPROOT)/ArpLib/$(OBJ_DIR)/libAmKernel.so \
			$(DIST_TARGET)/DevKit/ArpLib/$(OBJ_DIR)/libAmKernel.so
	(. "$(ARPROOT)/tools/distribute.sh"; \
		distribute $(ARPROOT)/AmFilters $(DIST_TARGET)/DevKit/ExampleFilters Sequitur \
	)
	
# include common build rules for above definitions

include $(ARPROOT)/makefiles/project

depends: $(DEPENDENCIES)
	@echo >/dev/null
