AR =		ar
ARFLAGS =	cr
BINEXT =
CC =		gcc
CFLAGS =	-Zmtd -mprobe -pipe -Wall -O2# -Wno-parentheses -Wno-import
CPPFLAGS =
DEFS =
INCLUDES =	-I..
INSTALL =	ginstall -c
INSTALL_DATA =	$(INSTALL) -m 644
INSTALL_PROGRAM =	$(INSTALL) -s
LDFLAGS =
LEX =		lex
LIBS =		-lgtk -lgdk -lglib -lgsbase -lobjcdll
LPR =		lpr -h
PROGRAMS =	$(OBJECTS:.o= )
RANLIB =	ar s
RM =		rm -f
YACC =		yacc

L_OBJECTS =	$(OBJECTS:.o=.obj)
LIBDEF =	$(TARGET:.a=.def)
L_TARGET =	$(TARGET:.a=.lib)
S_TARGET =	$(TARGET:.a=_s.a)
SL_TARGET =	$(TARGET:.a=_s.lib)
DYTARGET =	$(TARGET:.a=.dll)
DYLIBTOOL =	$(CC) -Zdll -Zmtd -Zomf

prefix =	/usr/local
bindir =	$(prefix)/bin
libdir =	$(prefix)/lib
dlldir =	$(prefix)/dll
incdir =	$(prefix)/include

COMPILE =	$(CC) -c $(CFLAGS) $(DEFS) $(INCLUDES) $(CPPFLAGS)

.SUFFIXES:	.m .cc
.c.o:
		$(COMPILE) $< -o $@
.m.o:
		$(COMPILE) $< -o $@
.cc.o:
		$(COMPILE) $< -o $@

SHELL =		/bin/sh

$(TARGET) :	$(OBJECTS) $(LIBDEF)
		emxomf $(OBJECTS)
		$(DYLIBTOOL) -o $(DYTARGET) $(LIBDEF) $(L_OBJECTS) $(LIBS)
		emximp -o $@ $(LIBDEF)
		emximp -o $(L_TARGET) $(LIBDEF)
		-$(RANLIB) $@

$(LIBDEF) :	$(OBJECTS)
		echo LIBRARY $(TARGET:.a= ) >$@
		echo DATA MULTIPLE NONSHARED READWRITE LOADONCALL >>$@
		echo CODE LOADONCALL >>$@
		echo EXPORTS >>$@
		emxexp -u $(OBJECTS) >>$@

$(S_TARGET) :	$(OBJECTS)
		$(AR) $(ARFLAGS) $@ $(OBJECTS)
		-$(RANLIB) $@
		emxomf $@

check :		$(TARGET) $(S_TARGET)

clean :
		$(RM) $(CLEAN) $(L_OBJECTS) $(TARGET) $(DYTARGET)
		$(RM) $(LIBDEF) $(L_TARGET) $(S_TARGET) $(SL_TARGET)

distclean :	clean

print :
		$(LPR) $(HEADERS) $(SOURCES)

install :	$(TARGET)
		$(INSTALL_DATA) $(TARGET) $(libdir)
		-$(RANLIB) $(libdir)/$(TARGET)
		$(INSTALL_DATA) $(L_TARGET) $(libdir)
		-$(INSTALL_DATA) $(S_TARGET) $(libdir)
		-$(RANLIB) $(libdir)/$(S_TARGET)
		-$(INSTALL_DATA) $(SL_TARGET) $(libdir)
		$(INSTALL) $(DYTARGET) $(dlldir)
		$(RM) -r $(incdir)/GToolKit
		mkdir $(incdir)/GToolKit
		$(INSTALL_DATA) $(HEADERS) $(incdir)/GToolKit

uninstall :
		$(RM) $(libdir)/$(TARGET) $(libdir)/$(L_TARGET)
		$(RM) $(libdir)/$(S_TARGET) $(libdir)/$(SL_TARGET)
		$(RM) $(dlldir)/$(DYTARGET)
		$(RM) -r $(incdir)/GToolKit

