0

I know this error relates to missing TAB, but I somehow cannot find out where on line 1 is the tab missing:

Makefile:

## -*- mode: make; tab-width: 8; -*-
##
## Simple Makefile
##
## TODO: 
##  proper configure for non-Debian file locations,   [ Done ]
##  allow RHOME to be set for non-default R etc

## comment this out if you need a different version of R, 
## and set set R_HOME accordingly as an environment variable

R_HOME =        $(shell R RHOME)

sources =       $(wildcard *.cpp)
programs =      $(sources:.cpp=)


## include headers and libraries for R 
RCPPFLAGS =         $(shell $(R_HOME)/bin/R CMD config --cppflags)
RLDFLAGS =      $(shell $(R_HOME)/bin/R CMD config --ldflags)
RBLAS =         $(shell $(R_HOME)/bin/R CMD config BLAS_LIBS)
RLAPACK =       $(shell $(R_HOME)/bin/R CMD config LAPACK_LIBS)

## if you need to set an rpath to R itself, also uncomment
#RRPATH :=      -Wl,-rpath,$(R_HOME)/lib

## include headers and libraries for Rcpp interface classes
RCPPINCL =      $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RCPPLIBS =      $(shell echo 'Rcpp:::LdFlags()'  | $(R_HOME)/bin/R --vanilla --slave)


## include headers and libraries for RInside embedding classes
RINSIDEINCL =       $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RINSIDELIBS =       $(shell echo 'RInside:::LdFlags()'  | $(R_HOME)/bin/R --vanilla --slave)

## compiler etc settings used in default make rules
CXX =           $(shell $(R_HOME)/bin/R CMD config CXX)
CPPFLAGS =      -Wall $(shell $(R_HOME)/bin/R CMD config CPPFLAGS)
CXXFLAGS =      $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R CMD 

config CXXFLAGS)
LDLIBS =        $(RLDFLAGS) $(RRPATH) $(RBLAS) $(RLAPACK) $(RCPPLIBS) $(RINSIDELIBS)

all: $(programs)
    @test -x /usr/bin/strip && strip $^

run: $(programs)
    @for p in $(programs); do echo; echo "Running $$p:"; ./$$p; done

clean:
    rm -vf $(programs)
    rm -vrf *.dSYM

runAll:
    for p in $(programs); do echo "Running $$p"; ./$$p; done

enter image description here

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
  • I cannot reproduce your error. I suggest try to minimize the example-- remove lines and test, until you find the smallest, simplest makefile that gives this error. It might also be useful to tell us which version of Make you are using (`make -v`). – Beta Oct 29 '12 at 13:56
  • This is almost always the same problem: your recipes (the shell commands) *must start with a TAB character*. You appear to be using spaces instead. – reinierpost Oct 29 '12 at 15:37
  • 1
    @reinierpost, doesn't the error message indicate a problem on line 1? Or is this one of those charming eccentricities of Microsoft? – Beta Oct 29 '12 at 18:06
  • It is *not* an eccentricity of Microsoft. – reinierpost Nov 01 '12 at 13:30

3 Answers3

3

Personally I have faced the same problem with a Makefile saved by some editor on Windows. The cause then was a BOM (Byte Order Mark) in the Makefile which was confusing Make.

To check if it is so you could (manually) copy and paste the whole Makefile (or maybe except for the header comment) into a new file created in some other editor/IDE. Also here is a great answer on how to remove BOM on Windows.

Community
  • 1
  • 1
Eldar Abusalimov
  • 24,387
  • 4
  • 67
  • 71
1

If your "Makefile.win" is an exact copy, then replace all spaces before the commands with tabs:

all: $(programs)
<insert tab here, no spaces>@test -x /usr/bin/strip && strip $^

run: $(programs)
<insert tab here, no spaces>@for p in $(programs); do echo; echo "Running $$p:"; ./$$p; done

clean:
<insert tab here, no spaces>rm -vf $(programs)
<insert tab here, no spaces>rm -vrf *.dSYM

runAll:
<insert tab here, no spaces>for p in $(programs); do echo "Running $$p"; ./$$p; done

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • I "had" done that "before" posting the question here. But I don't know how this Notepad treats the tab! When I copied the makefile to Linux and opened it through Kwrite, I realized that I "again" have to replace those tabs with new tabs! – Aquarius_Girl Oct 30 '12 at 04:39
1

The line just before LDLIBS apparently reads:

config CXXFLAGS)

That would generate a makefile syntax error, but I would expect it to be with a line number larger than 1.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 2
    Thankful to you. It was the fault of "damn" `Notepad` of Windows! the damn thing was showing the error on line 1. I copied the makefile to Linux and opened it through Kwrite. Then the compiler showed the error on the "proper" line number. – Aquarius_Girl Oct 30 '12 at 04:37