#######################################################################
# This file is part of the argtable2 library.
# Copyright (C) 1998,1999,2000,2001,2003,2004 Stewart Heitmann
# sheitmann@users.sourceforge.net
#
# The argtable2 library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This software 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#######################################################################
@SET_MAKE@
SHELL       = /bin/sh

.SUFFIXES:
.SUFFIXES: .c .o

#these variables may be overridden when invoking MAKE (eg: make all prefix=$HOME)
prefix      ?= @prefix@
exec_prefix ?= @exec_prefix@
libdir      ?= @libdir@
includedir  ?= @includedir@
mandir      ?= @mandir@/man3
docdir      ?= $(prefix)/share/doc/argtable2
exampledir  ?= $(prefix)/share/doc/argtable2/example


all:
	cd src; $(MAKE) all
    
example:
	cd example; $(MAKE) all

check:
	cd tests; $(MAKE) check

installcheck:
	cd tests; $(MAKE) installcheck

install: all
	@INSTALL@ -d $(includedir)
	@INSTALL@ -d $(libdir)
	@INSTALL@ -d $(mandir)
	@INSTALL@ -d $(docdir)
	@INSTALL@ -d $(exampledir)
	@INSTALL@ -m 644 src/argtable2.h            $(includedir)
	@INSTALL@ -m 644 src/libargtable2.a         $(libdir)
	@INSTALL@ -m 644 src/@LIBDYNAMIC@        $(libdir)/@LIBDYNAMICVERS@
	@INSTALL@ -m 644 doc/*.html                 $(docdir)
	@INSTALL@ -m 644 doc/*.ps                   $(docdir)
	@INSTALL@ -m 644 doc/*.pdf                  $(docdir)
	@INSTALL@ -m 644 doc/argtable2.3            $(mandir)
	@INSTALL@ -m 644 example/*.c                $(exampledir)
	@INSTALL@ -m 644 example/Makefile           $(exampledir)
	@INSTALL@ -m 644 example/README.txt         $(exampledir)
	@STRIP@ -S $(libdir)/libargtable2.a $(libdir)/@LIBDYNAMICVERS@
	@RM@ -f $(libdir)/@LIBDYNAMIC@
	cd $(libdir) ; @LN@ -s @LIBDYNAMICVERS@ @LIBDYNAMIC@

uninstall:
	@RM@ -f $(includedir)/argtable2.h
	@RM@ -f $(libdir)/libargtable2.a
	@RM@ -rf $(docdir)
	@RM@ -f $(mandir)/argtable2.3

clean:
	@RM@ -f core *.core core.* *.o *~
	cd src; $(MAKE) clean
	cd example; $(MAKE) clean
	cd tests; $(MAKE) clean

distclean: clean
	@RM@ -f Makefile config.h config.status config.cache config.log
	@RM@ -rf autom4te.cache
	cd src; $(MAKE) distclean
	cd example; $(MAKE) distclean
	cd tests; $(MAKE) distclean

dist: distclean
	tar -cvzf ../argtable-2.@PACKAGE_VERSION@.tar.gz -C .. --exclude CVS argtable2

# make rpm can only be done on Linux (as root user)
rpm: distclean
	tar -cvzf /usr/src/redhat/SOURCES/argtable-2.@PACKAGE_VERSION@.tar.gz -C .. --exclude CVS argtable2
	rpm -ba argtable.spec --clean
	cp /usr/src/redhat/SRPMS/argtable-2.@PACKAGE_VERSION@-?.src.rpm ..
	cp /usr/src/redhat/RPMS/*/argtable-2.@PACKAGE_VERSION@-?.*.rpm ..     
