I'm learning about Makefiles and application cross-compiling, and I'd like to find a way to prevent variables from being redefined in Makefiles further down the chain.
As an example, I write a top-level Makefile /usr/src/someapp.mk that will...
1) download the application's source code from the web into /usr/src/someapp-1.2.3/
2) untar the source, and
3) run its original /usr/src/someapp-1.2.3/Makefile
Since the original Makefile was written as a stand-alone script, it will unknowningly (re)define the usual suspects (CC, AR/RANLIB, etc.) with local values, effectively erasing the value I chose in the top-level Makefile:
#My top-level /usr/src/someapp.mk:
all:
wget someapp-1.2.3.tar.gz
tar xzvf someapp-1.2.3.tar.gz
cd someapp-1.2.3 && $(MAKE)
#Original Makefile from www /usr/src/someapp-1.2.3/Makefile:
#RANLIB locally redefined... :-/
RANLIB=ranlib
all:
$(RANLIB)...
I'd like users to be able to download the original source code instead of providing my own, modified version: Is there a way to have "make" either ignore when variables are redefined locally or rewrite them on the fly?
Thank you.