#
# Makefile for `dired'
#
# Makefile 1.25   Delta'd: 14:10:19 3/9/92   Mike Lijewski, CNSF
#

#
# Your C++ compiler goes here.
#
CC = g++

#
# flags you need to compile:
#
#   Add -DNO_STRSTR if you don't have the ANSI C function strstr().
#
#   Add -O if you trust your optimizer.
#
#   Add -DNO_STRCHR if you don't have strchr() and strrchr().
#
#   Add -DNO_SYMLINKS if your OS doesn't support symbolic links.  If
#   you don't define this, it is assumed that your OS supports symbolic
#   links.
#
#   Add -DNEED_LG if your version of `ls' needs the `-lg' flags in
#   order to display both the owner and group of files in a long
#   listing.  Typically, BSD-based OSs need this and SYSV ones don't.
#
CFLAGS = -DNO_SYMLINKS

#
# Those flags needed to compile in the type of terminal
# control you have.  Use -DTERMIOS if you have <termios.h>, the POSIX
# terminal control.  Use -DTERMIO if you have <termio.h>, the SYSV
# terminal control.  Otherwise, the default assumes you have <sgtty.h>,
# the BSD terminal control.
#
# If you choose to use -DTERMIOS and have problems, try -DTERMIO.  On
# at least two systems I've tried, the vendor hasn't had all the
# include files set up correctly to include <unistd.h> together with 
#  <osfcn.h>, among others.
#
TERMFLAGS = -DTERMIO

#
# libraries needed:
#
#                   -ltermcap on BSD-like systems
#                   -ltermlib on SYSV-like systems
#                   -lcurses on systems w/o the above libraries
#
LIBS = -lterm

##############################################################################
# nothing should need to be changed below here.
##############################################################################

SHELL     = /bin/sh
MAKESHELL = /bin/sh

HDR  = classes.h dired.h display.h keys.h

MISC = dired.1 dired.lpr Makefile INSTALL MANIFEST README

OBJ  = classes.o commands.o dired.o display.o help.o utilities.o

SRC  = classes.C command1.C command2.C dired.C display.C help.C \
       patchlevel.C utilities.C

#
# Sorry for including patchlevel.C in the compile line instead of the
# list of object files.  The Cfront 2.0 on my main development
# machine chokes when passed a list consisting solely of .o files.
#
dired: $(OBJ)
	$(CC) $(CFLAGS) -o $@ $(OBJ) patchlevel.C $(LIBS)

display.o: display.C display.h
	$(CC) -c $(CFLAGS) $(TERMFLAGS) display.C

#
# Commands.C is built from command1.C and command2.C the first time
# it is needed.  This is so that the shar files don't get too big.
#
commands.C: command1.C command2.C
	cat command1.C command2.C > commands.C

clean:
	-rm -f core *.o *~ *..c dired

#
# This depends on Rich Salz' cshar program.
#
shar: $(SRC) $(HDR) $(MISC)
	cshar -n1 -e5 -o dired-01 $(MISC)
	cshar -n2 -e5 -o dired-02 command1.C $(HDR)
	cshar -n3 -e5 -o dired-03 command2.C
	cshar -n4 -e5 -o dired-04 classes.C dired.C display.C  help.C
	cshar -n5 -e5 -o dired-05 patchlevel.C utilities.C
        
tar:
	tar cf dired.tar $(SRC) $(HDR) $(MISC)
	compress -f dired.tar

#
# dependencies
#
classes.o   : classes.h
commands.o  : classes.h dired.h display.h keys.h command1.C command2.C
dired.o     : classes.h dired.h display.h
utilities.o : classes.h dired.h display.h keys.h


.SUFFIXES: .C .o

.C.o:
	$(CC) $(CFLAGS) -c $*.C
