为什么make总是更新此目标? [英] Why does make always update this target?

查看:103
本文介绍了为什么make总是更新此目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Gentoo机器(GNU make 3.82)上使用 make 和以下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已经存在:

Using make on my Gentoo machine (which is GNU make 3.82) with the following Makefile, I wonder why the target data/spectra/o4_greenblatt_296K.dat gets updated every time I execute make data/spectra/o4_greenblatt_296K.dat, even though none of the files params/base/fwhm.dat, params/base/wavelength_grid.dat, and data/raw/o4green_gpp.dat has changed, and the file data/spectra/o4_greenblatt_296K.dat already exists:

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 新手提供帮助,非常感激:)

Any help you guys can give a make newbie is greatly appreciated :)

推荐答案

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

I would guess that it's because there is no file named input_spectra_o4_raw, which is a prerequisite of your 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:伪目标.

You should research how to use the .PHONY: pseudo-target.

这篇关于为什么make总是更新此目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆