##
## Makefile for RfidSample4 executable for Thredbo
##

include common.mk

### Edit this section for a new project : start #####
PRJNAME					:=rfidsample4
BUILDDIR				:=
OSBUILDDIR				:=
### Edit this section for a new project : end #####
PLATFORMOUTDIR			:=$(BUILDDIR)$(GLOBALOUTDIR)
PROJOUTDIR				:=$(PLATFORMOUTDIR)/$(CONFIG)/$(PRJNAME)
OSPROJOUTDIR			:=$(OSBUILDDIR)$(GLOBALOUTDIR)$(sep)$(CONFIG)$(sep)$(PRJNAME)
OUTDIR					:=$(PLATFORMOUTDIR)/$(CONFIG)
SRCDIR					:=
INCROOTDIR				:=include
OUTPUTFILENAME			:=$(PRJNAME).elf
OUTPUTFILE				:=$(OUTDIR)/$(OUTPUTFILENAME)
PROJECTFLAGS			:=-DUNICODE -Dlinux
LIBDIR					:=   -L. \
						-Llib \
						-L$(OUTDIR)

LIBS					:=-lrfidapi32 -lpthread -lz -lxml2 -lrt -lltk -lssh2 -lssl -lcrypto -lcurl

CXXFLAGS				:=$(GLOBALCXXFLAGS)

INCDIR					:= 	-I. \
						-I$(INCROOTDIR)

	
OBJS					+= \
						$(PROJOUTDIR)/RFIDSample4.o \
						$(PROJOUTDIR)/General.o \
	
$(PROJOUTDIR)/RFIDSample4.o : RFIDSample4.cpp
	$(CXX) $(PROJECTFLAGS) $(INCDIR) RFIDSample4.cpp $(CXXFLAGS) $(TARGET) -o $(PROJOUTDIR)/RFIDSample4.o
$(PROJOUTDIR)/General.o : General.cpp
	$(CXX) $(PROJECTFLAGS) $(INCDIR) General.cpp $(CXXFLAGS) $(TARGET) -o $(PROJOUTDIR)/General.o
	
	
##
## Build Targets
##

.PHONY : prebuild 
prebuild:
ifneq ($(CONFIG),clean)
ifeq (,$(wildcard $(OSPROJOUTDIR)))
	@$(MKDIR) $(OSPROJOUTDIR)
endif
endif

$(OUTPUTFILE): $(OBJS)
	@echo "linking.."
	$(CXX) $(LIBDIR) $(TARGET) -o $(OUTPUTFILE) $(OBJS) $(LIBS) $(RPATHOPTIONS)

.PHONY : clean 
clean:
clean: prebuild
	$(RMDIR) $(PLATFORMOUTDIR)$(sep)release$(sep)$(PRJNAME)
	$(RMDIR) $(PLATFORMOUTDIR)$(sep)debug$(sep)$(PRJNAME)
	$(RM) $(PLATFORMOUTDIR)$(sep)release$(sep)$(OUTPUTFILENAME)
	$(RM) $(PLATFORMOUTDIR)$(sep)debug$(sep)$(OUTPUTFILENAME)


.PHONY : debug
debug: prebuild
debug: $(OUTPUTFILE)

.PHONY : release
release: prebuild
release: $(OUTPUTFILE)
