#----------------------------------------------------------------------
#  Makefile
# 
#   Makefile for devsTest Directory
# 
# (c) Copyright 1995  Hewlett-Packard Company.
# The contents of this software are proprietary and confidential to
# the Hewlett- Packard Company, and are limited in distribution to
# those with a direct need to know.  Individuals having access to
# this software are responsible for maintaining the confidentiality
# of the content and for keeping the software secure when not in use.
# Transfer to any party is strictly forbidden other than as expressly
# permitted in writing by Hewlett-Packard Company.  Unauthorized
# transfer to or possession by any unauthorized party may be a
# criminal offense.
# 
#		     RESTRICTED RIGHTS LEGEND
# 
#      Use,  duplication,  or disclosure by the Government  is
#      subject to restrictions as set forth in subdivision (b)
#      (3)  (ii)  of the Rights in Technical Data and Computer
#      Software clause at 52.227-7013.
# 
#			 HEWLETT-PACKARD COMPANY
#			 3000 Hanover St.
#			 Palo Alto, CA  94304
# 
# LINK ERRORS:
# 
#  If ld gives "target of unconditional branch out of range" errors,
#  you most likely need too upadate your system with path PHSS_5083.
# 
#  This problem seems to be made worse by many levels of nested
#  inlines.
#  
#  This same problem was HELPED (but not fixed) by fixing the order of
#  the files in the final link-compile step.  For all of the tests,
#  <testname>.o is listed before ssLib.o and any other modules it needs
#  to link in.
#
# TARGETS:
#
#  all:              All Tests
#  destructiveTests: Tests which write to device object.
#  clean:            Removes all executables and all .o files.
#
# COMPILER WARNINGS:
#
#  See tail of file for explanation
#
# ----------------------------------------------------------------------
# $Source: /projects/HMS/nsr/udfAncil/devsTest/Makefile,v $
# $Revision: 1.17 $	$Author: hmgr $
# $State: Exp $   	$Locker:  $
# $Date: 96/02/05 09:13:38 $


NSRDIR=../..
COREDIR=$(NSRDIR)/udfCore
CONFIGDIR=$(COREDIR)/config
MSDIR=$(COREDIR)/ms
SSDIR=$(COREDIR)/ss
SYSDIR=$(COREDIR)/sys
DEVDIR=$(COREDIR)/devs
DESCRDIR=$(COREDIR)/descr

INCLUDE_DIRS    = -I$(NSRDIR) -I$(CONFIGDIR) -I$(SSDIR) -I$(SYSDIR) \
		-I$(DEVDIR) -I$(DESCRDIR) -I$(COREDIR)

TESTS=ssDevTst msDevTst msACstr

ASM= gas
CC=gcc
CFLAGS=-g $(OFLAGS)
CXX= g++

CXXFLAGS= -g -D_INCLUDE__STDC__ $(INCLUDE_DIRS) -I"../devs" -DNSR_VERIFY $(OFLAGS)

LIBFLAGS= $(CXXFLAGS) -D_NO_ALIASES_
TSTFLAGS= $(CXXFLAGS) -D_HP_ALIASES_

#	$(NSRDIR)/nsrCfg.h \

SSINCLS=\
	$(COREDIR)/nsrLib.h \
	$(SYSDIR)/nsrError.h \
	$(SYSDIR)/nsrAux.h \
	$(DEVDIR)/nsrscsi.h \
	$(DEVDIR)/nsrASSdv.h \
	$(DEVDIR)/nsrRSSdv.h

SSLIBSOURCES=\
	$(SYSDIR)/nsrError.cpp \
	$(SYSDIR)/nsrAux.cpp 

MSINCLS=\
	$(SSINCLS) \
	$(DEVDIR)/acptlib.h\
	$(DEVDIR)/RealMSdv.h \
	$(DEVDIR)/nsrAMSdv.h \
	$(DEVDIR)/nsrRMSdv.h

MSLIBSOURCES=\
	$(SSLIBSOURCES) \
	$(DEVDIR)/nsrRMSdv.cpp

all:	$(TESTS)

ssDevLib.o:	$(SSINCLS) $(SSLIBSOURCES) ssDevLib.cpp Makefile
	$(CXX) $(TSTFLAGS) -DSSDEVTEST -c ssDevLib.cpp 
		
ssDevTst.o:	$(SSINCLS) ssDevTst.cpp Makefile
	$(CXX) $(TSTFLAGS) -DSSDEVTEST -c ssDevTst.cpp

acptlib.o:	$(DEVDIR)/acptlib.c $(DEVDIR)/acptlib.h Makefile
	$(CC) $(CFLAGS) -c $(DEVDIR)/acptlib.c

dlist.o:        dlist.c dlist.h Makefile
	$(CC) $(CFLAGS) -c dlist.c

msDevLib.o:	$(MSINCLS) $(MSLIBSOURCES) msDevLib.cpp Makefile
	$(CXX) $(LIBFLAGS) -DMSDEVTEST -c msDevLib.cpp
		
msDevTst.o:	$(MSINCLS) msDevTst.cpp dlist.h Makefile
	$(CXX) $(TSTFLAGS) -DMSDEVTEST -c msDevTst.cpp

msACstr.o:	$(MSINCLS) msACstr.cpp dlist.h Makefile
	$(CXX) $(TSTFLAGS) -DMSDEVTEST -c msACstr.cpp

msACobj.o:	msACobj.cpp msACobj.h Makefile
	$(CXX) $(TSTFLAGS) -DMSDEVTEST -c msACobj.cpp

nsrRSSdv.o:	$(DEVDIR)/nsrRSSdv.h $(DEVDIR)/nsrRSSdv.cpp
	$(CXX) $(TSTFLAGS) -DSSDEVTEST -c $(DEVDIR)/nsrRSSdv.cpp

nsrRMSdv.o:	$(DEVDIR)/nsrRMSdv.h $(DEVDIR)/nsrRMSdv.cpp
	$(CXX) $(TSTFLAGS) -DMSDEVTEST -c $(DEVDIR)/nsrRMSdv.cpp

#
# First, the simple templates
#

ssDevTst:	$(SSINCLS) ssDevTst.o ssDevLib.o nsrRSSdv.o Makefile
	$(CXX) $(CXXFLAGS) -o ssDevTst ssDevTst.o nsrRSSdv.o ssDevLib.o -lrwtool

msDevTst:	$(MSINCLS) msDevTst.o nsrRMSdv.o msDevLib.o dlist.o acptlib.o \
		Makefile msACobj.o nsrRSSdv.o
	$(CXX) $(CXXFLAGS) -DMSDEVTEST -o msDevTst msDevTst.o msDevLib.o \
		nsrRMSdv.o dlist.o acptlib.o nsrRSSdv.o msACobj.o -lrwtool 

msACstr:	$(MSINCLS) msACstr.o msDevLib.o dlist.o acptlib.o Makefile \
		msACobj.o nsrRSSdv.o nsrRMSdv.o
	$(CXX) $(CXXFLAGS) -DMSDEVTEST -o msACstr msACstr.o msDevLib.o \
		dlist.o acptlib.o nsrRSSdv.o nsrRMSdv.o msACobj.o -lrwtool 

clean:
	rm -f $(TESTS) *.o

#############################################################
#
# USING SUFFIX RULES
#                   
# (DVM 4/5/95)
#
# The suffix approach to making the link step separate did not work,
# as the dependency upon changes in any of the include files was not
# reflected. This would manifest itself in link time errors, usually
# right after a significant change to the includes.
#
# The fix for this was to explicitly call out each .o for each test,
# and include a dependency on the include change.
#
# This .cpp.o rule uses an intermediate assembly product to perform compilation.
#
# .cpp.o:
# 	$(CXX) -S $(CXXFLAGS) $< > $*.s
# 	$(ASM) $*.s -o $*.o 
#
# ssLib.o:	$(INCLS) $(LIBSOURCES) Makefile ssLib.cpp
#	$(CXX) -S $(CXXFLAGS) -DNSR_VERIFY  ssLib.cpp > $*.s
#	$(ASM) ssLib.s -o ssLib.o 
#
# This is the failed .cpp.o rule:
#
# .cpp.o:	$(INCLS)
#	$(CXX) -c $(CXXFLAGS) $<
#
#########################################################
# 
# COMPILER WARNINGS:
#
# Use:
# CXXFLAGS= -g -DSSLIB -D_INCLUDE__STDC__ -I"../devs" -DNSR_VERIFY -Wall -Wshadow -Wconversion -Winline -Woverloaded-virtual -Wstrict-prototypes 
#
# ************** Flag Definitions ***************
# (courtesy of JLK)
#
# -f is 'force' (I think)
# -W is 'enable Warnings'
#
# -Wall includes:
#   -W		print extra warning messages (p.32, Using GNU CC)
#       There's a lot of causes, but this one is major:  warn when 
#	a function can return either with or w/o a value.  (Falling off 
#	the end of the function body is considered returning without a 
# 	value.)  For example, this function would evoke such a warning:
#		foo (a)  {
#		   if (a > 0)
#			return a;
#		}
#   -Wimplicit  warn whenever a function or parameter is implicityly declared
#   -Wreturn-type	warn on returns that default to int, or no return-val
#			and return-type not void 
#   -Wunused	unused local variables
#   -Wswitch    switch on enum misses values
#   -Wcomment   warn when /* appears inside of a comment.  (nested comments)
#   -Wtrigraphs (garbage)
#   -Wformat    check calls to printf and scanf to make sure that arguments 
#               have types approp. to format string
#   -Wchar-subscripts	warn if an array subscript has type char.  This is a
#			a common cause of error, as ppl often forget that
#			this type is signed on some machines.
#   -Wuninitialize	(only works when optimizing) uninit'd vars
#   -Wparentheses	warn in certain places ppl often leave out needed p's
#   -Wenum-clash	warn about conversion betw diff enum types
#   -Wtemplate-debugging	note that templates aren't fully imp'd
#
# -Wshadow 		warn when a local var shadows another local var
# -Wconversion 		warn if a protoype causes a type conversion that is
#			diff from what would happen to same arg in absence
#			of proto.  Incl. conversions of fixed point to float
#			and vice versa, and conv's changing the width or 
#			signedness of a fixed point arg except when the
#			same as the default promotion.
#
#			Also, warn if a negative integer constant expression
#			is implicitly converted to an unsigned type.
#			For example, warn about 'x = -1' if x is unsigned.
#			But do not warn about explicit casts like 
#			'(unsigned) -1'
# -Winline		warn if a func can't be inlined 
# -Woverloaded-virtual 	warn when a derived class func declar. may be in err
#			in defining a virtual func.  In a derived class, the
#			definitions of virt funcs must match the type sig
#			of a virt func defined in the base class.  Warn if not.
# -Wstrict-prototypes 	you must specify argument types.  An old-style func
#			is permitted w/o warning if preceded by a declaration
#			that specifies the arg types.
# And I originally had 
# this one but we do it 
# all the time, and it 
# caused too many warnings:
# -Waggregate-return 	warn on funcs that return structs, unions, or arrays
#
# -fansi-overloading is no longer meaningful (according to the compiler)
#	From the g++ FAQ:  "One of the weakest areas of g++ other than 
#   templates is the resolution of overloaded functions and operators
#   in complex cases.  The usual symptom is that in a case where the ARM
#   says that it is ambiguaous which funct should be chosen, g++ chooses 
#   one (often the first one declared).  This is uaually not a problem when 
#   porting C++ code from other compilers to g++, but shows up when code 
#   developed under g++ is ported to other compilers.
#
#       As of 2.5.0, the overloading code has been rewritten.  For now,
#   you must specify the option '-fansi-overloading' to get the new code,
#   since there were some important users actually depending on g++'s 
#   incorrect resolution of ambiguities.  This switch should disappear in
#   the future.
#
