#/*****************************************************************************/
#/*                                                                           */
#/*  Compiler - a Parser Generator Program, Version 2.0                       */
#/*  Copyright (c) 2000, 2003  Charles M. Fayle  All Rights Reserved.         */
#/*                                                                           */
#/*  This software is distributed under the terms of the GNU General Public   */
#/*  License as specified in the file gpl.txt included with the distribution. */
#/*                                                                           */
#/*****************************************************************************/
#//
#//  $Id$
#//

SHELL	= /bin/sh

MAKECONFIG_CXX				= g++
MAKECONFIG_CC				= gcc

MAKECONFIG_CXXFLAGS_X11		= -I$(X11DIR)/include
MAKECONFIG_CXXFLAGS_QT		= -I$(QTDIR)/include/Qt  -I$(QTDIR)/include/QtCore  -I$(QTDIR)/include/QtGui  -I$(QTDIR)/include/Qt3Support

MAKECONFIG_LFLAGS_X11		= -L$(X11DIR)/lib
MAKECONFIG_LIBS_X11			= -lXext -lX11 -lm

MAKECONFIG_LFLAGS_QT		= -L$(QTDIR)/lib
MAKECONFIG_LIBS_QT			= -lQtCore -lQtGui -lQt3Support

MAKECONFIG_LINK				= g++
MAKECONFIG_LFLAGS			= -Wl,-rpath-link,$(X11DIR)/lib
MAKECONFIG_LIBS				= 

MAKECONFIG_MOC				= $(QTDIR)/bin/moc

MAKECONFIG_CXXFLAGS			= -pipe -O3 -Wno-deprecated -DQT_THREAD_SUPPORT -DQT3_SUPPORT
MAKECONFIG_CFLAGS			= -pipe -O3 -Wno-deprecated -DQT_THREAD_SUPPORT -DQT3_SUPPORT

CXX			=	$(MAKECONFIG_CXX)
CXXFLAGS	=	$(MAKECONFIG_CXXFLAGS_QT)	\
				$(MAKECONFIG_CXXFLAGS)
CC			=	$(MAKECONFIG_CC)
CFLAGS		=	$(MAKECONFIG_CFLAGS)
INCPATH 	=	
LFLAGS		=	$(MAKECONFIG_LFLAGS_QT)		\
		  		$(MAKECONFIG_LFLAGS_X11)	\
		  		$(MAKECONFIG_LFLAGS)
LIBS		=	$(MAKECONFIG_LIBS_QT)		\
				$(MAKECONFIG_LIBS_X11)		\
				$(MAKECONFIG_LIBS)
MOC			=	$(MAKECONFIG_MOC)

.SUFFIXES: .cpp .cxx .cc .C .c

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cxx.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cc.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.C.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.c.o:
	$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

VPATH		= ..:.
DESTDIR 	= ./
TARGET1		= compiler
TARGET2		= cpgcmd

HEADERS =							\
	tvaluelist.h					\
	idGenerator.h					\
	idMap.h							\
	stringToken.h					\
	filePath.h						\
	unionScalar.h					\
	stackTypes.h					\
	stackElement.h					\
	lexicalDriver.h					\
	optionLexicalDriver.h			\
	optionRegexpData.h				\
	parserDriver.h					\
	optionParserDriver.h			\
	optionParserData.h				\
	applicationMainWindow.h			\
	applicationTypes.h				\
	menuControl.h					\
	menuNodeData.h					\
	mainViewMenu.h					\
	interfaceControl.h				\
	defaultInterface.h				\
	viewControl.h					\
	defaultView.h					\
	connectionView.h				\
	undefinedView.h					\
	roleData.h						\
	replaceNode.h					\
	functorTemplates.h				\
	optionData.h					\
	fontchangeControl.h				\
	optionEditView.h				\
	optionDialog.h					\
	connectionInterface.h			\
	helpViewer.h					\
	tlist.h							\
	trelation.h						\
	memoryAllocator.h				\
	automaton.h						\
	parse.h							\
	escapeSingleCharData.h			\
	escapeParserData.h				\
	escapeParserDriver.h			\
	regexpSingleCharData.h			\
	regexpParserData.h				\
	regexpParserDriver.h			\
	compilerData.h					\
	compilerCalculate.h				\
	compilerInterface.h				\
	grammarDialog.h					\
	parserDialog.h					\
	sortItem.h						\
	terminalView.h					\
	errorTokenView.h				\
	nonterminalView.h				\
	implicitView.h					\
	precedenceView.h				\
	ruleView.h						\
	conflictEntryView.h				\
	conflictStatusView.h			\
	conflictActionView.h			\
	conflictCodeView.h				\
	errorSelectView.h				\
	errorCodeView.h					\
	terminalSelectView.h			\
	terminalCodeView.h				\
	ruleSelectView.h				\
	ruleCodeView.h					\
	classCodeView.h					\
	machineView.h					\
	sourceView.h					\
	simulateControlView.h			\
	simulateInputView.h				\
	simulateTreeView.h

SOURCES1 =						\
	idGenerator.cpp				\
	idMap.cpp					\
	stringToken.cpp				\
	filePath.cpp				\
	lexicalDriver.cpp			\
	optionLexicalDriver.cpp		\
	parserDriver.cpp			\
	optionParserDriver.cpp		\
	applicationMainWindow.cpp	\
	menuNodeData.cpp			\
	mainViewMenu.cpp			\
	interfaceControl.cpp		\
	defaultInterface.cpp		\
	viewControl.cpp				\
	defaultView.cpp				\
	connectionView.cpp			\
	undefinedView.cpp			\
	optionData.cpp				\
	fontchangeControl.cpp		\
	optionEditView.cpp			\
	optionDialog.cpp			\
	connectionInterface.cpp		\
	helpViewer.cpp				\
	main.cpp					\
	memoryAllocator.cpp			\
	trelation.cpp				\
	automaton.cpp				\
	parse.cpp					\
	escapeParserDriver.cpp		\
	regexpParserDriver.cpp		\
	compilerData.cpp			\
	compilerCalculate.cpp		\
	generateCode.cpp			\
	baseClassCode.cpp			\
	compilerInterface.cpp		\
	compilerOptionData.cpp		\
	grammarDialog.cpp			\
	parserDialog.cpp			\
	sortItem.cpp				\
	terminalView.cpp			\
	errorTokenView.cpp			\
	nonterminalView.cpp			\
	implicitView.cpp			\
	precedenceView.cpp			\
	ruleView.cpp				\
	conflictEntryView.cpp		\
	conflictStatusView.cpp		\
	conflictActionView.cpp		\
	conflictCodeView.cpp		\
	errorSelectView.cpp			\
	errorCodeView.cpp			\
	terminalSelectView.cpp		\
	terminalCodeView.cpp		\
	ruleSelectView.cpp			\
	ruleCodeView.cpp			\
	classCodeView.cpp			\
	machineView.cpp				\
	sourceView.cpp				\
	simulateControlView.cpp		\
	simulateInputView.cpp		\
	simulateTreeView.cpp		\
	simulateXpmImageData.cpp

OBJECTS1 = $(SOURCES1:.cpp=.o)

SRCMOC1	=							\
	moc_applicationMainWindow.cpp	\
	moc_interfaceControl.cpp		\
	moc_defaultInterface.cpp		\
	moc_viewControl.cpp				\
	moc_defaultView.cpp				\
	moc_undefinedView.cpp			\
	moc_fontchangeControl.cpp		\
	moc_optionEditView.cpp			\
	moc_optionDialog.cpp			\
	moc_connectionView.cpp			\
	moc_helpViewer.cpp				\
	moc_compilerInterface.cpp		\
	moc_grammarDialog.cpp			\
	moc_parserDialog.cpp			\
	moc_terminalView.cpp			\
	moc_errorTokenView.cpp			\
	moc_nonterminalView.cpp			\
	moc_implicitView.cpp			\
	moc_precedenceView.cpp			\
	moc_ruleView.cpp				\
	moc_conflictEntryView.cpp		\
	moc_conflictStatusView.cpp		\
	moc_conflictActionView.cpp		\
	moc_conflictCodeView.cpp		\
	moc_errorSelectView.cpp			\
	moc_errorCodeView.cpp			\
	moc_terminalSelectView.cpp		\
	moc_terminalCodeView.cpp		\
	moc_ruleSelectView.cpp			\
	moc_ruleCodeView.cpp			\
	moc_classCodeView.cpp			\
	moc_machineView.cpp				\
	moc_sourceView.cpp				\
	moc_simulateControlView.cpp		\
	moc_simulateInputView.cpp		\
	moc_simulateTreeView.cpp

OBJMOC1 = $(SRCMOC1:.cpp=.o)

SOURCES2 =						\
	maincmd.cpp					\
	stringToken.cpp				\
	filePath.cpp				\
	lexicalDriver.cpp			\
	parserDriver.cpp			\
	memoryAllocator.cpp			\
	trelation.cpp				\
	automaton.cpp				\
	parse.cpp					\
	escapeParserDriver.cpp		\
	regexpParserDriver.cpp		\
	compilerData.cpp			\
	compilerCalculate.cpp		\
	generateCode.cpp			\
	baseClassCode.cpp

OBJECTS2 = $(SOURCES2:.cpp=.o)

all: $(DESTDIR)$(TARGET1) $(DESTDIR)$(TARGET2)

$(DESTDIR)$(TARGET1): $(OBJECTS1) $(OBJMOC1) 
	$(MAKECONFIG_LINK) $(LFLAGS) -o $(TARGET1) $(OBJECTS1) $(OBJMOC1) $(LIBS)

$(DESTDIR)$(TARGET2): $(OBJECTS2)
	$(MAKECONFIG_LINK) -o $(TARGET2) $(OBJECTS2)

moc: $(SRCMOC1)

moc_%.cpp: %.h
	$(MOC) $< -o $@

%.d: %.cpp
	$(SHELL) -ec "$(CXX) -MM $(CXXFLAGS) $(INCPATH) $< | sed 's/$*\\.o[ :]*/$@ &/g' > $@"

objects: $(OBJECTS1) $(OBJMOC1)

clean:
	-rm -f $(OBJECTS1) $(OBJMOC1) $(SRCMOC1) maincmd.o
	-rm -f *.d
	-rm -f core

ifneq ($(MAKECMDGOALS),clean)

-include $(SOURCES1:.cpp=.d)
-include $(SRCMOC1:.cpp=.d)
-include maincmd.d

endif
