# Makefile for TermSize 
#   Invoke using: "gmake"         standard build
#                 "gmake clean"   virgin build
#                 "gmake refreshlib" check for NcDialog library update
#                 "gmake all"     'clean' + 'refreshlib' + 'standard'
#
# Mahlon R. Smith - The Software Samurai
# Tools: G++ / Gcc 11.2.1 for Linux (Fedora 34) (libstdC++.so.6.0.29)
# NOTE: This application requires tools that fully support the C++11 standard.
# 18-Oct-2021

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

# Source header files for the application
TS_HFILES = NCurses.hpp NCursesKeyDef.hpp gString.hpp
TS_OFILES = TermSize.o

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


#** Build the TermSize Application **
termsize: $(TS_OFILES) NcDialog.a
> g++ -o termsize $(TS_OFILES) NcDialog.a -lncursesw

TermSize.o: TermSize.cpp $(TS_HFILES)
> $(COMPILE) TermSize.cpp


# Refresh the NcDialog family of header files and the link library
# from the source directory. Note that the path to the NcDialog/Dialog1 directory 
# may be different on your system, depending on where you installed it.
.PHONY: refreshlib
refreshlib:
> @echo '** Refreshing TermSize copy of NcDialog headers and library **'
> rsync -pogtiu ../NcDialog/Dialog1/NcDialog.a ./.
> rsync -pogtiu ../NcDialog/Dialog1/NCurses.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/NCursesKeyDef.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/gString.hpp ./.


#** Build All **
.PHONY: all
all:
> gmake clean
> gmake refreshlib
> gmake


.PHONY: clean
clean:
> rm -f termsize $(TS_OFILES) 1>/dev/null 2>/dev/null


