使用以下Makefile
在我的Gentoo机器(GNU make 3.82)上使用 make ,我想知道为什么每次执行时data/spectra/o4_greenblatt_296K.dat
都会更新make data/spectra/o4_greenblatt_296K.dat
{{ 1}},即使文件params/base/fwhm.dat
,params/base/wavelength_grid.dat
和data/raw/o4green_gpp.dat
都没有更改,文件data/spectra/o4_greenblatt_296K.dat
已经存在:
FWHM = params/base/fwhm.dat
WLGRID = params/base/wavelength_grid.dat
$(WLGRID): code/create_wavelength_grid.py
cp code/create_wavelength_grid.py params/base/wavelength_grid.dat
$(FWHM): code/create_fwhm_param.py
cp code/create_fwhm_param.py params/base/fwhm.dat
data/raw/o4green_gpp.dat:
echo 1 > data/raw//o4green_gpp.dat
input_spectra_o4_raw: data/raw/o4green_gpp.dat
data/spectra/o4_greenblatt_296K.dat: $(WLGRID) $(FWHM) input_spectra_o4_raw
echo 1 > data/spectra/o4_greenblatt_296K.dat
input_spectra_o4: data/spectra/o4_greenblatt_296K.dat
非常感谢你们给 make 新手的任何帮助:)
答案 0 :(得分:1)
我猜这是因为没有名为input_spectra_o4_raw
的文件,这是data/spectra/o4_greenblatt_296K.dat
的先决条件。
这个决定看起来像这样:
1. params/base/wavelength_grid.dat and params/base/fwhm.dat are both up to date
2. check input_spectra_o4_raw - file does not exist, so build it first
3. there is a target for input_spectra_o4_raw, and it's prerequisite
data/raw/o4green_gpp.dat is up to date, so run all the commands to build
input_spectra_o4_raw (there are none, though, so we essentially just mark that we've
done everything we need to for input_spectra_o4_raw and that we built it new)
4. we just built input_spectra_o4_raw, so data/spectra/o4_greenblatt_296K.dat is out of
date with respect to that prerequisite and needs to be rebuilt
您应该研究如何使用.PHONY:
伪目标。