include "/Developer/Makefiles/pbx_jamfiles/Jambase" ;

PROFILE_DIR = "$(SRCROOT)/../util/profile" ;
GSS_DIR = "$(SRCROOT)/../lib/gssapi" ;
INCLUDE_DIR = "$(SRCROOT)/../include" ;
ERROR_TABLES_DIR = "$(SRCROOT)/../lib/krb5/error_tables" ;

DEPENDS all : 
    "$(PROFILE_DIR)/profile.h"
    "$(INCLUDE_DIR)/adm_err.h"
    "$(INCLUDE_DIR)/asn1_err.h"
    "$(INCLUDE_DIR)/kdb5_err.h"
    "$(INCLUDE_DIR)/krb5_err.h"
    "$(INCLUDE_DIR)/kv5m_err.h"
    "$(INCLUDE_DIR)/krb5.h"
    "$(GSS_DIR)/gssapi.h"
    "$(INCLUDE_DIR)/autoconf.h"
;

DEPENDS install : all ;

Clean.Remove clean : 
    "$(PROFILE_DIR)/profile.h"
    "$(INCLUDE_DIR)/adm_err.h"
    "$(INCLUDE_DIR)/asn1_err.h"
    "$(INCLUDE_DIR)/kdb5_err.h"
    "$(INCLUDE_DIR)/krb5_err.h"
    "$(INCLUDE_DIR)/kv5m_err.h"
    "$(INCLUDE_DIR)/krb5.h"
    "$(GSS_DIR)/gssapi.h"
    "$(INCLUDE_DIR)/autoconf.h"
;

rule profile.h
{
    DEPENDS "$(1)" : "$(2)" ;
}

actions profile.h
{
    cat "$(2)" > "$(1)" ;
}

profile.h "$(PROFILE_DIR)/profile.h" : "$(PROFILE_DIR)/profile.hin" "$(PROFILE_DIR)/prof_err.h" ;

rule krb5.h
{
    DEPENDS "$(1)" : "$(2)" ;
    DEPENDS "$(1)" : "$(PREFIX)" ;
}

actions krb5.h
{
    echo "/* This is the prologue to krb5.h */" > "$(1)" ;
    echo "/* Unfortunately some of these defines are compiler dependent */" >> "$(1)" ;
    grep SIZEOF "$(SRCROOT)/GSSKerberosPrefix.h" >> "$(1)" ;
    grep HAVE_STDARG_H "$(SRCROOT)/GSSKerberosPrefix.h" >> "$(1)" ;
    grep HAVE_SYS_TYPES_H "$(SRCROOT)/GSSKerberosPrefix.h" >> "$(1)" ;
    cat "$(2)" >> "$(1)" ;
}

krb5.h "$(INCLUDE_DIR)/krb5.h" :
    "$(INCLUDE_DIR)/krb5.hin"
    "$(INCLUDE_DIR)/krb5_err.h"
    "$(INCLUDE_DIR)/kdb5_err.h"
    "$(INCLUDE_DIR)/kv5m_err.h"
    "$(INCLUDE_DIR)/asn1_err.h"
;

rule gssapi.h
{
    DEPENDS "$(1)" : "$(2)" ;
    DEPENDS "$(1)" : "$(PREFIX)" ;
}

actions gssapi.h
{
    echo "/* This is the prologue to gssapi.h */" > "$(1)" ;
    echo "/* It contains some choice pieces of autoconf.h */" >>  "$(1)" ;
    grep SIZEOF "$(SRCROOT)/GSSKerberosPrefix.h" >>  "$(1)" ;
    grep 'HAVE_.*_H' "$(SRCROOT)/GSSKerberosPrefix.h" >>  "$(1)" ;
    grep 'USE_.*_H' "$(SRCROOT)/GSSKerberosPrefix.h" >>  "$(1)" ;
    echo "/* End of gssapi.h prologue. */" >>  "$(1)" ;
    cat "$(2)" >>  "$(1)" ;
}

gssapi.h "$(GSS_DIR)/gssapi.h" :
    "$(GSS_DIR)/generic/gssapi.hin"
;

Cp "$(INCLUDE_DIR)/adm_err.h" : "$(ERROR_TABLES_DIR)/adm_err.h" ;
Cp "$(INCLUDE_DIR)/asn1_err.h" : "$(ERROR_TABLES_DIR)/asn1_err.h" ;
Cp "$(INCLUDE_DIR)/kdb5_err.h" : "$(ERROR_TABLES_DIR)/kdb5_err.h" ;
Cp "$(INCLUDE_DIR)/krb5_err.h" : "$(ERROR_TABLES_DIR)/krb5_err.h" ;
Cp "$(INCLUDE_DIR)/kv5m_err.h" : "$(ERROR_TABLES_DIR)/kv5m_err.h" ;

rule autoconf.h
{
}

actions autoconf.h
{
    touch "$(1)" ;
}

autoconf.h "$(INCLUDE_DIR)/autoconf.h" ;