tags:

views:

113

answers:

1

I have experienced at times that if any special/control character($,^M, or something else) somehow gets into a makefile, then if u try to make -f Makefile using that makefile it gives errors.

I want to know,

1.) Has anyone experienced something like this, and if yes, what causes these errors? What is peculiar about these special chars?

+1  A: 

UNIX traditionally is not very forgiving with input to programs. That attitude hasn't changed much since its first inception. ^M is carriage return which usually only gets into files when editing them in Windows environments. UNIX uses the line feed (\n, 0x0a) as line terminator and many tools complain about CR (\r, 0x0d) as they don't see a reason why that character should even exist.

$ are a different issue, as $ is part of makefile syntax. It's used to indicate variables/constants in makefiles. Those can be contextual ones, like $< or $*, or named ones like $(CC).

You can use the dos2unix utility to get rid of ^M and escape dollar signs with \$.

There are more peculiarities to make, nonetheless. For example the requirement that command lines for targets need to be indented by a tab character. As far as I know only makes not very widely used have lifted that restriction.

Joey
@Johannes Rossel: Would these peculiar requirements for a makefile text formatting be explanined in the man Make or info make or some other make help.
goldenmean
Those should usually be documented, yes. But most people writing makefiles know about them anyway :)
Joey