# Makefile for GNU SED, a batch editor.
# Copyright (C) 1987, 1991 Free Software Foundation, Inc.
# 
# This file is part of GNU SED.
# 
# GNU SED 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.
# 
# GNU SED 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 GNU SED; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

SHELL = /bin/sh

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

srcdir = .
VPATH = .

CC = gcc -O3 -s
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

# Things you might add to DEFS:
# -DSTDC_HEADERS	If you have ANSI C headers and libraries.
# -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.
# -DNO_VFPRINTF		If you lack vprintf function (but have _doprnt).

DEFS = -DHAVE_BCOPY -DHAVE_MEMCPY -DSTDC_HEADERS -DHAVE_VPRINTF
LIBS = 

CFLAGS = -g -DREGEX_MALLOC=1
LDFLAGS = -g
extra_objs =

prefix = /usr/local
exec_prefix = $(prefix)

# Prefix for each installed program, normally empty or `g'.
binprefix = 

# Where to install the executable.
bindir = $(exec_prefix)/bin

#### End of system configuration section. ####

objs = sed.o utils.o regex.o getopt.o getopt1.o
srcs = sed.c utils.c regex.c getopt.c getopt1.c alloca.c

distfiles = COPYING COPYING.LIB ChangeLog README INSTALL Makefile.in \
 configure configure.in regex.h getopt.h $(srcs)

all_objs= $(objs) $(extra_objs)
all:	sed

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

sed:	$(all_objs)
	$(CC) -o $@ $(LDFLAGS) $(all_objs) $(LIBS)

sed.o regex.o: regex.h
sed.o getopt1.o: getopt.h

install:	all
	$(INSTALL_PROGRAM) sed $(bindir)/$(binprefix)sed

TAGS:	$(srcs)
	etags $(srcs)

clean:
	rm -f sed *.o core

mostlyclean: clean

distclean: clean
	rm -f Makefile config.status

realclean: distclean
	rm -f TAGS

dist:	$(distfiles)
	echo sed-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q sed.c` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(distfiles) `cat .fname`
	tar chZf `cat .fname`.tar.Z `cat .fname`
	rm -rf `cat .fname` .fname

dist.afs: $(distfiles)
	echo sed-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q sed.c` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	cd `cat .fname`; \
	for file in $(distfiles); do ln -s ../"$$file" .; done; \
	cd ..
	tar chf `cat .fname`.tar `cat .fname`
	gzip `cat .fname`.tar
	rm -rf `cat .fname` .fname

alloca.o : alloca.c 
