Makefile无法安装软件

时间:2014-04-12 18:02:20

标签: unix makefile install solaris

所以我试图编辑一个makefile来在Unix系统上安装软件,但我似乎做错了什么,因为make install一直都失败了。

这是我在运行make install后得到的结果:

/usr/sbin/install -m 555 audit /export/home/student/epoll390/bin/audit cp: audit 
and /export/home/student/epoll390/bin/audit are identical *** 
Error code 2 make: Fatal error: Command failed for target `install' 

如果有人能够提供一些有关我做错事的见解,我将非常感激。 makefile在下面。

# Make file for audit

# Location to install binary. Default is /usr/local/bin. You may
# prefer to install it in /usr/bin or /sbin
BINDIR  = /export/home/student/epoll390/bin
#BINDIR=/usr/bin
#BINDIR=/usr/sbin

# Location to install man page. Default is /usr/local/man. You may
# prefer to install it in /usr/man
MANDIR  = /export/home/student/epoll390/bin
#MANDIR = /usr/man

# Compiler to use
CC  = gcc

# Linker to use
LD  = gcc

# Preprocessor options
CPPFLAGS = -DGETOPTLONG

# Compile and link options
# On a.out systems you might want to add -N when linking
# RPM_OPT_FLAGS can be set by rpm tool
# ...For production code
CFLAGS  = -Wall -O3 $(RPM_OPT_FLAGS)
LDFLAGS = -s
# ...For debug
#CFLAGS = -Wall -g
#LDFLAGS = -g

audit:  audit.o
    $(LD) $(LDFLAGS) -o audit audit.o

audit.o: audit.c
    $(CC) $(CPPFLAGS) $(CFLAGS) -c audit.c

install: audit
    /usr/sbin/install -m 555 audit $(BINDIR)/audit
    /usr/sbin/install -m 444 audit.1 $(MANDIR)/man1/audit.1

clean:
    $(RM) audit audit.o core *~ results

# check in
ci: clean
    -ci -l *

dist:   clean
    cd .. ; tar --exclude RCS -czvf audit-0.2.tar.gz audit-0.2

1 个答案:

答案 0 :(得分:1)

错误消息告诉我您在make install目录中正在运行/export/home/student/epoll390/bin,这恰好是您设置为BINDIR的内容。因此,cp(由install程序巧妙地伪装)拒绝执行它(通常正确地)认为错误的内容,即将文件复制到自身上。

要修复,请在该目录中运行make clean,创建/home/student/epoll390/audit,将所有源文件和makefile移动到新目录cd中,然后重试。