通用Makefile在FreeBSD上不起作用 [英] Generic Makefile not working on FreeBSD

查看:223
本文介绍了通用Makefile在FreeBSD上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,这与名为通用makefile的其他问题不是重复的.

Please note that this is not a duplicate of the other questions named generic makefile.

我已经按照所有有关通用Makefile的其他问题进行了说明,这是我从中得到的代码:

I have followed all of the instructions on other questions about generic makefiles, and this is the code I have come up with from that:

CFLAGS = -c
CC = cc
SOURCES = $(wildcard *.cc)
OBJECTS = $(patsubst %.cc,%.o,%(SOURCES))
EXEC = run

all: build clean

build: $(OBJECTS)
    $(CC) $(OBJECTS) -o $(EXEC)

%.o: %.cc
    $(CC) $(CFLAGS) $<

clean:
    rm *.o

但是,当我在目录中使用名为test.cc的文件执行make时,会出现以下跟随错误:

However, when I execute make with a file called test.cc in my directory, it gives me the followig error:

cc    -o run
cc: error: no input files
*** Error code 1

Stop.
make: stopped in /somewhere

请注意,我使用的是FreeBSD,makecc命令是操作系统随附的命令.

Please note that I am on FreeBSD and the make and cc commands are the ones which come with the OS.

推荐答案

线条

SOURCES = $(wildcard *.cc)
OBJECTS = $(patsubst %.cc,%.o,%(SOURCES))

是FreeBSD的make无法理解的GNU make语法,它具有自己的方言(特别是$(wildcard)$(patsubst)).如果您需要编写可移植到许多系统的makefile,则需要存在gmake并使用GNUmakefile,或者坚持 POSIX的功能.

are GNU make syntax, not understood by FreeBSD's make, which has its own dialect (specifically $(wildcard) and $(patsubst)). If you need to write makefiles portable to many systems, either require gmake to exist and use GNUmakefiles, or stick to the features of POSIX make.

您可以通过以下方式在FreeBSD上安装GNU make(gmake)

You can install GNU make (gmake) on FreeBSD with

cd /usr/ports/devel/gmake
make install clean

这篇关于通用Makefile在FreeBSD上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆