# Makefile for idpp -  Invoke using "gmake" or "gmake clean"
#                      Invoke static build using "gmake static"
#                      Refresh NcDialog files: "gmake refreshlib"
# Mahlon R. Smith
# Tools: G++ / Gcc 4.8.0 for Linux (Fedora 20)
#        NcDialog link library (interactive mode)
#        ncursesw link library (interactive mode)
# 
# ========================================================
# NOTE: All interactive-mode code is temporarily disabled.
# ========================================================
# 
# 1) For distribution:
#    Build both 32-bit and 64-bit x86 static executables
# 2) Use the '-static' link option on the distribution build, 
#    so shared libraries will not be used.
# 
# 
# 22-Jan-2015

HFILES = idpp.hpp idpp_file.hpp GlobalDef.hpp gString.hpp 
#HFILES = idpp.hpp idpp_file.hpp GlobalDef.hpp NCurses.hpp \
#         NCursesKeyDef.hpp NcWindow.hpp NcDialog.hpp gString.hpp 
#LFILES = NcDialog.a
OFILES = idpp.o idpp_file.o gString.o

COMPILE = g++ -x c++ -std=gnu++11 -Wall -c

# [interactive mode not yet implemented]
#idpp: $(OFILES) $(LFILES)
#	g++ -o idpp $(OFILES) $(LFILES) -lncursesw

idpp: $(OFILES)
	g++ -o idpp $(OFILES)

idpp.o: idpp.cpp $(HFILES) 
	$(COMPILE) idpp.cpp

idpp_file.o: idpp_file.cpp $(HFILES) 
	$(COMPILE) idpp_file.cpp

# Until interactive mode is added, this is our access to gString class.
gString.o: gString.cpp gString.hpp
	$(COMPILE) gString.cpp


.PHONY: static
static: $(OFILES)
	g++ -o idpp_s -static $(OFILES)


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


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

