[Omake] Another recursive omake question

Jason Hickey jyh at cs.caltech.edu
Wed Jun 7 21:20:19 PDT 2006


Benjamin Pierce wrote:
> Actually, I guess I see another way that is better than any of these:  
> in the OMakefile of the broken directory, change the .DEFAULT target  to 
> DEFAULTBROKEN or something.  Now, when working there, we have to  
> remember to do "omake DEFAULTBROKEN", but this is perhaps not so bad...

One style we often use is to use .DEFAULT only on the "most important" 
thing we care about, so that running omake without arguments does some 
minimal expected work.  All the other stuff is put to a different target 
like "all" or "install".

Alternately, the -k or -P options tell omake to continue, even if 
something is broken.  A list of broken targets is printed when omake is 
done (though the error messages may have scrolled off the screen!)  To 
minimize screen output, the -S and --progress options help.  Typing 
these options each time can be clumsy, but you can add them to the 
OMAKEFLAGS environment variable, or add a line like this.

    OMakeFlags(-S --progress)

> My old GNU makefile has some rules like this:
> 
>   tmp/%.tex : %.src $(SRC2TEX) tmp
>           $(SRC2TEX) $< > $@

There is a key difference here!  In omake, paths for implicit targets 
are not allowed.  The reason is that when tmp/%.tex is built, the 
tmp/OMakefile is consulted for a target %.tex.

You could add this to tmp/OMakefile

    %.tex: ../%.src $(SRC2TEX)
       $(SRC2TEX) $< > $@

Or, you might just want to use a .SUBDIRS body in the root instead so 
that the tmp directory can be deleted whenever you like.

    # Make sure the tmp directory exists.
    # Likely, we should support the following rule instead.
    #
    # tmp:
    #     mkdir -p $@
    mkdir -p tmp

    .SUBDIRS: tmp
        %.tex: ../%.src $(SRC2TEX)
            $(SRC2TEX) $< > $@

    .PHONY: clean

    clean:
        rm -f ... tmp

Also, sometimes for large projects, you don't want to define your tree 
statically, but just place some boilerplate in the root OMakefile. 
Suppose each directory of interest has a file called Files that has some 
specific info.  Then you could include all those directories in your 
project as follows.

    TMP = $(dir tmp)

    # Get all the subdirectories that contain a Files file
    DIRS = $(dirof $(find . -name Files))

    # Add them to the project, with some boilerplate
    .SUBDIRS: $(DIRS)
        # Include the config for this directory
        include Files

        # ...Common boilerplate goes here...

        # An example to copy all .src files to $(TMP)
        # Instead of using ls, you might define SRC in the Files file
        SRC = $(removesuffix $(ls *.src))
        foreach(filename, $(SRC))
           $(TMP)/$(filename).tex: $(filename).src
              cp $< $@

        # Another example, assuming Files defines MLFILES
        OCamlLibrary(mylib, $(MLFILES))

Jason

-- 
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257


More information about the Omake mailing list