Skip to content

Commit

Permalink
mk/checkconf.mk: update generation of conf.mk
Browse files Browse the repository at this point in the history
Make generation of conf.mk more consistent with what we do for conf.h,
that is:
- conf.mk shall not be touched if its content does not change,
- write "CHK" when checking the file, then "UPD" only if it needs
updating.

Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Reviewed-by: Pascal Brand <[email protected]>
  • Loading branch information
jforissier committed Apr 15, 2015
1 parent 0670725 commit 3354f9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $(conf-file): FORCE
$(call check-conf-h)

$(conf-mk-file): FORCE
$(call build-conf-mk)
$(call check-conf-mk)

#
# Do libraries
Expand Down
23 changes: 14 additions & 9 deletions mk/checkconf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ define check-conf-h
echo "#define $${guard}" >>[email protected]; \
echo -n "$${cnf}" | sed 's/_nl_ */\n/g' >>[email protected]; \
echo "#endif" >>[email protected]; \
if [ -r $@ ] && cmp -s $@ [email protected]; then \
rm -f [email protected]; \
else \
echo ' UPD $@'; \
mv [email protected] $@; \
fi
$(call mv-if-changed,[email protected],$@)
endef

define build-conf-mk
define check-conf-mk
$(q)set -e; \
echo ' CHK $@'; \
cnf="$(strip $(foreach var, \
$(call cfg-vars-by-prefix,CFG_), \
$(call cfg-make-variable,$(var))))"; \
Expand All @@ -43,8 +39,17 @@ define build-conf-mk
echo "PLATFORM=${PLATFORM}" >>[email protected]; \
echo "PLATFORM_FLAVOR=${PLATFORM_FLAVOR}" >>[email protected]; \
echo -n "$${cnf}" | sed 's/_nl_ */\n/g' >>[email protected]; \
echo ' UPD $@'; \
mv [email protected] $@;
$(call mv-if-changed,[email protected],$@)
endef

# Rename $1 to $2 only if file content differs. Otherwise just delete $1.
define mv-if-changed
if [ -r $2 ] && cmp -s $2 $1; then \
rm -f $1; \
else \
echo ' UPD $2'; \
mv $1 $2; \
fi
endef

define cfg-vars-by-prefix
Expand Down

0 comments on commit 3354f9b

Please sign in to comment.