make/update-rules.sh

changeset 76
c2a4fb5024b4
child 77
808a7324b467
equal deleted inserted replaced
75:b0b8bf3c536e 76:c2a4fb5024b4
1 #!/bin/sh
2
3 dir='src'
4 target='$(BUILDDIR)'
5
6 if [ -z "$CC" ]; then
7 for cc in gcc clang ; do
8 if command -v "$cc" > /dev/null ; then
9 CC="$cc"
10 break
11 fi
12 done
13 fi
14
15 if [ -z "$CC" ]; then
16 echo "No suitable compiler found to generate make rules"
17 exit 1
18 fi
19
20 if command -v sed > /dev/null ; then
21 :
22 else
23 echo "You need the 'sed' program for this script to work."
24 exit 1
25 fi
26
27 cd "$dir"
28
29 mv Makefile Makefile.old
30 sed '/FORCE:/q' Makefile.old > Makefile
31 echo >> Makefile
32 for file in `ls *.c` ; do
33 "$CC" -MT "$target/${file/.c/.o}" -MM $CFLAGS "$file"
34 printf '\t@echo "Compiling $<"\n'
35 printf '\t$(CC) -o $@ $(CFLAGS) -c $<\n\n'
36 done >> Makefile
37 rm Makefile.old

mercurial