# $Id: Makefile,v 1.48 2004/12/16 16:18:45 cslsublevel3org Exp $
#
# http://gubby.sourceforge.net
# Written by Christian Stigen Larsen <csl@sublevel3.org>
#
# On BSD variants, you should probably use gmake

VERSION=0.5.5
NAME=gubby

PREFIX=/usr
MANPATH=/usr/share/man

INC=-Iinclude/
#-I/usr/include/slang

LIBS=-lncurses
#LIBS=-lslang

# Notes on compiler options (OPTS)
#
# USE_STRSTREAM
#   If you are using an old, outdated, deprecated, archane version of
#   GCC (like 2.95.x), you probably have to compile with -DUSE_STRSTREAM
#   so that strstream is used instead of sstream.
#
# USE_SLANG
#   Experimental use of s-lang's slcurses wrapper instead of curses.
#

#-DUSE_STRSTREAM
#-DUSE_STRSTREAM

OPTS=-Wall -W -s -Os $(COPTS)

SRC:=$(wildcard src/*.cpp)
OBJ:=$(SRC:.cpp=.o)

all: warn gubby
dist: man gubby

gubby: $(OBJ)
	$(CXX) -s $(OPTS) $(OBJ) $(LIBS) -o $(NAME)
	chmod a+xr,go-w,u-s $(NAME)
	@echo "-- $(NAME) is now ready to run."
	@echo "-- To see where $(NAME) will be installed, type 'make -n install'"

warn:
	@echo "-- If compilation fails to find 'sstream', try 'make COPTS=-DUSE_STRSTREAM'"

%.o: %.cpp
	$(CXX) -c $(OPTS) $(INC) -o $@ $<

.PHONY: clean
clean:
	rm -f $(NAME) src/*.o *.o core doc/*.html

doc/gubby.1: doc/gubby.pod
	pod2man --release=$(NAME) --center='User Manuals' --section=1 $< > $@
	chmod u+w,a+r,go-w $@

doc/gubby.html: doc/gubby.pod
	pod2html $< > $@
	chmod u+w,a+r,go-w $@
	rm -f pod2htm*

manual: doc/gubby.1 doc/gubby.html
man: manual

install-man: doc/$(NAME).1
	chmod a+r-w doc/$(NAME).1
	mkdir -p $(MANPATH)/man1/
	cp -f doc/$(NAME).1 $(MANPATH)/man1/
	gzip -f $(MANPATH)/man1/$(NAME).1
	@echo "-- $(NAME) manual has been installed in $(MANPATH)/man1/$(NAME).1.gz"
	@echo "-- To read it type 'man gubby'"

install-gubby:
	cp -f $(NAME) $(PREFIX)/bin/
	@echo "-- $(NAME) has been installed in $(PREFIX)/bin/$(NAME)"
	@echo "-- To run, type 'gubby' or 'gubby -h'"

install: install-gubby install-man


syntax highlighted by Code2HTML, v. 0.9.1