make/update-rules.sh

Wed, 25 Dec 2024 19:33:04 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 25 Dec 2024 19:33:04 +0100
changeset 1054
fb1076ead56f
parent 988
15b3ca7ee33f
permissions
-rwxr-xr-x

add implementation for creating new json values

relates to #527

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"
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents: 755
diff changeset
4 target="$2"
988
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
5 extra_flags="$3"
755
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 if [ -z "$dir" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 echo "Usage: $0 <src_dir>"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents: 755
diff changeset
12 if [ -z "$target" ]; then
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents: 755
diff changeset
13 target='$(build_dir)'
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents: 755
diff changeset
14 fi
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents: 755
diff changeset
15
755
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 if [ -d "$dir" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 :
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 else
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 echo "'$dir' is not a directory"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 if [ -z "$CC" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 for cc in gcc clang ; do
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 if command -v "$cc" > /dev/null ; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 CC="$cc"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 break
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 done
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 if [ -z "$CC" ]; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 echo "No suitable compiler found to generate make rules"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 if command -v sed > /dev/null ; then
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 :
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 else
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 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
41 exit 1
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 fi
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 cd "$dir"
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 mv Makefile Makefile.old
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 sed '/FORCE:/q' Makefile.old > Makefile
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 echo >> Makefile
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 for file in `ls *.c` ; do
988
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
50 "$CC" -MT "$target/${file/.c/\$(OBJ_EXT)}" -MM $CFLAGS $extra_flags "$file"
755
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 printf '\t@echo "Compiling $<"\n'
988
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
52 printf '\t$(CC) -o $@ $(CFLAGS) %s -c $<\n\n' "$extra_flags"
755
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 done >> Makefile
255ee4abf2ec add update-rules script
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 rm Makefile.old

mercurial