1
votes

I've been trying to generate Makefile rules that execute before the automake Makefile rules. I've seen I can define "all-local" and "hooks" rules, but these are executed after the "all" and other rules, for instance.

Is there any way that I could execute a code of mine before the automake added rules? I want to automatically generate files in a directory, but the compilation process through make always tries to compile programs following automake Makefile rules. If I could add a "pre-" rule, I could generate the needed files, then let the normal compilation process to run.

I know about BUILT_SOURCES, but I'm trying not to use it

Is that possible? Thanks!

2
That's what BUILT_SOURCES is for - why on earth are you trying not to use it?ptomato

2 Answers

0
votes

There isn't a way to do this.

In general in a Makefile, if you want to do this, you should instead consider adding proper dependencies where needed.

0
votes

Makefiles can have the same target with different prerequisites, in which case the prerequisites will be merged:

# The following will be equivalent to 'target: prerequisite1 prerequisite2'
target: prerequisite1
target: prerequisite2

This can be inferred from the GNU make manual (really bad explanation there, but I did not find anything better).

You can leverage this feature in your own Makefile.am:

all: all-prehook

all-prehook:
    echo Prehook called here

.PHONY: all-prehook

Be careful automake will complain (Warning: overrides Automake target or something similar). You could shut it up by using -Wno-override: if your are using autoconf, just add it to your AM_INIT_AUTOMAKE call.