关于Makefile的简单问题

关于Makefile的简单问题,makefile,gnu-make,Makefile,Gnu Make,我有一个关于tiobench的以下Makefile。我写的。问题是,当我做全部制作时,这并没有像它应该做的那样将我留在安装目录中。为什么? # 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 #D

我有一个关于tiobench的以下Makefile。我写的。问题是,当我做
全部制作时,这并没有像它应该做的那样将我留在安装目录中。为什么?

# 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

这些命令在子shell中运行。它们不能影响您运行的shell的当前工作目录
make all

您所说的“不将我留在安装目录中”是什么意思?我的意思是我应该在
make all
之后留在/install中,这不会发生。
cd install
in
cd install&&tar cf-`cat$(BOM)`(cd$(BUILDRESULTS);tar xfp-
不是在子shell中运行的。如果我在命令行上使用适当的目录运行
cd install&&tar cf-`cat$(BOM)`(cd$(BUILDRESULTS);tar xfp-
,我将留在./install.yes中,当您在当前shell中运行它时,这是正确的,但是
make
在新的子shell中运行它的shell命令