Skip to content

build: Require libglad.la only when needed.

orbea requested to merge orbea/demos:glad into main

For the automake build its better to only depend on libglad.la when needed instead of always even when its not needed.

I noticed this because I only build a few make targets, incidentally none of these need libglad (i.e. make -C src/demos gears).

To identify these I used these two shell snippets, the first to add missing LDADD lines and the second to identify unneeded lines.

for i in $(grep -il glad *.c); do
  file=$(echo "$i" | tr - _)
  if ! grep -q ^"${file%.*}"_LDADD Makefile.am; then
    echo "${file%.*}_LDADD = ../glad/libglad.la" >> Makefile.am
  fi
done
sed -n '/_PROGRAMS/,/^$/p' Makefile.am > /tmp/_tmpfile

for i in $(grep -il glad *.c); do
  file=$(echo "$i" | tr - _)
  n1=$(grep ${i%.*} /tmp/_tmpfile | wc -l)
  n2=$(grep ${file%.*}_LDADD Makefile.am | wc -l)
  n=$(($n1+$n2))
  if [ $n -lt 2 ] && [ $n -gt 0 ]; then
    echo $i
  fi
done

Merge request reports

Loading