# Makefile for NDir
# Copyright (c) 1998, 1999 Michael Weers
#------------------------------------
# The installation directory prefix: Files will be installed in 
# some of its subdirectories

prefix= /usr/local
#prefix=$(HOME)

# Install with multi machine type option (n/y for no/yes, usually no)

multi_machine_mode= n 

#------------------------------------
#uncomment next line if you are using the GNU C++ standard library ver. 2.7.x
#GLOBAL_FLAGS += -DGNU_CPPSTDLIB_VER27
#------------------------------------
# Uncomment next line if using EGCS as compiler
#GLOBAL_FLAGS += -fno-rtti -fno-exceptions
#------------------------------------
export GLOBAL_FLAGS +=  -Wall -O2
#export GLOBAL_FLAGS +=  -g
#====================================
version= 0.8.2
package_revision= 1
#------------------------------------
machine= $(shell uname -m)
#------------------------------------
# directory prefix, for executable's directories
exec_prefix= $(prefix)
# general executables' directory
bindir= $(exec_prefix)/bin
# man page directory
mandir= $(prefix)/man

# directory for machine-dependend files (executables)
ifeq ($(multi_machine_mode),y)
binexecdir=$(bindir)/$(machine)
else
binexecdir=$(bindir)
endif
#------------------------------------
distname= NDir-$(version)-$(package_revision)
distdir= NDir-$(version)
distfiles= README INSTALL VERSION COPYING ChangeLog "To do.html" Makefile ndir.1 lv.1 lw.1 src bin 
#------------------------------------

.PHONY : compile clean distclean doc dist install uninstall install_alt print_defines

compile :
	$(MAKE) -C src ;

clean : 
	$(MAKE) clean -C src

distclean : clean
	rm -f *~

doc :
	$(MAKE) doc -C src 

dist : distclean doc
	echo $(version) > VERSION
	rm -rf $(distdir)
	mkdir $(distdir)
	cp -R $(distfiles) $(distdir)/
	tar czf $(distname).tar.gz $(distdir)
	rm -rf $(distdir)

install :
ifeq ($(multi_machine_mode),y)
	@echo "Installing NDir with multi machine type mode to $(binexecdir)"
else
	@echo "Installing NDir to $(bindir)"
endif
	mkdir -p $(bindir) $(binexecdir) $(mandir)/man1
	cp src/ndir $(binexecdir)/
	cp bin/uninstall-ndir $(bindir)/  
	cp *.1 $(mandir)/man1/
	cd $(bindir) ; chmod 744 uninstall-ndir 
	cd $(binexecdir) ; strip ndir ; ln -f -s ndir lw ; ln -f -s ndir lv ;
             
uninstall :
	echo "Please run 'uninstall-ndir' from the installation directory."

print_defines :
	$(CXX) -E -dM src/dir.cpp
