# Makefile for GNU CVS program.
# Do not use this makefile directly, but only from `../Makefile'.
# Copyright (C) 1986, 1988-1990 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.

# $CVSid: @(#)Makefile.in 1.19 94/09/29 $

SHELL = /bin/sh

srcdir     = @srcdir@
top_srcdir = @top_srcdir@
VPATH      = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@

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

# Where to put the system-wide .cvsrc file
libdir = $(prefix)/lib

# Where to put the manual pages.
mandir = $(prefix)/man

# Use cp if you don't have install.
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

LIBS = @LIBS@

SOURCES = add.c admin.c checkin.c checkout.c classify.c commit.c \
create_adm.c cvsrc.c diff.c entries.c find_names.c hash.c history.c ignore.c \
import.c lock.c log.c logmsg.c main.c myndbm.c rcs.c modules.c \
no_diff.c parseinfo.c patch.c recurse.c release.c remove.c repos.c rtag.c \
status.c tag.c update.c vers_ts.c version.c root.c subr.c server.c client.c
MSOURCES = mkmodules.c

OBJECTS = add.o admin.o checkin.o checkout.o classify.o commit.o \
create_adm.o cvsrc.o diff.o entries.o find_names.o hash.o history.o \
ignore.o import.o lock.o log.o logmsg.o main.o modules.o myndbm.o no_diff.o \
parseinfo.o patch.o rcs.o recurse.o release.o remove.o repos.o root.o \
rtag.o status.o tag.o update.o vers_ts.o server.o client.o

MOBJECTS = hash.o mkmodules.o myndbm.o

COMMON_OBJECTS = subr.o version.o

HEADERS = cvs.h rcs.h hash.h myndbm.h patchlevel.h \
	update.h server.h client.h

DISTFILES = Makefile.in $(HEADERS) $(SOURCES) $(MSOURCES)

PROGS = cvs mkmodules cvsbug

DEFS = @DEFS@ @includeopt@

CC	 = @CC@
CFLAGS = -g
CPPFLAGS=
LDFLAGS=

INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir)/lib
.c.o:
	$(CC) $(CPPFLAGS) $(INCLUDES) $(DEFS) $(CFLAGS) -c $<

all: $(PROGS)
.PHONY: all

saber_cvs:
	@cd ..; $(MAKE) saber SUBDIRS=src

lint:
	@cd ..; $(MAKE) lint SUBDIRS=src

# CYGNUS LOCAL: Do not depend upon installdirs
install:
	@for prog in $(PROGS); do \
	  echo Installing $$prog in $(bindir); \
	  $(INSTALL) $$prog $(bindir)/$$prog ; \
	done

installdirs:
	$(SHELL) $(top_srcdir)/mkinstalldirs $(bindir)

.PHONY: install installdirs

installcheck:
	RCSBIN=$(bindir) ; export RCSBIN ; $(SHELL) $(srcdir)/sanity.sh $(bindir)/cvs
.PHONY: installcheck

check: all
	if [ -d ../../rcs/src ] ; then \
		RCSBIN=`pwd`/../../rcs/src ; \
		export RCSBIN ; \
	fi ; \
	$(SHELL) $(srcdir)/sanity.sh `pwd`/cvs
.PHONY: check

# This is not yet ready to be part of the standard `make check'.
# We need to fix the problem with making sure we get the server we just built,
# for one thing.
remotecheck: all
	$(SHELL) $(srcdir)/sanity.sh -r `pwd`/cvs
.PHONY: remotecheck

tags: $(DISTFILES)
	ctags $(DISTFILES)

TAGS: $(DISTFILES)
	etags `for i in $(DISTFILES); do echo $(srcdir)/$$i; done`

ls:
	@echo $(DISTFILES)
.PHONY: ls

clean:
	/bin/rm -f $(PROGS) *.o core
.PHONY: clean

distclean: clean
	rm -f tags TAGS Makefile
.PHONY: distclean

realclean: distclean
.PHONY: realclean

dist:
	ln $(DISTFILES) ../`cat ../.fname`/src
.PHONY: dist

# Linking rules.

$(PROGS): ../lib/libcvs.a

cvs: $(OBJECTS) $(COMMON_OBJECTS)
	$(CC) $(OBJECTS) $(COMMON_OBJECTS) ../lib/libcvs.a $(LIBS) $(LDFLAGS) -o $@ 

xlint: $(SOURCES)
	files= ; \
	for i in $(SOURCES) ; do \
	  files="$$files $(srcdir)/$$i" ; \
	done ; \
	sh -c "lint $(DEFS) $(INCLUDES) $$files | grep -v \"possible pointer alignment problem\" \
	| grep -v \"argument closure unused\""

saber: $(SOURCES)
	# load $(CFLAGS) $(SOURCES)
	# load ../lib/libcvs.a $(LIBS)

mkmodules: $(MOBJECTS) $(COMMON_OBJECTS)
	$(CC) $(LDFLAGS) -o $@ $(MOBJECTS) $(COMMON_OBJECTS) ../lib/libcvs.a $(LIBS) $(LIBIBERTY)

cvsbug: cvsbug.sh
	cp $(srcdir)/cvsbug.sh cvsbug

# Compilation rules.

$(OBJECTS) $(COMMON_OBJECTS) mkmodules.o: $(HEADERS)

Makefile: Makefile.in
	cd .. ; $(SHELL) config.status

#../config.status: ../configure
#	cd .. ; $(SHELL) config.status --recheck

#../configure: ../configure.in
#	cd $(top_srcdir) ; autoconf
