# Makefile for xnetload 1.4
#
# $Id: Makefile,v 1.4 1998/04/10 20:34:41 rsmit06 Exp rsmit06 $
#

CC = gcc
CFLAGS = -O2 -Wall -DNUMAVG=5
#CFLAGS = -g -Wall -DNUMAVG=5 # for debugging
LIBS = -lXaw -lXmu -lXt -lX11

# This should be set with environment variables, but nobody does that,
# so I'll set these here.
DIRS = -I/usr/X11R6/include -L/usr/X11R6/lib

# Location where to install the binary.
BINDIR = /usr/local/bin

# Location where to install the manual-page.
MANDIR = /usr/local/man/man1

# Package name and version: BASENAME-VMAJOR.VMINOR.tar.gz
BASENAME = xnetload
VMAJOR   = 1
VMINOR   = 4

# Directory in which this library is built
BUILDDIR = $(BASENAME)-$(VMAJOR).$(VMINOR)

# If one of these is missing, comment them out!
README  = $(BUILDDIR)/README
LICENSE = $(BUILDDIR)/LICENSE
MANPAGE = $(BUILDDIR)/$(BASENAME).1
APPDEF  = $(BUILDDIR)/XNetload

# Object files.
OBJS = data.o x11-ui.o

##### No editing necessary beyond this point
.PHONY: clean install uninstall dist backup

# builds a binary.
$(BASENAME): $(OBJS)
	$(CC) $(CFLAGS) $(DIRS) -o $(BASENAME) $(LIBS) $(OBJS)

# Remove all generated files.
clean:;
	rm -f $(OBJS) $(BASENAME) *~ core \
	$(BASENAME)-$(VMAJOR).$(VMINOR).tar.gz \
	$(BASENAME)-backup-$(VMAJOR).$(VMINOR).tar.gz 

# Install the program and manual page. You should be root to do this.
install: $(BASENAME)
	@if [ `id -u` != 0 ]; then \
		echo "You must be root to install the program!"; \
		exit 1; \
	fi
	cp $(BASENAME) $(BINDIR)
	cp $(BASENAME).1 $(MANDIR)

uninstall:;
	@if [ `id -u` != 0 ]; then \
		echo "You must be root to uninstall the program!"; \
		exit 1; \
	fi
	rm -f $(BINDIR)/$(BASENAME)
	rm -f $(MANDIR)/$(BASENAME).1

# Build a tar distribution file. Only needed for the maintainer.
dist:;
	cd .. ; tar -czf $(BUILDDIR)/$(BASENAME)-$(VMAJOR).$(VMINOR).tar.gz \
	$(README) $(LICENSE) $(MANPAGE) \
	$(BUILDDIR)/Makefile $(BUILDDIR)/depend $(APPDEF) \
	$(BUILDDIR)/*.h $(BUILDDIR)/*.c 

# Make a backup, complete with the RCS files. Only for the maintainer.
backup: clean
	cd .. ; \
	tar -czf $(BUILDDIR)/$(BASENAME)-backup-$(VMAJOR).$(VMINOR).tar.gz \
	$(BUILDDIR)/*

# if the file depend doesn't exist, run 'make depend' first.
depend: $(OBJS:.o=.c)
	gcc -MM $(OBJS:.o=.c) >depend

# DO NOT DELETE THIS LINE 
include depend
