# Makefile for Exercalc  utility
#   Invoke using "gmake"         (build)
#         or     "gmake clean"   (remove old intermediate files)
#         or     "gmake all"     (both 'clean' and 'build)
# Mahlon R. Smith, The Software Samurai
# Tools: See information on development tools in: "Exercalc.cpp"
# 
# Note: The libraries and applications compiled with this makefile use 
#       functionality defined by the C++11 standard. As such you will need to 
#       use the -std=gnu++11 compile-time switch which became fully supported 
#       in GCC 4.7.1 and higher.
#       C++11 support is required for:
#        1) instantiating arrays of initialized class instances
#        2) scoped enums.
#        3) various additional functionality
# 11-Apr-2021

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

OFILES = Exercalc.o EcConfig.o EcLog.o Chart.o
HFILES = Exercalc.hpp EcConfig.hpp EcLang.hpp \
         GlobalDef.hpp NCurses.hpp NCursesKeyDef.hpp NcWindow.hpp NcDialog.hpp \
         gString.hpp Chart.hpp

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 application **
ecalc: $(OFILES) NcDialog.a
> g++ -o ecalc $(OFILES) NcDialog.a -lncursesw

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

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

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

Chart.o: Chart.cpp $(HFILES) 
> $(COMPILE) Chart.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 Exercalc copy of NcDialog headers and library **'
> rsync -pogtiu ../NcDialog/Dialog1/NcDialog.a ./.
> rsync -pogtiu ../NcDialog/Dialog1/GlobalDef.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/NCurses.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/NCursesKeyDef.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/NcWindow.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/gString.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/WaylandCB.hpp ./.
#> rsync -pogtiu ../NcDialog/Dialog1/Chart.hpp ./.
> rsync -pogtiu ../NcDialog/Dialog1/NcDialog.hpp ./.
                

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


#** Remove object files and binary **
.PHONY: clean
clean:
> rm -f $(OFILES) ecalc 1>/dev/null 2>/dev/null

