#
# Makefile for TINTIN++ 
# 

# It's a bad idea to edit Makefile if you don't know what you're doing.
# Makefile is automatically generated by ./configure from Makefile.in.
# If you want to change something, most likely you'll want to edit
# Makefile.in and change it there, then run ./configure.

CC = @CC@
CFLAGS = -O @DEFS@
LIBS = @LIBS@
INCS = -I.
RL = $(INCS) readline/libreadline.a -ltermcap

# I don't use pipe anymore, since it fucked over those with cc for some reason.
# PIPE = @PIPE@

# If you plan on doing debugging (with gdb), it is very helpful to turn all
# the alarms off so that you can step through the code without having to 
# jump to the ticker function.  This will also disable the internal
# tickcounter.
#F4 = -DDEBUG

# If you need to make connections through a SOCKS server, uncomment
# these 3 lines.  You also need to modify LIBDIR to point to the location
# of your SOCKS library.
#F6 = -DSOCKS
#LIBDIR = ../../../lib
#LIBS = $(LIBS) -L$(LIBDIR) -lsocks -lresolv

# BINDIR is the directory you wish tt++ to be placed if you wish to use
# make install.  
BINDIR = .

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

#########################################
# You shouldn't need to change anything #
# below this line.                      #
#########################################
# GREP-FOR-ME (this is for gripe)       #
#########################################

FFLAGS= $(F4) $(F6)
LFLAGS= 
OFILES = \
action.o      highlight.o   misc.o        rlhist.o      substitute.o	\
alias.o       history.o     net.o         rltab.o       text.o			\
antisub.o     ivars.o       new.o         rltick.o      ticks.o			\
files.o       llist.o       parse.o       rlvt100.o     utils.o			\
glob.o        log.o         path.o        scrsize.o     variables.o		\
help.o        main.o        rl.o          session.o

all: install

tt++: $(OFILES) tintin.h readline/libreadline.a Makefile
	@echo "---- Linking..."
	@$(CC) $(CFLAGS) $(FFLAGS) $(LFLAGS) -o tt $(OFILES) $(LIBS) $(RL)

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

readline/libreadline.a:
	@echo "---- Making GNU readline!"
	@echo "---- You may safely ignore any warnings it gives you (I think)."
	@echo "---- You can try editing readline/Makefile.in if you get"
	@echo "---- fatal errors, and then rerun ./configure."
	@sleep 2
	@(cd readline; make libreadline.a)
	@echo "---- Done with readline: back to your regularly scheduled make."

install: tt++
	@./install.sh $(BINDIR) $(DEFAULT_FILE_DIR) $(COMPRESSED_HELP)

# Autocompile all .c files into .o files using this rule:
.c.o:
	@echo "Compiling $<..."
	@$(CC) $(PIPE) $(CFLAGS) $(FFLAGS) $(INCS) -c $<

clean:
	@echo "Cleaning..."
	@rm -f *.o ../tt++ tt++ core readline/*.o readline/*.a

distclean: clean
	@rm -f Makefile config.status
	@(cd readline; make distclean)

# We don't use make depend anymore, since it's not needed.
# depend:
# 	makedepend -o ".o" $(INCS) $(CFILES)
# 
# # DO NOT DELETE THIS LINE -- make depend depends on it.