3
votes

My include file references many other make files using something like:

include Enablers/MSRP/Android.mk

the problem is that the make file that references all other makefiles is deep in sub-folders, or, in other words the correct path would be something like:

include ../../../../../Enablers/MSRP/Android.mk

In order for me to build my makefile I have to add ../../../../.. to make search path:

ndk-build -I../../../../.. -j8 other params...

(ndk-build is a wrapper for gnu make on android buildsystem, it's equivalent to make build-local.mk other params)

So, what can i do to to avoid adding the ../../../../.. to make search path? I could go the makefile and update all makefile include statements, but I'm looking for the way to add that extra include path at the top of my makefile. Something like:

makeincludepaht += include Enablers/MSRP/Android.mk
include Enablers/MSRP/Android.mk
...
2
The -I method is probably best. You can put the path at the top of your makefile, but that will marry the makefile to your directory structure. Are you sure you want to do that? - Beta
You can always create soft links from your deep directory to some top level and reference that in your makefile. The drawback is that without the links, your builds will fail so you'd need to create a script to automate the creation of the links if you want to share your makefile with others. - HonkyTonk
@Beta: what's the -I method that you are talking about? Is it something that I need to put on command line or inside makefile itself? I'm ok to marry for that directory structure by the way, that's exactly what I want. - Pavel P
@HonkyTonk: not going to work, I need this s%it working on windows as well (in regular cmd) - Pavel P
If you're ok with hard dependencies in regards to actual hard disk layout, you should be able to send a variable to make that contains the top level directory and use that to construct the rest in your makefile. This way there is no need for elaborate ..\..\.. usage. - HonkyTonk

2 Answers

2
votes

Append the new include path to the standard search path:

.INCLUDE_DIRS += ../../..

Look at the end of the Special Variables section for the .INCLUDE_DIRS special variable.

0
votes

I'm not familiar with ndk-build, but I have similar setup. I just set a variable in make that contains this path and then use that variable in all my includes.
makefile:
INCLUDE_TOP=../../../../..
include $(INCLUDE_TOP)/someDir/includes.mk

You can also then use INCLUDE_TOP inside includes.mk for all your paths. It is usually better to make it default to some value by conditionally setting in there.
includes.mk:
# will only set if not already set
INCLUDE_TOP ?= ./
HEADERS=$(INCLUDE_TOP)/headers