# Makefile for Salmon, a test of the 'exec' functions
#           -  "gmake"              build the Salmon application
#           -  "gmake clean"        delete the object files and executables
#           -  "gmake child"        build the childApp application
# 
# 
# Mahlon R. Smith, The Software Samurai
# Tools: G++ / Gcc 15.2.1 for Linux (Fedora 43)
# 17-May-2026

# This variable is defined for technical reasons
# (see 'make' documentation for more information)
.RECIPEPREFIX = >

# Files for Salmon Application
HFILES   = GlobalDef.hpp
HFILES_S = Salmon.hpp gString.hpp
OFILES_S = Salmon.o gString.o
OFILES_C = childApp.o 

# Standard compile
COMPILE = g++ -x c++ -std=gnu++17 -Wall -c


#** Build the Salmon Application **
salmon: $(OFILES_S)
> g++ -o salmon $(OFILES_S)

Salmon.o: Salmon.cpp $(HFILES) $(HFILES_S)
> $(COMPILE) Salmon.cpp

#** Build the childApp Application **
.PHONY: child
child:
> $(COMPILE) childApp.cpp 
> g++ -o childApp $(OFILES_C)
#> g++ -o childApp $(OFILES_C)

#** Build All **
# NOTE: The '-i' (ignore) option is used here in case none of the targets to 
#       be removed by "clean" exist. The '-s' (silent) option is also used here.
.PHONY: all
all:
> gmake -si clean
> gmake --no-print-directory child
> gmake --no-print-directory


#** Remove old object files and the executables for a clean build **
.PHONY: clean
clean:
> rm --force $(OFILES_S) $(OFILES_C) salmon childApp

