# Makefile for BubbleSort test application using the beta release of a 
# gString class.
#   Invoke using "gmake"          (rebuild)
#                "gmake all"      (rebuild all)
#                "gmake clean"    (remove object files)
# Mahlon R. Smith, The Software Samurai
# Tools: GNU G++ / Gcc 13.3.1 or greater
# Note: The build requires support for the C++13 standard.
# 
# 18-Feb-2025


.RECIPEPREFIX = >

OFILES  = BubbleSort.o BubbleSortParse.o gString.o
HFILES  = BubbleSort.hpp gString.hpp

#COMPILE = g++ -x c++ -std=gnu++17 -Wall -c
# Special compile: stop-on-error
COMPILE = g++ -x c++ -std=gnu++17 -Wall -fmax-errors=1 -c

#** Build the test application **
bubsort: $(OFILES)
> g++ -o bubsort $(OFILES)

BubbleSort.o: BubbleSort.cpp $(HFILES)
> $(COMPILE) BubbleSort.cpp

BubbleSortParse.o: BubbleSortParse.cpp $(HFILES)
> $(COMPILE) BubbleSortParse.cpp

gString.o: gString.cpp gString.hpp
> $(COMPILE) gString.cpp

#** 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

#** Remove old object files and the executable for a clean build **
.PHONY: clean
clean:
> rm --force $(OFILES) bubsort
