CFLAGS=-g -DPURIFY
SRCS=delta.c get.c slib.c sccs.h purify.h purify.c diffs.c sids.c \
	ci.c co.c sccssh.c getopt.c rcs.c clean.c prs.c popen.c libdiff.c \
	sfiles.c what.c admin.c info.c smoosh.c rcs2sccs.perl regression \
	sccsids.c sccslog.c range.c
ALL=delta get ci co admin diffs clean prs what info sccssh sids rcs2sccs \
	smoosh sccsids sccslog
LINKS=edit sdiffs unedit
L=slib.o purify.o getopt.o popen.o libdiff.o sfiles.o
BIN=/usr/bitsccs

all: $(ALL)
	-/bin/rm -f edit unedit sdiffs
	ln get edit
	ln diffs sdiffs
	ln clean unedit

solaris:
	$(MAKE) LIBS=-lnsl 

rcs2sccs: rcs2sccs.perl
	/bin/rm -f rcs2sccs
	cp -p rcs2sccs.perl rcs2sccs
	chmod -w rcs2sccs

what: what.o $(L)
	$(CC) $(CFLAGS) what.o $(L) $(LIBS) -o what

sccssh: sccssh.o $(L)
	$(CC) $(CFLAGS) sccssh.o $(L) $(LIBS) -o sccssh

sccssh.o: sccssh.c delta.c get.c admin.c

sccslog: sccslog.o range.o $(L)
	$(CC) $(CFLAGS) sccslog.o range.o $(L) $(LIBS) -o sccslog

smoosh: smoosh.o $(L)
	$(CC) $(CFLAGS) smoosh.o $(L) $(LIBS) -o smoosh

sccsids: sccsids.o $(L)
	$(CC) $(CFLAGS) sccsids.o $(L) $(LIBS) -o sccsids

admin: admin.o $(L)
	$(CC) $(CFLAGS) admin.o $(L) $(LIBS) -o admin

parent: parent.o $(L)
	$(CC) $(CFLAGS) parent.o $(L) $(LIBS) -o parent

sids: sids.o $(L)
	$(CC) $(CFLAGS) sids.o $(L) $(LIBS) -o sids

co: co.o rcs.o $(L)
	$(CC) $(CFLAGS) co.o rcs.o $(L) $(LIBS) -o co

prs: prs.o range.o $(L)
	$(CC) $(CFLAGS) prs.o range.o $(L) $(LIBS) -o prs

get: get.o $(L)
	$(CC) $(CFLAGS) get.o $(L) $(LIBS) -o get

clean: clean.o $(L)
	$(CC) $(CFLAGS) clean.o $(L) $(LIBS) -o clean

info: info.o $(L)
	$(CC) $(CFLAGS) info.o $(L) $(LIBS) -o info

delta: delta.o $(L)
	$(CC) $(CFLAGS) delta.o $(L) $(LIBS) -o delta

ci: ci.o rcs.o $(L)
	$(CC) $(CFLAGS) ci.o rcs.o $(L) $(LIBS) -o ci

diffs: diffs.o $(L) range.o
	$(CC) $(CFLAGS) diffs.o $(L) range.o $(LIBS) -o diffs

diffs.o purify.o ci.o co.o get.o slib.o delta.o: sccs.h purify.h

nice cclean sccsclean: FRC
	/bin/rm -f *.o a.out core
	clean *

clobber: FRC
	/bin/rm -f *.o a.out core difflib.a $(LINKS) $(ALL)
	clean *

gprof:
	$(MAKE) "CFLAGS=-O -pg" LIBS=-lc_p all

debug:
	$(MAKE) "CFLAGS=-g -DPURIFY -DDEBUG" all

fast:
	$(MAKE) "CFLAGS=-g -DPURIFY" all

ansi:
	$(MAKE) "CFLAGS=-g -Wall -ansi -pedantic -DANSIC -DLINT" all

Wall:
	$(MAKE) "CFLAGS=-g -Wall -DLINT -DPURIFY" all

fullwarn:
	$(MAKE) "CFLAGS=-g -fullwarn -DLINT -DPURIFY" all

test: regression testfast
	regression && testfast -sccssh -sccs < SFILES

p:
	$(MAKE) LIBS=$(LIBS) "CFLAGS=-O -g -fomit-frame-pointer" all

production:
	/bin/rm -f *.o a.out core difflib.a $(LINKS) $(ALL)
	-@get -s $(SRCS)
	$(MAKE) LIBS=$(LIBS) "CFLAGS=-O2 -g -fexpensive-optimizations -fomit-frame-pointer" all
	$(MAKE) install

p2:
	/bin/rm -f *.o a.out core difflib.a $(LINKS) $(ALL)
	$(MAKE) "CFLAGS=-O2 -g -fexpensive-optimizations" all

perf:
	/bin/rm -f *.o a.out core difflib.a $(LINKS) $(ALL)
	$(MAKE) "CFLAGS=-O2 -pg -fno-inline -fexpensive-optimizations -DPROFILE" \
	    LIBS="-static -lc_p" all
	$(MAKE) install

iperf:
	/bin/rm -f *.o a.out core difflib.a $(LINKS) $(ALL)
	$(MAKE) "CFLAGS=-O2 -DFASTPURIFY -pg -fexpensive-optimizations -DPROFILE" \
	    LIBS="-static -lc_p" all
	$(MAKE) install

install: $(ALL)
	for i in rcs2sccs $(LINKS); do /bin/rm -f $(BIN)/$$i; done
	cp $(ALL) $(BIN)
	ln $(BIN)/get $(BIN)/edit
	ln $(BIN)/diffs $(BIN)/sdiffs
	ln $(BIN)/clean $(BIN)/unedit

uninstall: 
	for i in $(LINKS) $(ALL); do /bin/rm -f $(BIN)/$$i; done

src:
	@get -s $(SRCS)

tags: $(SRCS)
	ctags -nm *.[ch]

get-e:
	@get -se $(SRCS) Makefile

FRC:
