#
# "$Id: Makefile.in,v 1.28 2001/07/03 15:21:08 mike Exp $"
#
#   Makefile for the ESP Package Manager (EPM).
#
#   Copyright 1999-2001 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)
SETUPLIBS =	@SETUPLIBS@
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 @SETUP@
EPM_OBJS =	aix.o bsd.o deb.o dist.o epm.o file.o inst.o pkg.o \
		portable.o rpm.o run.o setld.o snprintf.o string.o \
		swinstall.o tar.o
SETUP_OBJS =	setup.o setup2.o CheckButton.o Fl_Check_Browser.o Fl_Wizard.o
OBJS	=	$(EPM_OBJS) epminstall.o $(SETUP_OBJS)


#
# Make all targets...
#

all:	$(TARGETS)


#
# Clean all object files...
#

clean:
	rm -f $(OBJS) $(TARGETS)


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

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


#
# Install all targets...
#

install: epm @INSTALL_SETUP@
	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)
	-$(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
	echo Installing EPM manpages in $(mandir)/man5
	-$(MKDIR) $(mandir)/man5
	$(RM) $(mandir)/man5/epm.list.5
	$(CP) $(srcdir)/doc/epm.list.man $(mandir)/man5/epm.list.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-setup:	setup
	echo Installing EPM setup in $(libdir)/epm
	-$(MKDIR) $(libdir)/epm
	$(RM) $(libdir)/epm/setup
	$(CP) setup $(libdir)/epm
	$(STRIP) $(libdir)/epm/setup


#
# Test EPM...
#

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


#
# Make distributions using EPM...
#

aix: $(TARGETS)
	echo Please note: AIX support is not working yet.
	./epm -f aix -v epm

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

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

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

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

native: $(TARGETS)
	./epm -f native -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)

$(EPM_OBJS):	epm.h epmstring.h


#
# epm
#

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

epminstall.o:	epm.h epmstring.h


#
# setup
#

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

setup.o:	setup.h setup2.h Fl_Check_Browser.h Fl_Wizard.h
setup2.o:	setup.h setup2.h Fl_Check_Browser.h Fl_Wizard.h
Fl_Wizard.o:	Fl_Wizard.h
Fl_Check_Browser.o:	Fl_Check_Browser.h

$(OBJS):	Makefile config.h


#
# End of "$Id: Makefile.in,v 1.28 2001/07/03 15:21:08 mike Exp $".
#
