linux - GNU Makefile dependency in multi-job make -


i have c++ project under linux. i'm using gnu make , gcc

i have following rules:

all: ...  version: config:   rm -f config.h   @$(make) --no-print-directory config.h config.h:  # ..... create file config.h here 

make version increases build number. 1.1-123, 1.2-124 ... etc. version written in config.h file , config.h included in files in project.

now idea config.h rebuild in 1 of these cases: - when releasing version of program (rather developing/testing) - when not exists

so not want make dependancy:

all: config config: version 

because config file rebuild on every make , every single file recompiled, not changed files. want not re-build config file while developing, if make release_version now. lets rule is:

release_version: config version 

the problem when make release_version -j 3 it'll make 3 targets (config, version, all) @ same time means version might not ready creation of config.h, config.h might not ready all. must make dependency:

release_version: all: config config: version

but only when make release_version executed. if make all executed don't want have these dependencies.

maybe need like:

release_version: version_release config_release all_release

all_release: config config_release: config version_release: version

your examples bit haphazard. if re-read have , clarified it. version target do? relationship between version , config? relationship between release_version don't show anywhere, , config , version?

if understand correctly want have all rule build code using existing version of config.h (creating if doesn't exist), , release_version rule update config.h, build code if all. i'm not sure version , config do.

you can this, unless i'm missing something:

all: ...  release_version:         @rm -f config.h         @$(make) config.h         @$(make)  config.h:         ...create config.h...  .phony: release_version 

there lots of other options well.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -