###############################################################################
#   This file is part of TinTin++                                             #
#                                                                             #
#   Copyright 2004-2019 Igor van den Hoven                                    #
#                                                                             #
#   TinTin++ 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 TinTin++.  If not, see https://www.gnu.org/licenses.           #
###############################################################################

DEFINES = -D_GNU_SOURCE -DHAVE_CONFIG_H

CC = gcc -g -Wall
MAKE = make

prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${DESTDIR}${exec_prefix}/bin
docdir = /usr/local/doc

#this is the standard CFLAGS options, this is what most people should use

CFLAGS += $(DEFINES) 

LDFLAGS = 

INCS = 

LIBS = -lm -lgnutls -lpcre -lutil -lpthread -lz 

# If you prefer to be able to enter ISO latin-1 characters instead
# of being able to use the meta key for special emacs-like commands
# uncomment the following line.
#F1 = -DUSE_ISO_LATIN_ONE

# If you need to make connections through a SOCKS server, uncomment
# these 2 lines.  You also need to modify LIBSOCKS to point to the location
# of your SOCKS library.
#F6 = -DSOCKS
#LIBSOCKS = -lsocks5


# DEFAULT_FILE_DIR is the path to tintin files. 
# DEFAULT_FILE_DIR = @HOME@
DEFAULT_FILE_DIR = $(HOME)

FFLAGS= $(F1) $(F6)

HEADERS = \
config.h \
dict.h \
telnet.h \
tintin.h

OFILES = \
files.o help.o trigger.o input.o main.o misc.o net.o parse.o debug.o \
update.o history.o vt102.o terminal.o text.o memory.o math.o split.o \
system.o mapper.o tables.o buffer.o event.o tokenize.o chat.o utf8.o \
banner.o list.o forkpty.o utils.o line.o data.o variable.o msdp.o \
port.o scan.o telopt_client.o screen.o cursor.o nest.o show.o mccp.o \
telopt_server.o draw.o log.o path.o session.o class.o config.o ssl.o \
regex.o substitute.o daemon.o dict.o sort.o base.o string.o edit.o \
command.o

default: all

all:	tt++


tt++:	Makefile $(OFILES)
	@echo "---- Linking..."
	$(CC) $(INCS) $(CFLAGS) $(FFLAGS) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) ${LIBSOCKS}


Makefile: Makefile.in
	@echo "You need to run ./configure first; then try make."
	@exit 1


install: tt++
	-mkdir -p $(bindir)
	cp -f tt++ $(bindir)

# Autocompile all .c files into .o files using this rule:
%.o: %.c $(HEADERS)
	$(CC) $(PIPE) $(CFLAGS) $(FFLAGS) $(INCS) -c $<


clean:
	rm -f *.o *~ ../*~ ../mods/*~ tt++*


distclean:
	rm -f *.o *~ ../*~ ../mods/*~ tt++* Makefile config.h config.status config.log
