1

I have a Makefile with only project-level definitions: which source files to use, what binary or library to make, etc..

It includes ../../Make.Arch for architecture-specific definitions (such as compiler command).

In turn, Make.Arch is meant to include ../etc/Makefile.Standard for all the boilerplate of actually allowing the make system to work .

But include requires a path relative to where the makefile is actually being run (or maybe where the first Makefile is), not relative to the second... What to do?

Swiss Frank
  • 1,985
  • 15
  • 33

1 Answers1

1

Make interprets relative paths from the working directory, the directory in which Make is being run. You haven't specified how you're running Make, so I'll assume your running it in the directory with Makefile.

If you are allowed to modify the makefiles, you can change the paths.

You could change Make.Arch from this:

include ../etc/Makefile.Standard

to this:

include ../../../etc/Makefile.Standard

but that would require that any makefile that uses Make.Arch be two directories down from it. That's clearly not a good idea. But we can use a variable:

include $(ARCH_DIR)/../etc/Makefile.Standard

which is provided by Makefile (or any other makefile that uses Make.Arch):

ARCH_DIR := ../..
include $(ARCH_DIR)/Make.Arch

If you are not allowed to modify the makefiles, then you must cheat. One way is to create a symbolic link to Makefile.Standard.

mkdir ../etc
ln -s ../../../etc/Makefile.Standard ../etc

Now Makefile will work. (It ought to be possible to make a link to etc/, but for some reason I can't get that to work right now.)

Beta
  • 96,650
  • 16
  • 149
  • 150