##DOSBUILDTOP = ..
##DOS!include $(BUILDTOP)\config\windows.in

all:: all-$(WHAT)

all-unix:: krb5.h adm_err.h
all-mac::

all-windows::
	copy $(BUILDTOP)\util\et\com_err.h .
	copy $(BUILDTOP)\util\profile\profile.h .
	if not exist gssapi\nul mkdir gssapi
	copy $(BUILDTOP)\lib\gssapi\generic\gssapi.h gssapi
	copy $(BUILDTOP)\lib\gssapi\generic\gssapi_generic.h gssapi
	cd krb5
	@echo Making in include\krb5
	-$(MAKE) -$(MFLAGS) LIBCMD=$(LIBCMD)
	cd ..

krb5-pro.h: krb5/autoconf.h
	echo "/* This is the prologue to krb5.h */" > krb5-pro.h
	echo "/* Unfortunately some of these defines are compiler dependent */" >> krb5-pro.h
	grep SIZEOF krb5/autoconf.h >> krb5-pro.h
	grep HAVE_STDARG_H krb5/autoconf.h >> krb5-pro.h
	echo "/* End of prologue section */"  >> krb5-pro.h

krb5.h: krb5-pro.h $(srcdir)/krb5.hin krb5_err.h kdb5_err.h kv5m_err.h \
		asn1_err.h
	cat krb5-pro.h $(srcdir)/krb5.hin krb5_err.h kdb5_err.h kv5m_err.h \
		asn1_err.h > krb5.h

#
# Build the error table include files:
# adm_err.h asn1_err.h kdb5_err.h krb5_err.h kv5m_err.h

adm_err.h: $(SRCTOP)/lib/krb5/error_tables/adm_err.et
	$(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$*.h	\
		$(SRCTOP)/lib/krb5/error_tables/adm_err.et

asn1_err.h: $(SRCTOP)/lib/krb5/error_tables/asn1_err.et
	$(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$*.h	\
		$(SRCTOP)/lib/krb5/error_tables/asn1_err.et

kdb5_err.h: $(SRCTOP)/lib/krb5/error_tables/kdb5_err.et
	$(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$*.h	\
		$(SRCTOP)/lib/krb5/error_tables/kdb5_err.et

krb5_err.h: $(SRCTOP)/lib/krb5/error_tables/krb5_err.et
	$(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$*.h	\
		 $(SRCTOP)/lib/krb5/error_tables/krb5_err.et

kv5m_err.h: $(SRCTOP)/lib/krb5/error_tables/kv5m_err.et
	$(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$*.h	\
		$(SRCTOP)/lib/krb5/error_tables/kv5m_err.et

clean:: clean-$(WHAT)

clean-unix::
	$(RM) krb5.h krb5_err.h kdb5_err.h kv5m_err.h asn1_err.h adm_err.h

clean-mac::

clean-windows::
	$(RM) com_err.h
	$(RM) gssapi\gssapi.h gssapi\gssapi_generic.h
	if exist gssapi\nul rmdir gssapi
	cd krb5
	@echo Making clean in include\krb5
	-$(MAKE) -$(MFLAGS) clean
	cd ..
	@echo Making clean locally

install:: krb5.h k5-int.h
	$(INSTALL_DATA) $(C)krb5.h $(DESTDIR)$(KRB5_INCDIR)$(S)krb5.h
	$(INSTALL_DATA) $(srcdir)$(S)k5-int.h \
		$(DESTDIR)$(KRB5_INCDIR)$(S)k5-int.h
