5

我尝试建立一些项目的库。当我从终端将其作为 ./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
4

1 回答 1

13

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

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

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

#!/usr/bin/make -f

作为文件的第一行

于 2013-04-25T17:34:22.947 回答