#	$Header: /cvsroot/posix2/posix2/libext/libz/Makefile,v 1.1 2000/05/02 07:39:26 veit Exp $

# Generic Makefile template
# programming parts:    Alexander Mai    Version 19990917
# requires GNU make 

# tools section
AR     = ar rc
AWK    = gawk
CC     = gcc
CP     = cp
CTAGS  = ctags
DVIPS  = dvips
EMXEXP = emxexp
EMXIMP = emximp
EMXOMF = emxomf
IPFC   = ipfc
LATEX  = latex
LD     = gcc
LEX    = flex
LN     = cp
RANLIB = ar s
RC     = rc
RM     = rm -f
SED    = sed
TEX    = latex
YACC   = bison

INC = ../include/

# flags section
DEBUG     = -g -O2 -mpentium -D_DEBUG -DDEBUG 

WFLAGS   = -Wall -W -Wmissing-prototypes -Wshadow -Wcast-align \
   -Wpointer-arith -Winline -Wmissing-declarations  \
   -Wstrict-prototypes -Wconversion
 
DEFINES  = -D__ST_MT_ERRNO__ -Zmt -DHAVE_UNISTD_H -DHAVE_STRERROR \
 -DHAVE_MEMCPY -DOS2

INCLUDE  = -I. -I$(INC) 
CFLAGS  = $(DEFINES) $(DEBUG) $(WFLAGS) $(INCLUDE)

LIB=	z
HDRS=	$(INC)zconf.h $(INC)zlib.h
SRCS=	adler32.c compress.c crc32.c deflate.c gzio.c infblock.c \
	infcodes.c inffast.c inflate.c inftrees.c infutil.c trees.c \
	uncompr.c zutil.c


# Has to be adapted to the used suffix(es)
OBJS     = $(SRCS:.c=.o) 

.SUFFIXES:
.SUFFIXES: .a .asm .aux .c .C .cpp .cxx .def .dll .dvi .exe .fl .h .H .hlp \
           .inf .ipf .lib .log .map .o .obj .rc .res .tex .toc .uid .uil
.PHONY: clean default distclean veryclean


default: all

all: $(LIB).a exp

$(LIB).a: $(OBJS)
	$(RM) $@
	$(AR) $@ $^
	$(RANLIB) $@
	$(EMXOMF) -l -s -o $(LIB).lib $@

# Generic part: rules

%.a: %.def
	$(EMXIMP) -o $@ $<

%.c : %.l
	$(LEX) -o $@ $<

%.dll: %.lib %.def
	$(CC) -o $@ $< $(DLLFLAGS)

%.exe: %.obj
	$(CC) -Zomf -o $@ $^ $(LDFLAGS)

%.exe: %.o
	$(CC) -o $@ $^ $(LDFLAGS)

%.lib: %.a
	$(EMXOMF) $<

%.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@

%.o : %.C
	$(CC) $(CFLAGS) -c $< -o $@

%.o : %.cpp
	$(CC) $(CFLAGS) -c $< -o $@

%.o : %.cxx
	$(CC) $(CFLAGS) -c $< -o $@

%.obj : %.c
	$(CC) $(CFLAGS) -Zomf -c $< -o $@

%.obj : %.C
	$(CC) $(CFLAGS) -Zomf -c $< -o $@

%.obj : %.cpp
	$(CC) $(CFLAGS) -Zomf -c $< -o $@

%.obj : %.cxx
	$(CC) $(CFLAGS) -Zomf -c $< -o $@

#
# not-programming related
#
exp: $(LIB).a
	$(EMXEXP) -u -o $(LIB).a > exp.z

#
# Common maintainance targets
#
clean:
	$(RM) *.o *.obj *.res *.aux *.log *.toc core *.a *.lib dummy

veryclean: clean
	$(RM) *.exe *.dll exp.z

tags:
	$(CTAGS) *.c

# DO NOT DELETE THIS LINE -- make  depend  depends  on it.

$(OBJS): $(HDRS)