########################################################################
#
# Copyright (c) 2009-2011 Secure Endpoints Inc.
# Copyright (c) 2018 Kungliga Tekniska Högskolan
# (Royal Institute of Technology, Stockholm, Sweden).
# 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\gssapi 

intcflags=-DASN1_LIB

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

krb5src = \
	krb5/8003.c \
	krb5/accept_sec_context.c \
	krb5/acquire_cred.c \
	krb5/add_cred.c \
	krb5/address_to_krb5addr.c \
	krb5/aeap.c \
	krb5/arcfour.c \
        krb5/authorize_localname.c \
	krb5/canonicalize_name.c \
	krb5/creds.c \
	krb5/ccache_name.c \
	krb5/cfx.c \
	krb5/cfx.h \
	krb5/compare_name.c \
	krb5/compat.c \
	krb5/context_time.c \
	krb5/copy_ccache.c \
	krb5/decapsulate.c \
	krb5/delete_sec_context.c \
	krb5/display_name.c \
	krb5/display_status.c \
	krb5/duplicate_name.c \
	krb5/duplicate_cred.c \
	krb5/encapsulate.c \
	krb5/export_name.c \
	krb5/export_sec_context.c \
	krb5/external.c \
	krb5/get_mic.c \
	krb5/gsskrb5_locl.h \
	krb5/import_name.c \
	krb5/import_sec_context.c \
	krb5/indicate_mechs.c \
	krb5/init.c \
	krb5/init_sec_context.c \
	krb5/inquire_context.c \
	krb5/inquire_cred.c \
	krb5/inquire_cred_by_mech.c \
	krb5/inquire_cred_by_oid.c \
	krb5/inquire_mechs_for_name.c \
	krb5/inquire_names_for_mech.c \
	krb5/inquire_sec_context_by_oid.c \
        krb5/name_attrs.c \
        krb5/pname_to_uid.c \
	krb5/process_context_token.c \
	krb5/prf.c \
	krb5/release_buffer.c \
	krb5/release_cred.c \
	krb5/release_name.c \
	krb5/sequence.c \
	krb5/store_cred.c \
	krb5/set_cred_option.c \
	krb5/set_sec_context_option.c \
	krb5/ticket_flags.c \
	krb5/unwrap.c \
	krb5/verify_mic.c \
	krb5/wrap.c

mechsrc = \
	mech/context.h \
	mech/context.c \
	mech/cred.h \
	mech/cred.c \
	mech/gss_accept_sec_context.c \
	mech/gss_acquire_cred.c \
	mech/gss_acquire_cred_from.c \
	mech/gss_acquire_cred_impersonate_name.c \
	mech/gss_acquire_cred_with_password.c \
	mech/gss_add_cred.c \
	mech/gss_add_cred_from.c \
	mech/gss_add_cred_with_password.c \
	mech/gss_add_oid_set_member.c \
	mech/gss_aeap.c \
        mech/gss_authorize_localname.c \
	mech/gss_buffer_set.c \
	mech/gss_canonicalize_name.c \
	mech/gss_compare_name.c \
	mech/gss_context_time.c \
	mech/gss_create_empty_oid_set.c \
	mech/gss_cred.c \
	mech/gss_decapsulate_token.c \
	mech/gss_delete_name_attribute.c \
	mech/gss_delete_sec_context.c \
	mech/gss_destroy_cred.c \
	mech/gss_display_name.c \
	mech/gss_display_name_ext.c \
	mech/gss_display_status.c \
	mech/gss_duplicate_name.c \
	mech/gss_duplicate_cred.c \
	mech/gss_duplicate_oid.c \
	mech/gss_duplicate_oid_set.c \
	mech/gss_encapsulate_token.c \
	mech/gss_export_name.c \
	mech/gss_export_name_composite.c \
	mech/gss_export_sec_context.c \
	mech/gss_get_mic.c \
	mech/gss_get_neg_mechs.c \
	mech/gss_get_name_attribute.c \
	mech/gss_import_name.c \
	mech/gss_import_sec_context.c \
	mech/gss_indicate_mechs.c \
	mech/gss_init_sec_context.c \
	mech/gss_inquire_context.c \
	mech/gss_inquire_cred.c \
	mech/gss_inquire_cred_by_mech.c \
	mech/gss_inquire_cred_by_oid.c \
	mech/gss_inquire_mechs_for_name.c \
	mech/gss_inquire_name.c \
	mech/gss_inquire_names_for_mech.c \
	mech/gss_krb5.c \
	mech/gss_mech_switch.c \
	mech/gss_mo.c \
	mech/gss_names.c \
	mech/gss_oid.c \
	mech/gss_oid_equal.c \
	mech/gss_oid_to_str.c \
	mech/gss_pname_to_uid.c \
	mech/gss_process_context_token.c \
	mech/gss_pseudo_random.c \
	mech/gss_release_buffer.c \
	mech/gss_release_cred.c \
	mech/gss_release_name.c \
	mech/gss_release_oid.c \
	mech/gss_release_oid_set.c \
	mech/gss_rfc4121.c \
	mech/gss_seal.c \
	mech/gss_set_cred_option.c \
	mech/gss_set_name_attribute.c \
	mech/gss_set_neg_mechs.c \
	mech/gss_set_sec_context_option.c \
	mech/gss_sign.c \
	mech/gss_store_cred.c \
	mech/gss_store_cred_into.c \
	mech/gss_test_oid_set_member.c \
	mech/gss_unseal.c \
	mech/gss_unwrap.c \
	mech/gss_utils.c \
	mech/gss_verify.c \
	mech/gss_verify_mic.c \
	mech/gss_wrap.c \
	mech/gss_wrap_size_limit.c \
	mech/gss_inquire_sec_context_by_oid.c \
	mech/gssspi_exchange_meta_data.c \
	mech/gssspi_query_mechanism_info.c \
	mech/gssspi_query_meta_data.c \
	mech/mech_switch.h \
	mech/mech_locl.h \
	mech/name.h \
	mech/utils.h

spnegosrc = \
	spnego/accept_sec_context.c \
	spnego/compat.c \
	spnego/context_storage.c \
	spnego/context_stubs.c \
	spnego/external.c \
	spnego/init_sec_context.c \
	spnego/negoex_ctx.c \
	spnego/negoex_util.c \
	spnego/spnego_locl.h \
	spnego/negoex_locl.h

sanonsrc = \
	sanon/accept_sec_context.c \
	sanon/acquire_cred.c \
	sanon/add_cred.c \
	sanon/canonicalize_name.c \
	sanon/compare_name.c \
	sanon/context_time.c \
	sanon/crypto.c \
	sanon/delete_sec_context.c \
	sanon/display_name.c \
	sanon/display_status.c \
	sanon/duplicate_cred.c \
	sanon/duplicate_name.c \
	sanon/export_cred.c \
	sanon/export_name.c \
	sanon/export_sec_context.c \
	sanon/external.c \
	sanon/import_cred.c \
	sanon/import_name.c \
	sanon/import_sec_context.c \
	sanon/init_sec_context.c \
	sanon/inquire_context.c \
	sanon/inquire_cred.c \
	sanon/inquire_cred_by_mech.c \
	sanon/inquire_mechs_for_name.c \
	sanon/inquire_names_for_mech.c \
	sanon/inquire_sec_context_by_oid.c \
	sanon/negoex.c \
	sanon/process_context_token.c \
	sanon/release_cred.c \
	sanon/release_name.c

$(OBJ)\krb5\gsskrb5-private.h: $(krb5src)
	$(PERL) ../../cf/make-proto.pl -q -P remove -p $@ $(krb5src)

$(OBJ)\spnego\spnego-private.h: $(spnegosrc)
	$(PERL) ../../cf/make-proto.pl -q -P remove -p $@ $(spnegosrc)

$(OBJ)\sanon\sanon-private.h: $(sanonsrc)
	$(PERL) ../../cf/make-proto.pl -q -P remove -p $@ $(sanonsrc)

$(OBJ)\gssapi\asn1_gssapi_asn1.c $(OBJ)\gssapi\gssapi_asn1.h $(OBJ)\gssapi\gssapi_asn1-priv.h: \
$(BINDIR)\asn1_compile.exe mech\gssapi.asn1
	cd $(OBJ)\gssapi
	$(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\mech\gssapi.asn1 gssapi_asn1 \
	|| ( $(RM) $(OBJ)\gssapi\gssapi_asn1.h ; exit /b 1 )
	cd $(SRCDIR)

$(OBJ)\spnego\asn1_spnego_asn1.c $(OBJ)\spnego\spnego_asn1.h $(OBJ)\spnego\spnego_asn1-priv.h: \
$(BINDIR)\asn1_compile.exe spnego\spnego.asn1
	cd $(OBJ)\spnego
	$(BINDIR)\asn1_compile --one-code-file --sequence=MechTypeList \
		$(SRCDIR)\spnego\spnego.asn1 spnego_asn1 \
	|| ( $(RM) $(OBJ)\spnego\spnego_asn1.h ; exit /b 1 )
	cd $(SRCDIR)

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

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

INCFILES=				\
    $(INCDIR)\gssapi.h			\
    $(INCDIR)\gssapi\gssapi.h		\
    $(INCDIR)\gssapi\gssapi_krb5.h	\
    $(INCDIR)\gssapi\gssapi_oid.h	\
    $(INCDIR)\gssapi\gssapi_spnego.h	\
    $(INCDIR)\gssapi\gkrb5_err.h	\
    $(OBJ)\spnego\spnego-private.h	\
    $(OBJ)\sanon\sanon-private.h	\
    $(OBJ)\krb5\gsskrb5-private.h	\
    $(OBJ)\gkrb5_err.h			\
    $(OBJ)\negoex_err.h			\
    $(OBJ)\gssapi\gssapi_asn1.h		\
    $(OBJ)\gssapi\gssapi_asn1-priv.h	\
    $(OBJ)\spnego\spnego_asn1.h		\
    $(OBJ)\spnego\spnego_asn1-priv.h

all:: $(INCFILES)

libgssapi_OBJs = \
	$(OBJ)\krb5/8003.obj \
	$(OBJ)\krb5/accept_sec_context.obj \
	$(OBJ)\krb5/acquire_cred.obj \
	$(OBJ)\krb5/add_cred.obj \
	$(OBJ)\krb5/address_to_krb5addr.obj \
        $(OBJ)\krb5/authorize_localname.obj \
	$(OBJ)\krb5/aeap.obj \
	$(OBJ)\krb5/arcfour.obj \
	$(OBJ)\krb5/canonicalize_name.obj \
	$(OBJ)\krb5/creds.obj \
	$(OBJ)\krb5/ccache_name.obj \
	$(OBJ)\krb5/cfx.obj \
	$(OBJ)\krb5/compare_name.obj \
	$(OBJ)\krb5/compat.obj \
	$(OBJ)\krb5/context_time.obj \
	$(OBJ)\krb5/copy_ccache.obj \
	$(OBJ)\krb5/decapsulate.obj \
	$(OBJ)\krb5/delete_sec_context.obj \
	$(OBJ)\krb5/display_name.obj \
	$(OBJ)\krb5/display_status.obj \
	$(OBJ)\krb5/duplicate_cred.obj \
	$(OBJ)\krb5/duplicate_name.obj \
	$(OBJ)\krb5/encapsulate.obj \
	$(OBJ)\krb5/export_name.obj \
	$(OBJ)\krb5/export_sec_context.obj \
	$(OBJ)\krb5/external.obj \
	$(OBJ)\krb5/get_mic.obj \
	$(OBJ)\krb5/import_name.obj \
	$(OBJ)\krb5/import_sec_context.obj \
	$(OBJ)\krb5/indicate_mechs.obj \
	$(OBJ)\krb5/init.obj \
	$(OBJ)\krb5/init_sec_context.obj \
	$(OBJ)\krb5/inquire_context.obj \
	$(OBJ)\krb5/inquire_cred.obj \
	$(OBJ)\krb5/inquire_cred_by_mech.obj \
	$(OBJ)\krb5/inquire_cred_by_oid.obj \
	$(OBJ)\krb5/inquire_mechs_for_name.obj \
	$(OBJ)\krb5/inquire_names_for_mech.obj \
	$(OBJ)\krb5/inquire_sec_context_by_oid.obj \
        $(OBJ)\krb5/name_attrs.obj \
        $(OBJ)\krb5/pname_to_uid.obj \
	$(OBJ)\krb5/process_context_token.obj \
	$(OBJ)\krb5/prf.obj \
	$(OBJ)\krb5/release_buffer.obj \
	$(OBJ)\krb5/release_cred.obj \
	$(OBJ)\krb5/release_name.obj \
	$(OBJ)\krb5/sequence.obj \
	$(OBJ)\krb5/store_cred.obj \
	$(OBJ)\krb5/set_cred_option.obj \
	$(OBJ)\krb5/set_sec_context_option.obj \
	$(OBJ)\krb5/ticket_flags.obj \
	$(OBJ)\krb5/unwrap.obj \
	$(OBJ)\krb5/verify_mic.obj \
	$(OBJ)\krb5/wrap.obj \
	$(OBJ)\mech/context.obj \
	$(OBJ)\mech/cred.obj \
	$(OBJ)\mech/gss_accept_sec_context.obj \
	$(OBJ)\mech/gss_acquire_cred.obj \
	$(OBJ)\mech/gss_acquire_cred_from.obj \
	$(OBJ)\mech/gss_acquire_cred_impersonate_name.obj \
	$(OBJ)\mech/gss_acquire_cred_with_password.obj \
	$(OBJ)\mech/gss_add_cred.obj \
	$(OBJ)\mech/gss_add_cred_from.obj \
	$(OBJ)\mech/gss_add_cred_with_password.obj \
	$(OBJ)\mech/gss_add_oid_set_member.obj \
	$(OBJ)\mech/gss_aeap.obj \
	$(OBJ)\mech/gss_authorize_localname.obj \
	$(OBJ)\mech/gss_buffer_set.obj \
	$(OBJ)\mech/gss_canonicalize_name.obj \
	$(OBJ)\mech/gss_compare_name.obj \
	$(OBJ)\mech/gss_context_time.obj \
	$(OBJ)\mech/gss_create_empty_oid_set.obj \
	$(OBJ)\mech/gss_cred.obj \
	$(OBJ)\mech/gss_decapsulate_token.obj \
	$(OBJ)\mech/gss_delete_name_attribute.obj \
	$(OBJ)\mech/gss_delete_sec_context.obj \
	$(OBJ)\mech/gss_destroy_cred.obj \
	$(OBJ)\mech/gss_display_name.obj \
	$(OBJ)\mech/gss_display_name_ext.obj \
	$(OBJ)\mech/gss_display_status.obj \
	$(OBJ)\mech/gss_duplicate_cred.obj \
	$(OBJ)\mech/gss_duplicate_name.obj \
	$(OBJ)\mech/gss_duplicate_oid.obj \
	$(OBJ)\mech/gss_duplicate_oid_set.obj \
	$(OBJ)\mech/gss_encapsulate_token.obj \
	$(OBJ)\mech/gss_export_name.obj \
	$(OBJ)\mech/gss_export_name_composite.obj \
	$(OBJ)\mech/gss_export_sec_context.obj \
	$(OBJ)\mech/gss_get_mic.obj \
	$(OBJ)\mech/gss_get_neg_mechs.obj \
	$(OBJ)\mech/gss_get_name_attribute.obj \
	$(OBJ)\mech/gss_import_name.obj \
	$(OBJ)\mech/gss_import_sec_context.obj \
	$(OBJ)\mech/gss_indicate_mechs.obj \
	$(OBJ)\mech/gss_init_sec_context.obj \
	$(OBJ)\mech/gss_inquire_context.obj \
	$(OBJ)\mech/gss_inquire_cred.obj \
	$(OBJ)\mech/gss_inquire_cred_by_mech.obj \
	$(OBJ)\mech/gss_inquire_cred_by_oid.obj \
	$(OBJ)\mech/gss_inquire_mechs_for_name.obj \
	$(OBJ)\mech/gss_inquire_name.obj \
	$(OBJ)\mech/gss_inquire_names_for_mech.obj \
	$(OBJ)\mech/gss_krb5.obj \
	$(OBJ)\mech/gss_mech_switch.obj \
	$(OBJ)\mech/gss_mo.obj \
	$(OBJ)\mech/gss_names.obj \
	$(OBJ)\mech/gss_oid.obj \
	$(OBJ)\mech/gss_oid_equal.obj \
	$(OBJ)\mech/gss_oid_to_str.obj \
	$(OBJ)\mech/gss_pname_to_uid.obj \
	$(OBJ)\mech/gss_process_context_token.obj \
	$(OBJ)\mech/gss_pseudo_random.obj \
	$(OBJ)\mech/gss_release_buffer.obj \
	$(OBJ)\mech/gss_release_cred.obj \
	$(OBJ)\mech/gss_release_name.obj \
	$(OBJ)\mech/gss_release_oid.obj \
	$(OBJ)\mech/gss_release_oid_set.obj \
	$(OBJ)\mech/gss_rfc4121.obj \
	$(OBJ)\mech/gss_seal.obj \
	$(OBJ)\mech/gss_set_cred_option.obj \
	$(OBJ)\mech/gss_set_name_attribute.obj \
	$(OBJ)\mech/gss_set_neg_mechs.obj \
	$(OBJ)\mech/gss_set_sec_context_option.obj \
	$(OBJ)\mech/gss_sign.obj \
	$(OBJ)\mech/gss_store_cred.obj \
	$(OBJ)\mech/gss_store_cred_into.obj \
	$(OBJ)\mech/gss_test_oid_set_member.obj \
	$(OBJ)\mech/gss_unseal.obj \
	$(OBJ)\mech/gss_unwrap.obj \
	$(OBJ)\mech/gss_utils.obj \
	$(OBJ)\mech/gss_verify.obj \
	$(OBJ)\mech/gss_verify_mic.obj \
	$(OBJ)\mech/gss_wrap.obj \
	$(OBJ)\mech/gss_wrap_size_limit.obj \
	$(OBJ)\mech/gss_inquire_sec_context_by_oid.obj \
	$(OBJ)\mech/gssspi_exchange_meta_data.obj \
	$(OBJ)\mech/gssspi_query_mechanism_info.obj \
	$(OBJ)\mech/gssspi_query_meta_data.obj \
	$(OBJ)\spnego/accept_sec_context.obj \
	$(OBJ)\spnego/compat.obj \
	$(OBJ)\spnego/context_storage.obj \
	$(OBJ)\spnego/context_stubs.obj \
	$(OBJ)\spnego/external.obj \
	$(OBJ)\spnego/init_sec_context.obj \
	$(OBJ)\spnego/negoex_ctx.obj \
	$(OBJ)\spnego/negoex_util.obj \
	$(OBJ)\sanon/accept_sec_context.obj \
	$(OBJ)\sanon/acquire_cred.obj \
	$(OBJ)\sanon/add_cred.obj \
	$(OBJ)\sanon/canonicalize_name.obj \
	$(OBJ)\sanon/compare_name.obj \
	$(OBJ)\sanon/context_time.obj \
	$(OBJ)\sanon/crypto.obj \
	$(OBJ)\sanon/delete_sec_context.obj \
	$(OBJ)\sanon/display_name.obj \
	$(OBJ)\sanon/display_status.obj \
	$(OBJ)\sanon/duplicate_cred.obj \
	$(OBJ)\sanon/duplicate_name.obj \
	$(OBJ)\sanon/export_cred.obj \
	$(OBJ)\sanon/export_name.obj \
	$(OBJ)\sanon/export_sec_context.obj \
	$(OBJ)\sanon/external.obj \
	$(OBJ)\sanon/import_cred.obj \
	$(OBJ)\sanon/import_name.obj \
	$(OBJ)\sanon/import_sec_context.obj \
	$(OBJ)\sanon/init_sec_context.obj \
	$(OBJ)\sanon/inquire_context.obj \
	$(OBJ)\sanon/inquire_cred.obj \
	$(OBJ)\sanon/inquire_cred_by_mech.obj \
	$(OBJ)\sanon/inquire_mechs_for_name.obj \
	$(OBJ)\sanon/inquire_names_for_mech.obj \
	$(OBJ)\sanon/inquire_sec_context_by_oid.obj \
	$(OBJ)\sanon/negoex.obj \
	$(OBJ)\sanon/process_context_token.obj \
	$(OBJ)\sanon/release_cred.obj \
	$(OBJ)\sanon/release_name.obj \
	$(OBJ)\gkrb5_err.obj \
	$(OBJ)\negoex_err.obj \
	$(OBJ)\spnego\asn1_spnego_asn1.obj \
	$(OBJ)\gssapi\asn1_gssapi_asn1.obj

GCOPTS=-I$(SRCDIR) -I$(OBJ) -Igssapi -DBUILD_GSSAPI_LIB

{$(OBJ)\krb5}.c{$(OBJ)\krb5}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\krb5\ -Fd$(OBJ)\krb5\ -I$(OBJ)\krb5 $(GCOPTS)

{krb5}.c{$(OBJ)\krb5}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\krb5\ -Fd$(OBJ)\krb5\ -I$(OBJ)\krb5 $(GCOPTS) -DASN1_LIB

{$(OBJ)\mech}.c{$(OBJ)\mech}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\mech\ -Fd$(OBJ)\mech\ -I$(OBJ)\mech $(GCOPTS)

{mech}.c{$(OBJ)\mech}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\mech\ -Fd$(OBJ)\mech\ -I$(OBJ)\mech -I$(OBJ)\gssapi $(GCOPTS) -DASN1_LIB

{$(OBJ)\spnego}.c{$(OBJ)\spnego}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\spnego\ -Fd$(OBJ)\spnego\ -I$(OBJ)\spnego $(GCOPTS)

{spnego}.c{$(OBJ)\spnego}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\spnego\ -Fd$(OBJ)\spnego\ -I$(OBJ)\spnego -Imech $(GCOPTS) -DASN1_LIB

{$(OBJ)\sanon}.c{$(OBJ)\sanon}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\sanon\ -Fd$(OBJ)\sanon\ -I$(OBJ)\sanon -I$(OBJ) -I$(OBJ)\krb5 -I$(OBJ)\gssapi -Ikrb5 -Imech -Igssapi $(GCOPTS)

{sanon}.c{$(OBJ)\sanon}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\sanon\ -Fd$(OBJ)\sanon\ -I$(OBJ)\sanon -I$(OBJ) -I$(OBJ)\krb5 -I$(OBJ)\gssapi -Ikrb5 -Imech -Igssapi $(GCOPTS) -DASN1_LIB

{$(OBJ)\gssapi}.c{$(OBJ)\gssapi}.obj::
	$(C2OBJ_NP) -Fo$(OBJ)\gssapi\ -Fd$(OBJ)\gssapi\ -I$(OBJ)\gssapi $(GCOPTS)

{$(OBJ)}.c{$(OBJ)}.obj::
	$(C2OBJ_P) $(GCOPTS)

{gssapi}.h{$(INCDIR)\gssapi}.h:
	$(CP) $** $@

{$(OBJ)}.h{$(INCDIR)\gssapi}.h:
	$(CP) $** $@

LIBGSSAPI_LIBS=\
        $(LIBHEIMBASE)  \
	$(LIBROKEN)	\
	$(LIBHEIMDAL)	\
	$(LIBCOMERR)	\
	$(LIB_openssl_crypto)

LIBGSSAPI_SDKLIBS=\
	$(PTHREAD_LIB)  \
        Secur32.lib Shell32.lib Advapi32.lib

!ifndef STATICLIBS

RES=$(OBJ)\libgssapi-version.res

$(BINDIR)\gssapi.dll: $(libgssapi_OBJs) $(RES)
	$(DLLGUILINK_C) -implib:$(LIBGSSAPI)	\
		-out:$(BINDIR)\gssapi.dll	\
		-def:libgssapi-exports.def	\
		$(LIBGSSAPI_LIBS) $(RES) $(LIBGSSAPI_SDKLIBS) @<<
$(libgssapi_OBJs: =
)
<<
	$(DLLPREP_NODIST)

$(LIBGSSAPI): $(BINDIR)\gssapi.dll

clean::
	-$(RM) $(BINDIR)\gssapi.*

!else

$(LIBGSSAPI): $(libgssapi_OBJs)
	$(LIBCON_C) -OUT:$@ $(LIBGSSAPI_LIBS) $(LIBGSSAPI_SDKLIBS) @<<
$(libgssapi_OBJs: =
)
<<

!endif

all:: $(LIBGSSAPI)

clean::
	-$(RM) $(LIBGSSAPI)

prep:: mkdirs-gss

mkdirs-gss:
!if !exist($(OBJ)\krb5)
	$(MKDIR) $(OBJ)\krb5
!endif
!if !exist($(OBJ)\spnego)
	$(MKDIR) $(OBJ)\spnego
!endif
!if !exist($(OBJ)\sanon)
	$(MKDIR) $(OBJ)\sanon
!endif
!if !exist($(OBJ)\mech)
	$(MKDIR) $(OBJ)\mech
!endif
!if !exist($(OBJ)\gssapi)
	$(MKDIR) $(OBJ)\gssapi
!endif

clean::
	-$(RM) $(OBJ)\krb5\*.*
	-$(RM) $(OBJ)\spnego\*.*
	-$(RM) $(OBJ)\mech\*.*
	-$(RM) $(OBJ)\sanon\*.*
	-$(RM) $(OBJ)\gssapi\*.*

all-tools:: $(BINDIR)\gsstool.exe

$(BINDIR)\gsstool.exe: $(OBJ)\gsstool.obj $(OBJ)\gss-commands.obj $(LIBGSSAPI) $(LIBROKEN) $(LIBSL) $(LIBVERS)
	$(EXECONLINK)
	$(EXEPREP)

$(OBJ)\gss-commands.c $(OBJ)\gss-commands.h: gss-commands.in
	cd $(OBJ)
	$(CP) $(SRCDIR)\gss-commands.in gss-commands.in
	$(BINDIR)\slc.exe gss-commands.in
	cd $(SRCDIR)

!ifdef ELISP
# This macro invocation is used to update the libgssapi_OBJs
# definition below (generate-obj-macro is defined in maint.el):

(generate-obj-macro "libgssapi_OBJs"
	            (concat "\t$(OBJ)\\gkrb5_err.obj \\\n"
                            "\t$(OBJ)\\negoex_err.obj \\\n"
			    "\t$(OBJ)\\spnego\\asn1_spnego_asn1.obj \\\n"
			    "\t$(OBJ)\\gssapi\\asn1_gssapi_asn1.obj")
                    "krb5src" "mechsrc" "spnegosrc")
!endif

test-exports:
	$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libgssapi-exports.def

test:: test-exports


TEST_BINARIES=\
	$(OBJ)\test_oid.exe	\
	$(OBJ)\test_names.exe	\
	$(OBJ)\test_cfx.exe	\
	$(OBJ)\test_acquire_cred.exe	\
	$(OBJ)\test_cred.exe	\
	$(OBJ)\test_kcred.exe	\
	$(OBJ)\test_context.exe

$(OBJ)\test_oid.exe: $(OBJ)\test_oid.obj $(LIBGSSAPI) $(LIBROKEN)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\test_names.exe: $(OBJ)\test_names.obj $(LIBGSSAPI) $(LIBHEIMDAL) $(LIBROKEN) $(LIBVERS)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\test_cfx.exe: $(OBJ)\krb5\test_cfx.obj $(LIBHEIMDAL) $(LIBGSSAPI) $(LIBROKEN)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\test_acquire_cred.exe: $(OBJ)\test_acquire_cred.obj $(OBJ)\test_common.obj \
		$(LIBGSSAPI) $(LIBROKEN) $(LIBVERS)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\test_cred.exe: $(OBJ)\test_cred.obj $(LIBGSSAPI) $(LIBROKEN) $(LIBVERS)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\test_kcred.exe: $(OBJ)\test_kcred.obj $(LIBGSSAPI) $(LIBHEIMDAL)	\
		$(LIBROKEN) $(LIBVERS)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

$(OBJ)\test_context.exe: $(OBJ)\test_context.obj $(OBJ)\test_common.obj	\
		$(LIBGSSAPI) $(LIBHEIMDAL) $(LIBROKEN) $(LIBVERS)
	$(EXECONLINK)
	$(EXEPREP_NODIST)

{}.c{$(OBJ)}.obj::
	$(C2OBJ_P) -I$(OBJ)\krb5 -I$(OBJ) -I$(SRCDIR) -I$(SRCDIR)\gssapi

test-binaries: $(LIBGSSAPI) $(TEST_BINARIES)

run-test:
	cd $(OBJ)
	-test_oid
	-test_names
	-test_cfx
	-test_kcred
	cd $(SRCDIR)

test:: test-binaries run-test
