##makefile for lynx
##lynx written by Lou Montulli University of Kansas

##change the next line if you want lynx installed somewhere 
##besides /usr/local/bin

exec= /usr/local/bin

##change the next line if you want the lynx man file installed somewhere
##besides /usr/man/man1

doc= /usr/man/man1

#set the relative location of the WWW library Implementation directory, 
#from this directory
#do not set this to be an absolute path!!!
WWWINC= WWW/Library/Implementation

# !!!!!!!!!!!!!  IMPORTANT NEW INSTRUCTIONS   !!!!!!!!!!!!!!!!!!!!!
# You NO longer need to set the location of the WWW Library here.
# When you run this makefile the WWW library that is included in
# this distribution will be compiled and used to link Lynx.
# The location of the WWW library is specified in the specific 
# entry for your machine.  (see aix32: or ultrix: for examples below)
LIBWWW= NO LONGER RELEVENT!!!!!

# !!!!!!!!!!!!!  DIRECT WAIS ACCESS !!!!!!!!!!!!!!!!!!!!!!!!!!
# If you are adding direct wais access you must fill in the
# location of wais.a, client.a and the standard math library, libm.a.  
# You can pick up the freeWAIS source from sunsite.unc.edu.  
# Plese put an ABSOLUTE address here if you want it to work! 
# WAISLIB= /homea/local/lynx-dev/lynx2-0-12/wais.a /homea/local/lynx-dev/freeWAIS-0.1/bin/client.a /usr/lib/libm.a

#
#If you are on a SUN and need to link with -lresolv, search
#for "sun3:" or "sun4:"
#

#
# if you are on one of the supported systems (see all: list below)
# you should not have to modify anything from here down!
# If you are not, then you should edit the generic: entry below.
#

MYEMULATORLIB = emulator/myemulator_lib.a

all:  
	@echo
	@echo "Please run make with one of the following arguments"
	@echo "aix32      -- for RS/6000 running AIX 3.2"
	@echo "aix31      -- for RS/6000 running AIX 3.1 with curses bug"
	@echo "generic    -- for generic UNIX"
	@echo "linux      -- for PC linux"
	@echo "next       -- for NeXT OS"
	@echo "osf        -- for Alpha OSF/1"
	@echo "sgi        -- for SGI machines (untested)"
	@echo "sun3       -- for SUN 3 OS"
	@echo "sun4       -- for SUN 4 OS"
	@echo "svr4       -- for SVR4"
	@echo "snake      -- for HP-UX"
	@echo "solaris2   -- for Solaris 2.x"
	@echo "ultrix     -- for DEC Ultrix"
	@echo "decstation -- for DEC Ultrix (same as ultrix above)"
	@echo "low_curses -- for generic systems with faulty curses"
	@echo "clean      -- removes all '.o' and 'core' files"
	@echo "tar        -- runs clean, removes executable, and tars the whole directory"
	@echo "compress   -- runs tar, then compresses the result"
	@echo

# Map some extra commands to existing ones
unix: generic
decstation: ultrix

# if you are compiling on a previously unsupported system, modify
# this generic entry!!
#
#generic machines with original Berkeley curses
generic:  
	@echo "You must first compile the WWW library in WWW/Library"
	cd WWW/Library/unix; make
	cd src; make all CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX -DHAVE_SIGIO\
		-DREXEC -I../$(WWWINC)" LIBS="-lcurses -ltermcap" \
		WWWLIB="../WWW/Library/unix/libwww.a"

# Tested on DN 3500 & 4500's running Domain O/S 10.4 BSD
# -Acpu,mathchip may have to be changed on other machines - see man cpuhep
apollo:
	cd WWW/Library/apollo_m68k; make
	cd src; make all CC="cc" MCFLAGS="-O -DUNIX \
		-D_BUILTINS -W0,-opt,4 -Acpu,mathchip \
		-DREXEC -I../$(WWWINC)" LIBS="-lcurses -ltermcap" \
		WWWLIB="../WWW/Library/apollo_m68k/libwww.a $(MYWWWLIB)"

snake:  
	cd WWW/Library/snake; make
	cd src; make all CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX \
		-DREXEC -DSNAKE -I../$(WWWINC)" LIBS="-lcurses -ltermcap" \
		WWWLIB="../WWW/Library/snake/libwww.a "

svr4:  
	cd WWW/Library/svr4; make
	cd src; make all CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX -DHAVE_SIGIO\
		-DREXEC -I../$(WWWINC) -DNO_UTMP -DSVR4" \
		LIBS="-lcurses -lsocket -lnsl" \
		WWWLIB="../WWW/Library/svr4/libwww.a"

solaris2:  
	cd WWW/Library/solaris2; make
	cd src; make all CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX \
		-DHAVE_SIGIO -DREXEC -I../$(WWWINC) -DCURS_PERFORMANCE \
		-DNO_UTMP -DUSE_DIRENT -DSVR4" LIBS="-lcurses -ltermcap \
 		-lnsl -lsocket" WWWLIB="../WWW/Library/solaris2/libwww.a"


#osf doesn't much care for '\' as a line continuer?
osf:            
	cd WWW/Library/osf; make
	cd src; make all CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX -DREXEC -DHAVE_SIGIO -I../$(WWWINC)" LIBS="-lcurses -ltermcap" WWWLIB="../WWW/Library/osf/libwww.a"

dbg:   
	cd WWW/Library/rs6000; make
	cd src; make all CC="gcc" MCFLAGS="-g -Wall -DFANCY_CURSES -DUNIX 
		-DHAVE_SIGIO -DREXEC -I../$(WWWINC) -DDEBUG" LIBS="-lcurses \
		-ltermcap -lbsd" WWWLIB="../WWW/Library/rs6000/libwww.a" 

#sgi doesn't like '\' as a line continuer?
sgi:
	cd WWW/Library/sgi; make
	cd src; make all CC="cc" MCFLAGS="-g -cckr -DFANCY_CURSES -DHAVE_SIGIO -DUNIX -Dvfork=fork -DREXEC -I../$(WWWINC) -DNO_UTMP" LIBS="-lcurses -ltermcap -DSYSV -DPERFORMANCE" WWWLIB="../WWW/Library/sgi/libwww.a"

linux:
	cd WWW/Library/unix; make
	cd src; make all CC="gcc" MCFLAGS="-g -DUNIX -DREXEC -I../$(WWWINC)" LIBS="-lcurses -ltermcap" WWWLIB="../WWW/Library/unix/libwww.a"

aix32: 
	cd WWW/Library/rs6000; make
	cd src; make all CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX -DHAVE_SIGIO\
		-DREXEC -I../$(WWWINC)" LIBS="-lcurses -ltermcap -lbsd \
  		$(WAISLIB)" WWWLIB="../WWW/Library/rs6000/libwww.a"

aix31: 
	cd WWW/Library/rs6000; make
	cd src; make all CC="cc" MCFLAGS="-g -DUNIX -DHAVE_SIGIO\
		-DREXEC -I../$(WWWINC)" LIBS="-lcurses -ltermcap -lbsd" \
		WWWLIB="../WWW/Library/rs6000/libwww.a"

ultrix:  
	cd WWW/Library/decstation; make
	cd src; make all CC="cc" MCFLAGS="-g -Olimit 600 -DFANCY_CURSES \
		-DHAVE_SIGIO -DUNIX -DREXEC -DULTRIX -I../$(WWWINC)" \
		LIBS="-lcursesX -ltermcap" \
		WWWLIB="../WWW/Library/decstation/libwww.a "

sun:
	@echo "Run make again and use \"make sun3\" or \"make sun4\""

#
# add -lresolv to the last "LIBS" entry within the quotes if needed
#
sun3:    
	cd WWW/Library/sun3; make
	cd src; make all CC="gcc" MCFLAGS="-g -DUNIX -DFANCY_CURSES \
		-DHAVE_SIGIO -I../$(WWWINC) -DREXEC -DSUN -I/usr/5include"\
		LIBS="-lcurses -ltermcap -L/usr/5lib -lresolv" \
		WWWLIB="../WWW/Library/sun3/libwww.a"

#
# add -lresolv to the last "LIBS" entry within the quotes if needed
#
sun4:
	cd WWW/Library/sun4; make
	cd src; make all CC="gcc" MCFLAGS="-g -DUNIX -DFANCY_CURSES \
		-DHAVE_SIGIO -I../$(WWWINC) -DREXEC -DSUN -I/usr/5include" \
		LIBS="-lcurses -ltermcap -L/usr/5lib -lresolv" \
		WWWLIB="../WWW/Library/sun4/libwww.a"

next: 
	cd WWW/Library/next; make
	cd src; make all CC="cc" MCFLAGS="-g -DUNIX -DNEXT -DREXEC -DNO_CUSERID\
		-DHAVE_SIGIO -I../$(WWWINC) -I../$(WWWINC)" LIBS="-lcurses \
		-ltermcap" WWWLIB="../WWW/Library/next/libwww.a"

traversal:
	cd WWW/Library/rs6000; make
	cd src; make traversal CC="cc" MCFLAGS="-g -DFANCY_CURSES -DUNIX  \
		-DTRAVERSAL -DREXEC -I../$(WWWINC)" LIBS="-lcurses \
		-ltermcap -lbsd" WWWLIB="../WWW/Library/rs6000/libwww.a"

clean:
	rm -f core
	cd WWW/Library/apollo_m68k; rm -f *.a *.o
	cd WWW/Library/solaris2; rm -f *.a *.o
	cd WWW/Library/snake; rm -f *.a *.o
	cd WWW/Library/svr4; rm -f *.a *.o
	cd WWW/Library/vax_ultrix; rm -f *.a *.o
	cd WWW/Library/rs6000; rm -f *.a *.o
	cd WWW/Library/sgi; rm -f *.a *.o
	cd WWW/Library/unix; rm -f *.a *.o
	cd WWW/Library/decstation; rm -f *.a *.o
	cd WWW/Library/sun4; rm -f *.a *.o
	cd WWW/Library/sun3; rm -f *.a *.o
	cd WWW/Library/osf; rm -f *.a *.o
	cd WWW/Library/next; rm -f *.a *.o
	cd src;          make clean

tar:  clean
	rm -f src/lynx
	rm -f lynx
	rm -f src/a.out
	make save

zipcompress: compress zip
	echo "done!"

zip:  clean
	rm -f src/lynx
	rm -f lynx
	rm -f src/a.out
	rm -f ../lynx2-1.zip
	cd ..; zip -v -r lynx2-1.zip lynx2-1

save:
	cd ..; tar -cvf - lynx2-1 > lynx2-1.tar

compress: tar
	cd ..; compress -f -v lynx2-1.tar

install:
	rm  -f $(exec)/lynx
	cp  lynx $(exec)
	rm -f $(doc)/lynx.1
	cp  lynx.man $(doc)/lynx.1

