#
# "$Id: Makefile.in,v 1.45 2003/07/24 01:20:54 mike Exp $"
#
#   Makefile for the ESP Package Manager (EPM).
#
#   Copyright 1999-2003 by Easy Software Products, all rights reserved.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2, or (at your option)
#   any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#

#
# Programs...
#

CC	=	@CC@
CHMOD	=	@CHMOD@
CP	=	@CP@
CXX	=	@CXX@
MKDIR	=	@MKDIR@ -p
RM	=	@RM@ -f
SHELL	=	/bin/sh
STRIP	=	@STRIP@


#
# Program options...
#
# OPTIM   defines the common compiler optimization/debugging options.
#

ARFLAGS	=	crvs
CFLAGS	=	@CFLAGS@ $(OPTIM)
CXXFLAGS =	@CXXFLAGS@ $(OPTIM)
GUILIBS =	@GUILIBS@
LDFLAGS	=	@LDFLAGS@ $(OPTIM)
LIBS	=	@LIBS@
OPTIM	=	@OPTIM@


#
# Manpage extensions...
#

CAT1EXT	=	@CAT1EXT@
MAN1EXT	=	@MAN1EXT@
CAT5EXT	=	@CAT5EXT@
MAN5EXT	=	@MAN5EXT@


#
# Directories...
#

bindir		=	@bindir@
datadir		=	@datadir@
docdir		=	@docdir@
exec_prefix	=	@exec_prefix@
mandir		=	@mandir@
prefix		=	@prefix@
libdir		=	@libdir@
srcdir		=	@srcdir@

VPATH		=	$(srcdir)


#
# Rules...
#

.SILENT:

.SUFFIXES:	.c .cxx .h .o
.c.o:
	echo Compiling $<...
	$(CC) $(CFLAGS) -I. -I$(srcdir) -c $<
.cxx.o:
	echo Compiling $<...
	$(CXX) $(CXXFLAGS) -I. -I$(srcdir) -c $<


#
# Targets...
#

TARGETS	=	epm epminstall mkepmlist @GUIS@
EPM_OBJS =	aix.o bsd.o deb.o dist.o epm.o file.o inst.o osx.o pkg.o \
		portable.o qprintf.o rpm.o run.o setld.o slackware.o \
		snprintf.o string.o swinstall.o tar.o
SETUP_OBJS =	setup.o setup2.o gui-common.o snprintf.o
UNINST_OBJS =	uninst.o uninst2.o gui-common.o snprintf.o
OBJS	=	$(EPM_OBJS) epminstall.o $(SETUP_OBJS) $(UNINST_OBJS)


#
# Make all targets...
#

all:	$(TARGETS)	Makefile config.h


#
# Clean all object files...
#

clean:
	rm -f *.o
	rm -f $(TARGETS)


#
# Clean all object files and generated files...
#

distclean:
	rm -f $(OBJS) $(TARGETS)
	rm -f config.cache config.h config.log config.status
	rm -f mkepmlist Makefile


#
# Install all targets...
#

install: epm @INSTALL_GUIS@ @INSTALL_OSX@
	echo Installing EPM programs in $(bindir)
	-$(MKDIR) $(bindir)
	$(RM) $(bindir)/epm
	$(CP) epm $(bindir)
	-$(STRIP) $(bindir)/epm
	$(RM) $(bindir)/epminstall
	$(CP) epminstall $(bindir)
	-$(STRIP) $(bindir)/epminstall
	$(RM) $(bindir)/mkepmlist
	$(CP) mkepmlist $(bindir)
	echo Installing EPM manpages in $(mandir)/cat1 and $(mandir)/man1
	-$(MKDIR) $(mandir)/cat1
	$(RM) $(mandir)/cat1/epm.$(CAT1EXT)
	$(CP) $(srcdir)/doc/epm.1 $(mandir)/cat1/epm.$(CAT1EXT)
	$(RM) $(mandir)/cat1/epminstall.$(CAT1EXT)
	$(CP) $(srcdir)/doc/epminstall.1 $(mandir)/cat1/epminstall.$(CAT1EXT)
	$(RM) $(mandir)/cat1/mkepmlist.$(CAT1EXT)
	$(CP) $(srcdir)/doc/mkepmlist.1 $(mandir)/cat1/mkepmlist.$(CAT1EXT)
	$(RM) $(mandir)/cat1/setup.$(CAT1EXT)
	$(CP) $(srcdir)/doc/setup.1 $(mandir)/cat1/setup.$(CAT1EXT)
	-$(MKDIR) $(mandir)/man1
	$(RM) $(mandir)/man1/epm.1
	$(CP) $(srcdir)/doc/epm.man $(mandir)/man1/epm.1
	$(RM) $(mandir)/man1/epminstall.1
	$(CP) $(srcdir)/doc/epminstall.man $(mandir)/man1/epminstall.1
	$(RM) $(mandir)/man1/mkepmlist.1
	$(CP) $(srcdir)/doc/mkepmlist.man $(mandir)/man1/mkepmlist.1
	$(RM) $(mandir)/man1/setup.1
	$(CP) $(srcdir)/doc/setup.man $(mandir)/man1/setup.1
	echo Installing EPM manpages in $(mandir)/cat5 and $(mandir)/man5
	-$(MKDIR) $(mandir)/cat5
	$(RM) $(mandir)/cat5/epm.list.$(CAT5EXT)
	$(CP) $(srcdir)/doc/epm.list.5 $(mandir)/cat5/epm.list.$(CAT5EXT)
	$(RM) $(mandir)/cat5/setup.types.$(CAT5EXT)
	$(CP) $(srcdir)/doc/setup.types.5 $(mandir)/cat5/setup.types.$(CAT5EXT)
	-$(MKDIR) $(mandir)/man5
	$(RM) $(mandir)/man5/epm.list.5
	$(CP) $(srcdir)/doc/epm.list.man $(mandir)/man5/epm.list.5
	$(RM) $(mandir)/man5/setup.types.5
	$(CP) $(srcdir)/doc/setup.types.man $(mandir)/man5/setup.types.5
	echo Installing EPM documentation in $(docdir)
	-$(MKDIR) $(docdir)
	$(RM) $(docdir)/COPYING
	$(CP) $(srcdir)/COPYING $(docdir)
	$(RM) $(docdir)/README
	$(CP) $(srcdir)/README $(docdir)
	$(RM) $(docdir)/epm-manual.html
	$(CP) $(srcdir)/doc/epm-manual.html $(docdir)
	$(RM) $(docdir)/epm-manual.pdf
	$(CP) $(srcdir)/doc/epm-manual.pdf $(docdir)

install-guis:	setup uninst
	echo Installing EPM setup/uninst in $(libdir)/epm
	$(RM) -r $(libdir)/epm
	-$(MKDIR) $(libdir)/epm
	$(CP) setup $(libdir)/epm
	-$(STRIP) $(libdir)/epm/setup
	$(CP) uninst $(libdir)/epm
	-$(STRIP) $(libdir)/epm/uninst

install-osx:
	echo Installing EPM OSX data files in $(datadir)/epm
	$(RM) -r $(datadir)/epm
	-$(MKDIR) $(datadir)/epm
	$(CP) macosx/setup.icns $(datadir)/epm
	$(CP) macosx/setup.info $(datadir)/epm
	$(CP) macosx/setup.plist $(datadir)/epm
	$(CP) macosx/uninst.icns $(datadir)/epm
	$(CP) macosx/uninst.info $(datadir)/epm
	$(CP) macosx/uninst.plist $(datadir)/epm


#
# Uninstall EPM...
#

uninstall:
	echo Uninstalling EPM programs from $(bindir)
	$(RM) $(bindir)/epm
	$(RM) $(bindir)/epminstall
	$(RM) $(bindir)/mkepmlist
	echo Installing EPM manpages in $(mandir)/cat1 and $(mandir)/man1
	$(RM) $(mandir)/cat5/epm.list.$(CAT5EXT)
	$(RM) $(mandir)/cat5/setup.types.$(CAT5EXT)
	$(RM) $(mandir)/man5/epm.list.5
	$(RM) $(mandir)/man5/setup.types.5
	echo Uninstalling EPM documentation from $(docdir)
	$(RM) -r $(docdir)
	echo Uninstalling EPM setup/uninstall from $(libdir)/epm
	$(RM) -r $(libdir)/epm
	echo Uninstalling EPM OSX data files from $(datadir)/epm
	$(RM) -r $(datadir)/epm


#
# Makefile
#

Makefile:	Makefile.in configure
	if test -f config.status; then \
		./config.status --recheck; \
		./config.status; \
	else \
		./configure; \
	fi
	touch config.h


#
# config.h
#

config.h:	config.h.in configure
	if test -f config.status; then \
		./config.status --recheck; \
		./config.status; \
	else \
		./configure; \
	fi
	touch config.h


#
# Test EPM...
#

test:	$(TARGETS)
	if ./epm -v epm >test.log; then \
		echo Portable distribution build test PASSED.; \
	else \
		echo Portable distribution build test FAILED.; \
		cat test.log; \
	fi
	if ./epm -v -f native epm >test.log; then \
		echo Native distribution build test PASSED.; \
	else \
		echo Native distribution build test FAILED.; \
		cat test.log; \
	fi
	$(RM) test.log


#
# Make distributions using EPM...
#

aix: $(TARGETS)
	./epm -f aix -v epm

bsd: $(TARGETS)
	./epm -f bsd -v epm

slackware: $(TARGETS)
	./epm -f slackware -v epm

deb: $(TARGETS)
	./epm -f deb -v epm

gui: $(TARGETS)
	./epm -v -s epm.xpm --setup-program setup \
		--uninstall-program uninst --data-dir macosx epm

inst tardist: $(TARGETS)
	./epm -f tardist -v epm

pkg: $(TARGETS)
	./epm -f pkg -v epm

native: $(TARGETS)
	./epm -f native -v epm

osx: $(TARGETS)
	./epm -f osx -v epm

portable: $(TARGETS)
	./epm -v epm

rpm: $(TARGETS)
	./epm -f rpm -v epm

swinstall depot: $(TARGETS)
	./epm -f depot -v epm


#
# epm
#

epm:	$(EPM_OBJS)
	echo Linking epm...
	$(CC) $(LDFLAGS) -o epm $(EPM_OBJS) $(LIBS)

$(EPM_OBJS):	epm.h epmstring.h


#
# epminstall
#

epminstall:	epminstall.o dist.o qprintf.o snprintf.o
	echo Linking epminstall...
	$(CC) $(LDFLAGS) -o epminstall epminstall.o dist.o qprintf.o snprintf.o $(LIBS)

epminstall.o:	epm.h epmstring.h


#
# mkepmlist
#

mkepmlist:	mkepmlist.o qprintf.o snprintf.o
	echo Linking mkepmlist...
	$(CC) $(LDFLAGS) -o mkepmlist mkepmlist.o qprintf.o snprintf.o $(LIBS)

mkepmlist.o:	epm.h epmstring.h


#
# setup
#

setup:	$(SETUP_OBJS)
	echo Linking setup...
	$(CXX) $(LDFLAGS) -o setup $(SETUP_OBJS) $(GUILIBS) $(LIBS)

setup.o:	setup.h gui-common.h
setup2.o:	setup.h gui-common.h
gui-common.o:	gui-common.h


#
# uninst
#

uninst:	$(UNINST_OBJS)
	echo Linking uninst...
	$(CXX) $(LDFLAGS) -o uninst $(UNINST_OBJS) $(GUILIBS) $(LIBS)

uninst.o:	uninst.h gui-common.h
uninst2.o:	uninst.h gui-common.h

$(OBJS):	Makefile config.h


#
# End of "$Id: Makefile.in,v 1.45 2003/07/24 01:20:54 mike Exp $".
#
