# Makefile for AcEdit -  Invoke using:
#  "gmake"            (rebuild)
#  "gmake all"        (rebuild all)
#  "gmake clean"      (remove object files and executable)
#  "gmake refreshlib" (synchronize libraries and header files from parent directory)
#   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 20251211 for Linux (Fedora 42 workstation)
# 
# 29-Dec-2025

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

# Header-file groups and Object-file groups
HFILES = AcEdit.hpp AcEditFile.hpp \
         AnsiCmd.hpp AnsiCmdDef.hpp AnsiCmdWin.hpp \
         WaylandCB.hpp TFMan.hpp gString.hpp
OFILES = AcEdit.o AcEditMenu.o AcEditFile.o AcEditDlg.o AcEditCfg.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


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

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

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

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

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

AcEditCfg.o: AcEditCfg.cpp $(HFILES)
> $(COMPILE) AcEditCfg.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 ../AnsiCmdWin.hpp ./.
> rsync -pogtiu ../AnsiCmdDlg.hpp ./.
> rsync -pogtiu ../WaylandCB.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) ace
