#
# "$Id: Makefile.in 827 2010-12-29 17:32:40Z mike $"
#
#   Makefile for the ESP Package Manager (EPM).
#
#   Copyright 1999-2010 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...
#

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


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

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


#
# Directories...
#

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

VPATH		=	$(srcdir)


#
# Rules...
#

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


#
# Targets...
#

TARGETS		=	libepm.a \
			epm \
			epminstall \
			mkepmlist \
			@GUIS@
EPM_OBJS	=	aix.o \
			bsd.o \
			deb.o \
			dist.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 \
			support.o \
			swinstall.o \
			tar.o
SETUP_OBJS	=	setup.o \
			setup2.o \
			gui-common.o
UNINST_OBJS	=	uninst.o \
			uninst2.o \
			gui-common.o
OBJS		=	epm.o \
			$(EPM_OBJS) \
			epminstall.o \
			mkepmlist.o \
			$(SETUP_OBJS) \
			$(UNINST_OBJS)


#
# Make all targets...
#

all:	$(TARGETS) Makefile config.h


#
# Clean all object files...
#

clean:
	$(RM) $(OBJS)
	$(RM) $(TARGETS)


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

distclean:
	$(RM) $(OBJS)
	$(RM) $(TARGETS)
	$(RM) config.cache config.h config.log config.status
	$(RM) Makefile doc/Makefile macosx/Makefile
	$(RM) epm.list


#
# Run the clang.llvm.org static code analysis tool on the C sources.
#

.PHONY: clang clang-changes
clang:
	$(RM) -r clang
	scan-build -V -k -o `pwd`/clang $(MAKE) $(MFLAGS) clean all
clang-changes:
	scan-build -V -k -o `pwd`/clang $(MAKE) $(MFLAGS) all


#
# Install all targets...
#

install: all @INSTALL_GUIS@ @INSTALL_OSX@
	@echo Installing EPM programs in $(DESTDIR)$(bindir)
	-$(MKDIR) $(DESTDIR)$(bindir)
	$(CP) epm $(DESTDIR)$(bindir)
	$(STRIP) $(DESTDIR)$(bindir)/epm
	$(CP) epminstall $(DESTDIR)$(bindir)
	$(STRIP) $(DESTDIR)$(bindir)/epminstall
	$(CP) mkepmlist $(DESTDIR)$(bindir)
	@echo Installing EPM manpages in $(DESTDIR)$(mandir)/man1
	-$(MKDIR) $(DESTDIR)$(mandir)/man1
	$(CP) $(srcdir)/doc/epm.man $(DESTDIR)$(mandir)/man1/epm.1
	$(CP) $(srcdir)/doc/epminstall.man $(DESTDIR)$(mandir)/man1/epminstall.1
	$(CP) $(srcdir)/doc/mkepmlist.man $(DESTDIR)$(mandir)/man1/mkepmlist.1
	$(CP) $(srcdir)/doc/setup.man $(DESTDIR)$(mandir)/man1/setup.1
	@echo Installing EPM manpages in $(DESTDIR)$(mandir)/man5
	-$(MKDIR) $(DESTDIR)$(mandir)/man5
	$(CP) $(srcdir)/doc/epm.list.man $(DESTDIR)$(mandir)/man5/epm.list.5
	$(CP) $(srcdir)/doc/setup.types.man $(DESTDIR)$(mandir)/man5/setup.types.5
	@echo Installing EPM documentation in $(DESTDIR)$(docdir)
	-$(MKDIR) $(DESTDIR)$(docdir)
	$(CP) $(srcdir)/COPYING $(DESTDIR)$(docdir)
	$(CP) $(srcdir)/README $(DESTDIR)$(docdir)
	$(CP) $(srcdir)/doc/epm-book.html $(DESTDIR)$(docdir)

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

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


#
# Uninstall EPM...
#

uninstall:
	@echo Uninstalling EPM programs from $(DESTDIR)$(bindir)
	$(RM) $(DESTDIR)$(bindir)/epm
	$(RM) $(DESTDIR)$(bindir)/epminstall
	$(RM) $(DESTDIR)$(bindir)/mkepmlist
	@echo Uninstalling EPM manpages from $(DESTDIR)$(mandir)/man1
	$(RM) $(DESTDIR)$(mandir)/man1/epm.1
	$(RM) $(DESTDIR)$(mandir)/man1/epminstall.1
	$(RM) $(DESTDIR)$(mandir)/man1/mkepmlist.1
	$(RM) $(DESTDIR)$(mandir)/man1/setup.1
	@echo Uninstalling EPM manpages from $(DESTDIR)$(mandir)/man5
	$(RM) $(DESTDIR)$(mandir)/man5/epm.list.5
	$(RM) $(DESTDIR)$(mandir)/man5/setup.types.5
	@echo Uninstalling EPM documentation from $(DESTDIR)$(docdir)
	$(RM) -r $(DESTDIR)$(docdir)
	@echo Uninstalling EPM setup/uninstall from $(DESTDIR)$(libdir)/epm
	$(RM) -r $(DESTDIR)$(libdir)/epm
	@echo Uninstalling EPM OSX data files from $(DESTDIR)$(datadir)/epm
	$(RM) -r $(DESTDIR)$(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)
	@echo Starting portable distribution build test...
	@if ./epm -vv epm >test.log; then \
		echo Portable distribution build test PASSED.; \
	else \
		echo Portable distribution build test FAILED.; \
		cat test.log; \
	fi
	@echo Starting native distribution build test...
	@if ./epm -vv -s doc/epmlogo.tif -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 portable: $(TARGETS)
	./epm -v -s doc/epmlogo.gif --setup-program setup \
		--uninstall-program uninst --data-dir macosx epm

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

lsb rpm: $(TARGETS)
	./epm -f $@ -v -s doc/epmlogo.gif --setup-program setup \
		--uninstall-program uninst --data-dir macosx epm

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

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

osx: $(TARGETS)
	./epm -f osx -v -s doc/epmlogo.tif epm

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


#
# libepm.a
#

libepm.a:	$(EPM_OBJS)
	$(RM) libepm.a
	$(AR) $(ARFLAGS) libepm.a $(EPM_OBJS)
	$(RANLIB) libepm.a

$(EPM_OBJS):	epm.h epmstring.h


#
# epm
#

epm:	epm.o $(EPM_OBJS)
	$(CC) $(LDFLAGS) -o epm epm.o libepm.a $(LIBS)

epm.o:	epm.h epmstring.h


#
# epminstall
#

epminstall:	epminstall.o libepm.a
	$(CC) $(LDFLAGS) -o epminstall epminstall.o libepm.a $(LIBS)

epminstall.o:	epm.h epmstring.h


#
# mkepmlist
#

mkepmlist:	mkepmlist.o libepm.a
	$(CC) $(LDFLAGS) -o mkepmlist mkepmlist.o libepm.a $(LIBS)

mkepmlist.o:	epm.h epmstring.h


#
# setup
#

setup:	$(SETUP_OBJS) libepm.a
	$(CXX) $(LDFLAGS) -o setup $(SETUP_OBJS) libepm.a $(GUILIBS) $(LIBS)

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


#
# uninst
#

uninst:	$(UNINST_OBJS) libepm.a
	$(CXX) $(LDFLAGS) -o uninst $(UNINST_OBJS) libepm.a $(GUILIBS) $(LIBS)

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


#
# Common dependencies...
#

$(OBJS):	Makefile config.h


#
# End of "$Id: Makefile.in 827 2010-12-29 17:32:40Z mike $".
#
