# Makefile for CsvView (csvv)
#   - Invoke using "gmake" or "gmake clean" or "gmake refresh"
#   Note that the AnsiCmd link library is built in the AnsiCmd directory 
#   and imported into this application.
# 
# Mahlon R. Smith
# Tools: G++ / Gcc 15.2.1 for Linux, GNU++17 support required (Fedora 42 workstation)
# 
# 05-Apr-2026

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

# Header-file groups and Object-file groups
HFILES = CsvView.hpp CsvFile.hpp\
         AnsiCmd.hpp AnsiCmdDef.hpp gString.hpp
OFILES = CsvView.o CsvFile.o

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
#*** CZONE - Be sure debugging and API conditionals are reset. ***



csvv: $(OFILES) AnsiCmd.lib
> g++ -o csvv $(OFILES) gString.lib AnsiCmd.lib
#> g++ -o csvv $(OFILES) AnsiCmd.lib

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

CsvFile.o: CsvFile.cpp $(HFILES)
> $(COMPILE) CsvFile.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 refreshlib
> gmake --no-print-directory

#** Get a fresh copy of the AnsiCmd library and header files **
.PHONY: refreshlib
refreshlib:
> @echo '** Refreshing AnsiCmd headers and library **'
> rsync -pogtiu ../AnsiCmd.lib ./.
> rsync -pogtiu ../gString.lib ./.
> rsync -pogtiu ../AnsiCmdDef.hpp ./.
> rsync -pogtiu ../AnsiCmd.hpp ./.
> rsync -pogtiu ../TFMan.hpp ./.
> rsync -pogtiu ../gString.hpp ./.
> rsync -pogtiu ../report.pl ./.
> ./report.pl nobump

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