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