Make question - how to overwrite a rule - Unix

This is a discussion on Make question - how to overwrite a rule - Unix ; Hi, I use make to build a set of HTML pages from XML files. I have a rule which says: %html : autolayout.xml a_long_command with a_long_command as follows: a_program ... $@ ... $(filter-out depends.tabular,$(filter-out autolayout.xml,$^)) Now for special HTML pages ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Make question - how to overwrite a rule

  1. Make question - how to overwrite a rule

    Hi,

    I use make to build a set of HTML pages from XML files.

    I have a rule which says:

    %html : autolayout.xml
    a_long_command

    with a_long_command as follows:

    a_program ... $@ ... $(filter-out depends.tabular,$(filter-out autolayout.xml,$^))

    Now for special HTML pages I need some post processing.
    I started to write:

    special.html :
    a_long_command
    a_special_command
    a_second_special_command

    This works but I want a_long_command only ONCE in my Makefile.

    Any advice how to do that ?

  2. Re: Make question - how to overwrite a rule

    On Apr 15, 11:39 pm, "R.P." wrote:
    > Hi,
    >
    > I use make to build a set of HTML pages from XML files.
    >
    > I have a rule which says:
    >
    > %html : autolayout.xml
    > a_long_command
    >
    > with a_long_command as follows:
    >
    > a_program ... $@ ... $(filter-out depends.tabular,$(filter-out autolayout.xml,$^))
    >
    > Now for special HTML pages I need some post processing.
    > I started to write:
    >
    > special.html :
    > a_long_command
    > a_special_command
    > a_second_special_command
    >
    > This works but I want a_long_command only ONCE in my Makefile.
    >
    > Any advice how to do that ?


    You could use an intermediate file and another rule, e.g. special.html
    -> special_.html -> special_.xml

    %.html : %.xml
    a_long_command

    %.html : %_.html
    a_special_command
    a_second_special_command

    Then
    $ make blah.html special.html

    Or you could define a variable containing the text of a_long_command
    then reference it in your rules.

+ Reply to Thread