newbie : makefile problem - Unix

This is a discussion on newbie : makefile problem - Unix ; Hello, I am experiencing a problem writing a Makefile for a small project. Here is the makefile: # general SRCPATH= # sources, headers and objects MYSOURCES=$(SRCPATH)TAmoreObject.cxx $(SRCPATH)MockAmoreProvider.cxx $ (SRCPATH)AmorEveMain.cxx MYSOURCES+=$(SRCPATH)TAmoreObjectManager.cxx $ (SRCPATH)TAmoreFileBrowser.cxx MYSOURCES+=$(SRCPATH)VCanvasLayoutMaker.cxx $ (SRCPATH)SimpleLayoutMaker.cxx MYHEADERS=$(MYSOURCES:.cxx=.h) dico: $(MYHEADERS) $(SRCPATH)LinkDef.h rootcint ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: newbie : makefile problem

  1. newbie : makefile problem

    Hello,

    I am experiencing a problem writing a Makefile for a small project.
    Here is the makefile:

    # general
    SRCPATH=
    # sources, headers and objects
    MYSOURCES=$(SRCPATH)TAmoreObject.cxx $(SRCPATH)MockAmoreProvider.cxx $
    (SRCPATH)AmorEveMain.cxx
    MYSOURCES+=$(SRCPATH)TAmoreObjectManager.cxx $
    (SRCPATH)TAmoreFileBrowser.cxx
    MYSOURCES+=$(SRCPATH)VCanvasLayoutMaker.cxx $
    (SRCPATH)SimpleLayoutMaker.cxx
    MYHEADERS=$(MYSOURCES:.cxx=.h)

    dico: $(MYHEADERS) $(SRCPATH)LinkDef.h
    rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h

    I removed the unrelated stuff, but this simple makefile has the same
    problem :
    Whenever I do "make dico" it redoes the "rootcint..." even if no
    headers have been changed.
    I thought the command would be executed only if the dependencies
    indicated that the target was out of date.

    I am really a beginner with the make tool, therefore i apologise in
    advance if it is a stupid question, but how should I do, in order to
    have this command to be executed only if the headers have changed ?

    Thanks

    Barth

  2. Re: newbie : makefile problem

    barthelemy.von.haller@gmail.com wrote:

    > I am experiencing a problem writing a Makefile for a small project.
    > Here is the makefile:
    >

    [...]
    > dico: $(MYHEADERS) $(SRCPATH)LinkDef.h
    > rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h
    >
    > Whenever I do "make dico" it redoes the "rootcint..." even if no
    > headers have been changed.
    > I thought the command would be executed only if the dependencies
    > indicated that the target was out of date.


    Out of date compared to what? I think this is the key point, make
    compares the date of a file called "dico" with the dates of the
    dependencies. Since you don't have a file called dico, dico is always out
    of date.

  3. Re: newbie : makefile problem

    On 23 avr, 13:36, Marc wrote:
    > barthelemy.von.hal...@gmail.com wrote:
    > > I am experiencing a problem writing a Makefile for a small project.
    > > Here is the makefile:

    >
    > [...]
    > > dico: $(MYHEADERS) $(SRCPATH)LinkDef.h
    > > rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h

    >
    > > Whenever I do "make dico" it redoes the "rootcint..." even if no
    > > headers have been changed.
    > > I thought the command would be executed only if the dependencies
    > > indicated that the target was out of date.

    >
    > Out of date compared to what? I think this is the key point, make
    > compares the date of a file called "dico" with the dates of the
    > dependencies. Since you don't have a file called dico, dico is always out
    > of date.


    Ok, thanks for the explanation. I understand better now.
    So, how should I do to skip this "dico" target if no headers have
    changed ?

    Thanks in advance for your help

    barth

  4. Re: newbie : makefile problem

    In article
    ,
    barthelemy.von.haller@gmail.com wrote:
    > On 23 avr, 13:36, Marc wrote:
    >> barthelemy.von.hal...@gmail.com wrote:
    >> > I am experiencing a problem writing a Makefile for a small project.
    >> > Here is the makefile:

    >>
    >> [...]
    >> > dico: $(MYHEADERS) $(SRCPATH)LinkDef.h
    >> > rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h

    >>
    >> > Whenever I do "make dico" it redoes the "rootcint..." even if no
    >> > headers have been changed.
    >> > I thought the command would be executed only if the dependencies
    >> > indicated that the target was out of date.

    >>
    >> Out of date compared to what? I think this is the key point, make
    >> compares the date of a file called "dico" with the dates of the
    >> dependencies. Since you don't have a file called dico, dico is always out
    >> of date.

    >
    > Ok, thanks for the explanation. I understand better now.
    > So, how should I do to skip this "dico" target if no headers have
    > changed ?


    I'm not sure what 'rootcint' is supposed to do, but it looks
    like this program creates the file 'MyDict.cxx'. If so, that
    means that 'MyDict.cxx' is the file that depends on your
    headers. Hence, the makerules might look like this:

    dico: $(SRCPATH)MyDict.cxx

    $(SRCPATH)MyDict.cxx: $(MYHEADERS) $(SRCPATH)LinkDef.h
    rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h


  5. Re: newbie : makefile problem

    On 23 avr, 14:37, Marcel Bruinsma wrote:
    > In article
    > ,
    >
    >
    >
    > barthelemy.von.hal...@gmail.com wrote:
    > > On 23 avr, 13:36, Marc wrote:
    > >> barthelemy.von.hal...@gmail.com wrote:
    > >> > I am experiencing a problem writing a Makefile for a small project.
    > >> > Here is the makefile:

    >
    > >> [...]
    > >> > dico: $(MYHEADERS) $(SRCPATH)LinkDef.h
    > >> > rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h

    >
    > >> > Whenever I do "make dico" it redoes the "rootcint..." even if no
    > >> > headers have been changed.
    > >> > I thought the command would be executed only if the dependencies
    > >> > indicated that the target was out of date.

    >
    > >> Out of date compared to what? I think this is the key point, make
    > >> compares the date of a file called "dico" with the dates of the
    > >> dependencies. Since you don't have a file called dico, dico is always out
    > >> of date.

    >
    > > Ok, thanks for the explanation. I understand better now.
    > > So, how should I do to skip this "dico" target if no headers have
    > > changed ?

    >
    > I'm not sure what 'rootcint' is supposed to do, but it looks
    > like this program creates the file 'MyDict.cxx'. If so, that
    > means that 'MyDict.cxx' is the file that depends on your
    > headers. Hence, the makerules might look like this:
    >
    > dico: $(SRCPATH)MyDict.cxx
    >
    > $(SRCPATH)MyDict.cxx: $(MYHEADERS) $(SRCPATH)LinkDef.h
    > rootcint -f $(SRCPATH)MyDict.cxx -c $(MYHEADERS) $(SRCPATH)LinkDef.h


    Excellent !
    I got it ! your example works and helped me to figure out the reason
    why it works.

    Thanks


+ Reply to Thread