# Makefile for GNU grep
# Copyright (C) 1992 Free Software Foundation, Inc.

AWK=gawk

release:
	$(MAKE) grep.exe egrep.exe fgrep.exe gnugrep.dll gnuregex.dll \
	CC="gcc -Zomf -Zmtd -O -s" O=".obj" RELEASE=""
debug:
	$(MAKE) grep.exe CC="gcc -g" O=".o" DEBUG=""

RELEASE=release
DEBUG=debug

CFLAGS=-DGREP -DUSG -DSTDC_HEADERS -DHAVE_UNISTD_H -DHAVE_STRING_H \
	-DHAVE_STRERROR -DHAVE_MEMCHR

OBJ=grep$O getopt$O dfa$O kwset$O obstack$O search$O

.SUFFIXES: .c $O

.c$O:
	$(CC) $(CFLAGS) -I. -c $<

gnugrep.dll: $(OBJ) regex.lib gnugrep.def
	$(CC) -Zdll -o $@ $(OBJ) regex.lib gnugrep.def

gnuregex.dll: regex$O gnuregex.def
	$(CC) -Zdll -o $@ regex$O gnuregex.def

regex.lib: gnuregex.def
	emximp -o regex.imp gnuregex.def
	emximp -o $@ regex.imp
	rm -f regex.imp

egrep.exe fgrep.exe: grep.exe
	copy grep.exe $@

$(RELEASE)grep.exe: main$O grep.def
	$(CC) -o $@ main$O grep.def

$(RELEASE)grep$O: grep.c
	$(CC) $(CFLAGS) -I. -c -Dmain=grepmain grep.c

$(DEBUG)grep.exe: $(OBJ) regex$O grep.def
	$(CC) -o $@ $(OBJ) regex$O grep.def

clean:
	rm -f core *$O regex.lib check.done tmp.script khadafy.out

# Some header file dependencies that really ought to be automatically deduced.
grep$O search$O: grep.h
dfa$O search$O: dfa.h
kwset$O search$O: kwset.h
kwset$O obstack$O: obstack.h
regex$O search$O: regex.h
