# Makefile for FirstProg 
#   Invoke using: "gmake"         standard build
#                 "gmake clean"   virgin build
#                 "gmake refreshlib" check for NcDialog library update
#                 "gmake all"     'clean' + 'refreshlib' + 'standard'
# 13-Sep-2026

# This variable is defined for technical reasons,
# i.e. to avoid Tab characters in source files.
# (see 'make' documentation for more information)
.RECIPEPREFIX = >

HFILES = GlobalDef.hpp NCurses.hpp NCursesKeyDef.hpp NcWindow.hpp NcDialog.hpp \
         gString.hpp WaylandCB.hpp
LFILES = NcDialog.a
OFILES = FirstProg.o 

# Definition for compiler invocation
COMPILE = g++ -x c++ -std=gnu++17 -Wall -c

# Link the main source file to create an executable binary
FirstProg: $(OFILES) $(HFILES) $(LFILES)
> g++ -o FirstProg FirstProg.o NcDialog.a -lncursesw

# Comile the main source file
FirstProg.o: FirstProg.cpp $(HFILES)
> $(COMPILE) FirstProg.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

#** Refresh the NcDialog family of header files and the link library **
.PHONY: refreshlib
refreshlib:
> @echo '** Refreshing FirstProg copy of NcDialog headers and library **'
> rsync -pogtiu ../Dialog1/NcDialog.a ./.
> rsync -pogtiu ../Dialog1/GlobalDef.hpp ./.
> rsync -pogtiu ../Dialog1/NCurses.hpp ./.
> rsync -pogtiu ../Dialog1/NCursesKeyDef.hpp ./.
> rsync -pogtiu ../Dialog1/NcWindow.hpp ./.
> rsync -pogtiu ../Dialog1/NcDialog.hpp ./.
> rsync -pogtiu ../Dialog1/gString.hpp ./.
> rsync -pogtiu ../Dialog1/WaylandCB.hpp ./.


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


