#
# makefile
#
# Copyright (C) 1994 Be Inc.  All Rights Reserved
#

srcdir = .

ifeq ($(WHAT)x, x)

###
include $(BUILDHOME)/buildprefs/make.pre
###

LIST = \
	less \
	lessecho \
	lesskey

install: FORCE
	for WHAT in $(LIST); do \
		$(MAKE) $(PARALLELMFLAGS) WHAT=$$WHAT $@;  \
	done

clean:	FORCE
	-rm -rf $(OBJ_DIR)

.DEFAULT: FORCE
	for WHAT in $(LIST); do \
		$(MAKE) $(PARALLELMFLAGS) WHAT=$$WHAT $@; \
	done

FORCE:

else

SHELL		:= /bin/sh

#######
include $(BUILDHOME)/buildprefs/make.pre
#######

INCLUDES	+= -I.
LDFLAGS		+= -ltermcap

TARGET		= $(OBJ_DIR)/$(WHAT)

APP_VERSION		= -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL"


ifeq ($(WHAT), less)
	SRCS	= \
				brac.c \
				ch.c \
				charset.c \
				cmdbuf.c \
				command.c \
				decode.c \
				edit.c \
				filename.c \
				forwback.c \
				help.c \
				ifile.c \
				input.c \
				jump.c \
				line.c \
				linenum.c \
				lsystem.c \
				main.c \
				mark.c \
				optfunc.c \
				option.c \
				opttbl.c \
				os.c \
				output.c \
				position.c \
				prompt.c \
				screen.c \
				search.c \
				signal.c \
				tags.c \
				ttyin.c \
				version.c
	ifeq ($(CPU),ppc)
		SRCS +=	\
				regexp.c
	endif
endif


ifeq ($(WHAT), lessecho)
	SRCS	= \
				lessecho.c \
				version.c
endif

ifeq ($(WHAT), lesskey)
	SRCS	= \
				lesskey.c \
				version.c
endif

OBJS := $(SRCS_LIST_TO_OBJS)

$(TARGET):	$(OBJ_DIR) $(OBJS)
		$(LD) -o $@ $(OBJS) $(LDFLAGS)
		$(SETVERSION) $@ $(SYSTEM_VERSION) $(APP_VERSION)
		
ifeq ($(WHAT), less)
install::	$(TARGET)
		install -m 0644 less.hlp $(INSTALL_ETC)/less.hlp
		rm -f $(INSTALL_BIN)/more
		ln -s less $(INSTALL_BIN)/more
endif

#######
include $(BUILDHOME)/buildprefs/make.post
#######

endif
