# websrc/pictools/Makevars # this file defines make variables for use in MakeTargets and MakeServerPix #$(info ###) #$(info ### Start reading MakeVars in $(CURDIR) at $(shell date "+%H:%M:%S.%3N")) # this file and MakeTargets are a tool for # building files from SRCROOT/_SITEPATH into STAGINGAREA/_SITEPATH # and then uploading them to SSHDEST:PICSDIR/_SITEPATH # where the PIC... variables are set in the environment # and _SITEPATH is the path from SRCROOT to the current directory # # Build and upload directories are created automatically. # # A Makefile is typically two or three lines: # SUBDIRS = subdirectories-if-any # include ${PICTOOLS}/MakeVars # # set additional variables (or add make targets) # include ${PICTOOLS}/MakeTargets # # Local targets. These operate only on the current directory: # build: transfer local files to STAGINGAREA/_SITEPATH # upload: transfer files from stage area to server # clean: remove $(JUNKFILES) # rebuild: force re-upload by deleting dummy time targets # MakeTargets, UploadPix, and similar include-able Makefiles # must define targets for build and upload. # # Recursive targets. Operate on this dir and all SUBDIRS. # The value of SUBDIRS may be set on the command line: # It is not passed recursively, so the named sub-directories # and all their descen # make SUBDIRS=2007 uploaddants are processed. # all: same as buildall # buildall: does build in this directory and then SUBDIRS # uploadall: does buildall, uploadall in the SUBDIRS, # and then upload # cleanall: do clean locally and recursively # All variables can be overridden on the command line to make. # However, these values are not exported # to recursively invoked instances of make. ################################################################ # Directory Tree Properties # Pictools operates over three directory trees each having # the same set of sub-directories: # a source tree # a staging area # the site server # In addition there may be a tree of images whose subdirectories # correspond to a subtree of the staging area and # an identical subtree on the server. # # Property values and environment variables define these # directories and the subpaths to directories within them. # Directory and file names must be written in Cygwin style: # proper slashes, no spaces, and starting with /cygdrive/ followed # by a drive letter. (Spaces can sometimes be included # by preceding them with backslashes. Good luck.) # Predefined # These two variables must be defined outside PICTOOLS # and outside Pictools.properties. They may be set in the # user's environment or in the shell initialization script. # # PICTOOLS # Must be predefined to contain the path to this pictools directory. # Starts with slash; no final slash. # Example value: /cygdrive/c/websrc/pictools # SRCROOT # Must be predefined as the path to the tree of directories # holding the site source. Starts with slash; no final slash. # Example value: /cygdrive/c/websrc # Directory Tree Variables # Typically defined in SRCROOT/Pictools.properties # STAGINGAREA # Path to the tree of directories holding the staging area. # Starts with slash; no final slash. # Example value: /cygdrive/c/physpics.com # PICSDIR # A directory path on the server leading from the initial # SSHDEST directory to the directory corresponding to SRCROOT. # Examples: physpics.com (dreamhost); httpdocs (networksolutions) # The value may be empty. # Usually the value does not begin with a slash. # No final slash unless value is "/" (highly unlikely). # SSHDEST # user name and host name of server # example value: physpics@physpics.com # # By the above, the server tree resides at ${SSHDEST}:${PICSDIR} # for example: physpics@physpics.com:httpdocs # from GNU Make : CURDIR # from MakeVars: SRC SRCROOT SERVER # from ./Pictools.properties : PICSDIR SSHDEST # Variables set by MakeVars # These may be used by the client Makefile # _SITEPATH = path from $(SRCROOT) to $(CURDIR) # something like: /annal/2015, may be empty # STAGE = ${STAGINGAREA}${_SITEPATH} # 'build' places files in this directory # SERVER = $(SSHDEST):$(PICSDIR)$(_SITEPATH) # 'upload' runs 'scp' to copy from STAGE to SERVER # SRC = the initial current directory # (some rules change to other directories) # PIXSTAGE = $(STAGINGAREA)$(PICTREESUBPATH) # destination for scale images built from picturedir: entries in caps file # Content Variables # To build and upload files, a client Makefile defines these # COPYFILES = file1 file2 file3 ... # if needed, these files are built locally by 'build' # 'build' then copies these files to STAGE # and 'upload' copies them from there to SERVER # Copying is recursive; the list may include directories like 'images' # BUILDTOSTAGE = file ... # files to be built directly into $(STAGE) # the files listed will appear in $(STAGE), but not the local $(SRC) # nevertheless, they are listed WITHOUT the $(STAGE) directory # Rules for making items on the list DO have the $(STAGE) directory # If file ffff.ext is in the BUILDTOSTAGE list, # there must be a rule for building $(STAGE)/ffff.ext # BUILDONLY = files to be generated locally for 'build', but not uploaded # TAR_EXCLUDE_LIST = _notes CVS *.BAK *~* Thumbs.db *.exe \ # *.jar *.class *.tgz *.tar \ # Pictools.csh Pictools.mkinc $(MORE_TAR_EXCLUDES) # List of files to be omitted when creating tar files. # Replace this value if you do not wish to exclude some of these files. # MORE_TAR_EXCLUDES # See values of TAR_EXCLUDE_LIST. Define this value # to add items to be excluded. # SRCTAR_FILES = default files to be preserved in DIRSRC.tgz; the latter is uploaded # MORE_SRCTAR_FILES = additions to SRCTAR default files # Build Info Variables # The following variables may be set by the client Makefile to direct the build # SUBDIRS = dir1 dir2 ... # subdirectories for buildall, updateall, and cleanall # DEFINES = symbol defines for genhtml. Form: -Dsymbol=value # Typically used to fill in fields in templates. # example: DEFINES = -DtripTitle="Florida, Spring, 2007" # LOCALJUNK = list of files or wild cards: eg, *.o foo* # These files are deleted for 'make clean' # AFTERSSH = # MakeTarget and friends invoke this command after every invocation of ssh. # On platforms like DreamHost which limit the frequency of incoming ssh calls, # This variable may be set the shell or in Pictools.properties to something like # AFTERSSH = sleep 10 # PICSCP = scp # may be set to fakescp to use ftp instead of scp; no longer fully functinoal # PICPASS # if using fakescp, the ftp password must be supplied # if the variable is not set, a value is prompted for at runtime # Default Content List Variables # These variables are given tentative values in MakeVars # If the client wants some other value, it can reset them # after including MakeVars # # HTMLFILES = *.html # IMAGEFILES = *.png *.PNG *.jpg *.JPG *.gif *.GIF *.bmp *.BMP # JSFILES = *.js # CSSFILES = *.css # The above are set in MakeVars to a list of the # files in the current directory. # These files are copied to STAGE and uploaded to SERVER. # The list can be modified in the Makefile. # Note that only single case names are recognized. # PHPFILES = *.php # these are copied to STAGE and uploaded # CAPFILE = *.cap # is set by MakeVars to *.cap. May be set by the # client to some other value. NO MORE THAN ONE # .cap file is supported. It is processed # through gendirs to create image viewing pages. # For cap file xxx.cap, MakeTargets generates # a file called xxx-titles.txt. This has HTML code # for the elements of a list that can be included in # the html portion of a .php page like this: # # JUNKFILES = *~ $(LOCALJUNK) # list of files to be removed for `make clean' # define special targets # # FINISH_BUILD = target ... # target(s) to be build at the end of the build target # default: empty # admin, for example, uses this to touch com/ # if MapComputeChanges.java has changed # # FINISH_UPLOAD = target ... # targets to be built after upload # default: doupload (it MAKEs StageMake) # can perform additional tasks via SSH and SCP # # SENTINELS = file ... # list of files not to be uploaded from $(STAGE) # default: serverdir uploadtime # must be exported from the Makefile # Parameters for gendirs: # How many columns of thumb images to generate from gendirs # THUMBCOLS = 5 # Rescaling parameter for ImageMagick, for pictures and thumbs # examples: 33% 768x768> 576x576> # IMAGESCALE = xxx # THUMBSCALE = xxx # Debugging # If PICTOOLSDEBUG has a small integer value in the shell environment, # this file and some scripts will output progress messages to # /tmp/pictoolsdebug.log If 5 or greater, this file will dump all variable values. ##################################################################### # check SRCROOT ifeq "${SRCROOT}" "" $(error SRCROOT is undefined in the environment. Set it to the root of the tree of web page sources.) endif ifeq "${SRCROOT}" "$(dir ${SRCROOT})" $(error Value of SRCROOT should not end in a slash, \ but it does (${SRCROOT})) endif ifneq "/" "$(patsubst /%,/,${SRCROOT})" $(error SRCROOT (${SRCROOT}) does not begin with a slash, but must) endif SRCROOT := ${shell ${PICTOOLS}/lowerdriveletter $(SRCROOT)} # capture curdir value for use in rules that change directory SRC := ${shell ${PICTOOLS}/lowerdriveletter $(CURDIR)} ### ### if SRC is empty here, it may be that lowerdriveletter.exe ### was copied from another platform and not recompiled ### # if not a child of SRCROOT, get properties from SRCROOT ifeq "" "$(findstring ${SRCROOT},$(SRC))" ### have not read Pictools.properties, so PICTURESROOT is empty # ifeq "" "$(findstring ${PICTURESROOT},$(SRC))" # $(warning ### !!! Current directory ($(CURDIR)) \ # isn't in SRCROOT ($(SRCROOT)) or PICTURESROOT ($(PICTURESROOT)) ) # endif $(warning ### !!! Current directory ($(CURDIR)) \ is outside the tree at SRCROOT ($(SRCROOT)) (? maybe it is in PICTURESROOT) ) _PROPDIR = $(SRCROOT) else _PROPDIR = $(SRC) endif # get the Pictools.properties values # run propcon everytime to ensure that Pictools.mkinc is up-to-date $(info $(shell ${PICTOOLS}/propcon.exe -d $(_PROPDIR) Pictools.mkinc)) include $(_PROPDIR)/Pictools.mkinc #$(info finished reading Pictools.mkinc $(shell date +%S.%N5)) # check STAGINGAREA ifeq "${STAGINGAREA}" "" $(error STAGINGAREA is undefined. Set it to the root of the staging directories.) endif ifeq "${STAGINGAREA}" "$(dir ${STAGINGAREA})" $(error STAGINGAREA (${STAGINGAREA}) wrongly has a final slash) endif ifneq "/" "$(patsubst /%,/,${STAGINGAREA})" $(error STAGINGAREA (${STAGINGAREA}) wrongly lacks an initial slash) endif # set _SITEPATH to the path from SRCROOT to this directory # (use SRC, but delete its initial string SRCROOT) # (SRCROOT lacks trailing /, so the value of the subst is empty or starts with /) _SITEPATH := $(subst ${SRCROOT},,$(SRC)) # set destinations in physpics.com on this machine STAGE ?= ${STAGINGAREA}$(_SITEPATH) PIXSTAGE = $(STAGINGAREA)$(PICTREESUBPATH) #set destination on server SERVER = ${SSHDEST}:${PICSDIR}$(_SITEPATH) #${info STAGE is $(STAGE)} #${info _SITEPATH is $(_SITEPATH)} #${info SRCROOT is ${SRCROOT}} #${info SERVER is ${SERVER}} # make lists of local files to upload IMAGEFILES ?= $(wildcard *.png *.PNG *.jpg *.JPG *.gif *.GIF) JSFILES ?= $(wildcard *.js) CSSFILES ?= $(wildcard *.css) PHPFILES ?= $(wildcard *.php) HTMLFILES ?= $(wildcard *.html *.htm) PROPFILES ?= $(wildcard *.properties) SCRIPTFILES ?= $(wildcard *.csh) $(wildcard *.sh) # To build and upload files, a client Makefile defines one or more of these # COPYFILES files in the list are built if needed; copied to stage; upload # BUILDTOSTAGE files are built if not in stage; they are uploaded # BUILDONLY files in this list are built; but not copied to stage or uploaded # files existing or constructed in . that are copied to stage # and copied again to the server _COPYTWICE = $(sort $(COPYFILES) \ $(IMAGEFILES) \ $(HTMLFILES) \ $(PHPFILES) \ $(JSFILES) \ $(CAPFILE) \ $(CSSFILES) \ $(PROPFILES)\ $(SCRIPTFILES)) _COPYTWICEONSTAGE = $(_COPYTWICE:%=$(STAGE)/%) _BUILDONTOSTAGE = $(BUILDTOSTAGE:%=$(STAGE)/%) # .cap files are processed with gendirs and the results are uploaded CAPFILE ?= $(wildcard *.cap) ifneq (,$(strip $(word 2, $(CAPFILE)))) $(error Max one .cap file. This directory has: $(CAPFILE)) endif # JUNKFILES are deleted for `make clean' JUNKFILES ?= *~ $(LOCALJUNK) # items to not include in tar files TAR_EXCLUDE_LIST ?= _notes CVS *.BAK *~* Thumbs.db *.exe \ *.jar *.class *.tgz *.tar \ Pictools.csh Pictools.mkinc $(MORE_TAR_EXCLUDES) _TAR_EXCLUDES = $(TAR_EXCLUDE_LIST:%=--exclude="%" ) SRCTAR_FILES = Makefile $(_COPYTWICE) resources $(MORE_SRCTAR_FILES) FINISH_BUILD ?= FINISH_UPLOAD ?= doupload ################## # parameters for gendirs # how many columns of images THUMBCOLS ?= 5 # maximum dimension for full-sized and thumb images, respectively IMAGESCALE ?= 576x576> THUMBSCALE ?= 144x144> PICSCP ?= scp ifeq '${PICSCP}' 'fakescp' ifeq 'upload' '${findstring upload, $(MAKECMDGOALS)}' ifndef PICPASS PICPASS := $(shell /bin/bash -c \ 'read -s -p "password for ${SSHDEST}: " foo; echo $$foo') _DISCARDVALUE := $(shell echo > /dev/tty) export PICPASS endif endif endif # export / unexport # No export or unexport is applied here. Make variables and properties # are not in the environment for sub-makes or executables/scripts in recipes. # At one time I thought properties should be in the environment for # execuables/scripts called by recipes. Defniitely more trouble than it was worth. # Now executables and scripts are expected to fetch properties for themselves. # the default action is build .PHONY: all all: build # general directory construction rule # call it by writing an order-only dependence on "directory-to-be-made/." %/. : mkdir -p $@ ######################################################## # start log entry, if PICTOOLSDEBUG is defined # DUMP VARIABLES to /tmp/pictoolsdebug.txt, if PICTOOLSDEBUG >= 5 APOS=' ifdef PICTOOLSDEBUG ifndef DEBUGMESSAGE DEBUGMESSAGE := PICTOOLSDEBUG is ${PICTOOLSDEBUG} export DEBUGMESSAGE $(shell echo >> /tmp/pictoolsdebug.log ; \ echo '__________________________________________________________' \ >> /tmp/pictoolsdebug.log ; \ echo MakeVar `date` $(DEBUGMESSAGE) >> /tmp/pictoolsdebug.log; \ echo in dir $(SRC) >> /tmp/pictoolsdebug.log; \ ) endif __DISCARDVAR := $(shell echo `test ${PICTOOLSDEBUG} -ge 5` $$?) ifeq ("x$(__DISCARDVAR)x","x0x") # true: 5 or greater $(info Dump VARS $(shell date +%S.%N5)) $(shell $(foreach var, $(sort $(.VARIABLES)), \ echo '$(var) is $(subst $(APOS), APOS, $($(var)))' >> /tmp/pictoolsdebug.log;) \ ) else ifeq ("x$(__DISCARDVAR)x","x2x") # error, not an integer $(error PICTOOLSDEBUG is ${PICTOOLSDEBUG}, but should be a small non-negative integer) endif endif #$(info Finished reading MakeVars $(shell date +%S.%N5))