This is the mail archive of the automake@gnu.org mailing list for the automake project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 1st action before build


Sylvain GIL <sylvain.gil@solsoft.fr> writes:

> I have a little issue with Makefile.am. What I want to do is to insert
> an action before my program is compiled.
>
> bin_PROGRAMS = myprog
> myprog_SOURCES = myprog.c myfile.c
>
> will generate something like:
>
> myprog: $(myprog_OBJECTS) $(myprog_DEPENDENCIES)
>
> I would like to do some actions in the same directory just before the
> myprog_OBJECTS dependency is followed or more generally before myprog
> compile start. Is there a way to do so ?
>
> Without giving too much detail, my 1st source file _can't_ be compiled
> unless a pre-action is done.

OK.  Then express that dependency.

> I found a very ugly way to work around it by adding a "dumb" entry in
> bin_PROGRAMS before myprog and overriding its target but it looks like
> evil :)

It also won't work with parallel makes.

If you need to do something before compiling myprog.o, express that
dependency.  For examply, if 'foo.h' is a file that needs to exist
before myprog.c can be compiled, use the following line in your
Makefile. 

  myprog.o: foo.h

If there's a "pre-action" which is not a header file, you can do:

  stamp-pre-action:
        do pre-action stuff
        echo timestamp > stamp-pre-action

  myprog.o: stamp-pre-action

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]