Hristo Venev
Hristo Venev

Reputation: 992

Handling whitespaces in file names using autotools

How do I tell automake to use a file with whitespaces in its name? This doesn't seem to work.

bin_PROGRAMS = prog
prog_SOURCES = "a file.c" "another file.c"

Upvotes: 5

Views: 710

Answers (2)

arand
arand

Reputation: 164

One way around it, albeit very clunky, is to store two copies of the file in your source

another file.ext
another_file.ext

then using

EXTRA_DIST = another_file.ext

dist-hook:
    cp $(distdir)/another_file.ext "$(distdir)/another file.ext"

you'll be able to distribute the file with spaces in it, you will still need to keep the file with replaced spaces, and make sure the files are in sync (and indicate this fact to others).

In most cases it would be more convenient to just rename the files without spaces though, unless you've got a very odd case needing spaced-out files.

Upvotes: 0

ptomato
ptomato

Reputation: 57870

You can't. (Surprisingly, this is the only extremely serious fault in Automake in my opinion, but people hardly ever complain about it.)

I once worked around installing data files with spaces in their names, by renaming the files in the source tree so that they didn't have spaces, then renaming them to their spaceful names in install-data-hook. (link)

That, however, has no bearing on your problem, to which my answer is still: you can't. As far as I know, prog_SOURCES is just a shell variable. A specially-named one, sure, but once Automake finds it, it simply separates it on spaces. Spaces are spaces, whether they're escaped, quoted, or plain. They should have designed it so that you could escape spaces, but I'm sure they won't change it now because it would cause widespread Automake breakage.

Upvotes: 5

Related Questions