关于Makefile的简单问题

发布于 2024-10-05 19:45:27 字数 1820 浏览 4 评论 0原文

我有一个用于 tiobench 的以下 Makefile。我写的。问题是,当我执行 make all 时,这不会将我留在安装目录中,因为它应该是这样。为什么 ?

# Makefile for tiotest

#include $(shell while [ "`pwd`" != / -a \! -r options.mk ]; do cd .. ; done ; pwd )/options.mk

#CFLAGS=-O3 -fomit-frame-pointer -Wall
CFLAGS=-O2 -Wall

#DEFINES=-DUSE_MMAP 
#-DUSE_MADVISE

# This enables support for 64bit file offsets, allowing
# possibility to test with files larger than (2^31) bytes.

#DEFINES=-DLARGEFILES

#DEFINES=

MODULE=tiotest
PROJECT=tiobench
# do it once instead of each time referenced
VERSION=$(shell egrep "tiotest v[0-9]+.[0-9]+" tiotest.c | cut -d " " -f 7 | sed "s/v//g")
DISTNAME=$(PROJECT)-$(VERSION)

INSTALL := $(CURDIR)/install
INSTALL_DIR := $(INSTALL)/test/bin
BOM := $(CURDIR)/BOM
BUILDRESULTS := $(CURDIR)/buildresults
MODULE := tiotest

build: $(MODULE)

crc32.o: crc32.c crc32.h
    $(CC) -c $(CFLAGS) $(DEFINES) crc32.c -o crc32.o

tiotest.o: tiotest.c tiotest.h crc32.h crc32.c Makefile
    $(CC) -c $(CFLAGS) $(DEFINES) tiotest.c -o tiotest.o

$(MODULE): tiotest.o crc32.o
    $(CC) -o $(MODULE) tiotest.o crc32.o -lpthread
    @echo
    @echo "./tiobench.pl --help for usage options"
    @echo

configure:

clean: clean-install
    rm -f tiotest.o crc32.o $(MODULE) core

distclean: clean

clean-install:
    -rm -rf $(INSTALL) $(BUILDRESULTS)

install: clean-install build
    mkdir -p $(INSTALL_DIR)
    cp $(MODULE) $(INSTALL_DIR)
    #$(STRIP) $(INSTALL_DIR)/$(MODULE)
    @echo install tree is in $(INSTALL)

buildresults: install
    mkdir $(BUILDRESULTS)
    cd install && tar cf - `cat $(BOM)` | (cd $(BUILDRESULTS) ; tar xfp -)
    @echo buildresults tree is in $(BUILDRESULTS)

all: distclean configure build install buildresults

.PHONY: build clean-install install buildresults clean distclean all

I have a following Makefile for tiobench. I wrote it. The problem is, when I do make all , this does not leave me in the install directory as it should. Why ?

# Makefile for tiotest

#include $(shell while [ "`pwd`" != / -a \! -r options.mk ]; do cd .. ; done ; pwd )/options.mk

#CFLAGS=-O3 -fomit-frame-pointer -Wall
CFLAGS=-O2 -Wall

#DEFINES=-DUSE_MMAP 
#-DUSE_MADVISE

# This enables support for 64bit file offsets, allowing
# possibility to test with files larger than (2^31) bytes.

#DEFINES=-DLARGEFILES

#DEFINES=

MODULE=tiotest
PROJECT=tiobench
# do it once instead of each time referenced
VERSION=$(shell egrep "tiotest v[0-9]+.[0-9]+" tiotest.c | cut -d " " -f 7 | sed "s/v//g")
DISTNAME=$(PROJECT)-$(VERSION)

INSTALL := $(CURDIR)/install
INSTALL_DIR := $(INSTALL)/test/bin
BOM := $(CURDIR)/BOM
BUILDRESULTS := $(CURDIR)/buildresults
MODULE := tiotest

build: $(MODULE)

crc32.o: crc32.c crc32.h
    $(CC) -c $(CFLAGS) $(DEFINES) crc32.c -o crc32.o

tiotest.o: tiotest.c tiotest.h crc32.h crc32.c Makefile
    $(CC) -c $(CFLAGS) $(DEFINES) tiotest.c -o tiotest.o

$(MODULE): tiotest.o crc32.o
    $(CC) -o $(MODULE) tiotest.o crc32.o -lpthread
    @echo
    @echo "./tiobench.pl --help for usage options"
    @echo

configure:

clean: clean-install
    rm -f tiotest.o crc32.o $(MODULE) core

distclean: clean

clean-install:
    -rm -rf $(INSTALL) $(BUILDRESULTS)

install: clean-install build
    mkdir -p $(INSTALL_DIR)
    cp $(MODULE) $(INSTALL_DIR)
    #$(STRIP) $(INSTALL_DIR)/$(MODULE)
    @echo install tree is in $(INSTALL)

buildresults: install
    mkdir $(BUILDRESULTS)
    cd install && tar cf - `cat $(BOM)` | (cd $(BUILDRESULTS) ; tar xfp -)
    @echo buildresults tree is in $(BUILDRESULTS)

all: distclean configure build install buildresults

.PHONY: build clean-install install buildresults clean distclean all

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰之心 2024-10-12 19:45:27

命令在子 shell 中运行。它们无法影响您运行 make all 的 shell 的当前工作目录

the commands are run in a sub shell. they can't effect the current working directory of the shell from which you ran make all

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文