#
# Top level Makefile Template for xosview.
#
#
# $Id$
#
include Makefile.config

OBJS = \
llist.o \
Host.o \
xwin.o \
Xrm.o \
defaultstring.o \
meter.o \
fieldmeter.o \
fieldmeterdecay.o \
fieldmetergraph.o \
bitfieldmeter.o \
bitmeter.o \
xosview.o \
snprintf.o \
main.o

CFILES := $(OBJS:.o=.cc)
DEPFILES := $(OBJS:%=.%.d)

INSTALL            = @INSTALL@

#-----------------------------------------------------------------------

all : meterlib xosview

defaultstring.cc: Xdefaults defresources.awk
	@AWK@ -f defresources.awk Xdefaults > defaultstring.cc

meterlib:
	cd @top_srcdir@/@host_dir@ && $(MAKE)

@top_srcdir@/@host_dir@/libmeter.a: meterlib

##  Also use LDFLAGS, which is inherited from the system.
xosview: $(OBJS) @top_srcdir@/@host_dir@/libmeter.a
	$(CXX) $(LDFLAGS) $(LFLAGS) -o xosview $(OBJS) $(LIBS)

##  If for some reason (such as permissions) you wish to change where
##    xosview is installed, re-run configure with
##    --prefix=<path>, which will change the next line.
PREFIX_TO_USE=@prefix@
BINDIR=$(PREFIX_TO_USE)/bin
MANDIR=$(PREFIX_TO_USE)/man/man1
XAPPLOADDIR=$(PREFIX_TO_USE)/lib/X11/app-defaults
PACKAGENAME=xosview-$(VERS)
DISTRIBDIR=@top_srcdir@/../$(PACKAGENAME)

##  These next lines look really ugly.  The echo statements are an
##    attempt to make the output look a little nicer.
install: xosview
	@echo "***  Installing executable..."
	@INSTALL_PROGRAM@ @INSTALL_ARGS@ xosview $(BINDIR)
	@echo "***  Installing application defaults..."
	@INSTALL_DATA@ Xdefaults $(XAPPLOADDIR)/XOsview
	@echo "***  Making sure $(MANDIR) exists..."
	@if [ ! -d $(MANDIR) ]; then \
	  echo "***  Making $(MANDIR)..."; \
	  mkdir $(MANDIR); \
	fi
	@echo "***  Installing man page..."
	@INSTALL_DATA@ xosview.1 $(MANDIR)

install-man:
	@echo "Use the 'install' target -- it installs the man page, too."
	@#@INSTALL_DATA@ xosview.1 $(MANDIR)

distrib: checksource distclean
	cd @top_srcdir@/..; rm -rf $(PACKAGENAME)
	mkdir $(DISTRIBDIR)
	(cd @top_srcdir@; tar cf - *) | (cd $(DISTRIBDIR); tar xf -)
	cd $(DISTRIBDIR); rm -rf `find . -name "CVS"`
	cd @top_srcdir@/..; tar cf $(PACKAGENAME).tar $(PACKAGENAME)
	gzip -f9 @top_srcdir@/../$(PACKAGENAME).tar
	cd @top_srcdir@/..; uuencode $(PACKAGENAME).tar.gz \
          $(PACKAGENAME).tar.gz > $(PACKAGENAME).tar.gz.uue

#  The next one is only used by bgrayson to set up the local
#  mirrors of the xosview distributions.
distrib-and-copy: distrib
	cp ../$(PACKAGENAME).tar.gz `echo ~bgrayson/public_html/xosview`
	scp ../$(PACKAGENAME).tar.gz omni:~bgrayson/public_html/xosview

clean :
	@echo "***  Cleaning..."
	@cd @host_dir@ && $(MAKE) clean
	@#  Only clean the config directory if it exists...
	@sh -c 'if [ -d config ]; then \
	    echo "***  Cleaning config directory..."; \
	    cd config && $(MAKE) clean; fi'
	rm -f xosview $(OBJS) $(DEPFILES) *~ defaultstring.cc

checksource:
	@#  Check that certain unsafe things aren't in any of the
	@#  code.
	@echo "***  Grep'ing for uses of strcmp, sprintf, strcat, strcmp,"
	@echo "     strcasecmp instead of safer strncmp, snprintf, strncat,"
	@echo "     strncmp, strncasecmp...."
	@#  If egrep finds no matches, it returns as if it is an
	@#  error.  Reverse that error code....
	@#  We also should not check snprintf.cc, which calls vsprintf.
	@sh -c 'egrep "strcmp|sprintf|strcat|strcmp|strcasecmp" \
		`echo *.cc *.h */*.cc */*.h | sed -e 's/snprintf.cc//'`; \
		if [ $$? != 0 ]; then exit 0; else \
		echo "***  Bad functions found -- error!"; exit 1; fi'
	@#  Also check that the version in the man page is the
	@#  same as the one in the Makefile, VERS.
	@echo "***  Checking for consistent version in config/Makefile.top.in and man page..."
	@#  This is a tricky little thing, since both 'make' and
	@#  'sh' try to deal with the embedded $3 for awk.
	@sh -c 'manver=`sed -ne 2p xosview.1 | awk \{print\ \\$$3\}`; \
	  manver2=`sed -ne 3p xosview.1 | awk \{print\ \\$$3\}`; \
	  if [ x"$$manver" != x"$$manver2" ]; then \
	    echo "!!!  Version mismatch in the man page file xosview.1:"; \
	    echo "     $$manver in SCCS header (line 2),"; \
	    echo "     $$manver2 in title (line 3)."; \
	    exit 1; \
	  fi; \
	  if [ x"$$manver" != x"$(VERS)" ]; then \
	    echo "!!!  Apparent version mismatch:  "; \
	    echo "      $(VERS) in config/Makefile.top.in,"; \
	    echo "      $$manver in man page file xosview.1"; exit 1; \
	  fi'

distclean: clean
	@#  Also check _all_ subdirs, not just the configured one, for
	@#  object files.
	@echo "***  Checking for any missed .o files..."
	@sh -c 'objects=`find . -name "*.o" -print`; if [ x"$$objects" != x ]; then \
	  echo "The following object files still need to be removed:";\
	  echo $$objects; exit 1; fi'
	@echo "***  Removing all Makefiles..."
	@rm -f Makefile Makefile.config Makefile.GNU.autodep \
           @host_dir@/Makefile config.cache config.log config.status


maintainer-clean: distclean
	rm -f configure

@AUTODEPEND@


syntax highlighted by Code2HTML, v. 0.9.1