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

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#### Start of system configuration section. ####

CC=gcc
LINT=lint

# Things you might add to DEFS:
# -DSTDC_HEADERS	If you have ANSI C headers and libraries.
# -DHAVE_UNISTD_H	If you have unistd.h.
# -DUSG			If you have System V/ANSI C string
#			and memory functions and headers.
# -D__CHAR_UNSIGNED__	If type `char' is unsigned.
#			gcc defines this automatically.
DEFS=	-DGREP -DSTDC_HEADERS -DHAVE_MEMCHR -DHAVE_STRERROR -DHAVE_GETPAGESIZE \
		-DHAVE_SYS_PARAM_H -DHAVE_STRING_H
# Standard flags for gcc 
CFLAGS=-O2
# use the following line if you want to use the runtime library of emx
# CFLAGS=-O2 -Zmtd
LDFLAGS=-s $(CFLAGS)

# Location of source files
srcdir=.
# Prefix for installed program, normally empty or `c:'.
binprefix=
# Prefix for installed man page, normally empty.
manprefix=

# Where to install executables.
bindir=/os2/apps
# Where to install emx.dll
dlldir=/os2/apps/dll
#### End of system configuration section. ####

SRCS=grep.c getopt.c regex.c dfa.c kwset.c obstack.c search.c
OBJS=grep.o getopt.o regex.o dfa.o kwset.o obstack.o search.o

.c.o:
	$(CC) $(CFLAGS) $(DEFS) -I$(srcdir) -c $<

all: grep.exe 

# For Saber C.
grep.load: $(SRCS)
	#load $(CFLAGS) $(DEFS) -I$(srcdir) (SRCS)

# For Lint.
grep.lint: $(SRCS)
	$(LINT) $(CFLAGS) $(DEFS) -I$(srcdir) $(SRCS)

check: grep.exe
	$(srcdir)/tests/check

install: grep.exe
	copy grep.exe $(BINDIR)/
	copy emx.dll $(DLLDIR)/

grep.exe: $(OBJS) $(LIBOBJS) $(ALLOCA)
	$(CC) $(LDFLAGS) -o grep.exe $(OBJS) $(LIBOBJS) $(LIBS) $(ALLOCA)

clean:
	if exist grep.exe del grep.exe
	if exist *.o del *.o 
	if exist khadafy.out del khadafy.out
	if exist core del core 

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