make/update-rules.sh

Fri, 12 Apr 2024 22:23:31 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Apr 2024 22:23:31 +0200
changeset 60
3954c551ded3
parent 8
756b49205a29
permissions
-rwxr-xr-x

remove unnecessary parameters

#!/bin/sh

dir="$1"

if [ -z "$dir" ]; then
  echo "Usage: $0 <src_dir>"
  exit 1
fi

if [ -d "$dir" ]; then
  :
else
  echo "'$dir' is not a directory"
  exit 1
fi

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 "\$(BUILD_DIR)/${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