#Changes to make compile possible on Suns and BSD boxen thanks to Thomas Strmberg


OBJS =    support.o \
	  callbacks.o \
	  new_message_window.o \
	  about_window.o \
	  main_window.o \
	  Message.o \
	  Folder.o \
	  Server.o \
          Configuration.o \
	  Althea.o \
	  ABEntry.o \
	  Addressbook.o \
	  load_config.o \
	  SendMail.o \
	  tcpUtilities.o \
	  imap.o \
          basicNetwork.o \
          SelectFolder.o \
	  print_dialog.o \
	  helpDialog.o \
	  smtp.o \
	  save_config.o \
	  configwindow.o \
	  registerwindow.o \
	  register.o \
	  crypto.o \
	  promptwindow.o \
	  progressbar.o \
	  tolower.o \
	  MIME.o

#uncomment the next two lines and comment the two after those...
#NOSSLFLAG = -DNOSSL
#SSLFLAGS =
SSLFLAGS = -lssl -lcrypto
NOSSLFLAG =


PACKAGE=\"althea\"
LOCALEDIR=\"/usr/share/locale\"


#mail poll interval in ms

MAIL_POLL_INTERVAL = 60000

CFLAGS = `gtk-config --cflags` -DPACKAGE=${PACKAGE} -DLOCALEDIR=${LOCALEDIR}
DEBUGFLAGS = -Wall -ftemplate-depth-30 -g ${NOSSLFLAG}
LDADD = `gtk-config --libs` ${LDFLAGS}

DESTDIR = /usr/local/bin
PIXDIR = /usr/local/share/althea
DOCDIR = /usr/local/doc/althea

all : ${OBJS} 
	g++ ${DEBUGFLAGS} ${SSLFLAGS} -o althea main.cpp -DPIXDIR=\"${PIXDIR}\" ${OBJS} ${CFLAGS} ${LDADD}


ABEntry.o : ABEntry.h ABEntry.cpp
	g++ ${DEBUGFLAGS} -c ABEntry.cpp

Addressbook.o : ABEntry.h Addressbook.h Addressbook.cpp
	g++ ${DEBUGFLAGS} -c Addressbook.cpp 

Althea.o : Althea.h Althea.cpp
	g++ ${DEBUGFLAGS} -c Althea.cpp ${CFLAGS}

Configuration.o : Configuration.h Configuration.cpp
	g++ ${DEBUGFLAGS} -c Configuration.cpp ${CFLAGS}

Folder.o : Server.h SelectFolder.h Folder.h Folder.cpp connection.h
	g++ ${DEBUGFLAGS} -c Folder.cpp ${CFLAGS}

Message.o : Server.h imap.h Message.h Message.cpp connection.h
	g++ ${DEBUGFLAGS} -c Message.cpp ${CFLAGS}

SelectFolder.o : imap.h basicNetwork.h tcpUtilities.h SelectFolder.h SelectFolder.cpp connection.h progressbar.h progressbar.cpp tolower.h
	g++ ${DEBUGFLAGS} -c SelectFolder.cpp ${CFLAGS}

SendMail.o : Message.h SendMail.h SendMail.cpp smtp.h support.h
	g++ ${DEBUGFLAGS} -c SendMail.cpp ${CFLAGS}

Server.o : imap.h Server.h Server.cpp connection.h
	g++ ${DEBUGFLAGS} -c Server.cpp ${CFLAGS}

about_window.o : callbacks.h support.h about_window.h about_window.cpp

	g++ ${DEBUGFLAGS} -c about_window.cpp ${CFLAGS}

configwindow.o : callbacks.h support.h configwindow.h configwindow.cpp
	g++ ${DEBUGFLAGS} -c configwindow.cpp ${CFLAGS}

registerwindow.o : callbacks.h support.h registerwindow.h registerwindow.cpp
	g++ ${DEBUGFLAGS} -c registerwindow.cpp ${CFLAGS}

basicNetwork.o : tcpUtilities.h basicNetwork.h basicNetwork.cpp connection.h
	g++ ${DEBUGFLAGS} -c basicNetwork.cpp ${CFLAGS}

tolower.o : tolower.h tolower.cpp
	g++ ${DEBUGFLAGS} -c tolower.cpp

MIME.o : MIME.h MIME.cpp
	 g++ ${DEBUGFLAGS} -c MIME.cpp

callbacks.o : main_window.h new_message_window.h Althea.h callbacks.h callbacks.cpp promptwindow.h MIME.h tolower.h support.h
	g++ ${DEBUGFLAGS} -DMAIL_POLL_INTERVAL=${MAIL_POLL_INTERVAL} -c callbacks.cpp ${CFLAGS}

imap.o : basicNetwork.h imap.h imap.cpp imapLiterals.h errors.h connection.h
	g++ ${DEBUGFLAGS} -c imap.cpp ${CFLAGS}

register.o : tcpUtilities.h register.h register.cpp connection.h
	g++ ${DEBUGFLAGS} -c register.cpp ${CFLAGS}

promptwindow.o : promptwindow.h promptwindow.cpp
	g++ ${DEBUGFLAGS} -c promptwindow.cpp ${CFLAGS}

progressbar.o : progressbar.h progressbar.cpp
	g++ ${DEBUGFLAGS} -c progressbar.cpp ${CFLAGS}

load_config.o : Althea.h Server.h Configuration.h load_config.h load_config.cpp crypto.h promptwindow.h
	g++ ${DEBUGFLAGS} -c load_config.cpp ${CFLAGS}

save_config.o : Althea.h Server.h Configuration.h save_config.h save_config.cpp crypto.h
	g++ ${DEBUGFLAGS} -c save_config.cpp ${CFLAGS}

main_window.o : Althea.h main_window.h main_window.cpp
	g++ ${DEBUGFLAGS} -c main_window.cpp ${CFLAGS}

new_message_window.o : new_message_window.h new_message_window.cpp
	g++ ${DEBUGFLAGS} -c new_message_window.cpp ${CFLAGS}

support.o : callbacks.h support.h support.cpp
	g++ ${DEBUGFLAGS} -c support.cpp ${CFLAGS}

tcpUtilities.o : tcpUtilities.h tcpUtilities.cpp connection.h
	g++ ${DEBUGFLAGS} ${NOSSLFLAG} -c tcpUtilities.cpp

crypto.o : crypto.h crypto.cpp
	g++ ${DEBUGFLAGS} -c crypto.cpp

print_dialog.o : print_dialog.cpp print_dialog.h
	g++ ${DEBUGFLAGS} -c print_dialog.cpp ${CFLAGS}

smtp.o : smtp.cpp smtp.h errors.h connection.h
	g++ ${DEBUGFLAGS} ${NOSSLFLAG} -c smtp.cpp ${CFLAGS}

helpDialog.o : helpDialog.cpp helpDialog.h
	g++ ${DEBUGFLAGS} -c helpDialog.cpp -DDOCDIR=\"${DOCDIR}\" ${CFLAGS}

${DESTDIR} :
	mkdir -p ${DESTDIR}

${DOCDIR} :
	mkdir -p ${DOCDIR}

${PIXDIR} :
	mkdir -p ${PIXDIR}

install : althea pixmaps Documentation ${DESTDIR}  ${PIXDIR}
	cp ./althea ${DESTDIR}
	cp -r Documentation/* ${DOCDIR}
	cp -r pixmaps/* ${PIXDIR}

uninstall: 
	rm -f ${DESTDIR}/althea
	rm -rf ${DOCDIR}/*
	rmdir ${DOCDIR}
	rm -rf ${PIXDIR}/*
	rmdir ${PIXDIR}

clean :
	rm -f althea
	rm -f *.o
	rm -f *~
