# Makefile for GNU DIFF
# Copyright (C) 1988, 1989 Free Software Foundation, Inc.

# This file is part of GNU DIFF.

# GNU DIFF 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 1, or (at your option)
# any later version.
# 
# GNU DIFF 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 DIFF; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */


# You can compile this with ordinary cc as well,
# but gcc makes it faster.
# Also, gcc supports -O and -g together.
CC=gcc -O
CFLAGS = -g
INSTALL = install

# On system V, enable these three lines:
# CFLAGS = -g -DUSG
# LIBS = -lPW
# INSTALL = cp

bindir=/usr/local/bin
prefix=

# All source files
srcs=diff.c analyze.c io.c context.c ed.c normal.c util.c dir.c diff.h \
	regex.c regex.h limits.h diff3.c
# Object files for diff only.
objs=diff.o analyze.o io.o context.o ed.o normal.o util.o dir.o regex.o
tapefiles = $(srcs) README diagmeet.note Makefile COPYING

all: diff diff3

diff3:	diff3.o
	$(CC) -o diff3 $(CFLAGS) $(LDFLAGS) diff3.o $(LIBS)

diff: $(objs)
	$(CC) -o diff $(CFLAGS) $(LDFLAGS) $(objs) $(LIBS)

$(objs): diff.h

context.o diff.o: regex.h

diff3.o: diff3.c
	$(CC) -c $(CFLAGS) -DDIFF_PROGRAM=\"$(bindir)/diff\" diff3.c

clean:
	rm -f *.o diff diff3 diff.tar diff.tar.Z

install: install-diff install-diff3

install-diff: $(prefix)$(bindir)/diff

$(prefix)$(bindir)/diff: diff
	$(INSTALL) diff $(prefix)$(bindir)/diff

install-diff3: $(prefix)$(bindir)/diff3

$(prefix)$(bindir)/diff3: diff3
	$(INSTALL) diff3 $(prefix)$(bindir)/diff3

diff.tar: $(tapefiles)
	mkdir tmp
	mkdir tmp/diff
	ln $(tapefiles) tmp/diff
	cd tmp; tar cf ../diff.tar diff
	rm -rf tmp

diff.tar.Z: diff.tar
	compress < diff.tar > diff.tar.Z
