# Makefile for Taggit
#   Invoke using: "gmake"         standard build
#                 "gmake clean"   virgin build
#                 "gmake all"     'clean' + 'standard'
#                 "gmake refreshlib" check for NcDialog library update
#
# Mahlon R. Smith - The Software Samurai
# Tools: G++ / Gcc 4.8.3 (or higher) for Linux (current: g++ 10.2.1 Fedora 32)
# NOTE: This application requires tools that fully support the C++11 standard.
# 17-Sep-2020

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

# Application Files
HFILES = Taggit.hpp TagData.hpp TagMp3.hpp TagOgg.hpp TagAsf.hpp GlobalDef.hpp \
         NCurses.hpp NCursesKeyDef.hpp NcWindow.hpp NcDialog.hpp gString.hpp
OFILES = Taggit.o TagConfig.o TagDialog.o TagMenu.o TagMp3.o TagOgg.o TagAsf.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 FileMangler Application **
taggit: $(OFILES) NcDialog.a
> g++ -o taggit $(OFILES) NcDialog.a -lncursesw

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

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

TagDialog.o: TagDialog.cpp TagDialog.hpp $(HFILES)
> $(COMPILE) TagDialog.cpp

TagMenu.o: TagMenu.cpp TagDialog.hpp $(HFILES)
> $(COMPILE) TagMenu.cpp

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

TagOgg.o: TagOgg.cpp $(HFILES) CRC_Gen.hpp
> $(COMPILE) TagOgg.cpp

TagAsf.o: TagAsf.cpp $(HFILES)
> $(COMPILE) TagAsf.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 Taggit 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/NcDialog.hpp ./.


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


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


