#
# Makefile for Rexx/Wrapper
#
# The variable 'srcdir' refers to the source-distribution, and can be set with
# the configure script by "--srcdir=DIR".
#

SHELL		= /bin/sh
THIS		= Makefile

VER=@VER@
VER_DOT=@VER_DOT@
VER_DATE=@VER_DATE@
PACKAGE_DIR=RexxWrapper-$(VER_DOT)
PACKAGE_NAME=rexxwrapper
INTERPRETER = @INTERPRETER@

srcdir		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir  = @bindir@
docdir		= $(srcdir)/doc
thisdir		=@thisdir@
target = @target@

INSTALL		= $(srcdir)/install-sh

#------------------------------------------------------------------------

#
# Distro files not needed by clients
#
DISTFILES =       \
 COPYING          \
 README           \
 aclocal.m4       \
 preinst.rexx     \
 configur.in      \
 configure.in     \
 configure        \
 favicon.ico      \
 rexxwrapper-config.in \
 Makefile.in

DISTDISTFILES =                  \
	$(PACKAGE_DIR)/COPYING          \
	$(PACKAGE_DIR)/README           \
	$(PACKAGE_DIR)/aclocal.m4       \
	$(PACKAGE_DIR)/preinst.rexx     \
	$(PACKAGE_DIR)/configur.in      \
	$(PACKAGE_DIR)/configure.in     \
	$(PACKAGE_DIR)/configure        \
	$(PACKAGE_DIR)/favicon.ico      \
	$(PACKAGE_DIR)/rexxwrapper-config.in \
	$(PACKAGE_DIR)/Makefile.in

DOCFILES =               \
 $(docdir)/index.html    \
 $(docdir)/images/*.png

DISTDOCFILES =                   \
 $(PACKAGE_DIR)/doc/index.html   \
 $(PACKAGE_DIR)/doc/images/*.png

#
# Files needed by clients
#
BASEFILES =       \
 install-sh       \
 config.guess     \
 config.h.in      \
 config.sub       \
 common/defines.h        \
 intbuild.c       \
 rexxtok.c        \
 rexxwrap.c       \
 getargv0.c       \
 rexxwrap.cmd     \
 configur         \
 defined_values.in \
 rxdefines.h

DISTBASEFILES =                  \
	$(PACKAGE_DIR)/install-sh       \
	$(PACKAGE_DIR)/config.guess     \
	$(PACKAGE_DIR)/config.h.in      \
	$(PACKAGE_DIR)/config.sub       \
	$(PACKAGE_DIR)/intbuild.c       \
	$(PACKAGE_DIR)/rexxtok.c        \
	$(PACKAGE_DIR)/rexxwrap.c       \
	$(PACKAGE_DIR)/getargv0.c       \
	$(PACKAGE_DIR)/rexxwrap.cmd     \
	$(PACKAGE_DIR)/configur         \
	$(PACKAGE_DIR)/defined_values.in \
	$(PACKAGE_DIR)/rxdefines.h

#
# Common files
#
COMMONFILES = \
 common/accommon.m4  \
 common/getopt.c     \
 common/defines.h    \
 common/loader.c     \
 common/rxdef.h      \
 common/rxpack.c     \
 common/rxpack.h

DISTCOMMONFILES =            \
	$(PACKAGE_DIR)/common/accommon.m4  \
	$(PACKAGE_DIR)/common/getopt.c     \
	$(PACKAGE_DIR)/common/defines.h    \
	$(PACKAGE_DIR)/common/loader.c     \
	$(PACKAGE_DIR)/common/rxdef.h      \
	$(PACKAGE_DIR)/common/rxpack.c     \
	$(PACKAGE_DIR)/common/rxpack.h

#
# DES encryption files
#
DESFILES =        \
 des/cbc_cksm.c   \
 des/des.h        \
 des/des_enc.c    \
 des/des_locl.h   \
 des/ecb_enc.c    \
 des/podd.h       \
 des/rand_key.c   \
 des/set_key.c    \
 des/sk.h         \
 des/spr.h        \
 des/str2key.c

DISTDESFILES =                   \
	$(PACKAGE_DIR)/des/cbc_cksm.c   \
	$(PACKAGE_DIR)/des/des.h        \
	$(PACKAGE_DIR)/des/des_enc.c    \
	$(PACKAGE_DIR)/des/des_locl.h   \
	$(PACKAGE_DIR)/des/ecb_enc.c    \
	$(PACKAGE_DIR)/des/podd.h       \
	$(PACKAGE_DIR)/des/rand_key.c   \
	$(PACKAGE_DIR)/des/set_key.c    \
	$(PACKAGE_DIR)/des/sk.h         \
	$(PACKAGE_DIR)/des/spr.h        \
	$(PACKAGE_DIR)/des/str2key.c

#
# zlib compression files
#
ZLIBFILES =       \
 zlib/adler32.c   \
 zlib/compress.c  \
 zlib/deflate.c   \
 zlib/deflate.h   \
 zlib/infblock.c  \
 zlib/infblock.h  \
 zlib/infcodes.c  \
 zlib/infcodes.h  \
 zlib/inffast.c   \
 zlib/inffast.h   \
 zlib/inffixed.h  \
 zlib/inflate.c   \
 zlib/inftrees.c  \
 zlib/inftrees.h  \
 zlib/infutil.c   \
 zlib/infutil.h   \
 zlib/trees.c     \
 zlib/trees.h     \
 zlib/uncompr.c   \
 zlib/zconf.h     \
 zlib/zlib.h      \
 zlib/zutil.c     \
 zlib/zutil.h

DISTZLIBFILES =                  \
	$(PACKAGE_DIR)/zlib/adler32.c   \
	$(PACKAGE_DIR)/zlib/compress.c  \
	$(PACKAGE_DIR)/zlib/deflate.c   \
	$(PACKAGE_DIR)/zlib/deflate.h   \
	$(PACKAGE_DIR)/zlib/infblock.c  \
	$(PACKAGE_DIR)/zlib/infblock.h  \
	$(PACKAGE_DIR)/zlib/infcodes.c  \
	$(PACKAGE_DIR)/zlib/infcodes.h  \
	$(PACKAGE_DIR)/zlib/inffast.c   \
	$(PACKAGE_DIR)/zlib/inffast.h   \
	$(PACKAGE_DIR)/zlib/inffixed.h  \
	$(PACKAGE_DIR)/zlib/inflate.c   \
	$(PACKAGE_DIR)/zlib/inftrees.c  \
	$(PACKAGE_DIR)/zlib/inftrees.h  \
	$(PACKAGE_DIR)/zlib/infutil.c   \
	$(PACKAGE_DIR)/zlib/infutil.h   \
	$(PACKAGE_DIR)/zlib/trees.c     \
	$(PACKAGE_DIR)/zlib/trees.h     \
	$(PACKAGE_DIR)/zlib/uncompr.c   \
	$(PACKAGE_DIR)/zlib/zconf.h     \
	$(PACKAGE_DIR)/zlib/zlib.h      \
	$(PACKAGE_DIR)/zlib/zutil.c     \
	$(PACKAGE_DIR)/zlib/zutil.h

JUNK = $(OFILES) $(SHL_TARGETS)

################################################################################
all: rexxwrapper

rexxwrapper: $(srcdir)/rexxwrap.cmd
	rexx $(srcdir)/rexxwrap.cmd -program=rexxwrapper -rexxfiles=$(srcdir)/rexxwrap.cmd \
	-compiler=$(CC) -interpreter=$(INTERPRETER) -srcdir=$(srcdir) -compress

distclean: clean
	-rm -f Makefile config.h

mostlyclean: clean

realclean: distclean

zip:
	zip rxwrap$(VER) $(DISTFILES) $(BASEFILES) $(DESFILES) $(ZLIBFILES) $(COMMONFILES) $(DOCFILES)

dist:
	(cd $(srcdir)/..; tar cvf - \
	$(DISTDISTFILES) $(DISTBASEFILES) $(DISTDESFILES) $(DISTZLIBFILES) $(DISTCOMMONFILES) $(DISTDOCFILES) \
	| gzip > $(PACKAGE_DIR).tar.gz)

install: all
	$(INSTALL) -m 755 -d $(bindir)
	$(INSTALL) -m 755 -d $(prefix)/share/rexxwraper
	$(INSTALL) -m 755 -c $(srcdir)/rexxwrapper-config $(bindir)/rexxwrapper-config
	$(INSTALL) -m 755 -c rexxwrapper $(bindir)/rexxwrapper
	@for distfile in $(BASEFILES) $(DESFILES) $(ZLIBFILES) $(COMMONFILES); do \
		echo "$(INSTALL) -m 755 -c $$distfile $(prefix)/share/rexxwrapper/$$distfile"; \
		$(INSTALL) -m 755 -c $$distfile $(prefix)/share/rexxwrapper/$$distfile ; \
	done

clean:
	rm -f $(JUNK)

#
# End of makefile
#
