# websrc/MakeTargets # for instructions, see ${PICTOOLS}/MakeVars # additional targets defined below, if DIGESTDIR is set # captions.cap: runs gencaps over DIGESTDIR # to get a list of all pictures # newpix: constructs newpix.cap listing all pictures in DIGESTDIR # that are not mentioned in existing *.cap files. # If newpix.cap exists, the target fails with an error. ifneq '$(DIGESTDIR)' '' # all pictures in DIGESTDIR directory are downsized into DEST # and their thummbs into DEST/thumbs # PICTURES is set in MakeVars _PICNAMES = $(PICTURES:$(DIGESTDIR)/%=%) _PICDESTS = $(_PICNAMES:%=$(DEST)/%) _THUMBSDIR = $(DEST)/thumbs _PICTHUMBS = $(foreach VAR,$(_PICNAMES), \ $(_THUMBSDIR)/$(basename $(VAR)).jpg) # arrange to upload the thumbs _UPLOADTHUMBS = $(DEST)/thumbs/uploadtime ifeq '$(CAPTIONS)' '' CAPTIONS = captions.cap endif endif captions.cap: ${PICTOOLS}/gencaps -d $(DIGESTDIR) .deps: $(CAPTIONS) gawk -f $${PICTOOLS}/gendeps.gawk *.cap > .deps ifneq '$(CAPTIONS)' '' # each xxx.cap file is segmented by header lines like: # file: segmentname segment description words # gencaps generates in ./segmentname a file index.html and # one .html file for each captioned picture # gendeps creates a dependencies file: # each xxx.html file depends on its .cap file and frame.tpl # ./segmentname/index.html depends on the .cap file and template.tpl # _SEGFILES is a list of all the above generated .html files # _SEGMENTS is a list of all segmentname-s include .deps _SEGUPLOADS = $(_SEGMENTS:%=$(DEST)/%/uploadtime) endif # there will be one -titles file for each .cap file, # no matter how many segments are in that file _TITLENAMES = $(CAPTIONS:%.cap=%-titles.txt) ## target to list uncaptioned pictures into newcaps.txt .PHONY: newpix newpix: @if [ -e newpix.cap ] ; then \ echo "***" Error: newpix.cap pre-exists; \ elif [ -z "$(PICTURESDIR)" ] ; then \ echo "***" Error: no PICTURESDIR; \ else \ echo "genother -d $(PICTURESDIR) > newpix.cap" ; \ ${PICTOOLS}/genother -d $(PICTURESDIR) > newpix.cap ; \ fi _COPYTODEST = $(COPYFILES:%=$(DEST)/%) \ $(IMAGEFILES:%=$(DEST)/%) \ $(HTMLFILES:%=$(DEST)/%) \ $(JSFILES:%=$(DEST)/%) \ $(CSSFILES:%=$(DEST)/%) _HTMLF = $(HINFILES:%.hin=$(DEST)/%.html) DESTFILES = $(_COPYTODEST) $(_HTMLF) $(UPLOADFILES) # make each .html file depend on the files included by the .hin file # for each .html file we add a line to .hdeps: file.html ':' list from -depend ifneq "$(_HTMLF)" "" .hdeps: $(HINFILES) $(_TITLENAMES) echo > .hdeps; \ for file in $(_HTMLF); do \ hinf=`basename $$file .html`.hin ; \ deps=`${PICTOOLS}/genhtml -depend $$hinf` ; \ echo $$file : $$deps >> .hdeps;\ done include .hdeps endif ################################### # build to staging area build: $(_PICTHUMBS) $(_PICDESTS) \ $(BUILDFILES) $(DESTFILES) \ $(_TITLENAMES) $(_SEGFILES) $(DESTFILES) $(_SEGFILES): | $(DEST)/. # dirs: $(DEST)/. $(DEST)/%.html: %.hin | $(DEST)/. ${PICTOOLS}/genhtml -o $@ $< $(DEST)/%.html: ${PICTOOLS}/genhtml $(DEST)/%: % | $(DEST)/. cp $< $@ ############### build subdirectories for CAPTIONS files # gendirs creates all the DEST/segment directories and populates them # gendirs is run by most elements of .deps define run-gendirs @echo run gendirs for $< in $(DEST) @cp $< $(DEST) ; \ cmd='${PICTOOLS}/gendirs ${DEFINES} -n $(THUMBCOLS) \ -w $(INDEXTPL) -v $(PICFILETPL) -x $(PICCELLTPL) \ $(notdir $<) > $(SRC)/$(basename $<)-titles.txt' ; \ if [ $${PICTOOLSDEBUG:-0} -gt 0 ] ; then \ echo cd ${DEST} '&&' eval $$cmd >> /tmp/pictoolsdebug.log; \ fi; \ cd $(DEST) && eval $$cmd; \ rm $(notdir $<) endef # when TITLENAMES gets built, # it builds all the image subdirectories as a sidefeffect $(_TITLENAMES) : %-titles.txt: \ %.cap $(INDEXTPL) $(PICFILETPL) $(PICCELLTPL) | $(DEST)/. $(run-gendirs) ######### build images from DIGESTDIR $(_PICDESTS) : $(DEST)/% : $(DIGESTDIR)/% | $(DEST)/. convert -geometry "$(IMAGESCALE)" $< $@ $(_THUMBSDIR)/%.jpg: $(DIGESTDIR)/%.JPG|$(_THUMBSDIR)/.; $(make-thumb) $(_THUMBSDIR)/%.jpg: $(DIGESTDIR)/%.jpg|$(_THUMBSDIR)/.; $(make-thumb) $(_THUMBSDIR)/%.jpg: $(DIGESTDIR)/%.GIF|$(_THUMBSDIR)/.; $(make-thumb) $(_THUMBSDIR)/%.jpg: $(DIGESTDIR)/%.gif|$(_THUMBSDIR)/.; $(make-thumb) $(_THUMBSDIR)/%.jpg: $(DIGESTDIR)/%.PNG|$(_THUMBSDIR)/.; $(make-thumb) $(_THUMBSDIR)/%.jpg: $(DIGESTDIR)/%.png|$(_THUMBSDIR)/.; $(make-thumb) ################################### # upload # upload from this directory: # local files and DIGEST pictures, DIGEST thumbs, segments # each DEST directory will have two flag files, # uploadtime for when it was uploaded # and serverdir for when the directory has been made on the server # note that _UPLOADTHUMBS is "" if there is no DIGESTDIR # and _SEGUPLOADS is "" is there are no SEGMENTS _SERVERDIRS = $(_UPLOADTIMES:$(DEST)%/uploadtime=$(DEST)%/serverdir) _UPLOADTIMES = $(DEST)/uploadtime $(_UPLOADTHUMBS) $(_SEGUPLOADS) upload: build server_dirs $(_UPLOADTIMES) server_dirs: | $(_SERVERDIRS) # upload local files and pictures from DIGESTDIR, if any $(DEST)/uploadtime: $(DESTFILES) $(_PICDESTS) ; $(run-scp) # upload thumbs converted from DIGESTDIR # note that $(_UPLOADTHUMBS) is $(DEST)/thumbs/uploadtime # and $(_PICTHUMBS) is a list of the thumb .jpg files $(_UPLOADTHUMBS): $(_PICTHUMBS) | $(_THUMBSDIR)/serverdir cd $(_THUMBSDIR); \ ${PICSCP} $(subst $(_THUMBSDIR)/,,$?) $(SERVER)/thumbs touch $@ # upload segment directories # .deps gives the run-scp rule for $(_SEGMENTS): $(DEST)/%/uploadtime