# Generated automatically from Makefile.in by configure.
# $Id: Makefile.in,v 1.7 2001/05/05 20:19:33 rocky Exp $
# Makefile for Motif version of xps.
#
#  Copyright (C) 1998-2001 Rocky Bernstein
#  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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#######################################
# Set up various variables variously:
#######################################
SHELL = /bin/sh

PACKAGE  = xps

srcdir   = .

# Files making up this package
OBJS     = $(PACKAGE).o common.o xstuff.o xpsplay.o callback.o loadavg.o \
	   MenuSupport.o askquestion.o process.o getpixelbyname.o dialog.o
OS_SRC   = $(PACKAGE).c loadavg.c 
GEN_SRC  = common.c xstuff.c xpsplay.c callback.c MenuSupport.c askquestion.c \
	   process.c getpixelbyname.c dialog.c
SRC      = $(OS_SRC) $(GEN_SRC)
DOCS     = docs/$(PACKAGE).man docs/$(PACKAGE).html

# Stuff for needed for "make install"
prefix          = /opt/platform/X11
INSTALL         = /opt/platform/bin/install -c
INSTALL_DATA    = ${INSTALL} -m 644
mkinstalldirs   = $(SHELL) ./mkinstalldirs
XAPPLOADDIR     = /opt/platform/X11/lib/X11/app-defaults
exec_prefix     = ${prefix}
mandir          = ${prefix}/man/man$(MANSUFFIX)
bindir          = ${exec_prefix}/bin
KMEM_GROUP      = 

# Stuff for X 
X_CFLAGS	=  -I/opt/platform/X11/include
X_LIBS		=  -L/opt/platform/X11/lib -R/opt/platform/X11/lib -lXm -lXt -lXext -lX11 -lXmu
X_PRE_LIBS	=  -lSM -lICE
X_EXTRA_LIBS	= -lsocket  -lnsl

# Stuff for compiling and loading C programs.
CFLAGS          = -O2 -g
CC              = gcc
INCLUDES        = -I.  -I/usr/dt/share/include -I/usr/openwin/share/include
LIBS            = -lkvm -lelf  -lkstat
ALL_CFLAGS      = $(CFLAGS) $(X_CFLAGS) $(INCLUDES) 
ALL_LIBS	= $(LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS)

PERL 		= perl

# Things for building a distribution
LN_S	        = ln -s
TAR             = tar   # Need to use GNU tar!
COMPRESS        = gzip --verbose --best
COMPRESS_EXT    = gz

#########################################################################
# Just dependencies.
#########################################################################

# THIS SHOULD BE THE FIRST TARGET!
all: help-text $(PACKAGE) Makefile configure
# Remove all implicit rules
.SUFFIXES:
# These are the implict rules we've got here.
.SUFFIXES: .c .o

# These are the targets below for which the target isn't a file.
.PHONY:	all docs clean distclean maintainer-clean dist depend \
install install.app install-nosuid install-suid install-sgid install.man 

# Build all forms of documentation: manual-pages and HTML
docs: 
	echo "Making documentation (manual page and HTML)"; \
	(cd docs && $(MAKE) all) 

#########################################################################
# Enough. Makefile RULES!
#########################################################################
$(PACKAGE): $(OBJS)
	$(CC) $(DEBUG) -o $@ $(OBJS) $(ALL_LIBS)

.c.o:
	$(CC) -c $(ALL_CFLAGS) $<

# What we need to do to install this on your system.
install: install-nosuid install.man install.app

# Try to install as suid so we can see info about all processes.
# However that may fail if installing across mounted filesystems, 
# so revert to non-suid if that fails.
install-suid: $(PACKAGE) 
	@if [ -d $(bindir) ]; then set +x; \
	else (set -x; $(mkinstalldirs) $(bindir)); fi
	@if [ -w /bin/su ]; then set -x; \
	$(INSTALL) -m 4775 -o root $(PACKAGE) $(bindir) || \
	$(INSTALL) -m 775 $(PACKAGE) $(bindir); \
	else /bin/echo "You are not root, not installing as suid."; \
	$(INSTALL) -m 775 -o root $(PACKAGE) $(bindir);  fi

# Install, need to sgid.
install-sgid: $(PACKAGE) 
	@if [ -d $(bindir) ]; then set +x; \
	else (set -x; $(mkinstalldirs) $(bindir)); fi
	@if [ -w /usr/bin/su ]; then set -x; \
	$(INSTALL) -m 2755 -o root -g $(KMEM_GROUP) $(PACKAGE) $(bindir) || \
	$(INSTALL) -m 775 $(PACKAGE) $(bindir); \
	else /bin/echo "You are not root, not installing as sgid."; \
	$(INSTALL) -m 775 -o root $(PACKAGE) $(bindir);  fi

# Install, but don't need to suid to see info about all processes.
install-nosuid: $(PACKAGE) 
	@if [ -d $(bindir) ]; then set +x; \
	else (set -x; $(mkinstalldirs) $(bindir)); fi
	$(INSTALL) -m 755 $(PACKAGE) $(bindir)

# Install the system-default X resources for this program.
install.app: Xps
	@if [ -d $(XAPPLOADDIR) ]; then set +x; \
	else (set -x; $(mkinstalldirs) $(XAPPLOADDIR)); fi
	$(INSTALL) $< $(XAPPLOADDIR)

# Install the manual page for this program.
install.man: 
	(cd docs && $(MAKE) install.man)

# What we need to do to get this off your system.
uninstall: 
	if [ -f $(bindir)/$(PACKAGE) ] ; then \
	  rm $(bindir)/$(PACKAGE); \
	fi ;\
	if [ -f $(XAPPLOADDIR)/Xps ] ; then \
	  rm $(XAPPLOADDIR)/Xps; \
	fi ;\
	(cd docs && $(MAKE) uninstall)

# Clean enough for another rebuild on the same platform. 
clean:
	rm -f $(OBJS) $(PACKAGE) getloadavg Makefile.bak

# Clean enough for another rebuild on *any* platform. 
distclean: clean
	rm -f os.h $(PACKAGE).c loadavg.h loadavg.c sigmap.h \
	      config.h config.cache 

# Clean to remove all unneeded files and anything that can be regenerated.
maintainer-clean: distclean
	@echo "This command is intended for maintainers to use;"
	rm -f */sigmap.h $(DOCS) \
	config.status configure Xps *~ */*~ */*.o help/*.h 

# From xkeycaps Imakefile by Jamie Zawinski <jwz@netscape.com>
#  This really makes me sick... 
dist: distclean $(GEN_SRC) $(DOCS) configure Xps Xps.ad.h
	@NAME=`sed -n							    \
  's/.*["]\([0-9]\.[0-9][0-9]*\).*/xps-\1/p' version.h` ;                   \
  rm -f $$NAME ; $(LN_S) . $$NAME ;					    \
  touch configure.stamp ;                                                   \
  FILES= ;								    \
  echo creating tar file $${NAME}.tar.$(COMPRESS_EXT)... ;		    \
  $(TAR) -vpcf -                                                            \
    `cat MANIFEST $$FILES | sed "s|^|$$NAME/|g; s| | $$NAME/|g" `	    \
   | $(COMPRESS) > $${NAME}.tar.$(COMPRESS_EXT) ;			    \
  rm $$NAME

# The help directory contains text that is used in help buttons.
help-text: 
	echo "Making all in help"; \
	(cd help && $(MAKE) all) 

$(PACKAGE).c loadavg.c loadavg.h os.h:
	$(srcdir)/configure

# Stand alone program that can be use for testing that the loadavg.c
# program works; especially used after porting to a new platform.
getloadavg: loadavg.c loadavg.h
	$(CC) $(CFLAGS) -DSTANDALONE $(LIBS) $< -o $@

Xps.ad.h: Xps.ad
	$(srcdir)/ad2c $< >$@

Xps: Xps.ad
#	echo '!! Uncomment only those entries below that you wish to change' >$@
#	cat $< | sed -e "s/^/\!/" >> $@
	cat $<  >> $@

configure: configure.in 
	cd ${srcdir} && autoconf
     
config.h: config.h.in config.cache
	$(srcdir)/config.status
     
Makefile: Makefile.in
	$(srcdir)/config.status
	-make depend

# The list of signals used in the signal list for sending a kill signal
# This is platform/release-specific, but we should provide a default
# set for each platform.
sigmap.h: 
	$(PERL) makesig.pl > $@

# Update dependencies for object (.o files) on their headers (.h files)
# The leading dash indicates that errors in this should be ignored
# since this makefile already has a default set of dependencies.
depend: 
	-makedepend $(SRC) $(INCLUDES)

#########################################################################
# DO NOT DELETE THIS LINE -- make depend depends on it.
#########################################################################
# File dependencies.
#
# I want to have the best of both worlds. We want automatic file
# dependency generation, but I don't want to have to require folks
# having makedepend installed and having that run. So we have a depend
# target as well as list dependency below "by" hand.  Well, actually
# the below is with the aid of makedepend but I've removed the
# system-installed files, such as /usr/include and .../X11 and .../Xm 
# headers.
#
# The multiple lines and format below is to make it easier to compare
# against the file when run against make depend.
#########################################################################
xps.o: config.h os.h 
xps.o: common.h xpstypes.h
xps.o: xstuff.h xps.h loadavg.h askquestion.h

loadavg.o: config.h os.h 
loadavg.o: loadavg.h

common.o: config.h os.h 
common.o: xstuff.h xpstypes.h
common.o: xps.h xpsplay.h common.h version.h loadavg.h

xstuff.o: config.h os.h
xstuff.o: common.h dialog.h xps.h process.h callback.h
xstuff.o: xstuff.h xpstypes.h
xstuff.o: version.h MenuSupport.h askquestion.h getpixelbyname.h
xstuff.o: help/interval.h help/debug.h
xstuff.o: help/watch_user.h help/user_color.h Xps.ad.h help/general.h
xstuff.o: help/button.h help/process_tree.h help/keyfns.h help/keymouse.h
xstuff.o: help/warranty.h
xstuff.o: help/pscmdline.h

xpsplay.o: xpsplay.h

callback.o: config.h os.h 
callback.o: xstuff.h
callback.o: callback.h common.h askquestion.h

process.o: config.h os.h 
process.o: xstuff.h xpstypes.h
process.o: common.h dialog.h process.h sigmap.h
process.o: askquestion.h callback.h
process.o: help/process_window.h help/kill_signal.h

MenuSupport.o: MenuSupport.h 

askquestion.o: config.h

askquestion.o: askquestion.h
askquestion.o: askquestion.h os.h
askquestion.o: xpstypes.h

getpixelbyname.o: getpixelbyname.h
