# Copyright (c)1998 by Angry Red Planet.
#
# This code is distributed under a modified form of the
# Artistic License.  A copy of this license should have
# been included with it; if this wasn't the case, the
# entire package can be obtained at
# <URL:http://www.angryredplanet.com/>.
#
# ----------------------------------------------------------------------
#
# Makefiles/library
#
# Common makefile for libraries.
#
# ----------------------------------------------------------------------
#
# Known Bugs
# ~~~~~~~~~~
#
# ----------------------------------------------------------------------
#
# To Do
# ~~~~~
#
# ----------------------------------------------------------------------
#
# History
# ~~~~~~~
#
# Dec 6, 1998:
#	First public release.
#
#

#--------------------------------------------------------
#	Standard rules for building a library.
#
#	Include this file in your library makefile to use
#	the normal build rules.
#
#	Input:
#		IMG_NAME: The name of the library
#		ARPROOT: ARP source root directory
#
#	Output:
#		Everything.
#--------------------------------------------------------

#--------------------------------------------------------
#	High-level Project Information
#--------------------------------------------------------

#	we are building a library.
	IMG_TYPE	= STATIC
	
# 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 ls 2>/dev/null -1 *.cpp *.S)

	RSRC_DIRS	+= $(shell ls 2>/dev/null -1 *.rdef)

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

#	specify the list of resource files
	RSRCS		=
	
#	specify any additional beos shared libraries needed.
	ADD_BESHLIBS	=

#	specify additional non-beos shared libraries needed.
	ADD_SHLIBS		= 

#	specify any additional beos static libraries needed.
	ADD_BESTLIBS	=

#	specify additional non-beos static libraries needed.
	ADD_STLIBS		=

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

#	specify any additional local include paths.
	LOCAL_INCLUDES	= $(ARPROOT)/ArpHeader/

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

# Special rules for copying library into public directory

	DEST_DIR			= $(ARPROOT)/ArpLib/
	PUBLIC_TARGET		= $(DEST_DIR)$(TARGET)
	LIB_RSRC_DIRS		= $(addprefix $(OBJ_DIR)/, $(RSRC_DIRS:.rdef=.rsrc))
	PUBLIC_LIB_RSRCDIRS	= $(addprefix $(DEST_DIR), $(LIB_RSRC_DIRS))

# define the actual work to be done	

#default::
#	echo "$(RSRC_DIRS)"
	
#default:: PUBLIC_ALL
#	@echo >/dev/null

release:: PUBLIC_ALL

PUBLIC_ALL:: $(PUBLIC_TARGET) $(PUBLIC_LIB_RSRCDIRS)

$(PUBLIC_TARGET): $(TARGET)
	mkdir -p $(shell dirname $@) > /dev/null 2>&1
	$(COPY) $< $@

$(PUBLIC_LIB_RSRCDIRS): $(LIB_RSRC_FILES)
	@for i in $(LIB_RSRC_DIRS) xxx; do (					\
		if [ "$$i" != "xxx" ]; then							\
			echo "$(COPY) $$i $(DEST_DIR)$$i";				\
			$(COPY) $$i $(DEST_DIR)$$i;						\
		fi;													\
	) done

clean:: clean_project
	-rm -rf $(PUBLIC_TARGET) $(PUBLIC_LIB_RSRCDIRS)

# include common build rules for above definitions

include $(ARPROOT)/makefiles/project

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