Search code examples
makefiledependenciesdocbook

Makefile dependency for unknown files in known directory (for DocBook)


As part of the build I'm processing DocBook file that produces multiple HTML files (one file per chapter).

I want to postprocess those HTML files and copy them elsewhere. Those files depend on DocBook source, but I cannot know filenames in advance (filenames depend on DocBook source too).

I've got rule that sort-of works if the files are generated already:

www/manual/%.html: build/manual/%.html
   postprocess "$<" "$@"

but I don't know how to tell make to generate them, if they aren't there yet. If I just add rule for www/manual/index.html, only that file gets postprocessed, not all of them.

I suppose I need makedepend for DocBook or perhaps some nifty wildcard trick. What's the solution for this?


Solution

  • I'm going to blindly assume GNU Make here; if not, similar techniques should apply with slightly altered syntax.

    If it were me, I'd use a rule akin to yours above, possibly with a file list generated by the wildcard function

    And then I'd put that rule in a separate sub-makefile, called recursively

    That is, in your main Makefile,

    
      build:
        # do the docbook processing
        $(MAKE) -f htmlprocessmakefile
    

    That Makefile will see the full list of HTML files that have been created.