The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
# makefile for rebuilding perl and all the modules we have built
# or for rebuilding individual modules
SHELL =		/usr/bin/ksh
CPAN_VERSION =	5.6.1
FCCS_VERSION =	fccs-03
#needed for compatibility with ../build.mk:
TOOL =		perl
PERL_VERSION =	$(TOOL)-$(CPAN_VERSION)
TOP =	/opt/oss
PERLDIR =	$(PERL_VERSION)-$(FCCS_VERSION)
PERL_ROOT =	$(TOP)/pkg
PREFIX =	$(PERL_ROOT)/$(PERLDIR)
#needed for compatibility with ../biuld.mk:
VERSION =	$(CPAN_VERSION)-$(FCCS_VERSION)

MQS =		MQSeries-1.14
DBDORA =	DBD-Oracle-1.12
DBI =		DBI-1.20
EXPAT_VER =	-1.95.2
MQSERVER =	'PERL_CHANNEL/TCP/dsas105(1414)'

MODULES = \
	libnet-1.0703 \
	Storable-0.7.2 \
	Time-HiRes-01.20 \
	Net-Daemon-0.35 \
	Digest-MD5-2.16 \
	Digest-SHA1-2.01 \
	Digest-HMAC-1.01 \
	MIME-Base64-2.12 \
	Net-DNS-0.19 \
	Mail-CheckUser-1.13 \
	Proc-Daemon-0.02 \
	Proc-Simple-1.14 \
	Openview-Message-0.01 \
	Business-CreditCard-0.26 \
	Data-UUID-0.06

XML_PARSER =	XML-Parser-2.31
XML_MODULES =	\
	XML-Simple-1.05 \
	XML-Generator-0.8
#this does not behave same as 0.8
#XML-Generator-0.91

all:	testOracleVar
	@banner ALL_PERL
	@echo "using perl PATH=$(PREFIX)/bin"
	( export PATH=$(PREFIX)/bin:$$PATH && make perl )
	( export PATH=$(PREFIX)/bin:$$PATH && make all_modules )

print_macros:
	@echo TOOL=$(TOOL)
	@echo CPAN_VERSION=$(CPAN_VERSION)
	@echo PERL_VERSION=$(PERL_VERSION)
	@echo FCCS_VERSION=$(FCCS_VERSION)
	@echo PREFIX=$(PREFIX)
	@echo VERSION=$(VERSION)
	@echo PERLDIR=$(PERLDIR)
	@echo PERL_ROOT=$(PERL_ROOT)

all_modules:	modules xmlparser xml_modules dbi dbd mqs

modules:	testPath
	rm -rf $(MODULES)
	for m in $(MODULES); do \
	make module MODULE=$$m  PREFIX=$(PREFIX) ; \
	done

xml_modules:	testPath
	rm -rf $(XML_MODULES)
	for m in $(XML_MODULES); do \
	make module MODULE=$$m  PREFIX=$(PREFIX) ; \
	done

dbi:	testPath
	make module MODULE=DBI-1.20 PREFIX=$(PREFIX)

dbd:	testPath testOracleVar dbi touch.d/$(DBDORA).tch

touch.d:
	mkdir touch.d

xmlparser:	touch.d/$(XML_PARSER).tch
touch.d/$(XML_PARSER).tch:	$(XML_PARSER).tar.gz
	tar -zxvf $(XML_PARSER).tar.gz
	(  cd $(XML_PARSER) && \
	perl Makefile.PL EXPATLIBPATH=$(TOP)/lib \
	EXPATINCPATH=$(TOP)/include && \
	make && \
	make test && \
	make install )
	rm -rf $(XML_PARSER)
	touch $@

#chmod +w CONFIG;
mqs_config:
	( cd $(MQS); \
	mv CONFIG CONFIG.orig; \
	cp ../$$(uname).MQS.CONFIG CONFIG \
	)

mqs_target:
	( export MQSERVER=$(MQSERVER); \
	cd $(MQS) ;\
	make $(MQS_TARGET) \
	)

mqs_build:
	( export MQSERVER=$(MQSERVER); \
	cd $(MQS) ;\
	cp ../$$(uname).MQS.CONFIG ./CONFIG; \
	perl Makefile.PL; \
	make ; \
	)

mqs:	testPath /opt/mqm touch.d/$(MQS).tch
touch.d/$(MQS).tch:
	@banner $(MQS)
	rm -rf $(MQS)
	gunzip -c $(MQS).tar.gz | tar -xvf -
	touch $(MQS)/.LICENSE.ACCEPTED
	make -s mqs_config
	make -s mqs_build
	make -s mqs_target MQS_TARGET=test
	make -s mqs_target MQS_TARGET=install
	touch $@


touch.d/$(DBDORA).tch:	testOracleVar
	@banner $(DBDORA)
	test ! -z "$(ORACLE_HOME)"
	-rm -rf   $(DBDORA)
	gunzip -c $(DBDORA).tar.gz | tar -xf -
	cd $(DBDORA) ;\
	perl Makefile.PL; \
	make ; \
	make test  ; \
	make install
	touch touch.d/$(DBDORA).tch


perl:	testVar $(PERL_VERSION) touch.d/$(PERL_VERSION).tch

touch.d/$(PERL_VERSION).tch:
	@banner perl
	@if ls  $(PREFIX) >/dev/null 2>&1 ; \
	then \
	echo "Error: Cannot install to an existing directory" ;\
	echo "Error: Please delete or move $(PREFIX)" ;\
	exit 1;\
	fi
	- cd $(PERL_VERSION); make distclean;
	cd $(PERL_VERSION); \
	./Configure -Dprefix=$(PREFIX) -Ubincompat5005 -Uuselargefiles \
	-A eval:libswanted='\"cl pthread $$libswanted\" ' -des; \
	make ; \
	make test; \
	make install
	touch touch.d/$(PERL_VERSION).tch

realclean distclean: clean_tch
	-rm -rf $(PERL_VERSION)

clean:	clean_tch
clean_tch :
	-rm -f touch.d/*.tch

module:	touch.d/$(MODULE).tch

touch.d/$(MODULE).tch :
	@banner $(MODULE)
	-rm -rf $(MODULE)
	gunzip -c $(MODULE).tar.gz | tar -xf -
	cd $(MODULE); \
	perl Makefile.PL </dev/null; \
	make test ; \
	if test -r Skipit_Makefile.aperl; then \
	make -f Makefile.aperl inst_perl MAP_TARGET=perl; \
	fi ;\
	make install
	rm -rf $(MODULE)
	touch touch.d/$(MODULE).tch

$(PERL_VERSION):
	@if ls  $(PREFIX) >/dev/null 2>&1 ; \
	then \
	echo "Error: Cannot install to an existing directory" ;\
	echo "Error: Please delete or move $(PREFIX)" ;\
	exit 1;\
	fi
	gunzip -c $(PERL_VERSION).tar.gz |tar xf -
	@echo "untar of perl is done"

testVars:	testVar testPath testOracleVar

testVar:	touch.d
	@echo "******** Building to: $(PREFIX) *********"

testOracleVar:
	@if test  -z "$$ORACLE_HOME" ; \
	then \
	echo " Please set \"export ORACLE_HOME=<value>\"" ;\
	exit 1; \
	else \
	echo ORACLE_HOME=$(ORACLE_HOME); \
	fi
	@if test  -z "$$ORACLE_USERID" ; \
	then \
	echo " Please set \"export ORACLE_USERID=<username/password@dbname>\"" ;\
	exit 1; \
	else \
	echo ORACLE_USERID=$(ORACLE_USERID); \
	fi

testPath:
	@if echo $$PATH | egrep -q '^$(PREFIX)/bin:'; then \
	echo PATH is OK; \
	else \
	echo "ERROR: You must have $(PREFIX)/bin first in your path as follows:" ;\
	echo "   export PATH=$(PREFIX)/bin:\$$PATH" ;\
	exit 1; \
	fi