#
# Makefile --
#
#      This file contains the Makefile of the PAPyRUS application.
#
# Copyright (C) 1996  Carlos Nunes - loscar@mime.univ-paris8.fr
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


CC  = gcc
CCC = g++
CXX = g++

#RES_FILE = Papyrus.ad.fr     # French version of the App defaults
RES_FILE = Papyrus.ad.eng     # English version of the App defaults

TCL = -ltcl7.5
TCL_INCLUDE = /usr/local/include
TCL_LIB = /usr/local/lib

X11 = -lX11
X11_INCLUDE = /usr/X11R6/include
X11_LIB = /usr/X11R6/lib

XPM = -lXpm
XPM_INCLUDE = /usr/X11R6/include
XPM_LIB = /usr/X11R6/lib

XM = -lXm
XM_INCLUDE = /usr/X11R6/include
XM_LIB = /usr/X11R6/lib

FLAGS = -m486 -O2 -Wall -ansi -pedantic
#FLAGS = -g -Wall -ansi -pedantic


#########################################################################################
#
# You may not have to change anything after this message.
#
#########################################################################################


CXXDEFINES =  -DHAVE_GUI -I$(TCL_INCLUDE) -I$(XPM_INCLUDE)	\
	      -I$(XM_INCLUDE) -I$(X11_INCLUDE)
CDEFINES   =  -DHAVE_GUI -I$(TCL_INCLUDE) -I$(XPM_INCLUDE)	\
	      -I$(XM_INCLUDE) -I$(X11_INCLUDE)

CXXFLAGS = $(FLAGS) $(CXXDEFINES)
CFLAGS   = $(FLAGS) $(CDEFINES)

LIBS =  -L$(XM_LIB) $(XM) -L$(X11_LIB) -L$(X11_LIB) 		\
	-lXmu -lXt -lSM -lICE -lXExExt -lXext 			\
	-L$(XPM_LIB) $(XPM) -lX11 -L$(TCL_LIB) $(TCL) -lm


SRCS =	gui/callbacks.c      	gui/menus.c		gui/widgets.c			\
        gui/modify_text.c    	gui/mainWin.c   	gui/dialogs.c			\
	gui/actions.c		gui/init.c		kernel/isfuncs.cc		\
	kernel/attributes.cc	kernel/main.cc		kernel/papyrus_output.cc	\
	kernel/container.cc	kernel/ps_output.cc	kernel/ascii_output.cc		\
	kernel/frame.cc		kernel/cursor.cc	kernel/display.cc		\
	kernel/events.cc   	kernel/page.cc  	kernel/paragraph.cc   		\
	kernel/document.cc   	kernel/line.cc     	kernel/word.cc			\
	kernel/wordSegment.cc	kernel/thePosition.cc	kernel/image.cc			\
	kernel/util.cc									\
	kernel/FontManager/fontManager.cc       	kernel/FontManager/fontFamily.cc\
	kernel/StyleManager/styleManager.cc		kernel/StyleManager/styleItem.cc\
	tcl/tclMain.c		tcl/tclInit.cc		tcl/tclGet.cc			\
	tcl/commandsAM.cc	tcl/commandsNZ.cc					\
	misc/shortcuts.c	misc/parseAFM.c

OBJS =	gui/callbacks.o      	gui/menus.o		gui/widgets.o			\
        gui/modify_text.o    	gui/mainWin.o   	gui/dialogs.o			\
	gui/actions.o		gui/init.o		kernel/isfuncs.o		\
	kernel/attributes.o	kernel/main.o		kernel/papyrus_output.o		\
	kernel/container.o	kernel/ps_output.o	kernel/ascii_output.o		\
	kernel/frame.o		kernel/cursor.o		kernel/display.o		\
	kernel/events.o   	kernel/page.o  		kernel/paragraph.o   		\
	kernel/document.o   	kernel/line.o     	kernel/word.o			\
	kernel/wordSegment.o	kernel/thePosition.o	kernel/image.o			\
	kernel/util.o									\
	kernel/FontManager/fontManager.o 	      	kernel/FontManager/fontFamily.o \
	kernel/StyleManager/styleManager.o		kernel/StyleManager/styleItem.o \
	tcl/tclMain.o		tcl/tclInit.o		tcl/tclGet.o			\
	tcl/commandsAM.o	tcl/commandsNZ.o					\
	misc/shortcuts.o	misc/parseAFM.o

INCS =  gui/actions.h		gui/callbacks.h		gui/dialogs.h			\
	gui/globals.h		gui/mainWin.h		gui/menus.h			\
	gui/widgets.h		gui/init.h		gui/modify_text.h		\
	kernel/container.h	kernel/events.h		kernel/marker.h			\
	kernel/line.h		kernel/attributes.h					\
	kernel/cursor.h		kernel/frame.h		kernel/page.h			\
	kernel/word.h		kernel/display.h	kernel/papyrus.h		\
	kernel/globals.h	kernel/paragraph.h	kernel/margin.h			\
	kernel/wordSegment.h	kernel/shape.h		kernel/document.h		\
	kernel/isfuncs.h	kernel/thePosition.h	kernel/image.h			\
	kernel/util.h		kernel/output.h		kernel/FontManager/fontFamily.h	\
	kernel/FontManager/fontManager.h		kernel/StyleManager/styleItem.h	\
	kernel/StyleManager/styleManager.h						\
	tcl/mytcl.h		tcl/tclGet.h		tcl/commands.h			\
	misc/shortcuts.h	misc/parseAFM.h


all:	bin/papyrus


bin/papyrus: $(OBJS)
	$(CC) -o $@ $+ $(LIBS)

clean:
	\rm -f $(OBJS) *~ *.bak *.BAK bin/papyrus *.ps


install: uninstall
	@mkdir /usr/local/lib/Papyrus
	@chmod 755 /usr/local/lib/Papyrus
	install -m 0644 lib/* /usr/local/lib/Papyrus
	install -m 0644 scripts/* /usr/local/lib/Papyrus
	install -m 0666 scripts/tclIndex /usr/local/lib/Papyrus
	install -s -m 0755 bin/papyrus /usr/local/bin
	install -m 0444 bin/$(RES_FILE) /usr/X11R6/lib/X11/app-defaults/Papyrus

uninstall:
	@\rm -rf /usr/local/lib/Papyrus
	@rm -f /usr/local/bin/papyrus


depend:	
	cp Makefile Makefile.bak
	sed '/^#----- dependences -----/q' Makefile.bak >Makefile
	echo >>Makefile
	$(CXX) $(CXXFLAGS) -M $(SRCS) >>Makefile


#----- dependences -----

