# c++-examples/any/makefile
#
# WARNING: this makefile isn't safe for parallel making!
#
# builds the C++ ANY example
#
# MS 92
#
# $Header: /cvs/Darwin/src/live/Security/SecuritySNACCRuntime/c++-examples/any/makefile,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $
# $Log: makefile,v $
# Revision 1.1.1.1  2001/05/18 23:14:05  mb
# Move from private repository to open source repository
#
# Revision 1.3  2000/12/22 00:03:01  dmitch
# Misc. updates for clean build on Cheetah 1D7.
#
# Revision 1.2  2000/06/08 19:58:44  dmitch
# Mods for X port.
#
# Revision 1.1.1.1  1999/03/16 18:05:57  aram
# Originals from SMIME Free Library.
#
# Revision 1.9  1997/02/16 16:47:46  rj
# made return *this after calling abort()'' a compile time option.
#
# Revision 1.8  1995/07/24  15:29:07  rj
# useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme.
# any-test.[hC] becomes any.[hC] due to to snacc's new file name generation scheme.
#
# `cd && make' instead of `cd; make'.
#
# changed `_' to `-' in file names.
#
# Revision 1.7  1995/02/20  11:46:19  rj
# build snacc if it doesn't exist.
# some makes leave a trailing slash on $(@D), others don't. this causes some mkdir(1)s to deny their cooperation. therefore, the slash has got to be stripped.
#
# Revision 1.6  1995/02/13  14:58:12  rj
# augment CPPFLAGS, not overwrite
#
# Revision 1.5  1994/10/08  04:35:42  rj
# enhance portability by using standard make capabilities instead of utilies (basename, dirname) not found on every platform.
#
# for the dependencies, generate the snacc compiler if it doesn't exist.
#
# Revision 1.4  1994/09/01  02:26:53  rj
# use CXX instead of CC to get another default linkage
#
# Revision 1.3  1994/08/31  21:38:34  rj
# rebuild the executables when the c++-lib is newer.
#
# Revision 1.2  1994/08/31  10:31:47  rj
# since .o files get moved, a few more dependencies are needed.
#
# Revision 1.1  1994/08/31  08:48:03  rj
# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
#

include ../../makehead

TOP		= ../..

ASN1_SRC_DIR	= $(TOP)/asn1specs

ASN1_C++_LIB_DIR	= $(TOP)/c++-lib
BUILD_DIR           = /Data_and_Apps/dmitchBuild
ASN1_C++_INC_DIR	= $(ASN1_C++_LIB_DIR)/inc
ASN1_C++_LIB		= $(ASN1_C++_LIB_DIR)/libasn1c++.a -framework cdsa_utilities -F/System/Library/PrivateFrameworks
#ASN1_C++_LIB		= $(BUILD_DIR)/libsnacc++.a
#ASN1_C++_LIB		= -framework snaccRuntime -F/Data_and_Apps/dmitchBuild -lstdc++

COMPILERDIR	= $(TOP)/compiler
SNACC		= $(COMPILERDIR)/snacc
USEFUL_TYPES	= $(ASN1_SRC_DIR)/asn-useful.asn1
SNACCFLAGS	= -C $(SNACC_NOVOLAT) -u $(USEFUL_TYPES)

CC		= $(CXX)
CPPFLAGS	+= -I$(TOP) -I$(ASN1_C++_INC_DIR) $(LENFLAG) -DVDADER_RULES -F/System/Library/PrivateFrameworks

ASN1FILES	= $(ASN1_SRC_DIR)/any.asn1

# generated by snacc from any.asn1:
ASN1HFILES	= any.h
ASN1CFILES	= any.cpp

CFILES = \
	genber.C	\
	example.C

DISTFILES = \
	README		\
	makefile	\
	$(CFILES)

#-------------------------------------------------------------------------------

all::		genber def indef

$(ASN1HFILES)	\
$(ASN1CFILES):	$(SNACC) $(ASN1FILES)
		$(REASON)
		$(SNACC) $(SNACCFLAGS) $(ASN1FILES)

$(SNACC):
		cd $(@D) && $(MAKE) $(@F)

def-obj		\
indef-obj:
		mkdir $@

def-obj/any.o	\
def-obj/example.o:
		$(REASON)
		$(MAKE) LENFLAG= `echo $(@D) | sed -e 's:/$$::'` $(@F)
		mv $(@F) $@

indef-obj/any.o	\
indef-obj/example.o:
		$(REASON)
		$(MAKE) LENFLAG=-DUSE_INDEF_LEN `echo $(@D) | sed -e 's:/$$::'` $(@F)
		mv $(@F) $@

genber:		def-obj/any.o genber.o
		$(REASON)
		$(CC) $(LDFLAGS) -o $@ def-obj/any.o genber.o $(ASN1_C++_LIB) $(LIBS) -lstdc++

def: 		def-obj/any.o def-obj/example.o
		$(REASON)
		$(CC) $(LDFLAGS) -o $@ def-obj/any.o def-obj/example.o $(ASN1_C++_LIB) $(LIBS) -lstdc++

indef:		indef-obj/any.o indef-obj/example.o
		$(REASON)
		$(CC) $(LDFLAGS) -o $@ indef-obj/any.o indef-obj/example.o $(ASN1_C++_LIB) $(LIBS) -lstdc++

genber	\
def	\
indef:		

.PHONY:	check

check::		genber def indef
		$(RM) foo.ber bar.ber
		./genber
		./indef att.ber > foo.ber
		./def foo.ber > bar.ber
		@echo ''
		@if cmp -s bar.ber att.ber; then\
		  echo "+++ Passed simple encode/decode tests using any.asn1.";\
		else\
		  echo "--- Failed simple encode/decode tests using any.asn1.";\
		fi
		@echo ''
		$(RM) foo.ber bar.ber

clean::
		$(RM) *.o *~ .emacs* core def indef genber att.ber $(ASN1HFILES) $(ASN1CFILES)
		$(RM) -r def-obj indef-obj
		$(RM) foo.ber bar.ber

depend::	$(SNACC)

include ../../maketail

depend::
		cp dependencies deps
		for dir in def-obj indef-obj; do\
		  < dependencies sed -e 's:^\(.*\.o\):'"$$dir"'/\1:' >> deps;\
		done
		mv deps dependencies
