LCDetectors
diff -u -r1.8 -r1.9
--- Makefile 16 Sep 2006 22:42:48 -0000 1.8
+++ Makefile 16 Sep 2006 23:53:45 -0000 1.9
@@ -3,70 +3,179 @@
# build shell scripts.
#
+# SLAC NFS location of GeomConverter.
ifndef GEOMCONVERTER
- GEOMCONVERTER=$(PRJ_DIST)/GeomConverter/pro/bin/GeomConverter
+ GEOMCONVERTER=/nfs/slac/g/lcd/mc/prj/sw/dist/GeomConverter/pro/bin/GeomConverter
endif
-rebuild: update_all taglist lcdd_all heprep_all zip_all update_all
+# SLAC NFS location of LCSim website.
+ifndef PRJ_WWW
+ PRJ_WWW=/nfs/slac/g/lcd/mc/prj/www/lcsim/
+endif
+
+# List of all detectors.
+DETECTORS=$(shell cat detectors/taglist.txt)
+
+.DEFAULT: help
+
+help:
+ @echo "----LCDetectors Makefile Targets----" ; \
+ echo ; \
+ echo "ALL DETECTORS"; \
+ echo ; \
+ echo "build_all - rebuild all detectors"; \
+ echo "update_all - update detectors to WWW"; \
+ echo "lcdd_all - make LCDD files for all detectors"; \
+ echo "heprep_all - make HepRep files for all detectors"; \
+ echo "zip_all - make zip files for all detectors"; \
+ echo ; \
+ echo "SINGLE DETECTOR"; \
+ echo ; \
+ echo "Define a detector using" ;\
+ echo " export DETECTOR=detname"; \
+ echo "or" ; \
+ echo " make DETECTOR=detname" ;\
+ echo ; \
+ echo "build - rebuild single detector"; \
+ echo "update - update single detector to WWW"; \
+ echo "lcdd - make LCDD file for single detector"; \
+ echo "heprep - make HepRep file for single detector"; \
+ echo "cvs_commit - commit changes to single detector"; \
+ echo "mkdir - make directory for new detector"; \
+ echo "template - copy template files to new detector dir"; \
+ echo "properties - create detector.properties file for single detector"; \
+ echo "zip - create zip file for single detector"; \
+ echo "new - create a new detector"; \
+ echo ; \
+ echo "MISCELLANEOUS"; \
+ echo "taglist - create detectors/taglist.txt"; \
+ echo "taglist_commit - commit detectors/taglist.txt to CVS"; \
+ echo "cvs_update - update from LCDetectors CVS";
+ echo ; \
+ echo "Questions or bugs to <[log in to unmask]>";
+
+# Rebuild all detectors. CAREFUL WITH THIS TARGET.
+build_all: lcdd_all heprep_all zip_all update_all
+# Remake the taglist at ./detector/taglist.txt
taglist:
- @cd detectors && ./make_taglist.sh
+ @ echo "Creating detector taglist ..." ; \
+ > taglist.txt; \
+ for d in `find detectors -type d -mindepth 1 -maxdepth 1`; do \
+ dd=$$(basename $$d); \
+ if [ -e $$d/compact.xml ]; then \
+ echo $$dd >> taglist.txt ; \
+ fi \
+ done ; \
+ sort taglist.txt > taglist.txt.tmp ; \
+ mv taglist.txt.tmp ./detectors/taglist.txt; \
+ cp taglist.txt /nfs/slac/g/lcd/mc/prj/www/lcsim/detectors; \
+ cat ./detectors/taglist.txt;
+# Commit the taglist to the CVS.
taglist_commit:
@cd detectors && cvs commit -m "Update taglist." taglist.txt
+# Update from the LCDetectors CVS, getting possibly new detector directories.
cvs_update:
@cd detectors && cvs update -d
+# Update each detector the LCDetectors CVS.
update_all:
- @cd detectors && ./update_detectors.sh
+ @for detector in $(DETECTORS); do \
+ $(MAKE) update DETECTOR=$$detector; done
+# Create the LCDD file for each detector.
lcdd_all:
- @cd detectors && ./make_all_lcdd.sh
+ @for detector in $(DETECTORS); do \
+ $(MAKE) lcdd DETECTOR=$$detector; done
+# Create the HepRep file for each detector.
heprep_all:
- @cd detectors && ./make_all_heprep.sh
+ @for detector in $(DETECTORS); do \
+ $(MAKE) heprep DETECTOR=$$detector; done
+# Create the zip file for each detector.
zip_all:
- @cd detectors && ./make_zips.sh
+ @for detector in $(DETECTORS); do \
+ $(MAKE) zip DETECTOR=$$detector; done
+# Following are targets that are only defined if the
+# DETECTOR variable is defined. This means the user
+# is currently working on this detector. These targets
+# are also used by the above targets that operate on all
+# detectors.
ifdef DETECTOR
# Check for a compact description before doing anything.
detcheck=$(shell if [ ! -e detectors/$(DETECTOR)/compact.xml ]; then echo "no"; else echo "yes"; fi)
+# If the check for the compact description fails, then throw a fatal error.
ifeq ($(detcheck),no)
$(error FATAL ERROR: Check for compact description at ./detectors/$(DETECTOR)/compact.xml failed!)
endif
.PHONY: build update zip lcdd cvs_commit mkdir template properties new
+.DEFAULT: build
+
+# Build a single detector.
build: lcdd zip
+# Update detector to the website if necessary.
update:
- @cd detectors && ./update_detector.sh $(DETECTOR)
-
-zip:
- @cd detectors && ./make_detector_zip.sh $(DETECTOR)
+ @if [[ detectors/$(DETECTOR).zip -nt $(PRJ_WWW)/detectors/$(DETECTOR).zip ]]; then \
+ chk_local=$$(md5sum detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
+ chk_www=$$(md5sum $(PRJ_WWW)/detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
+ if [[ $$chk_local != $$chk_www ]]; then \
+ echo "Detector $(DETECTOR) needs update ..."; \
+ echo "Copying detectors/$(DETECTOR).zip to $(PRJ_WWW)/detectors ..."; \
+ cp detectors/$(DETECTOR).zip $(PRJ_WWW)/detectors; \
+ else \
+ echo "$(PRJ_WWW)/detectors/$(DETECTOR).zip is already up-to-date."; \
+ fi \
+ else \
+ echo "Detector $(DETECTOR) is already up-to-date."; \
+ fi
+# Create the LCDD file for a single detector.
lcdd:
- @cd detectors && ./make_lcdd.sh $(DETECTOR)
+ @echo "Creating LCDD file for $(DETECTOR)..." ; \
+ $(GEOMCONVERTER) -o lcdd ./detectors/$(DETECTOR)/compact.xml ./detectors/$(DETECTOR)/$(DETECTOR).lcdd;
+# Create the HepRep file for a single detector.
heprep:
- @cd detectors && ./make_heprep.sh $(DETECTOR)
+ @echo "Creating HepRep file for $(DETECTOR)..." ; \
+ $(GEOMCONVERTER) -o heprep ./detectors/$(DETECTOR)/compact.xml ./detectors/$(DETECTOR)/detector.heprep;
+# Commit changes to LCDetectors cvs for a single detector.
cvs_commit:
@if [ -d detectors/$(DETECTOR) ]; then cd detectors/$(DETECTOR) && cvs commit -m "Updates to $(DETECTOR) detector."; fi
+# Create a new detector directory.
mkdir:
@if [ ! -d detectors/$(DETECTOR) ]; then cd detectors && mkdir $(DETECTOR); fi
+# Copy the template files to a detector directory.
template:
@cp -R detectors/template/* detectors/$(DETECTOR)
+# Recreate the detector.properties file for a single detector.
properties:
@echo "name: $(DETECTOR)" > detectors/$(DETECTOR)/detector.properties
+# Create the zip file for a single detector.
+zip:
+ @echo "Creating zip file for $(DETECTOR) ..."; \
+ if [ -e detectors/$(DETECTOR).zip ]; then rm detectors/$(DETECTOR).zip; fi; \
+ cd detectors/$(DETECTOR); \
+ for f in $$(find . -print | grep -v CVS); do zip -o $(DETECTOR) $$f &> /dev/null; done; \
+ chmod 775 $(DETECTOR).zip; \
+ zipinfo $(DETECTOR).zip; \
+ cd ../..; \
+ mv detectors/$(DETECTOR)/$(DETECTOR).zip detectors;
+
+# Create a new detector.
new: mkdir template properties
endif