#
# Makefile for RosettaMan
#   It's helpful to read the README-rman file first.
#   You should read over all parts of this file,
#      down to the "you shouldn't modify" line
#
# Tom Phelps (phelps@cs.Berkeley.EDU)
#


### you need to localize the paths on these lines

# The executable `rman' is placed in BINDIR.
# If you're also installing TkMan (available separately--see README-rman),
#    this must be a directory that's in your bin PATH.
# MANDIR holds the man page.

BINDIR = /usr/neosoft/bin
MANDIR = /usr/neosoft/man/man1


### if you have GNU gcc v2.x, use these definitions

CC = gcc
# if you don't have gcc v2.x, try -O for CFLAGS
CFLAGS = -O2 -finline-functions

### if you just have a standard UNIX, use these instead of GNU
### CC must be an ANSI C compiler

#CC = cc
#CFLAGS = -O

# Solaris and SysV people may need this
#CFLAGS = -O2 -finline-functions

# For HP-UX
#CC = cc
#CFLAGS = -Aa -O


# the printf strings used to set the <TITLE> and
# to set URL hyperlinks to referenced manual pages
# can be defined at runtime.  The Defaults are defined below.
# The first %s parameter is the manual page name,
# the second the volume/section number.

MANTITLEPRINTF = "%s(%s) manual page"
MANREFPRINTF = "http://localhost/cgi-bin/man2html?%s?%s"


# # # these lines are probably fine

STRIP = strip
CP = cp
# or you can use GNU's cp and backup files that are about to be overwritten
#CP = cp -b


#--------------------------------------------------
#
# you shouldn't modify anything below here
#
#--------------------------------------------------

version = 2.0
rman = rman-$(version)
srcs = rman.c
objs = rman
defs = -DMANTITLEPRINTF='$(MANTITLEPRINTF)' -DMANREFPRINTF='$(MANREFPRINTF)'
libs = 
aux = README-rman Makefile rman.1 rman.html Copyright
distrib = $(srcs) $(libs) $(aux) contrib


all:  rman
	@echo 'Files made in current directory.'
	@echo 'You should "make install".'

rman: rman.c Makefile
	$(CC) $(defs) -DROSETTAMANVERSION=\"$(version)\" $(CFLAGS) -o rman rman.c

rman.1: rman.html rman
	echo '.TH RosettaMan 1' > rman.1
	cat ../html/html.dtd rman.html | sgmls | ../html/html2man.pl >> rman.1

debug:
	$(CC) $(defs) -DROSETTAMANVERSION=\"debug\" -g -Wall -o rman rman.c

prof: rman.c
#	quantify -cache-dir=/home/barad-dur/e/mhgs/phelps/spine/rman/cache $(CC) -O2 -o rman rman.c
	$(CC) $(defs) -DROSETTAMANVERSION=\"prof\" -gp -g -o rman rman.c

install: rman
#	$(INSTALL) -s rman $(BINDIR)
	$(STRIP) rman
	$(CP) rman $(BINDIR)
	$(CP) rman.1 $(MANDIR)

test: rman
	ls -l rman
	ginstall -s rman $(BINDIR)/alpha
	rman -v

sww:
	rm -f rman $(wildcard ~/bin/{sparc,dec}/rman)
	rman

clean:
	rm -f $(objs)

tar: rman.1
	rm -rf $(rman)*
	mkdir $(rman)
	$(CP) -hR $(distrib) $(rman)
#	expand -4 rman.c > $(rman)/rman.c
	rm -f $(rman)/contrib/*~
	@echo 'gcksum crc   length name' > MANIFEST
	@echo '----------   ------ ----' >> MANIFEST
	@gcksum $(filter-out contrib, $(filter-out %~, $(distrib) $(wildcard contrib/*))) | gtee -a MANIFEST
	mv MANIFEST $(rman)
	gtar chvf $(rman).tar $(rman)
	compress $(rman).tar
#	gzip -9v $(rman).tar
	rm -rf $(rman)
	@echo "*** Did you remember to ci -l first?"

uu: tar
	gznew $(rman).tar.Z
	echo 'uudecode, gunzip (from GNU), untar' > $(rman).tar.gz.uu
	uuencode $(rman).tar.gz $(rman).tar.gz >> $(rman).tar.gz.uu
