File: mkconfig

package info (click to toggle)
picosat 960-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 544 kB
  • ctags: 1,506
  • sloc: ansic: 15,668; sh: 136; makefile: 125
file content (35 lines) | stat: -rwxr-xr-x 550 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

die () {
   echo "*** mkconfig: $*" 1>&2
   exit 1
}

[ -f makefile ] || die "can not find 'makefile'"

sed \
  -e '/^C[A-Z]*=/!d' \
  -e 's,^,#define PICOSAT_,' \
  -e 's,= *, ",' \
  -e 's,$,",' \
  makefile

id=""
if [ -d .git -a -f .git/HEAD ]
then
  head="`awk 'NF == 1' .git/HEAD`"
  if [ x"$head" = x ]
  then
    head="`awk '{print $2}' .git/HEAD`"
    if [ ! x"$head" = x -a -f ".git/$head" ]
    then
      id=" `cat .git/$head`"
    fi
  else
    id=" $head"
  fi
fi

echo "#define PICOSAT_VERSION \"`cat VERSION`$id\""

exit 0