Index: branches/1.0/Makefile
===================================================================
--- branches/1.0/Makefile	(revision 834)
+++ branches/1.0/Makefile	(revision 840)
@@ -2,4 +2,5 @@
 #
 TMPDIR = /tmp
+DESTDIR = /usr/local
 
 # Clear this if you don't want to use ${FAKEROOT}
@@ -17,6 +18,6 @@
 REQUIRED = ./jobarchived ./jobmond ./web
 
-deb:	deb-jobmond deb-jobarchived deb-webfrontend
-rpm:	rpm-jobmond rpm-jobarchived rpm-webfrontend
+deb:	tarball-bzip
+rpm:	tarball-bzip
 
 all:	tarball deb rpm
@@ -24,5 +25,5 @@
 tarball:	tarball-gzip tarball-bzip
 
-tarball-gzip:	${REQUIRED}
+tarball-gzip:	${REQUIRED} rpmspec
 	mkdir -p ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}
 	( rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
@@ -31,5 +32,5 @@
 	mv ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}.tar.gz ..
 
-tarball-bzip:	${REQUIRED}
+tarball-bzip:	${REQUIRED} rpmspec
 	mkdir -p ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}
 	( rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
@@ -37,4 +38,69 @@
 	( cd ${TMPDIR}/.monarch_buildroot; tar jcvf ganglia_jobmonarch-${VERSION}.tar.bz2 ./ganglia_jobmonarch-${VERSION} )
 	mv ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}.tar.bz2 ..
+
+rpmspec: pkg/rpm/jobmonarch.spec.in
+	sed -e 's/__VERSION__/$(VERSION)/g' -e 's/__RELEASE__/$(RELEASE)/g' ./pkg/rpm/jobmonarch.spec.in > jobmonarch.spec
+
+debpkgdir: pkg/deb/debian
+	rsync -a --exclude=.svn pkg/deb/debian debian
+	sed -i -e 's/^Version:.*$//Version: $(VERSION)-$(RELEASE)/g' ./debian/control
+
+rpm: tarball-bzip
+	rpmbuild -tb ../ganglia_jobmonarch-${VERSION}.tar.bz2
+
+deb: debpkgdir
+	dpkg-buildpackage -b
+
+install:
+	# Files in SBIN_DIR
+	install -m 0755 -d $(DESTDIR)/usr/sbin
+	install -m 0755 jobmond/jobmond.py $(DESTDIR)/usr/sbin/
+	install -m 0755 jobarchived/jobarchived.py $(DESTDIR)/usr/sbin/
+	(cd $(DESTDIR)/usr/sbin/; ln -s jobmond.py jobmond; ln -s jobarchived.py jobarchived)
+	#
+	# Files specific to distros if /etc/sysconfig => rpm else (/etc/default => debian)
+	if test -d /etc/sysconfig; then \
+		install -m 0755 -d $(DESTDIR)/etc/rc.d/init.d; \
+		install -m 0755 pkg/rpm/init.d/jobmond $(DESTDIR)/etc/rc.d/init.d/; \
+		install -m 0755 pkg/rpm/init.d/jobarchived $(DESTDIR)/etc/rc.d/init.d/; \
+		install -m 0755 -d $(DESTDIR)/etc/sysconfig; \
+		install -m 0755 pkg/rpm/sysconfig/jobmond $(DESTDIR)/etc/sysconfig; \
+		install -m 0755 pkg/rpm/sysconfig/jobarchived $(DESTDIR)/etc/sysconfig; \
+	else \
+		install -m 0755 -d $(DESTDIR)/etc/init.d; \
+		install -m 0755 pkg/deb/init.d/jobmond $(DESTDIR)/etc/init.d/; \
+		install -m 0755 pkg/deb/init.d/jobarchived $(DESTDIR)/etc/init.d/; \
+		install -m 0755 -d $(DESTDIR)/etc/default; \
+		install -m 0755 pkg/deb/default/jobmond $(DESTDIR)/etc/default; \
+		install -m 0755 pkg/deb/default/jobarchived $(DESTDIR)/etc/default; \
+	fi
+	#
+	# Files in /etc
+	#
+	install -m 0644 jobmond/jobmond.conf $(DESTDIR)/etc; \
+	install -m 0644 jobarchived/jobarchived.conf $(DESTDIR)/etc; \
+	#
+	# Files in /usr/share
+	#
+	install -m 0755 -d $(DESTDIR)/usr/share/jobarchived/
+	install -m 0755 jobarchived/job_dbase.sql $(DESTDIR)/usr/share/jobarchived/
+	#
+	# Create the /var/lib/jobarchive directory where rrds are stored.
+	#
+	install -m 0755 -d $(DESTDIR)/var/lib/jobarchive/
+	#
+	# Files for ganglia (adapt to rpm or deb or unknown ganglia packaging)
+	#
+	if test -d /etc/sysconfig; then \
+		install -m 0755 -d $(DESTDIR)/usr/share/ganglia; \
+		(cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)/usr/share/ganglia); \
+	elif test -d /etc/default; then \
+		install -m 0755 -d $(DESTDIR)/usr/share/ganglia-webfrontend; \
+		(cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)/usr/share/ganglia-webfrontend); \
+	else \
+		install -m 0755 -d $(DESTDIR)/$(WEBDIR); \
+		(cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)/$(WEBDIR)); \
+	fi
+
 
 deb-webfrontend:	${REQUIRED}
@@ -97,75 +163,6 @@
 	mv ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond_${VERSION}-${RELEASE}.deb ..
 
-rpm-jobmond:	${REQUIRED}
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/etc/init.d >/dev/null
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/etc/sysconfig >/dev/null
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/usr/sbin >/dev/null
-	install -m 755 jobmond/jobmond.py ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/usr/sbin
-	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/usr/sbin; \
-	ln -s jobmond.py jobmond || true)
-	install jobmond/jobmond.conf ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/etc
-	install pkg/rpm/init.d/jobmond ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/etc/init.d
-	install pkg/rpm/sysconfig/jobmond ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/etc/sysconfig
-	cp pkg/rpm/jobmonarch-jobmond.spec \
-	${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}/jobmonarch-jobmond-${VERSION}-${RELEASE}.spec
-	( cd ${TMPDIR}/.monarch_buildroot/; \
-	cat jobmonarch-jobmond-${VERSION}-${RELEASE}/jobmonarch-jobmond-${VERSION}-${RELEASE}.spec \
-	| sed "s/^Buildroot:.*$//Buildroot: \${TMPDIR}\/\.monarch_buildroot\/jobmonarch-jobmond-${VERSION}-${RELEASE}/g" \
-	| sed "s/^Version:.*$//Version: ${VERSION}/g" \
-	| sed "s/^Release:.*$//Release: ${RELEASE}/g" \
-	>jobmonarch-jobmond-${VERSION}-${RELEASE}/jobmonarch-jobmond-${VERSION}-${RELEASE}.spec.new; \
-	mv jobmonarch-jobmond-${VERSION}-${RELEASE}/jobmonarch-jobmond-${VERSION}-${RELEASE}.spec.new \
-	jobmonarch-jobmond-${VERSION}-${RELEASE}/jobmonarch-jobmond-${VERSION}-${RELEASE}.spec )
-	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}; \
-	${FAKEROOT} rpmbuild --buildroot=${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE} -bb jobmonarch-jobmond-${VERSION}-${RELEASE}.spec )
-	mv ${TMPDIR}/.monarch_buildroot/jobmonarch-jobmond-${VERSION}-${RELEASE}.rpm ..
-
-rpm-jobarchived:	${REQUIRED}
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d >/dev/null
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/sysconfig >/dev/null
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin >/dev/null
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/share/jobarchived >/dev/null
-	install -m 755 jobarchived/jobarchived.py ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin
-	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin; \
-	ln -s jobarchived.py jobarchived || true)
-	install jobarchived/jobarchived.conf ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc
-	install pkg/rpm/init.d/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d
-	install pkg/rpm/sysconfig/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/sysconfig
-	install jobarchived/job_dbase.sql \
-	${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/share/jobarchived
-	cp pkg/rpm/jobmonarch-jobarchived.spec \
-	${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/jobmonarch-jobarchived-${VERSION}-${RELEASE}.spec
-	( cd ${TMPDIR}/.monarch_buildroot/; \
-	cat jobmonarch-jobarchived-${VERSION}-${RELEASE}/jobmonarch-jobarchived-${VERSION}-${RELEASE}.spec \
-	| sed "s/^Buildroot:.*$//Buildroot: \${TMPDIR}\/\.monarch_buildroot\/jobmonarch-jobarchived-${VERSION}-${RELEASE}/g" \
-	| sed "s/^Version:.*$//Version: ${VERSION}/g" \
-	| sed "s/^Release:.*$//Release: ${RELEASE}/g" \
-	>jobmonarch-jobarchived-${VERSION}-${RELEASE}/jobmonarch-jobarchived-${VERSION}-${RELEASE}.spec.new; \
-	mv jobmonarch-jobarchived-${VERSION}-${RELEASE}/jobmonarch-jobarchived-${VERSION}-${RELEASE}.spec.new \
-	jobmonarch-jobarchived-${VERSION}-${RELEASE}/jobmonarch-jobarchived-${VERSION}-${RELEASE}.spec )
-	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}; \
-	${FAKEROOT} rpmbuild --buildroot=${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE} -bb jobmonarch-jobarchived-${VERSION}-${RELEASE}.spec )
-	mv ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}.rpm ..
-
-rpm-webfrontend:	${REQUIRED}
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend-${VERSION}-${RELEASE}/${WEBDIR} >/dev/null
-	( cd web; \
-	rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
-	. ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend-${VERSION}-${RELEASE}/${WEBDIR} )
-	cp pkg/rpm/jobmonarch-webfrontend.spec \
-	${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend-${VERSION}-${RELEASE}/jobmonarch-webfrontend-${VERSION}-${RELEASE}.spec
-	( cd ${TMPDIR}/.monarch_buildroot/; \
-	cat jobmonarch-webfrontend-${VERSION}-${RELEASE}/jobmonarch-webfrontend-${VERSION}-${RELEASE}.spec \
-	| sed "s/^Buildroot:.*$//Buildroot: \${TMPDIR}\/\.monarch_buildroot\/jobmonarch-webfrontend-${VERSION}-${RELEASE}/g" \
-	| sed "s/^Version:.*$//Version: ${VERSION}/g" \
-	| sed "s/^Release:.*$//Release: ${RELEASE}/g" \
-	| sed "s+/var/www/ganglia+${WEBDIR}+g" \
-	>jobmonarch-webfrontend-${VERSION}-${RELEASE}/jobmonarch-webfrontend-${VERSION}-${RELEASE}.spec.new; \
-	mv jobmonarch-webfrontend-${VERSION}-${RELEASE}/jobmonarch-webfrontend-${VERSION}-${RELEASE}.spec.new \
-	jobmonarch-webfrontend-${VERSION}-${RELEASE}/jobmonarch-webfrontend-${VERSION}-${RELEASE}.spec )
-	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend-${VERSION}-${RELEASE}; \
-	${FAKEROOT} rpmbuild --buildroot ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend-${VERSION}-${RELEASE} -bb jobmonarch-webfrontend-${VERSION}-${RELEASE}.spec )
-	mv ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend-${VERSION}-${RELEASE}.rpm ..
-
-clean:	${TMPDIR}/.monarch_buildroot
+clean:
 	rm -rf ${TMPDIR}/.monarch_buildroot
+	rm -rf ./jobmonarch.spec
+	rm -rf ./debian
