make는 변경되지 않은 파일을 다시 컴파일합니다.

make는 변경되지 않은 파일을 다시 컴파일합니다.

방금 첫 번째 Makefile을 작성했는데 왜 GNUmake가 호출될 때마다 모든 것을 다시 컴파일하는지 이해가 되지 않습니다 make. 여기있어:

# Makefile
CC         = c++

ROOTFLAGS  = $(shell root-config --cflags)
MGDOFLAGS  = $(shell mgdo-config --cflags)
CLHEPFLAGS = $(shell clhep-config --include)
ALLFLAGS   = $(ROOTFLAGS) $(MGDOFLAGS) $(CLHEPFLAGS)

ROOTLIBS  = $(shell root-config --glibs) -lSpectrum
MGDOLIBS  = $(shell mgdo-config --libs)
CLHEPLIBS = $(shell clhep-config --libs)
ALLLIBS   = $(ROOTLIBS) $(MGDOLIBS) $(CLHEPLIBS)

EXEC = tier1browser selectEvents currentPlot

all : $(EXEC)

selectEvents : selectEvents.cc
    mkdir -p bin && \
    $(CC) $(ALLFLAGS) -o bin/$@ $< $(ALLLIBS)

currentPlot : currentPlot.cc
    mkdir -p bin && \
    $(CC) $(ROOTFLAGS) -o bin/$@ $< $(ROOTLIBS) -fopenmp -Ofast

tier1browser : tier1Browser.cxx tier1BrowserDict.cxx
    mkdir -p bin && \
    $(CC)-4.9 $(ALLFLAGS) -I. -o bin/$@ $< lib/tier1BrowserDict.cxx $(ALLLIBS)   

tier1BrowserDict.cxx : tier1Browser.h tier1BrowserLinkDef.h
    mkdir -p lib && \
    cd lib && \
    rootcling -f $@ $(MGDOFLAGS) $(CLHEPFLAGS) -c ../tier1Browser.h ../tier1BrowserLinkDef.h; \
    cd ..

.PHONY : all clean

clean : 
    rm -rf bin/* lib/*

뭐가 문제 야? 최종 폴더 계층 구조:

bin/currentPlot
bin/selectEvents
bin/tier1browser
lib/tier1BrowserDict.cxx
lib/tier1BrowserDict_rdict.pcm
Makefile
currentPlot.cc
selectEvents.cc
tier1Browser.cxx
tier1Browser.h
tier1BrowserLinkDef.h

초보자가 더 효율적이고 우아하게 만들 수 있는 다른 팁이 있나요?

답변1

Makefile에 현재 디렉터리에 대한 종속성을 요청합니다.

currentPlot : currentPlot.cc

currentPlot make는 현재 디렉토리에 파일 이름이 있을 것으로 예상 하고 bin디렉토리( -o bin/$@)에 빌드하고 있습니다.

관련 정보