File: tryfeature.sh

package info (click to toggle)
tinyssh 20250501-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,388 kB
  • sloc: ansic: 20,245; sh: 1,582; python: 1,449; makefile: 913
file content (43 lines) | stat: -rwxr-xr-x 829 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
#!/bin/sh

# version 20241107

scriptname="`basename $0`"

if [ x"${CC}" = x ]; then
  echo "usage: env CC=<compiler> ${scriptname} feature.c"
  echo '$CC not set'
  exit 1
fi

if [ x"$1" = x ]; then
  echo "usage: env CC=<compiler> ${scriptname} feature.c"
  echo 'missing feature.c argument'
  exit 1
fi

# input
tryname="$1"

# output
headermacro=`echo ${tryname} | sed 's/\.c//' | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`

# temporary
binname="${tryname}.tmp.bin"
logname="${tryname}.tmp.log"

cleanup() {
  ex=$?
  rm -f "${binname}" "${logname}"
  exit "${ex}"
}
trap "cleanup" EXIT TERM INT

"${CC}" ${CFLAGS} -O0 -o "${binname}" "${tryname}" ${LDFLAGS} 1>"${logname}" 2>&1
if [ $? -eq 0 ]; then
  echo "#define ${headermacro} 1"
else
  echo "#undef ${headermacro}"
  cat "${logname}" >&2
fi
exit 0