make/update-rules.sh

Mon, 18 Dec 2023 14:14:47 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 18 Dec 2023 14:14:47 +0100
changeset 759
475335643af4
parent 755
255ee4abf2ec
child 766
e59b76889f00
permissions
-rwxr-xr-x

increase version number to 3.1

remove per-file version information
from Doxygen output

755
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 #!/bin/sh
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 dir="$1"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 if [ -z "$dir" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 echo "Usage: $0 <src_dir>"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 if [ -d "$dir" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 :
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 else
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 echo "'$dir' is not a directory"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 if [ -z "$CC" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 for cc in gcc clang ; do
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 if command -v "$cc" > /dev/null ; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 CC="$cc"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 break
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 done
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 if [ -z "$CC" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 echo "No suitable compiler found to generate make rules"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 if command -v sed > /dev/null ; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 :
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 else
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 echo "You need the 'sed' program for this script to work."
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 cd "$dir"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 mv Makefile Makefile.old
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 sed '/FORCE:/q' Makefile.old > Makefile
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 echo >> Makefile
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 for file in `ls *.c` ; do
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 "$CC" -MT "\$(build_dir)/${file/.c/\$(OBJ_EXT)}" -MM $CFLAGS "$file"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 printf '\t@echo "Compiling $<"\n'
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 printf '\t$(CC) -o $@ $(CFLAGS) -c $<\n\n'
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 done >> Makefile
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 rm Makefile.old

mercurial