####################################################################### # Makefile to catalog test datasets ####################################################################### scrdir := . dsnames := $(shell cat dataset_list) idlists := $(foreach name, $(dsnames), idlists/$(name).ids) nvdss := $(foreach name, $(dsnames), nvds_$(name).xml) vdss := $(foreach name, $(dsnames), vds_$(name).xml) ddbs := $(foreach name, $(dsnames), ddb/vds_$(name) ddb/nvds_$(name)) dscs := $(foreach name, $(dsnames), dsc/$(name)) drcs := $(foreach name, $(dsnames), drc/$(name)) ####################################################################### all: dsc drc show: @echo $(dsnames) @echo $(nvdss) idlist: $(idlists) nvds: $(nvdss) vds: $(vdss) ddb: $(ddbs) dsc: $(dscs) drc: $(drcs) ####################################################################### # gmake tutorial: # candidates : target : dependencies # $< is first dependency # $@ is the target # $* is the part of the target that matches the pattern # (replaces % in target) # Build ID list. $(idlists) : idlists/%.ids : infiles/%.infiles @echo "***** Making $@" @rm -f $@ @$(scrdir)/build_cbnts $* $< # Build nonvirtual dataset. $(nvdss) : nvds_%.xml : idlists/%.ids @echo "***** Making $@" @$(scrdir)/build_nvds $* # Build virtual dataset. $(vdss) : vds_%.xml : nvds_%.xml @echo "***** Making $@" @dataset_make_virtual -u -r $< -f $@ # Insert virtual or nonvirtual dataset in DDB. # If already present, we take no action. $(ddbs) : ddb/% : %.xml @echo "***** Making $@" @echo inserting $< in DDB @DID=`dataset_property -f $< id 2>/dev/null`; \ DIDCHK=`dataset_property -i $$DID id`; \ if [ -z "$$DIDCHK" ]; then \ dataset_insert -f $< -r > $@; \ echo " ID $$DID inserted in catalog"; \ else \ echo " ID $$DID already in catalog--no action taken"; \ echo $$DID > $@; \ fi # Insert virtual dataset in DSC. $(dscs) : dsc/% : ddb/vds_% ddb/nvds_% @echo "***** Making $@" @echo inserting $* in DSC @VID=`cat ddb/vds_$*`; \ NVID=`cat ddb/nvds_$*`; \ NAME=$*; \ VIDCHK=`dataset_selection_catalog -n $$NAME`; \ if [ "$$VIDCHK" = $$VID ]; then \ echo " $$NAME is aready in DSC"; \ else \ echo " inserting $$NAME in DSC"; \ dataset_selection_catalog -w $$NAME $$VID $$NVID; \ fi; @touch $@ # Updatet DRC with virtual and non-virtual datasets $(drcs) : drc/% : ddb/vds_% ddb/nvds_% @echo "***** Making $@" @VID=`cat ddb/vds_$*`; \ NVID=`cat ddb/nvds_$*`; \ NAME=$*; \ VIDCHK=`dataset_replica_catalog -i $$NVID`; \ if [ -z "$$VIDCHK" ]; then \ echo inserting $$NAME in DRC; \ dataset_replica_catalog -w $$VID $$NVID; \ else if [ $$VIDCHK != $$VID ]; then \ echo "Nonvirtual ID $$NVID is already in DRC and is associated with a"; \ echo " different virtual ID ($$VIDCHK instead of $$VID)"; \ exit 1; \ fi; fi @touch $@ #######################################################################