# Makefile for "less"
#
# Invoked as:
#	make all
#   or	make install
# Plain "make" is equivalent to "make all".
#
# If you add or delete functions, remake funcs.h by doing:
#	make newfuncs
# This depends on the coding convention of function headers looking like:
#	" \t public <function-type> \n <function-name> ( ... ) "
#
# Also provided:
#	make lint	# Runs "lint" on all the sources.
#	make clean	# Removes "less" and the .o files.
#	make clobber	# Pretty much the same as make "clean".


##########################################################################
# System-specific parameters
##########################################################################

# (AMIGA ONLY) if you have a single drive system you have to put
#  the system disk back in if you have no 'set' vars
#  otherwise we can use this var
NO_GETENV = 1

# Define XENIX if running under XENIX 3.0
XENIX = 0

# VOID is 1 if your C compiler supports the "void" type,
# 0 if it does not.
VOID = 1

# offset_t is the type which lseek() returns.
# It is also the type of lseek()'s second argument.
offset_t = long

# STAT is 1 if your system has the stat() call.
STAT = 0

# PERROR is 1 if your system has the perror() call.
# (Actually, if it has sys_errlist, sys_nerr and errno.)
PERROR = 1

# TERMIO is 1 if your system has /usr/include/termio.h.
# This is normally the case for System 5.
# If TERMIO is 0 your system must have /usr/include/sgtty.h.
# This is normally the case for BSD.
TERMIO = 0

# SIGSETMASK is 1 if your system has the sigsetmask() call.
# This is normally the case only for BSD 4.2,
# not for BSD 4.1 or System 5.
SIGSETMASK = 1

##########################################################################
# Optional and semi-optional features
##########################################################################

# REGCMP is 1 if your system has the regcmp() function.
# This is normally the case for System 5.
# RECOMP is 1 if your system has the re_comp() function.
# This is normally the case for BSD.
# If neither is 1, pattern matching is supported, but without metacharacters.
REGCMP = 0
RECOMP = 0

# SHELL_ESCAPE is 1 if you wish to allow shell escapes.
# (This is possible only if your system supplies the system() function.)
SHELL_ESCAPE = 1

# EDITOR is 1 if you wish to allow editor invocation (the "v" command).
# (This is possible only if your system supplies the system() function.)
# EDIT_PGM is the name of the (default) editor to be invoked.
EDITOR = 1
EDIT_PGM = ed

# GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
# This will generally work if your system provides the "popen" function
# and the "echo" shell command.
GLOB = 0

# LOGFILE is 1 if you wish to allow the -l option (to create log files).
LOGFILE = 0

# ONLY_RETURN is 1 if you want RETURN to be the only input which
# will continue past an error message.
# Otherwise, any key will continue past an error message.
ONLY_RETURN = 0


##########################################################################
# Compilation environment.
##########################################################################

# LIBS is the list of libraries needed.
LIBS = -lc


# OPTIM is passed to the compiler and the loader.
# It is normally "-O" but may be, for example, "-g".
OPTIM = 


##########################################################################
# Files
##########################################################################

SRC1 =	main.c option.c prim.c ch.c position.c input.c output.c 
SRC2 =	screen.c prompt.c line.c signal.c os.c help.c ttyin.c command.c version.c
SRCAMIGA = print.c io.c

SRC =	$(SRC1) $(SRC2) $(SRCAMIGA)
OBJ =	main.o option.o prim.o ch.o position.o input.o output.o screen.o \
	prompt.o line.o signal.o os.o help.o ttyin.o command.o version.o \
	print.o io.o


##########################################################################
# Rules
##########################################################################

DEFS =	-DTERMIO=$(TERMIO) \
-DSIGSETMASK=$(SIGSETMASK) \
-Doffset_t=$(offset_t) -DVOID=$(VOID) \
-DEDITOR=$(EDITOR) -DEDIT_PGM=$(EDIT_PGM) \
-DLOGFILE=$(LOGFILE) -DSHELL_ESCAPE=$(SHELL_ESCAPE) \
-DONLY_RETURN=$(ONLY_RETURN) \
-DGLOB=$(GLOB) \
-DSTAT=$(STAT) \
-DPERROR=$(PERROR) \
-DAMIGA=1 -DNO_GETENV=$(NO_GETENV)

CFLAGS = $(OPTIM) $(DEFS) -n


less: $(OBJ)
	ln -g $(OPTIM) -o less $(OBJ) $(LIBS)


$(OBJ): less.h funcs.h

# help.o depends on makefile for the definition of HELPFILE.
help.o: makefile


newfuncs:
	mv funcs.h funcs.h.OLD
	awk -f mkfuncs.awk $(SRC) >funcs.h

clean:
	rm -f $(OBJ) less

clobber:
	rm -f *.o less install_less install_man install_help

shar:
	shar -v install less.man makefile.* > less.shar.a
	shar -v less.nro $(SRC1) > less.shar.b
	shar -v README less.help *.h *.awk $(SRC2) > less.shar.c
