File:  [LON-CAPA] / nsdl / build / Makefile
Revision 1.7: download - view: text, annotated - select for diffs
Sat Oct 12 16:48:37 2002 UTC (19 years, 10 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
improving "help" targets; also approaching a solution for bug 348 (generate
a distributable tarball for NSDL gateway)

# The NSDL to LON-CAPA Gateway Server

# Scott Harrison
# $Id: Makefile,v 1.7 2002/10/12 16:48:37 harris41 Exp $

# Quick usage:
# Either type "make all" (compiles and installs code onto your system), or
# type "make tardist" and use the distributable tarball.

DISTPROBE=`perl ./distprobe`
DIST=$(DISTPROBE)
CATEGORY="development"
SOURCE=..
TARGET=""
NORESTORECONF="0"
HOSTNAME=""
LAUNCH=| perl
OUTSTREAM=>
SAVE=program.pl.$(TIMESTAMP)
LAUNCHSAVE=$(OUTSTREAM) $(SAVE)
METAMTARGET=""
MTARGET=""
VERSION=0.1

help:
	@echo "*** You need to specify a valid target ***"
	@echo "To get a list of valid targets: \"make help_TARGETS\""
	@echo "To get a list of valid options: \"make help_OPTIONS\""
	@echo " "
	@echo "Typically invoked targets are:"
	@echo "    make build"
	@echo "    make install"
	@echo "    make all"
	@echo "    make tardist"
	@echo "    make clean"

help_OPTIONS:
	@echo "You can specify options to your Makefile target."
	@echo "(option) DIST can be redhat6, redhat7, debian2.2, or default"
	@echo "(option) CATEGORY can be runtime or development"
	@echo "(option) SOURCE is an absolute or relative directory path"
	@echo "(option) TARGET is an absolute or relative directory path"

help_TARGETS:
	@echo "Valid targets"	
	@echo "build: compile the CVS source tree"
	@echo "install: install from a compiled CVS source tree to a "
	@echo "         specified TARGET destination on the filesystem"
	@echo "test: test different parts of the LON-CAPA system (TEST_*)"
	@echo "TEST_lpml: make sure that the system can process "
	@echo "                   the Linux Packaging Markup Language"
	@echo "TEST_system_dependencies: make sure that all needed system "
	@echo "                          components are active and present "
	@echo "                          on the server such as perl modules"
	@echo "                          and the MySQL database"
	@echo "TEST_weblayer: mimic various web-based interactions with "
	@echo "                respect to the login and various system "
	@echo "                actions on the Gateway server"
	@echo "HTML: generate an HTML-formatted description of the "
	@echo "      NSDL to LON-CAPA Gateway Server CVS source files"
	@echo "doc: compiles documentation for the system administration of"
	@echo "     the gateway server"
	@echo "status: compare the TARGET filesystem with a compiled CVS "
	@echo "        source directory"
	@echo "statuspost: post the results of "make status" to "
	@echo "            TARGET/home/httpd/html/lon-status/filestatus.html"
	@echo "rpmstatus: compare the rpms on a system to defined lists "
	@echo "           CVS:doc/otherfiles/cd_rpms and "
	@echo "           CVS:doc/otherfiles/rpm_list.txt"
	@echo "rpmstatuspost: post the results of "make rpmstatus" to "
	@echo "            TARGET/home/httpd/html/lon-status/rpmstatus.html"
	@echo "tardist: build a tarball that will upgrade the software on a "
	@echo "         system"

build: Makefile.build
	echo -n "" > WARNINGS
	make -f Makefile.build all
	make warningnote

Makefile.build: Makefile alwaysrun
	cat gatewayfiles.lpml | \
	perl lpml_parse.pl build $(CATEGORY) $(DIST) "$(SOURCE)" \
	"$(TARGET)" > Makefile.build

NET_install:
	make TIMESTAMP=`date +"%s"` METAMTARGET="TRANSPORT" \
	MTARGET="install" HOSTNAME="$(HOSTNAME)" lpmladm
	make warningnote

install: Makefile.install
	@echo -n "" > WARNINGS
	make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" \
	directories
	make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" files
	make warningnote

Makefile.install: Makefile alwaysrun
	cat gatewayfiles.lpml | \
	perl lpml_parse.pl install $(CATEGORY) $(DIST) "$(SOURCE)" \
	"$(TARGET)" > Makefile.install

alwaysrun:

test: TEST_lpml TEST_system_dependencies TEST_weblayer
	@echo "ALL TESTS SUCCESSFUL"

TEST_lpml:
	@echo "TESTING LPML INSTALLATION MECHANISM"
	cd lpml_test; perl filecomparetest.pl

TEST_system_dependencies:
	@echo "TESTING WEB LAYER"

TEST_weblayer:
	@echo "TESTING SYSTEM DEPENDENCIES"

HTML:
	install -d HTML
	cp $(SOURCE)/doc/gatewayfiles/*.gif HTML
	cat gatewayfiles.lpml | \
	perl lpml_parse.pl html development default "$(SOURCE)" '$(TARGET)' \
	> HTML/index.html

doc:
	@echo "Not yet implemented"

status:
	@echo "Not yet implemented"

statuspost:
	@echo "Not yet implemented"

tardist:
	@echo "Not yet fully implemented"
	make MANIFEST_all

MANIFEST_all:
	rm -f $(SOURCE)/MANIFEST
	make MANIFEST_lpml

MANIFEST_lpml:
#	cat $(SOURCE)/buildfiles.lpml | \
#	perl lpml_parse.pl MANIFEST development default \
#	'$(SOURCE)' '$(TARGET)' | grep '[[:alnum:]]' >> $(SOURCE)/MANIFEST
#	cat $(SOURCE)/testfiles.lpml | \
#	perl lpml_parse.pl MANIFEST development default \
#	'$(SOURCE)' '$(TARGET)' | grep '[[:alnum:]]' >> $(SOURCE)/MANIFEST
	cat $(SOURCE)/build/gatewayfiles.lpml | \
	perl lpml_parse.pl MANIFEST development default \
	'$(SOURCE)' '$(TARGET)' | grep '[[:alnum:]]' >> $(SOURCE)/MANIFEST

warningnote:
	@if (test -s WARNINGS); then \
		W=`grep -c '\*\*\*\* WARNING' WARNINGS`; \
		E=`grep -c '\*\*\*\* ERROR' WARNINGS`; \
		N=`grep -c '\*\*\*\* NOTE' WARNINGS`; \
		echo "--->  $$W WARNINGS ENCOUNTERED!       "; \
		echo "--->  $$E ERRORS ENCOUNTERED!         "; \
		echo "--->  $$N NOTES ENCOUNTERED!          "; \
		echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
		echo "!!!!  Please read the WARNINGS file !!!!"; \
		echo "!!!!   to make sure everything is   !!!!"; \
		echo "!!!!    correct and taken care of   !!!!"; \
		echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
	fi

lpmladm:
	@if (test $(METAMTARGET) = "TRANSPORT"); then \
		echo "Transporting to $(HOSTNAME)"; \
		sudo mkdir lpmladm.$(TIMESTAMP); \
		sudo make DIST=$(DIST) CATEGORY=$(CATEGORY) \
		SOURCE="$(SOURCE)" \
		TARGET="lpmladm.$(TIMESTAMP)" \
		NORESTORECONF="$(NORESTORECONF)" "$(MTARGET)"; \
		cd lpmladm.$(TIMESTAMP); \
		sudo tar czf ../tarball$(TIMESTAMP).tar.gz .; \
		cd ..; scp tarball$(TIMESTAMP).tar.gz \
		lpmladm@$(HOSTNAME):~/tarball$(TIMESTAMP).tar.gz; \
		sudo rm -Rf lpmladm.$(TIMESTAMP); \
		sudo rm -f tarball$(TIMESTAMP).tar.gz; \
		ssh lpmladm@$(HOSTNAME) sudo mv tarball$(TIMESTAMP).tar.gz /; \
		ssh lpmladm@$(HOSTNAME) sudo tar -x -z -C / \
		-p --same-owner -f \
		/tarball$(TIMESTAMP).tar.gz; \
		ssh lpmladm@$(HOSTNAME) sudo rm -f \
		/tarball$(TIMESTAMP).tar.gz; \
	elif (test $(METAMTARGET) = "LAUNCH"); then \
		echo "Launching process on $(HOSTNAME)"; \
		LAUNCHSAVE=$(OUTSTREAM) $(SAVE); \
		make DIST=$(DIST) CATEGORY=$(CATEGORY) SOURCE="$(SOURCE)" \
		TARGET="$(TARGET)" NORESTORECONF="$(NORESTORECONF)" \
		LAUNCH="$(LAUNCHSAVE)" "$(MTARGET)"; \
		scp $(SAVE) lpmladm@$(HOSTNAME):$(SAVE); \
		ssh lpmladm@$(HOSTNAME) sudo -u $(LAUNCHUSER) perl $(SAVE); \
	else \
		echo "**** ERROR **** Incorrect METAMTARGET"; \
	fi
#		ssh lpmladm@$(HOSTNAME) sudo rm -f $(SAVE); \

clean:
	@echo "Not yet implemented"


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>