#
# Copyright (C) 1997-2004, R3vis Corporation.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library 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, or visit http://www.gnu.org/copyleft/lgpl.html.
#
# Contributor(s):
#   Wes Bethel, R3vis Corporation, Marin County, California
#
# The OpenRM project is located at http://openrm.sourceforge.net/.
#
# $Id: Makefile,v 1.8 2004/04/18 17:03:27 wes Exp $
# Version: $Name: OpenRM-1-5-2-RC3 $
# $Revision: 1.8 $
# $Log: Makefile,v $
# Revision 1.8  2004/04/18 17:03:27  wes
# Added install target, removed previous stuff that used an environment
# variable for doing an install target.
#
# Revision 1.7  2004/04/09 14:46:55  wes
# Added new build targets: linux-x86_64, linux-x86_64-debug, linux-x86_32,
# and linux-x86_32-debug. Tweak and test to support builds on Darwin.
#
# Revision 1.6  2004/03/31 15:05:26  wes
# Updates for Darwin/MacOS-X
#
# Revision 1.5  2004/02/23 03:02:11  wes
# MacOSX targets.
#
# Revision 1.4  2004/01/17 03:59:47  wes
# Updated copyright line.
#
# Revision 1.3  2003/12/12 00:26:05  wes
# Added FreeBSD stuff. Thanks to Igor Pokrovsky for the contribution.
#
# Revision 1.2  2003/02/02 02:07:13  wes
# Updated copyright to 2003.
#
# Revision 1.1.1.1  2003/01/28 02:15:23  wes
# Manual rebuild of rm150 repository.
#
# Revision 1.11  2002/12/31 00:56:49  wes
#
# Added linux-cr-debug build target for use with Chromium.
#
# Revision 1.10  2002/08/19 00:54:01  wes
# Added -del *.dll to win-32-clean target.
#
# Revision 1.9  2002/08/19 00:26:26  wes
# Updated win32 stuff.
#
# Revision 1.8  2001/10/14 23:37:27  wes
# Minor tweak for Win32.
#
# Revision 1.7  2001/06/03 20:19:56  wes
# Added rmi to subdirs.
#
# Revision 1.6  2001/03/31 17:13:47  wes
# v1.4.0-alpha-2 checkin
#
# Revision 1.5  2000/12/04 00:34:50  wes
# Replaced Unix'isms for W32 builds with DOS equivalents.
#
# Revision 1.4  2000/10/03 11:43:26  wes
# Contributions from jdb - general housekeeping and cleanup.
#
# Revision 1.3  2000/04/22 01:44:13  wes
# Added docs and cleandocs targets.
#
# Revision 1.2  2000/04/20 17:53:13  wes
# Win-32 LIBDIR definition change - now use backslash in pathname.
#
# Revision 1.1.1.1  2000/02/28 21:29:40  wes
# OpenRM 1.2 Checkin
#
# Revision 1.1.1.1  2000/02/28 17:18:47  wes
# Initial entry - pre-RM120 release, source base for OpenRM 1.2.
#
#
SHELL = /bin/sh
INSTALL_DIR = /usr/local/rm152
INSTALL_CMD = install

default:
	@echo "Specify an architecture:"
	@echo "  freebsd"
	@echo "  irix6-32"
	@echo "  irix6-32-debug"
	@echo "  irix6-n32"
	@echo "  irix6-n32-debug"
	@echo "  irix6-n32-mips4"
	@echo "  irix6-n32-mips4-debug"
	@echo "  irix6-64"
	@echo "  irix6-64-debug"
	@echo "  linux"
	@echo "  linux-debug"
	@echo "  linux-cr-debug"
	@echo "  linux-x86_64-debug"
	@echo "  linux-x86_64"
	@echo "  linux-x86_32-debug"
	@echo "  linux-x86_32"
	@echo "  macosx-X11"
	@echo "  macosx-X11-debug"
	@echo "  solaris"
	@echo "  solaris-debug"
	@echo "  win-32-static"
	@echo "  win-32-dynamic"
	@echo "  win-32-clean"

subdirs = rm rmaux rmi rmv

# unix targets
freebsd \
irix6-32 \
irix6-32-debug \
irix6-n32 \
irix6-n32-debug \
irix6-n32-mips4 \
irix6-n32-mips4-debug \
irix6-64 \
irix6-64-debug \
linux \
linux-debug \
linux-cr-debug \
linux-x86_64-debug \
linux-x86_64 \
linux-x86_32-debug \
linux-x86_32 \
macosx-X11 \
macosx-X11-debug \
solaris \
solaris-debug:
	@for i in $(subdirs); \
	do \
	   (cd $$i; echo "Making in $(PWD)/$$i..."; \
	   PWD=$(PWD)/$$i; export PWD; touch depend; $(MAKE) -f Makefile.x11 $@; \
	   echo "All objects made in $(PWD)/$$i."); \
	done

install:
	@if (test -e $(INSTALL_DIR) ) then \
	  echo "Installing into $(INSTALL_DIR)...";\
	else \
	  echo "$(INSTALL_DIR), does not exist. Attempting to create it...";\
	  mkdir $(INSTALL_DIR) ;\
	fi

	@ echo "Installing header files in $(INSTALL_DIR)/include..."
	@ cp -r include $(INSTALL_DIR)

	@ echo "Installing libraries in $(INSTALL_DIR)/lib..."
	@ cp -r lib $(INSTALL_DIR)

	@ if (test -n `which ranlib`) then \
	  ranlib $(INSTALL_DIR)/lib/librm.a ; \
	  ranlib $(INSTALL_DIR)/lib/librmaux.a ; \
	  ranlib $(INSTALL_DIR)/lib/librmv.a ; \
	  ranlib $(INSTALL_DIR)/lib/librmi.a ; \
	fi

# assume that the HTML docs are included with the distro and complete.
	@ echo "Installing HTML documentation into $(INSTALL_DIR)/docs..."
	@ if (test -e $(INSTALL_DIR)/docs) then \
	   echo "" ; \
	else \
	   mkdir $(INSTALL_DIR)/docs ;\
	fi
	@ cp -r doc/HTML/* $(INSTALL_DIR)/docs

	@ echo "Install into $(INSTALL_DIR) complete."

clean:
	@\rm -rf lib/*;
	@for i in $(subdirs); \
	do \
	(cd $$i; echo "Cleaning $(PWD)/$$i..."; \
	PWD=$(PWD)/$$i; export PWD; $(MAKE) -f Makefile.x11 $@); \
	done 

pristine:
	@\rm -rf lib/*;
	@for i in $(subdirs); \
	do \
	(cd $$i; echo "Cleaning $(PWD)/$$i..."; \
	PWD=$(PWD)/$$i; export PWD; $(MAKE) -f Makefile.x11 $@); \
	done 

dep:
	@for i in $(subdirs); \
	do \
	   (cd $$i; echo "Making dependencies in $(PWD)/$$i..."; \
	   PWD=$(PWD)/$$i; export PWD; touch depend; $(MAKE) -f Makefile.x11 $@; \
	   echo "All dependencies made in $(PWD)/$$i."); \
	done

docs:
	@echo "Making docs..."; cd doc; ./makeDocs.csh; cd ../; echo "Making docs finished."

cleandocs:
	@echo "Making cleandocs..."; cd doc; \rm -f ./HTML/*.html; cd ../; echo "Making cleandocs finished."

# win-32 targets have their own special way with things.
win-32-static:
	cd rm
	nmake /f Makefile.w32 win-32-static
	cd ..\rmv
	nmake /f Makefile.w32 win-32-static
	cd ..\rmaux
	nmake /f Makefile.w32 win-32-static
	cd ..\rmi
	nmake /f Makefile.w32 win-32-static

win-32-clean:
	cd lib
	-del *.lib
	-del *.dll
	cd ..\rm
	nmake /f Makefile.w32 clean
	cd ..\rmv
	nmake /f Makefile.w32 clean
	cd ..\rmaux
	nmake /f Makefile.w32 clean
	cd ..\rmi
	nmake /f Makefile.w32 clean

win-32-dynamic:
	cd rm
	nmake /f Makefile.w32 win-32-dynamic
	cd ..\rmv
	nmake /f Makefile.w32 win-32-dynamic
	cd ..\rmaux
	nmake /f Makefile.w32 win-32-dynamic
	cd ..\rmi
	nmake /f Makefile.w32 win-32-dynamic

# EOF
