make/update-rules.sh

changeset 76
c2a4fb5024b4
child 77
808a7324b467
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/update-rules.sh	Mon Jun 02 19:16:36 2025 +0200
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+dir='src'
+target='$(BUILDDIR)'
+
+if [ -z "$CC" ]; then
+  for cc in gcc clang ; do
+    if command -v "$cc" > /dev/null ; then
+      CC="$cc"
+      break
+    fi
+  done
+fi
+
+if [ -z "$CC" ]; then
+  echo "No suitable compiler found to generate make rules"
+  exit 1
+fi
+
+if command -v sed > /dev/null ; then
+  :
+else
+  echo "You need the 'sed' program for this script to work."
+  exit 1
+fi
+
+cd "$dir"
+
+mv Makefile Makefile.old
+sed '/FORCE:/q' Makefile.old > Makefile
+echo >> Makefile
+for file in `ls *.c` ; do
+  "$CC" -MT "$target/${file/.c/.o}" -MM $CFLAGS "$file"
+  printf '\t@echo "Compiling $<"\n'
+  printf '\t$(CC) -o $@ $(CFLAGS) -c $<\n\n'
+done  >> Makefile
+rm Makefile.old

mercurial