make file issue:每行都有错误

时间:2013-04-25 17:32:00

标签: linux gcc makefile

我尝试构建一个项目的库。当我从终端运行它作为./MakeFile时,每行都会收到一堆错误。下面是makefile和错误。这有什么问题?对于其他项目,Makefie工作正常,因此系统不知道如何解释此文件。 谢谢!

LIBDIR = ../../lib

IFLAGS = -I../../include -I/usr/local/include

CFLAGS = $(IFLAGS) -O3 -Wunused -m32 #-fPIC

CC = gcc

AR = ar

SRC =   allocfailed.c cleanup.c ECDFwd.c ECDLeadField.c ECDSolve.c ECDSolve2.c \
    GetBasis.c  GetCoeffs.c GetHull.c NLeadField.c NSolveFwd.c NSolveWts.c \
    rnynm.c xbd.c xlubksb.c xludcmp.c

OBJ =   $(SRC:.c=.o)

all:    liblfu.a

liblfu.a: $(OBJ)
    $(AR) cr liblfu.a $(OBJ)
    @mkdir -p $(LIBDIR)
    mv liblfu.a $(LIBDIR)

clean:
    /bin/rm -rf *.o *.il *.a core


./Makefile: line 1: LIBDIR: command not found
./Makefile: line 3: IFLAGS: command not found
./Makefile: line 5: IFLAGS: command not found
./Makefile: line 5: CFLAGS: command not found
./Makefile: line 7: CC: command not found
./Makefile: line 9: AR: command not found
./Makefile: line 11: SRC: command not found
./Makefile: line 15: SRC:.c=.o: command not found
./Makefile: line 15: OBJ: command not found
./Makefile: line 17: all:: command not found
./Makefile: line 19: OBJ: command not found
./Makefile: line 19: liblfu.a:: command not found
./Makefile: line 20: AR: command not found
./Makefile: line 20: OBJ: command not found
./Makefile: line 20: cr: command not found
./Makefile: line 21: LIBDIR: command not found
./Makefile: line 21: @mkdir: command not found
./Makefile: line 22: LIBDIR: command not found

1 个答案:

答案 0 :(得分:10)

您正在将make文件作为脚本运行,只需键入make

即可

make命令将Makefile(或makefile)作为默认输入。它不可运行。

您可以通过添加(假设make在/ usr / bin中)

使其可运行
#!/usr/bin/make -f

作为文件的第一行