Pavel P
Pavel P

Reputation: 16940

gnu make put include path into make file

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
...

Upvotes: 3

Views: 3974

Answers (2)

Pavel P
Pavel P

Reputation: 16940

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.

Upvotes: 2

Ben
Ben

Reputation: 673

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

Upvotes: 0

Related Questions