forked from vlfeat/vlfeat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new update-mak.sh tool to help keep Makefile.mak updated
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
# file: update-mak.sh | ||
# description: Helper script to update Makefile.mak | ||
# author: Andrea Vedaldi | ||
|
||
# This script updates Makefile.mak based on the current source tree | ||
# and version in vl/generic.h. It saves the new version to | ||
# Makefile.mak.new. | ||
|
||
function make | ||
{ | ||
# sed below removes the trailing '\' from the last entry | ||
( | ||
printf '%-69s\\\n' "$1 =" | ||
find "$2" -name '*.c' | tr '/' '\' | while read -r x | ||
do | ||
printf ' %-66s \\\n' "$x" | ||
done | ||
) | sed '$s/ *\\$//' | ||
echo | ||
} | ||
|
||
function sub | ||
{ | ||
# Put substitution text at the beginning. Then sed puts the | ||
# beginning in its hold buffer, finds the paragraph starting with | ||
# "$2 =", deletes all but the last lines of it and substititue the | ||
# last line with the hold buffer. It also removes trailing | ||
# whitespaces. | ||
(make "$2" "$3" ; echo "$1") | \ | ||
sed -e '1{h;d;}' \ | ||
-e '2,/^$/{H;d;}' \ | ||
-e "/$2 =/,/^$/{/^$/!d;g;}" \ | ||
-e 's/ *$//' | ||
} | ||
|
||
function subv | ||
{ | ||
# Substitutes VER = x.x.x with the new version string. | ||
echo "$1" | sed -e "/VER *=/s/\(\([0-9][0-9]*\.\{0,1\}\)\{3\}\)/$2/" | ||
} | ||
|
||
# source version string from vl/generic.h | ||
ver=$(cat vl/generic.h | sed -n \ | ||
's/.*VL_VERSION_STRING.*\(\([0-9][0-9]*\.\{0,1\}\)\{3\}\).*/\1/p') | ||
|
||
# source current nmake script | ||
a=$(cat Makefile.mak) | ||
|
||
# updaetes version string | ||
a=$(subv "$a" "$ver") | ||
|
||
# updates hard-wired list of source code files in the nmake script | ||
a=$(sub "$a" libsrc vl) | ||
a=$(sub "$a" cmdsrc src) | ||
a=$(sub "$a" mexsrc toolbox) | ||
|
||
echo "$a" > Makefile.mak.new |