CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE)
SED = sed

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

.c.o:
	$(CC) $(CFLAGS) -c $(srcdir)/$*.c
@SHARED_RULE@

LIBDONE=DONE
LIB_SUBDIRS=.
INSTALLFILE = cp

LINTFLAGS=-uhvb 
LINTFILES= error_message.c et_name.c init_et.c com_err.c
LIBOBJS= error_message.o et_name.o init_et.o com_err.o
# for et_lex.lex.c include in error_table.y
LOCALINCLUDE=-I. -I$(srcdir)

FILES=	Makefile et_name.c error_message.c compile_et.c \
		et_lex.lex.l error_table.y init_et.c \
		com_err.c com_err.h \
		error_table.h mit-sipb-copyright.h \
		test_et.c test1.et test2.et \
		compiler.h internal.h \
		com_err.texinfo texinfo.tex
CFILES=	compile_et.c error_table.c error_message.c et_name.c \
	init_et.c com_err.c

SRCS=$(CFILES)

DEPLIBS=
SHLIB_LIBS=
SHLIB_LDFLAGS= $(LDFLAGS) @SHLIB_RPATH_DIRS@	
SHLIB_LIBDIRS= @SHLIB_LIBDIRS@
STEXT=@STEXT@

all:: all-$(WHAT)

all-windows: com_err.obj error_message.obj et_name.obj
	copy com_err.h $(BUILDTOP)\include

#
# what to build...
#

#
# rules
#
error_table.o: et_lex.lex.c

# solaris make loses on com_err.c but not on init_et.c, but this helps
com_err.o: com_err.c
#
# real entries...
#

all-unix:: compile_et includes shared
all-mac:: libcom_err.a
shared:
	 mkdir shared

# The real compile_et just isn't portable.  (But then again, anything using 
# lex and yacc isn't portable by definition.  :-(  )
#
#compile_et: compile_et.o error_table.o
#	$(CC) $(CFLAGS) -o $@ compile_et.o error_table.o $(LEXLIB) $(BSDLIB)
#
#install::
#	$(INSTALLPROG) compile_et $(DESTDIR)$(PROGDIR)/compile_et

compile_et: $(srcdir)/compile_et.sh $(srcdir)/config_script
	$(SHELL) $(srcdir)/config_script $(srcdir)/compile_et.sh \
		$(AWK) $(SED) > compile_et
	chmod 755 compile_et	

et_c.awk: $(srcdir)/et_c.awk
	$(CP) $(srcdir)/et_c.awk et_c.awk

et_h.awk: $(srcdir)/et_h.awk
	$(CP) $(srcdir)/et_h.awk et_h.awk

clean:: clean-$(WHAT)

clean-unix::
	$(RM) compile_et compile_et.o error_table.o 
clean-mac:: clean-unix

depend:: 

install:: com_err.h 
	$(INSTALL_DATA) $(srcdir)/com_err.h  $(DESTDIR)$(KRB5_INCDIR)/com_err.h

install:: mit-sipb-copyright.h
	$(INSTALL_DATA) $(srcdir)/mit-sipb-copyright.h $(DESTDIR)$(KRB5_INCDIR)/mit-sipb-copyright.h

#
#install:: compile_et.1
#	$(INSTALL_DATA) $(srcdir)/compile_et.1 $(DESTDIR)$(CLIENT_MANDIR)/compile_et.1
#

## install_library_target(com_err,$(LIBOBJS),$(LINTFILES),)


all-mac:: libcom_err.$(STEXT)

libcom_err.$(STEXT): $(LIBOBJS)
	$(ARCHIVE) $@ $(LIBOBJS)
	$(RANLIB) $@

DONE:: $(LIBOBJS)
	 $(RM) DONE
	 echo $(LIBOBJS) >DONE

clean-unix::
	$(RM) $(LIBOBJS)

clean-mac::
	$(RM) libcom_err.a
	$(RM) $(LIBOBJS)

install::
	$(INSTALL_DATA) libcom_err.a $(DESTDIR)$(KRB5_LIBDIR)/libcom_err.a
	$(RANLIB)    $(DESTDIR)$(KRB5_LIBDIR)/libcom_err.a
## 

clean-unix:: clean-files

clean-mac:: clean-files

clean-files::
	rm -f *~ \#* *.bak \
		*.otl *.aux *.toc *.PS *.dvi *.x9700 *.ps \
		*.cp *.fn *.ky *.log *.pg *.tp *.vr \
		*.o profiled/?*.o libcom_err.a libcom_err_p.a \
		com_err.o compile_et \
		et.ar TAGS y.tab.c lex.yy.c error_table.c \
		et_lex.lex.c \
		test1.h test1.c test2.h test2.c test_et \
		eddep makedep *.ln

clean-windows::
	$(RM) comerr.lib comerr.bak

com_err.ps : com_err.dvi
com_err.dvi: com_err.texinfo

libcom_err.o:	$(LIBOBJS)
	ld -r -s -o libcom_err.o $(LIBOBJS)
	chmod -x libcom_err.o


archive:	et.tar

TAGS:	et_name.c error_message.c compile_et.c error_table.c \
		lex.yy.c init_et.c
	etags et_name.c error_message.c compile_et.c \
		error_table.c init_et.c

depend::  et_lex.lex.c

