#-----------------------------------------------
#
# Makefile for the TinyTrak3 GPL program, a program which will
# allow the user to modify the behavior of the Byonics TinyTrak3
# APRS position encoder.
#
# Copyright 2013,2014 Andy Stewart
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, see
# <http://www.gnu.org/licenses/>.
#
# Please report all bugs and problems to the author:
#
# Andy Stewart (KB1OIQ)
# kb1oiq@arrl.net
# http://home.comcast.net/~andystewart
#

# The user must decide where to install the program.
# The binary executable will be installed in the
# BINDIR directory.
#
#-----------------------------------------------

#BINDIR = /usr/bin
BINDIR = /usr/local/bin

# Set the FLTK_INC variable to be the location of the 
# include files for FLTK.

FLTK_INC = /usr/include/FL
#FLTK_INC = /usr/local/include/FL

# Set the SERIAL_INC variable to be the location of the 
# include files for Serial.

SERIAL_INC = /usr/include/libserial
#SERIAL_INC = /usr/local/include

# tt3_gpl.{cxx,h} are machine generated by Fluid (MACH_{SRCS,HDRS})
# tt3_gpl_i.{cxx.h} are hand coded (HAND_{SRCS,HDRS})

MACH_SRCS = tt3_gpl.cxx
HAND_SRCS = tt3_gpl_i.cxx
MACH_HDRS = tt3_gpl.h
HAND_HDRS = tt3_gpl_i.h

SRCS = $(MACH_SRCS) $(HAND_SRCS)
HDRS = $(MACH_HDRS) $(HAND_HDRS)

EXE = tt3_gpl

CC = g++

#DEBUG = -g
DEBUG = 

CFLAGS = -Wl,--no-as-needed -ldl

all:	
	@if [ ! -f $(SERIAL_INC)/SerialPort.h -o  ! -f $(FLTK_INC)/Fl.H ]; \
	then echo "ERROR: Cannot find all required development files!"; \
	else $(MAKE) $(EXE); \
	fi

clean:
	rm -f $(MACH_SRCS) $(MACH_HDRS) $(EXE) *~ *.o

$(EXE): $(SRCS)
	$(CC) $(DEBUG) $(CFLAGS) -o $(EXE) $(SRCS) -I. -I$(SERIAL_INC) -lfltk -lfltk_images -lserial

tt3_gpl.cxx tt3_gpl.h: tt3_gpl.fl
	fluid -c tt3_gpl.fl

install:
	cp $(EXE) $(BINDIR)

uninstall:
	rm $(BINDIR)/$(EXE)

help:
	@echo ""
	@echo "Targets in this Makefile:"
	@echo ""
	@echo "all        create the program executable (the default)"
	@echo "clean      clean up (delete) machine generated files"
	@echo "help       print this text"
	@echo "install    copy files to their destinations"
	@echo "uninstall  remove installed files"
	@echo ""
