2010-12-04 12 views
0

私はtiobench用に以下のMakefileを持っています。私はそれを書きました。問題は、私がmake allを実行したときに、これはインストールディレクトリに私を残さないということです。どうして ?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 
+0

"インストールディレクトリに私を残しません"とはどういう意味ですか? – vanza

+0

私は 'make all'の後に./installに残すべきだということを意味しましたが、これは起こりません。 – abc

答えて

2

コマンドはサブシェルで実行されます。実行したシェルの現在の作業ディレクトリに影響を与えることはできませんmake all

+0

'cd install'の' cd install'と 'tar cf - \' cat $(BOM)\ '| (cd $(BUILDRESULTS); tar xfp - ) 'はサブシェルでは実行されません。 'cd install && tar cf - \' cat $(BOM)\ '|を実行すると、 (cd $(BUILDRESULTS); tar xfp - ) '適切なディレクトリがあるコマンドラインで、私は./installに残されています。 – abc

+0

はい、現在のシェルで実行すると正しいですが、 'make'は新しいサブシェルでシェルコマンドを実行します –

+0

ありがとう、ありがとう。私は私のテストの結果に戻ります。 – abc