# MNTDISK -- A program to allow users to mount disks.

# Written by Mike J. Fuller (mikef@sarah.lerc.nasa.gov)
# for NASA Lewis Research Center.

# Install stuff.
BINDIR = /usr/local/bin
MANDIR = /usr/local/man
MANSECT = l
#LNKS = cdmount eodmount fdmount dosmount
LNKS = cdmount fdmount dosmount

# Nothing after here should need to be changed.
#DEBUGFLAGS = -g -v -DDEBUG	# Debug++
#DEBUGFLAGS = -g		# Normal debug
DEBUGFLAGS = -O			# Only for the brave

#CC = gcc
#CFLAGS = -pipe -Wswitch -Wunused -Wreturn-type -Wpointer-arith -Wcast-qual $(DEBUGFLAGS) $(DEFINES)
#CC = acc
CC = cc
CFLAGS = -pipe $(DEBUGFLAGS) $(DEFINES)

COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
LD = $(CC)
LDFLAGS = $(CFLAGS)
LIBS =
LINTFLAGS = $(DEFINES)
LPR = enscript -2r
SHELL = /bin/sh
TROFF = ptroff

PROG = mntdisk
HDRS = mntdisk.h
MAN = mntdisk.man
OBJS = mntdisk.o funcs.o
SRCS = mntdisk.c funcs.c

$(PROG):	$(OBJS)
	rm -f $@ $(LNKS)
	$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
	for i in $(LNKS); do ln $@ $$i; done

install:	$(PROG)
	if test `whoami` != root; then echo Must install as root.; exit 1; fi
	for i in $(PROG) $(LNKS); do if test -f $(BINDIR)/$$i; then rm -f $(BINDIR)/$$i; fi; done
	install -cs -g staff -m 4755 -o root $(PROG) $(BINDIR)
	for i in $(LNKS); do ln $(BINDIR)/$(PROG) $(BINDIR)/$$i; done
	for i in $(PROG) $(LNKS); do if test -f $(MANDIR)/man$(MANSECT)/$$i.$(MANSECT); then rm -f $(MANDIR)/man$(MANSECT)/$$i.$(MANSECT); fi; done
	install -c -m 444 $(MAN) $(MANDIR)/man$(MANSECT)/$(PROG).$(MANSECT)
	for i in $(LNKS); do ln $(MANDIR)/man$(MANSECT)/$(PROG).$(MANSECT) $(MANDIR)/man$(MANSECT)/$$i.$(MANSECT); done

lint:
	lint $(LINTFLAGS) $(SRCS)

tags:
	etags -t $(SRCS)

print:
	for i in $(HDRS) $(SRCS); do $(LPR) $$i; done
	$(TROFF) -man $(MAN)

wc:
	wc $(HDRS) $(SRCS)

clean:
	rm -f core $(PROG) $(LNKS) $(OBJS) *~ \#*

funcs.o:	mntdisk.h
mntdisk.o:	mntdisk.h
