# Makefile for p4prompt

# Uncomment the following line to compile with -p enabled:
#P4API = /usr/local/lib/p4api	# Location of the Perforce API libraries

# Uncomment the following line to use a different C++ compiler:
#CXX = /usr/bin/g++	# A compiler/linker compatible with P4API

# Consider using static linking if dynamic libraries (reported by ldd) might
# become unavavailable because of the network or the user's environment.
# Otherwise, the prompt might go away when there is such a problem.
#LDFLAGS = -static

# Installation targets:
PREFIX = /usr/local
INSTALLBIN = $(PREFIX)/bin
INSTALLMAN = $(PREFIX)/man
INSTALLMAN1DIR = $(INSTALLMAN)/man1

# Identity:
NAME = p4prompt
VERSION = 0.02
DISTNAME = $(NAME)

DIST =	README Makefile p4prompt.c $(NAME).pod GetClient.cpp apiGetClient.h
OBJ =	p4prompt.o $(P4API:%=GetClient.o)
CPPFLAGS = -DNAME=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \
	$(P4API:%=-DP4API) $(P4API:%=-I%)
CFLAGS = -g -Wall
CXXFLAGS = $(CFLAGS)
LDLIBS = $(P4API:%=-L% -lclient -lrpc -lsupp)

all: $(NAME) $(NAME).1

$(NAME): $(OBJ)
	$(CXX) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)

$(NAME).1: $(NAME).pod
	pod2man $(NAME).pod $(NAME).1

install:
	$(MAKE) all
	install -d $(INSTALLBIN)
	install -c $(NAME) $(INSTALLBIN)
	install -d $(INSTALLMAN1DIR)
	install -c $(NAME).1 $(INSTALLMAN1DIR)

dist:
	ln -s . $(DISTNAME)-$(VERSION)
	tar cvf $(DISTNAME)-$(VERSION).tar $(DIST:%=$(DISTNAME)-$(VERSION)/%)
	$(RM) $(DISTNAME)-$(VERSION)
	gzip $(DISTNAME)-$(VERSION).tar

clean:
	$(RM) $(OBJ) $(NAME) $(NAME).1