# generic AWT support for standard Java libraries
#
# Copyright (c) 1998
#	Transvirtual Technologies, Inc.  All rights reserved.
#
# See the file "lib-license.terms" for information on usage and redistribution 
# of this file. 

@VPATHOPT@=	@srcdir@@VPATHSEP@@srcdir@/X
srcdir=		@srcdir@
prefix=		@prefix@
exec_prefix=	@exec_prefix@
nativedir=	@nativedir@
INSTROOT=	@INSTROOT@
CC=		@CC@
LD=		@LD@
AR=		@AR@
RANLIB=		@RANLIB@
INCLUDES=	-I$(srcdir) -I../../../include -I$(srcdir)/../../../include -I../../../config -I$(srcdir)/../../../config -I$(srcdir)/X @X_INCLUDES@
CPPFLAGS=	@CPPFLAGS@
CFLAGS=		@CFLAGS@
ALL_CFLAGS=	$(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
INSTALL=	@INSTALL@
INSTALL_DATA=	@INSTALL_DATA@
MKDIR=		@MKDIR@
LN=		@LN_S@
TOUCH=		touch
DLLTOOL=	@DLLTOOL@
DEPTOOL=        @DEPTOOL@
PIC=		@PIC@
LDFLAGS=	@LIBSHARE@ @LDFLAGS@
LIBS=		@LIBS@
LDTAIL=		@LDTAIL@ @AWTLIB@
KVER=		@KVER@
OBJEXT=		@OBJEXT@
LIBEXT=		@LIBEXT@

LIBNAME=	libawt
LIB=		$(LIBNAME)$(LIBEXT)
LIBV=		$(LIBNAME)$(LIBEXT).$(KVER)

WRAPPER_CMD=	"s%^\(Java_[^(]*\).*$$%KAFFE_NATIVE(\1)%p"

OBJECT=

all:		$(LIB)

OBJECT=\
		X/tlk$(OBJEXT) \
		X/wnd$(OBJEXT) \
		X/evt$(OBJEXT) \
		X/gra$(OBJEXT) \
		X/fnt$(OBJEXT) \
		X/clr$(OBJEXT) \
		X/img$(OBJEXT) \
		X/imggif$(OBJEXT) \
		X/imgjpeg$(OBJEXT) \
		X/imgpng$(OBJEXT) \
		X/cbd$(OBJEXT)

DEPENDS=        $(OBJECT:@OBJEXT@=.d)
SOURCES=        $(OBJECT:@OBJEXT@=.c)

$(LIB):         .dir-stamp $(OBJECT) lib.exp external_wrappers.h
		@LINKLIB@

.dir-stamp:
		test -d X || $(MKDIR) X
		$(TOUCH) .dir-stamp

.c$(OBJEXT):
		$(CC) $(ALL_CFLAGS) -c $(PIC) $< -o $*.o

external_wrappers.h:	$(SOURCES)
		sed -n $(WRAPPER_CMD) $(srcdir)/X/*.c > external_wrappers.h

.SUFFIXES: .d

.c.d:           
		$(DEPTOOL) $(ALL_CFLAGS) $< > $@

clean:
		rm -f $(LIB) $(OBJECT) lib.exp external_wrappers.h
		rm -f $(DEPENDS) .depend 
		touch .depend

distclean:	clean
		rm -f Makefile .dir-stamp .depend
		-rmdir X

install:
		test -d $(INSTROOT)$(nativedir) || $(MKDIR) $(INSTROOT)$(nativedir)
		rm -f $(INSTROOT)$(nativedir)/$(LIB) $(INSTROOT)$(nativedir)/$(LIBV)
		$(INSTALL_DATA) $(LIB) $(INSTROOT)$(nativedir)/$(LIBV)
		$(LN) $(LIBV) $(INSTROOT)$(nativedir)/$(LIB)

derived-files:

depend:         .dir-stamp external_wrappers.h $(DEPENDS)
		rm -f .depend
		cat $(DEPENDS) > .depend

lib.exp:
		$(DLLTOOL) --def $(srcdir)/$(LIBNAME).def --output-exp lib.exp --output-lib $(LIBNAME).a --dllname $(LIB)
		touch lib.exp

@INC_DEPEND@
