I'm making images. My steps are:
- create PGM files using a C program
 - convert/resize PGM to PNG using Image Magic
 - remove (big) PGM files
 
To do it I use Make and a Bash script.
The Makefile is very simple:
all: 
    chmod +x d.sh
    ./d.sh
Most things are done by the script:
#!/bin/bash 
 
# script file for BASH 
# which bash
# save this file as d.sh
# chmod +x d.sh
# ./d.sh
# checked in https://www.shellcheck.net/
printf "make pgm files \n"
 gcc f.c -lm -Wall -march=native -fopenmp
if [ $? -ne 0 ]
then
    echo ERROR: compilation failed !!!!!!
    exit 1
fi
export  OMP_DISPLAY_ENV="TRUE"
printf "display OMP info \n"
printf "run the compiled program\n"
time ./a.out > a.txt
export  OMP_DISPLAY_ENV="FALSE"
printf "change Image Magic settings\n"
export MAGICK_WIDTH_LIMIT=100MP
export MAGICK_HEIGHT_LIMIT=100MP
printf "convert all pgm files to png using Image Magic v 6 convert \n"
# for all pgm files in this directory
for file in *.pgm ; do
  # b is name of file without extension
  b=$(basename "$file" .pgm)
  # convert  using ImageMagic
  convert "${b}".pgm -resize 2000x2000 "${b}".png
  echo "$file"
done
printf "delete all pgm files \n"
rm ./*.pgm
 
echo OK
printf "info about software \n"
bash --version
make -v
gcc --version
convert -version
convert -list resource
# end
I do not know Make well so I used Bash which I know better. It works well for me, but I read about Make and CMake. Should I change it?
naive explanation:
- My program is small (one file).
 - The dependency tree is very simple (2 libraries which I do not have to recompile).
 - Compilation time is very short, so I do not need a staged compilation
 - Usually, I create a directory with a descriptive name for the program so the files (now 3) do not need descriptive names and I use short names with an extension that explains the function of the file.
 
I like that I can run all the tasks with one command (with the easy name make) and go away.