首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么总是更新这个目标?

为什么总是更新这个目标?
EN

Stack Overflow用户
提问于 2013-09-12 12:40:02
回答 1查看 143关注 0票数 1

在我的Gentoo机器上使用make (即GNU 3.82)和下面的Makefile,我想知道为什么每次执行make data/spectra/o4_greenblatt_296K.dat时都更新目标data/spectra/o4_greenblatt_296K.dat,即使文件params/base/fwhm.datparams/base/wavelength_grid.datdata/raw/o4green_gpp.dat都没有改变,而且文件data/spectra/o4_greenblatt_296K.dat已经存在:

代码语言:javascript
复制
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

如果你们能帮到新手的话,我们会非常感激的:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-12 14:26:23

我猜想这是因为没有名为input_spectra_o4_raw的文件,这是data/spectra/o4_greenblatt_296K.dat的先决条件。

这个决定看上去有点像这样:

代码语言:javascript
复制
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:伪目标。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18764544

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档