OpenWrt Forum Archive

Topic: Makefile pain

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Just a small grumble that may or may not have any resonance with anyone out there.
I am trying to hack the Makefile for php5 package but am finding it impossible to figure out what the hell's going on. The design of the Makefiles seem to have made them as concise as possible, at the expense of completeness - the result seems to be an abstract implementation that's very hard to hack.

For example, how do I specify the CPPFLAGS argument if there are no explicit build commands for the base package? Also, it seems that PKG_CONFIGURE_OPTS is automagically passed to the configure directive - but how is anyone's guess....grrrr.

I guess it's the old discourse between maintainability and automation. Have let off steam now, comments welcome.

check the parts that say "define Build/Compile/php5..."
These contain all the commands that are run for the compile step.
If you want to pass the CPPFLAGS argument to make, why don't you just look for the $(MAKE) invocation in that instance and add it there? smile

Another thing about configure. It's there if you look for it...

    $(call Build/Configure/Default, \
        $(PKG_CONFIGURE_OPTS) \
        --disable-cli \
        [...]

Configure/Default is the default template for configure commands, which takes configure parameters using the first argument to the template, which translates to $(1).
You can read the common templates in include/package.mk

"why don't you just look for the $(MAKE) invocation in that instance and add it there?"

That's  part of the problem - it is missing for Build/Compile/php5, and I assume it's defaulted somewhere in the depths of include/package.mk
This typifies the problem I've come up against, the fact that hidden default methods might not always be the best strategy. I hope this is fair criticism, please correct me if you think otherwise.

The discussion might have continued from here.