我收到以下 Makefile 错误,感谢任何有用的建议
谁能告诉我我的 make 文件做错了什么?任何正确方向的帮助都值得赞赏。 错误:
make: ../apue.3e/systype.sh: Command not found
Makefile:3: ../apue.3e/Make.defines.: No such file or directory
Makefile:15: ../apue.3e/Make.libapue.inc: No such file or directory
make: *** No rule to make target `../apue.3e/Make.libapue.inc'. Stop.
我的 Makefile 目前看起来像这样:
ROOT=../apue.3e
PLATFORM=$(shell $(ROOT)/systype.sh)
include $(ROOT)/Make.defines.$(PLATFORM)
PROGS = shell2
all: $(PROGS)
%: %.c $(LIBAPUE)
$(CC) $(CFLAGS) [email protected] -o $@ $(LDFLAGS) $(LDLIBS)
clean:
rm -f $(PROGS) $(TEMPFILES) *.o
include $(ROOT)/Make.libapue.inc
我的目录结构看起来像这样,我认为我的 ROOT 路径不正确,但我无法弄清楚:
[singhrav@csci-gnode-02 ~]$ pwd
/export/homes/singhrav
[singhrav@csci-gnode-02 ~]$ ls
a.out cse_grid_tutorial Makefile OOP server tmp
client Homework03SinghRav Millionproject1 output shell2.c typescript
csci3800hw-singh.txt hw2 mysearch-result.txt output2 SinghRavisher_04
csci3800sp22 lab1 myShell pythonProject SinghRavisher_HW02
[singhrav@csci-gnode-02 ~]$ cd csci3800sp22
[singhrav@csci-gnode-02 ~/csci3800sp22]$ ls
apue.3e src.3e.tar.gz
[singhrav@csci-gnode-02 ~/csci3800sp22]$ cd apue.3e
[singhrav@csci-gnode-02 apue.3e]$ ls
cadvio environ include Make.defines.freebsd Make.libapue.inc relation systype.sh
daemons exercises intro Make.defines.linux printer signals termios
datafiles figlinks ipc1 Make.defines.macos proc sockets threadctl
db filedir ipc2 Make.defines.solaris pty standards threads
DISCLAIMER fileio lib Makefile README stdio
[singhrav@csci-gnode-02 apue.3e]$ cd intro
[singhrav@csci-gnode-02 intro]$ ls
getcputc hello ls1 Makefile mycat.c shell1.c shell2.c testerror.c uidgid.c
getcputc.c hello.c ls1.c mycat shell1 shell2 testerror uidgid
[singhrav@csci-gnode-02 intro]$ cp /export/homes/singhrav/csci3800sp22/apue.3e/intro/shell2 /export/homes/singhrav/lab1
[singhrav@csci-gnode-02 intro]$ cd ..
[singhrav@csci-gnode-02 apue.3e]$ cd ..
[singhrav@csci-gnode-02 ~/csci3800sp22]$ ls
apue.3e src.3e.tar.gz
[singhrav@csci-gnode-02 ~/csci3800sp22]$ cd ..
[singhrav@csci-gnode-02 ~]$ ls
a.out cse_grid_tutorial Makefile OOP server tmp
client Homework03SinghRav Millionproject1 output shell2.c typescript
csci3800hw-singh.txt hw2 mysearch-result.txt output2 SinghRavisher_04
csci3800sp22 lab1 myShell pythonProject SinghRavisher_HW02
[singhrav@csci-gnode-02 ~]$ cd lab1
[singhrav@csci-gnode-02 ~/lab1]$ ls
Makefile shell2
Can anyone tell what am I doing wrong in my make file? Any help in correct direction is appreciated.
Error:
make: ../apue.3e/systype.sh: Command not found
Makefile:3: ../apue.3e/Make.defines.: No such file or directory
Makefile:15: ../apue.3e/Make.libapue.inc: No such file or directory
make: *** No rule to make target `../apue.3e/Make.libapue.inc'. Stop.
My Makefile looks like this currently:
ROOT=../apue.3e
PLATFORM=$(shell $(ROOT)/systype.sh)
include $(ROOT)/Make.defines.$(PLATFORM)
PROGS = shell2
all: $(PROGS)
%: %.c $(LIBAPUE)
$(CC) $(CFLAGS) [email protected] -o $@ $(LDFLAGS) $(LDLIBS)
clean:
rm -f $(PROGS) $(TEMPFILES) *.o
include $(ROOT)/Make.libapue.inc
My directories structure looks like this,I think my ROOT path is not correct but I cant figure out :
[singhrav@csci-gnode-02 ~]$ pwd
/export/homes/singhrav
[singhrav@csci-gnode-02 ~]$ ls
a.out cse_grid_tutorial Makefile OOP server tmp
client Homework03SinghRav Millionproject1 output shell2.c typescript
csci3800hw-singh.txt hw2 mysearch-result.txt output2 SinghRavisher_04
csci3800sp22 lab1 myShell pythonProject SinghRavisher_HW02
[singhrav@csci-gnode-02 ~]$ cd csci3800sp22
[singhrav@csci-gnode-02 ~/csci3800sp22]$ ls
apue.3e src.3e.tar.gz
[singhrav@csci-gnode-02 ~/csci3800sp22]$ cd apue.3e
[singhrav@csci-gnode-02 apue.3e]$ ls
cadvio environ include Make.defines.freebsd Make.libapue.inc relation systype.sh
daemons exercises intro Make.defines.linux printer signals termios
datafiles figlinks ipc1 Make.defines.macos proc sockets threadctl
db filedir ipc2 Make.defines.solaris pty standards threads
DISCLAIMER fileio lib Makefile README stdio
[singhrav@csci-gnode-02 apue.3e]$ cd intro
[singhrav@csci-gnode-02 intro]$ ls
getcputc hello ls1 Makefile mycat.c shell1.c shell2.c testerror.c uidgid.c
getcputc.c hello.c ls1.c mycat shell1 shell2 testerror uidgid
[singhrav@csci-gnode-02 intro]$ cp /export/homes/singhrav/csci3800sp22/apue.3e/intro/shell2 /export/homes/singhrav/lab1
[singhrav@csci-gnode-02 intro]$ cd ..
[singhrav@csci-gnode-02 apue.3e]$ cd ..
[singhrav@csci-gnode-02 ~/csci3800sp22]$ ls
apue.3e src.3e.tar.gz
[singhrav@csci-gnode-02 ~/csci3800sp22]$ cd ..
[singhrav@csci-gnode-02 ~]$ ls
a.out cse_grid_tutorial Makefile OOP server tmp
client Homework03SinghRav Millionproject1 output shell2.c typescript
csci3800hw-singh.txt hw2 mysearch-result.txt output2 SinghRavisher_04
csci3800sp22 lab1 myShell pythonProject SinghRavisher_HW02
[singhrav@csci-gnode-02 ~]$ cd lab1
[singhrav@csci-gnode-02 ~/lab1]$ ls
Makefile shell2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
makefile 中的相对路径是相对于当前工作目录解释的,而不是相对于它们出现的 makefile 的位置。
因此,鉴于您显示的目录结构和 makefile 内容,只有当您从目录
csci3800sp22/apue.3e
启动make
时,该 makefile 才会起作用,这使得整个ROOT业务或多或少没有实际意义。您没有提供有关如何以及从何处启动
make
的足够信息来支持您应该做什么的建议。Relative paths in a makefile are interpreted relative to the current working directory, not relative to the location of the makefile in which they appear.
Given the directory structure and makefile content you show, therefore, that makefile will only work if you launch
make
from directorycsci3800sp22/apue.3e
, which makes the wholeROOT
business more or less moot. You have not provided enough information about how and from where you are launchingmake
to support a recommendation of what you should do instead.