########################################################################
#
# Copyright (c) 2009-2022, Secure Endpoints Inc.
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 
# - Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
# 
# - Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in
#   the documentation and/or other materials provided with the
#   distribution.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# 

RELDIR=lib\asn1

intcflags=-I$(SRCDIR) -I$(OBJ) -DROKEN_RENAME -DASN1_IOS_SUPPORTED -DASN1_LIB

!include ../../windows/NTMakefile.w32

ASN1_BINARIES =						    \
	$(LIBEXECDIR)\asn1_compile.exe

$(BINDIR)\asn1_compile.exe:				    \
	$(OBJ)\asn1parse.obj				    \
	$(OBJ)\gen.obj					    \
	$(OBJ)\gen_copy.obj				    \
	$(OBJ)\gen_decode.obj				    \
	$(OBJ)\gen_encode.obj				    \
	$(OBJ)\gen_print.obj				    \
	$(OBJ)\gen_free.obj				    \
	$(OBJ)\gen_glue.obj				    \
	$(OBJ)\gen_length.obj				    \
	$(OBJ)\gen_seq.obj				    \
	$(OBJ)\gen_template.obj				    \
	$(OBJ)\hash.obj					    \
	$(OBJ)\lex.obj					    \
	$(OBJ)\main.obj					    \
	$(OBJ)\symbol.obj				    \
	$(OBJ)\asn1_compile-version.res
	$(EXECONLINK) $(LIBROKEN) $(LIBVERS)
	$(EXEPREP_NOHEIM)

$(OBJ)\lex.c: lex.l $(OBJ)\asn1parse.h
	$(LEX) -o$@ lex.l

$(OBJ)\lex.obj: $(OBJ)\lex.c
	$(C2OBJ) -DYY_NO_UNISTD_H

$(OBJ)\asn1parse.c $(OBJ)\asn1parse.h: asn1parse.y
	$(YACC) -o $(OBJ)\asn1parse.c --defines=$(OBJ)\asn1parse.h $**

$(OBJ)\asn1_err.c $(OBJ)\asn1_err.h: asn1_err.et
	cd $(OBJ)
	$(BINDIR)\compile_et.exe $(SRCDIR)\asn1_err.et
	cd $(SRCDIR)

$(BINDIR)\asn1_print.exe: $(OBJ)\asn1_print.obj $(OBJ)\asn1_x690sample_asn1.s.obj $(LIBHEIMDAL)
	$(EXECONLINK) $(LIBVERS) $(LIBROKEN) $(LIBCOMERR)
	$(EXEPREP)

$(BINDIR)\asn1_gen.exe: $(OBJ)\asn1_gen.obj $(LIBHEIMDAL)
	$(EXECONLINK) $(LIBVERS) $(LIBROKEN)
	$(EXEPREP)

LIBASN1_X= \
	$(OBJ)\asn1_rfc2459_asn1.c		\
	$(OBJ)\asn1_rfc4108_asn1.c		\
	$(OBJ)\asn1_cms_asn1.c			\
	$(OBJ)\asn1_krb5_asn1.c			\
	$(OBJ)\asn1_ocsp_asn1.c			\
	$(OBJ)\asn1_pkinit_asn1.c		\
	$(OBJ)\asn1_pkcs8_asn1.c		\
	$(OBJ)\asn1_pkcs9_asn1.c		\
	$(OBJ)\asn1_pkcs10_asn1.c		\
	$(OBJ)\asn1_pkcs12_asn1.c		\
	$(OBJ)\asn1_digest_asn1.c		\
	$(OBJ)\asn1_kx509_asn1.c		\
	$(OBJ)\asn1_x690sample_asn1.c

LIBASN1_OBJS=	\
	$(OBJ)\der.obj				\
	$(OBJ)\der_get.obj			\
	$(OBJ)\der_put.obj			\
	$(OBJ)\der_free.obj			\
	$(OBJ)\der_print.obj			\
	$(OBJ)\der_length.obj			\
	$(OBJ)\der_copy.obj			\
	$(OBJ)\der_cmp.obj			\
	$(OBJ)\der_format.obj			\
	$(OBJ)\template.obj			\
	$(OBJ)\extra.obj			\
	$(OBJ)\oid_resolution.obj		\
	$(OBJ)\timegm.obj			\
	$(OBJ)\asn1_rfc2459_asn1.obj		\
	$(OBJ)\asn1_rfc4108_asn1.obj		\
	$(OBJ)\asn1_cms_asn1.obj		\
	$(OBJ)\asn1_krb5_asn1.obj		\
	$(OBJ)\asn1_ocsp_asn1.obj		\
	$(OBJ)\asn1_pkinit_asn1.obj		\
	$(OBJ)\asn1_pkcs8_asn1.obj		\
	$(OBJ)\asn1_pkcs9_asn1.obj		\
	$(OBJ)\asn1_pkcs10_asn1.obj		\
	$(OBJ)\asn1_pkcs12_asn1.obj		\
	$(OBJ)\asn1_digest_asn1.obj		\
	$(OBJ)\asn1_kx509_asn1.obj		\
	$(OBJ)\asn1_x690sample_asn1.obj		\
	$(OBJ)\asn1_err.obj

$(OBJ)\oid_resolution.obj: $(LIBASN1_X)

$(LIBASN1): $(LIBASN1_OBJS)
	$(LIBCON_C) -out:$@ @<<
$(**: =
)
<<

clean::
	-$(RM) $(LIBASN1)

#
# The static runtime version LIBASN1_S is for use by thirdparty
# components.  It is not used in the construction of the Heimdal
# DLLs.

LIBASN1_S_OBJS=	\
	$(OBJ)\der.s.obj			\
	$(OBJ)\der_get.s.obj			\
	$(OBJ)\der_put.s.obj			\
	$(OBJ)\der_free.s.obj			\
	$(OBJ)\der_print.s.obj			\
	$(OBJ)\der_length.s.obj			\
	$(OBJ)\der_copy.s.obj			\
	$(OBJ)\der_cmp.s.obj			\
	$(OBJ)\der_format.s.obj			\
	$(OBJ)\template.s.obj			\
	$(OBJ)\extra.s.obj			\
	$(OBJ)\oid_resolution.s.obj		\
	$(OBJ)\timegm.s.obj			\
	$(OBJ)\asn1_rfc2459_asn1.s.obj		\
	$(OBJ)\asn1_rfc4108_asn1.s.obj		\
	$(OBJ)\asn1_cms_asn1.s.obj		\
	$(OBJ)\asn1_krb5_asn1.s.obj		\
	$(OBJ)\asn1_ocsp_asn1.s.obj		\
	$(OBJ)\asn1_pkinit_asn1.s.obj		\
	$(OBJ)\asn1_pkcs8_asn1.s.obj		\
	$(OBJ)\asn1_pkcs9_asn1.s.obj		\
	$(OBJ)\asn1_pkcs10_asn1.s.obj		\
	$(OBJ)\asn1_pkcs12_asn1.s.obj		\
	$(OBJ)\asn1_digest_asn1.s.obj		\
	$(OBJ)\asn1_kx509_asn1.s.obj		\
	$(OBJ)\asn1_x690sample_asn1.s.obj	\
	$(OBJ)\asn1_err.s.obj

$(OBJ)\oid_resolution.s.obj: oid_resolution.c $(LIBASN1_X)
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ oid_resolution.c

$(OBJ)\der.s.obj: der.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_get.s.obj: der_get.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_put.s.obj: der_put.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_free.s.obj: der_free.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_print.s.obj: der_print.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_length.s.obj: der_length.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_copy.s.obj: der_copy.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_cmp.s.obj: der_cmp.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\der_format.s.obj: der_format.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\template.s.obj: template.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\extra.s.obj: extra.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\timegm.s.obj: timegm.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_rfc2459_asn1.s.obj: $(OBJ)\asn1_rfc2459_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_rfc4108_asn1.s.obj: $(OBJ)\asn1_rfc4108_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_cms_asn1.s.obj: $(OBJ)\asn1_cms_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_krb5_asn1.s.obj: $(OBJ)\asn1_krb5_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_ocsp_asn1.s.obj: $(OBJ)\asn1_ocsp_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_pkinit_asn1.s.obj: $(OBJ)\asn1_pkinit_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_pkcs8_asn1.s.obj: $(OBJ)\asn1_pkcs8_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_pkcs9_asn1.s.obj: $(OBJ)\asn1_pkcs9_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_pkcs10_asn1.s.obj: $(OBJ)\asn1_pkcs10_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_pkcs12_asn1.s.obj: $(OBJ)\asn1_pkcs12_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_digest_asn1.s.obj: $(OBJ)\asn1_digest_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_kx509_asn1.s.obj: $(OBJ)\asn1_kx509_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_x690sample_asn1.s.obj: $(OBJ)\asn1_x690sample_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_test_asn1.s.obj: $(OBJ)\asn1_test_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_test_template_asn1.s.obj: $(OBJ)\asn1_test_template_asn1.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(OBJ)\asn1_err.s.obj: $(OBJ)\asn1_err.c
	$(C2OBJ_C_MT) -Fo$@ -Fd$(@D)\ $**

$(LIBASN1_S): $(LIBASN1_S_OBJS)
	$(LIBCON_C) -out:$@ @<<
$(**: =
)
<<

clean::
	-$(RM) $(LIBASN1_S)


#
# Generate list of exports
#
# This target is only used during development to generate a list of
# symbols that are exported from all the object files in LIBASN1_OBJS.
#
exports-list.txt: $(LIBASN1_OBJS)
	$(PERL) ..\..\cf\w32-list-externs-from-objs.pl -q -u @<< > $@
$(**: =
)
<<

$(OBJ)\asn1_krb5_asn1.c $(OBJ)\krb5_asn1.h: $(BINDIR)\asn1_compile.exe krb5.asn1 krb5.opt
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file	\
		--option-file=$(SRCDIR)\krb5.opt \
		$(SRCDIR)\krb5.asn1 krb5_asn1 \
	|| ($(RM) $(OBJ)\krb5_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_ocsp_asn1.c $(OBJ)\ocsp_asn1.h: $(BINDIR)\asn1_compile.exe ocsp.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file \
		--option-file=$(SRCDIR)\ocsp.opt \
		$(SRCDIR)\ocsp.asn1 \
		ocsp_asn1 \
	|| ($(RM) $(OBJ)\ocsp_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_pkinit_asn1.c $(OBJ)\pkinit_asn1.h: $(BINDIR)\asn1_compile.exe pkinit.asn1 pkinit.opt
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe			\
		--template				\
		--one-code-file				\
		--option-file=$(SRCDIR)\pkinit.opt	\
		$(SRCDIR)\pkinit.asn1 pkinit_asn1	\
	|| ($(RM) $(OBJ)\pkinit_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_pkcs8_asn1.c $(OBJ)\pkcs8_asn1.h: $(BINDIR)\asn1_compile.exe pkcs8.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe --template --one-code-file $(SRCDIR)\pkcs8.asn1 pkcs8_asn1 \
	|| ($(RM) $(OBJ)\pkcs8_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_pkcs9_asn1.c $(OBJ)\pkcs9_asn1.h: $(BINDIR)\asn1_compile.exe pkcs9.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe --template --one-code-file $(SRCDIR)\pkcs9.asn1 pkcs9_asn1 \
	|| ($(RM) $(OBJ)\pkcs9_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_pkcs10_asn1.c $(OBJ)\pkcs10_asn1.h: $(BINDIR)\asn1_compile.exe pkcs10.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file \
		--option-file=$(SRCDIR)\pkcs10.opt \
		$(SRCDIR)\pkcs10.asn1 \
		pkcs10_asn1 \
	|| ($(RM) $(OBJ)\pkcs10_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_pkcs12_asn1.c $(OBJ)\pkcs12_asn1.h: $(BINDIR)\asn1_compile.exe pkcs12.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe --template --one-code-file $(SRCDIR)\pkcs12.asn1 pkcs12_asn1 \
	|| ($(RM) $(OBJ)\pkcs12_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_digest_asn1.c $(OBJ)\digest_asn1.h: $(BINDIR)\asn1_compile.exe digest.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe --template --one-code-file $(SRCDIR)\digest.asn1 digest_asn1 \
	|| ($(RM) $(OBJ)\digest_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_kx509_asn1.c $(OBJ)\kx509_asn1.h: $(BINDIR)\asn1_compile.exe kx509.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe --template --one-code-file $(SRCDIR)\kx509.asn1 kx509_asn1 \
	|| ($(RM) $(OBJ)\kx509_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_rfc2459_asn1.c $(OBJ)\rfc2459_asn1.h: $(BINDIR)\asn1_compile.exe rfc2459.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file \
		--option-file=$(SRCDIR)\rfc2459.opt \
		$(SRCDIR)\rfc2459.asn1 rfc2459_asn1 \
	|| ($(RM) $(OBJ)\rfc2459_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_rfc4108_asn1.c $(OBJ)\rfc4108_asn1.h: $(BINDIR)\asn1_compile.exe rfc4108.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file \
		$(SRCDIR)\rfc4108.asn1 rfc4108_asn1 \
	|| ($(RM) $(OBJ)\rfc4108_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_cms_asn1.c $(OBJ)\cms_asn1.h: $(BINDIR)\asn1_compile.exe cms.asn1 cms.opt
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file --option-file=$(SRCDIR)\cms.opt \
		$(SRCDIR)\cms.asn1 cms_asn1 \
	|| ($(RM) $(OBJ)\cms_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(gen_files_crmf) $(OBJ)\crmf_asn1.h: $(BINDIR)\asn1_compile.exe crmf.asn1 crmf.opt
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file --option-file=$(SRCDIR)\crmf.opt \
		$(SRCDIR)\crmf.asn1 crmf_asn1 \
	|| ($(RM) $(OBJ)\crmf_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_x690sample_asn1.c $(OBJ)\x690sample_asn1.h: $(BINDIR)\asn1_compile.exe x690sample.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--one-code-file \
		$(SRCDIR)\x690sample.asn1 x690sample_asn1 \
	|| ($(RM) $(OBJ)\x690sample_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_test_asn1.c $(OBJ)\test_asn1.h: $(BINDIR)\asn1_compile.exe test.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--option-file=$(SRCDIR)/test.opt		\
		--one-code-file \
		$(SRCDIR)\test.asn1 test_asn1 \
	|| ($(RM) $(OBJ)\test_asn1.h ; exit /b 1)
	cd $(SRCDIR)

$(OBJ)\asn1_test_template_asn1.c $(OBJ)\test_template_asn1.h: $(BINDIR)\asn1_compile.exe test.asn1
	cd $(OBJ)
	$(BINDIR)\asn1_compile.exe \
		--template	\
		--option-file=$(SRCDIR)/test.opt		\
		--one-code-file \
		$(SRCDIR)\test.asn1 test_template_asn1 \
	|| ($(RM) $(OBJ)\test_template_asn1.h ; exit /b 1)
	cd $(SRCDIR)

INCFILES=			    \
	$(INCDIR)\der.h		    \
	$(INCDIR)\heim_asn1.h	    \
	$(INCDIR)\der-protos.h	    \
	$(INCDIR)\der-private.h	    \
	$(INCDIR)\asn1-common.h	    \
	$(INCDIR)\asn1-template.h   \
	$(OBJ)\asn1_err.h

$(INCDIR)\der-protos.h: $(OBJ)\der-protos.h

GENINCFILES=					\
	$(INCDIR)\asn1_err.h			\
	$(INCDIR)\cms_asn1.h			\
	$(INCDIR)\crmf_asn1.h			\
	$(INCDIR)\digest_asn1.h			\
	$(INCDIR)\krb5_asn1.h			\
	$(INCDIR)\kx509_asn1.h			\
	$(INCDIR)\ocsp_asn1.h			\
	$(INCDIR)\pkcs12_asn1.h			\
	$(INCDIR)\pkcs8_asn1.h			\
	$(INCDIR)\pkcs9_asn1.h			\
	$(INCDIR)\pkcs10_asn1.h			\
	$(INCDIR)\pkinit_asn1.h			\
	$(INCDIR)\rfc2459_asn1.h		\
	$(INCDIR)\rfc4108_asn1.h		\
	$(INCDIR)\x690sample_asn1.h		\
	$(OBJ)\krb5_asn1-priv.h			\
	$(OBJ)\ocsp_asn1-priv.h			\
	$(OBJ)\pkinit_asn1-priv.h		\
	$(OBJ)\cms_asn1-priv.h			\
	$(OBJ)\crmf_asn1-priv.h			\
	$(OBJ)\rfc2459_asn1-priv.h		\
	$(OBJ)\rfc4108_asn1-priv.h		\
	$(OBJ)\x690sample_asn1-priv.h		\
	$(OBJ)\pkcs8_asn1-priv.h		\
	$(OBJ)\pkcs9_asn1-priv.h		\
	$(OBJ)\pkcs10_asn1-priv.h		\
	$(OBJ)\pkcs12_asn1-priv.h		\
	$(OBJ)\digest_asn1-priv.h		\
	$(OBJ)\kx509_asn1-priv.h		\
	$(OBJ)\test_template_asn1.h		\
	$(OBJ)\test_template_asn1-priv.h	\
	$(OBJ)\test_asn1.h			\
	$(OBJ)\test_asn1-priv.h

libasn1_base_SOURCES=	\
	der_locl.h 	\
	der.c		\
	der.h		\
	der_get.c	\
	der_put.c	\
	der_free.c	\
	der_print.c	\
	der_length.c	\
	der_copy.c	\
	der_cmp.c	\
	der_format.c	\
	template.c	\
	heim_asn1.h	\
	extra.c		\
	timegm.c

libasn1_SOURCES=	\
	oid_resolution.c

$(OBJ)\der-protos.h: $(libasn1_SOURCES)
	$(PERL) ..\..\cf\make-proto.pl -q -P remove -o $(OBJ)\der-protos.h $(libasn1_base_SOURCES) $(libasn1_SOURCES) || $(RM) $(OBJ)\der-protos.h

$(OBJ)\der-private.h: $(libasn1_SOURCES)
	$(PERL) ..\..\cf\make-proto.pl -q -P remove -p $(OBJ)\der-private.h $(libasn1_base_SOURCES) $(libasn1_SOURCES) || $(RM) $(OBJ)\der-private.h

clean::
	-$(RM) $(INCDIR)\der-protos.h

all:: $(INCFILES) $(GENINCFILES) $(ASN1_BINARIES) $(LIBASN1) $(LIBASN1_S)

all-tools:: $(LIBEXECDIR)\asn1_print.exe $(BINDIR)\asn1_gen.exe

clean::
	-$(RM) $(INCFILES)
	-$(RM) $(GENINCFILES)
	-$(RM) $(ASN1_BINARIES:.exe=.*)
	-$(RM) $(LIBASN1)
	-$(RM) $(LIBEXECDIR)\asn1_print.*
	-$(RM) $(LIBEXECDIR)\asn1_gen.*

TEST_BINARIES=\
	$(OBJ)\check-der.exe		\
	$(OBJ)\check-gen-template.exe	\
	$(OBJ)\check-timegm.exe 	\
	$(OBJ)\check-ber.exe		\
	$(OBJ)\check-template.exe

test-binaries: $(TEST_BINARIES)

test-run:
	cd $(OBJ)
	-check-der.exe
	-check-gen-template.exe
	-check-timegm.exe
	-check-ber.exe
	-check-template.exe
	cd $(SRC)

test:: test-binaries test-run

clean::
	-$(RM) $(TEST_BINARIES:.exe=*)

$(OBJ)\check-ber.exe: $(OBJ)\check-ber.obj \
		$(LIBHEIMDAL) $(LIBROKEN)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\check-der.exe: $(OBJ)\check-der.obj $(OBJ)\check-common.obj \
		$(LIBHEIMDAL) $(LIBROKEN)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\check-gen-template.exe: $(OBJ)\check-gen.obj $(OBJ)\check-common.obj \
		$(LIBHEIMDAL) $(LIBROKEN) $(OBJ)\asn1_test_template_asn1.obj \
                $(OBJ)\asn1_x690sample_asn1.s.obj
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\check-timegm.exe: $(OBJ)\check-timegm.obj \
		$(LIBHEIMDAL) $(LIBROKEN)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\check-template.exe: $(OBJ)\check-template.obj $(OBJ)\check-common.obj \
		$(LIBHEIMDAL) $(LIBROKEN) $(OBJ)\asn1_test_asn1.obj
	$(EXECONLINK)
	$(EXEPREP_NODIST)
