Next: , Previous: Failure in Make Rules, Up: Portable Make


11.3 Special Characters in Make Macro Names

Posix limits macro names to nonempty strings containing only ASCII letters and digits, ‘.’, and ‘_’. Many make implementations allow a wider variety of characters, but portable makefiles should avoid them. It is portable to start a name with a special character, e.g., ‘$(.FOO)’.

Some ancient make implementations don't support leading underscores in macro names. An example is NEWS-OS 4.2R.

     $ cat Makefile
     _am_include = #
     _am_quote =
     all:; @echo this is test
     $ make
     Make: Must be a separator on rules line 2.  Stop.
     $ cat Makefile2
     am_include = #
     am_quote =
     all:; @echo this is test
     $ make -f Makefile2
     this is test

However, this problem is no longer of practical concern.