make/update-rules.sh

Sat, 01 Feb 2025 13:59:01 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 01 Feb 2025 13:59:01 +0100
changeset 10
bf159cf9f4b6
parent 0
b4b281ef2d0f
permissions
-rwxr-xr-x

improve heatmap::add() by using C++23 ranges-v3

#!/bin/sh

dir="$1"
target="$2"
extra_flags="$3"

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

if [ -z "$target" ]; then
  target='../build'
fi

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

if [ -z "$CXX" ]; then
  for cxx in g++ clang++ ; do
    if command -v "$cxx" > /dev/null ; then
      CXX="$cxx"
      break
    fi
  done
fi

if [ -z "$CXX" ]; 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 *.cpp` ; do
  "$CXX" -MT "$target/${file/.cpp/\.o}" -MM $CXXFLAGS $extra_flags "$file"
  printf '\t@echo "Compiling $<"\n'
  printf '\t$(CXX) -o $@ $(CXXFLAGS) %s -c $<\n\n' "$extra_flags"
done  >> Makefile
rm Makefile.old

mercurial