###
### Makefile for GNU Interactive Tools
### $Id: Makefile.in,v 1.4 1998/03/10 05:12:11 tudor Exp $
###

###
### Copyright (C) 1993-1998 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.
###


PRODUCT		= "@PRODUCT@"
VERSION		= "@VERSION@"

HOST		= @HOST@
MAKE		= @MAKE@

srcdir		= @srcdir@
VPATH		= @srcdir@

prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= $(exec_prefix)/bin
libdir		= $(prefix)/lib/git
termdir		= $(prefix)/lib/git/term

SHELL		= /bin/sh
CFLAGS		= @CFLAGS@
LDFLAGS		= @LDFLAGS@
CPPFLAGS	= @CPPFLAGS@
DEFS		= @DEFS@ -D_GNU_SOURCE -DPREFIX=\"$(prefix)\" -I.. -I$(srcdir)
LIBS		= @LIBS@
CC		= @CC@
CPP		= @CPP@ $(CPPFLAGS) $(DEFS)
INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@


GIT_OBJS	= @GIT_OBJS@ tty.o window.o inputline.o status.o panel.o git.o\
		  configure.o misc.o signals.o xmalloc.o xstring.o xio.o xid.o\
		  xstack.o system.o fsusage.o getopt.o fnmatch.o title.o
GITWIPE_OBJS	= gitwipe.o
GITKEYS_OBJS	= gitkeys.o
GITPS_OBJS	= @GITPS_OBJS@ tty.o window.o configure.o misc.o gitps.o\
		  signals.o xmalloc.o xstring.o xio.o getopt.o
GITVIEW_OBJS	= @GITVIEW_OBJS@ tty.o window.o configure.o misc.o gitview.o\
		  signals.o xmalloc.o xstring.o xio.o getopt.o
GIT_BINS	= git gitps gitview gitkeys gitwipe
GIT_SCRIPTS	= gitmount gitaction gitunpack gitrgrep gitxgrep gitmkdirs\
		  .gitaction
GIT_RGREPS	= gitregrep gitrfgrep

###
### If you update this one, don't forget to update the hacks in
### configure.in.
###

GIT_PREFIX_DEP	= misc.o


###
### $(GIT_BINS) are considered "internal" targets and unfortunately
### are not affected by prefix changes.  If someone knows a better
### way of doing this, please let me know.  Right now a command like
### make git prefix=another-prefix will not rebuild misc.o.  --tudor
###

###
### Note that if you type `make prefix=other-prefix' and then `make'
### it will count as a prefix change, since we cannot change the
### prefix substituted in Makefile by `configure'.  Thus, if you
### decide to use a different prefix than the one choosed when
### `configure' has been invoked, either re-run `configure' with a
### different prefix or call make consistently with the same prefix
### all the time.
###


all: prefix-change $(GIT_BINS)

prefix-change:
	@echo $(prefix) > prefix.new
	@$(srcdir)/prefix.sh $(GIT_PREFIX_DEP)

install-dirs: prefix-change
	$(srcdir)/../mkinstalldirs $(bindir) $(libdir)

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

git: $(GIT_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(GIT_OBJS) $(LIBS)

gitps: $(GITPS_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(GITPS_OBJS) $(LIBS)

gitview: $(GITVIEW_OBJS)
	 $(CC) $(LDFLAGS) -o $@ $(GITVIEW_OBJS) $(LIBS)

gitkeys: $(GITKEYS_OBJS)
	 $(CC) $(LDFLAGS) -o $@ $(GITKEYS_OBJS) $(LIBS)

gitwipe: $(GITWIPE_OBJS)
	 $(CC) $(LDFLAGS) -o $@ $(GITWIPE_OBJS) $(LIBS)

install: all install-only

install-only: install-binaries install-scripts

install-binaries: prefix-change
	for i in $(GIT_BINS);\
	do\
	    rm -f $(bindir)/$$i;\
	    $(INSTALL_PROGRAM) $$i $(bindir)/$$i;\
	done

install-scripts: prefix-change
	for i in $(GIT_SCRIPTS);\
	do\
	    rm -f $(bindir)/$$i;\
	    $(INSTALL_PROGRAM) $(srcdir)/$$i $(bindir)/$$i;\
	done
	for i in $(GIT_RGREPS);\
	do\
	    rm -f $(bindir)/$$i;\
	    ln $(bindir)/gitrgrep $(bindir)/$$i;\
	done

install-strip: all install-stripped-binaries install-scripts

install-stripped-binaries: prefix-change
	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install-binaries

strip:
	-strip $(GIT_BINS)

dep:
	sed '/\#\#\# Dependencies/q' < Makefile.in > tmp_make
	(for i in *.c;\
	do\
	    $(CPP) -MM $$i;\
	done) >> tmp_make
	mv tmp_make Makefile.in

uninstall:
	-cd $(bindir) && rm -f $(GIT_BINS)
	-cd $(bindir) && rm -f $(GIT_SCRIPTS)
	-cd $(bindir) && rm -f $(GIT_RGREPS)

clean:
	-rm -f *.o *~ core* tutu* gogu* .gdb_history prefix.new $(GIT_BINS)

mostlyclean: clean

distclean: clean
	-rm -f Makefile config.status config.log config.cache
	-rm -f prefix prefix.new

realclean: distclean

tags:
	etags *.c *.h

etags:
	etags *.c *.h

### Dependencies
configure.o: configure.c file.h xstring.h stdc.h tty.h window.h \
 configure.h misc.h xtime.h
fnmatch.o: fnmatch.c fnmatch.h
fsusage.o: fsusage.c xio.h stat.h stdc.h fsusage.h
getopt.o: getopt.c
git.o: git.c file.h stdc.h xstring.h xmalloc.h getopt.h xio.h stat.h \
 tty.h window.h inputline.h status.h title.h panel.h xstack.h \
 configure.h signals.h system.h history.h tilde.h misc.h xtime.h
gitkeys.o: gitkeys.c stdc.h xio.h stat.h
gitps.o: gitps.c file.h stdc.h xstring.h xmalloc.h getopt.h tty.h \
 window.h configure.h tilde.h signals.h misc.h xtime.h
gitview.o: gitview.c file.h stdc.h xstring.h xmalloc.h getopt.h xio.h \
 stat.h window.h signals.h configure.h tty.h misc.h xtime.h tilde.h
gitwipe.o: gitwipe.c xtime.h file.h
history.o: history.c file.h xio.h stat.h stdc.h xstring.h history.h \
 xmalloc.h
inputline.o: inputline.c xstring.h stdc.h xmalloc.h configure.h \
 history.h tty.h window.h inputline.h tilde.h misc.h xtime.h
misc.o: misc.c xstring.h stdc.h xmalloc.h configure.h file.h tty.h \
 window.h misc.h xtime.h
panel.o: panel.c file.h xtime.h stdc.h xstring.h xmalloc.h xio.h \
 stat.h xid.h fsusage.h window.h status.h signals.h tty.h inputline.h \
 panel.h xstack.h tilde.h fnmatch.h configure.h system.h misc.h
signals.o: signals.c signals.h stdc.h tty.h window.h misc.h xtime.h
status.o: status.c xtime.h xstring.h stdc.h xmalloc.h window.h \
 status.h configure.h tty.h misc.h
system.o: system.c xmalloc.h stdc.h xstring.h xio.h stat.h tty.h \
 window.h signals.h inputline.h system.h misc.h xtime.h
tilde.o: tilde.c xmalloc.h stdc.h xstring.h tilde.h
title.o: title.c window.h stdc.h xmalloc.h xstring.h tty.h title.h \
 misc.h xtime.h
tty.o: tty.c file.h stdc.h xstring.h xmalloc.h xio.h stat.h tty.h \
 window.h signals.h misc.h xtime.h
window.o: window.c window.h stdc.h xmalloc.h tty.h
xid.o: xid.c xstring.h stdc.h xmalloc.h misc.h xtime.h xid.h
xio.o: xio.c xmalloc.h stdc.h xstring.h xio.h stat.h
xmalloc.o: xmalloc.c xmalloc.h stdc.h
xstack.o: xstack.c xmalloc.h stdc.h xstring.h xstack.h
xstring.o: xstring.c xmalloc.h stdc.h xstring.h
