0
  • It seems spaces in file names give makefile a hard time (for example here).

  • We can control file names, but not the directory name where our project resides.

  • How to fix this makefile inside ~/Downloads/OREN ISH that uses a $(shell pwd):

BASEDIR = $(shell pwd)
${BASEDIR}/main: ${BASEDIR}/main.c
    gcc $< -o $@

We get the following error (that disappears when ${BASEDIR} is removed):

make: Circular /home/oren/Downloads/OREN <- /home/oren/Downloads/OREN dependency dropped.
make: *** No rule to make target 'ISH/main.c', needed by '/home/oren/Downloads/OREN'.  Stop.
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

1 Answers1

3

There is no way to make whitespace in targets/prerequisites work.

You have two choices:

First, add a note to your documentation telling users that they should not install the software in a directory path containing whitespace. You can also test this easily with something like:

ifneq (1,$(words $(CURDIR)))
$(error Containing path cannot contain whitespace: '$(CURDIR)')
endif

Or second (and this is what I would recommend anyway, even if make handled whitespace in pathnames perfectly), write your makefile using only relative paths so you never need to worry about what the path to the root of your source tree looks like or what magical characters it might contain.

MadScientist
  • 92,819
  • 9
  • 109
  • 136