 # $Id$
 #
 # This file is part of the RHexLib Robot Control Software
 #
 #  The contents of this file are subject to the RHexLib Public
 # License Version 2.0 (the "License"); you may not use this file
 # except in compliance with the License. To obtain a copy of the
 # License, please contact <ulucs+rhexlib@cs.cmu.edu>.
 #
 #  Software distributed under the License is distributed on an "AS
 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 # implied. See the License for the specific language governing
 # rights and limitations under the License.
 #
 #  The Original Code is RHexLib Robot Control Software.
 #
 #  The Initial Developer of the Original Code is
 #    Carnegie Mellon University
 #
 #  Portions created by 
 #    Carnegie Mellon University
 # are Copyright (C) 2003.  All Rights Reserved.
 #
 #  Contributor(s): Uluc Saranli.
 #
 #  Alternatively, the contents of this file may be used under the
 # terms of the GNU Public license (the "GPL License"), in which
 # case the provisions of the GNU Public License are applicable
 # instead of those above.  If you wish to allow use of your version
 # of this file only under the terms of the GPL License and not to
 # allow others to use your version of this file under the RHexLib
 # Public License, indicate your decision by deleting the provisions
 # above and replace them with the notice and other provisions
 # required by the GPL License.  If you do not delete the provisions
 # above, a recipient may use your version of this file under either
 # the RHexLib Public License or the GPL License."
 #
 # Uluc Saranli <ulucs+rhexlib@cs.cmu.edu>

####################################################################

# This line defines the names of test executables. Note that we assume
# the presence of an associated .cc file for each executable.
TEST = PCMParser

# This line specifies the name of the library in which all the object
# files for the sources below will be collected into.
LIBRARY = libsimpcm.a

# This line specifies the source files that will becompiled to form
# the library
SOURCES = ContactCatcher.cc PCMInterface.cc Contact.cc DefaultContact.cc \
	OrientationContact.cc PCMBilateralSpring.cc PCMUnilateralSpring.cc \
	SpringContact.cc ConstraintContact.cc NonIsoFrictionContact.cc \
	PCMConstraint.cc PCMForce.cc PCMPlanarSpring.cc	PCMDataLogger.cc \
	KarnoppFrictionContact.cc KarnoppFrictionForce.cc \
	KarnoppFrictionContact2.cc KarnoppFrictionForce2.cc \
	AdhesionForce.cc SimpleAdhesionContact.cc

# This line specifies any additional flags that you want to feed the
# compiler. It is usually used to specify additional include
# directories through -I and additional link directories through -L
AUXFLAGS = \
	-DYY_NO_UNPUT \
	-I$(LIBUTILS_DIR)/include -L$(LIBUTILS_DIR) \
	-I$(ARACHI_DIR)/include -L$(ARACHI_DIR)/lib \
	-I$(SIMLIB_DIR)/include -L$(SIMLIB_DIR)/lib \
	-I$(LIBS_TOPDIR)/include \
	-L/usr/X11R6/lib

# This line specifies any additional libraries that you want to link
# your executable against. Note that you MUST specify the full path of
# the library in question.
AUXLIBS = \
	$(SIMLIB_DIR)/lib/libsimrti.a \
	$(SIMLIB_DIR)/lib/libsimpcm.a \
	$(SIMLIB_DIR)/lib/libsimcdl.a \
	$(SIMLIB_DIR)/lib/libsimrti.a \
	$(LIBUTILS_DIR)/libutils.a \
	$(SIMLIB_DIR)/lib/libsimcdl.a \
	$(SIMLIB_DIR)/lib/libsimpcm.a \
	$(SIMLIB_DIR)/lib/libsimrti.a \
	$(SIMLIB_DIR)/lib/libsimgraphics.a \
	$(ARACHI_DIR)/lib/libarachi.a \
	/usr/X11R6/lib/libX11.a \
	/usr/X11R6/lib/libXi.a \
	/usr/X11R6/lib/libXext.a \
	/usr/X11R6/lib/libXmu.a

LIBS = 

#################################################
# Lex and Yacc related make definitions       
#################################################

# This line defines the name of the LEX and YACC sources. Note that we 
# assume the the following two extensions: .l (for LEX) and .y (for YACC) 
LEX_SRC  = PCMParser.l
YACC_SRC = PCMParser.y
PARSER_PREFIX = PCMyy

# Parsing related derived parameters and updates 
LEX_CC   = $(LEX_SRC:.l=.lex.cc)
LEX_OBJ  = $(LEX_SRC:.l=.lex.o)
YACC_CC  = $(YACC_SRC:.y=.yacc.cc)
YACC_HH  = $(YACC_SRC:.y=.yacc.hh)
YACC_OBJ = $(YACC_SRC:.y=.yacc.o)

SOURCES += $(LEX_CC) $(YACC_CC)

#################################################
# The rest of this file should not be modified  #
#################################################

ifndef SIMLIB_DIR
$(error SIMLIB_DIR environment variable is not defined!)
endif

everything: all
clean : cleanall clean_parser

# Standard targets
include $(SIMLIB_DIR)/tools/tooldefs.mk
include $(SIMLIB_DIR)/tools/libtargets.mk

# Parsing related targets
parser: $(LEX_CC) $(YACC_CC) 

$(LEX_OBJ): $(LEX_CC) $(YACC_CC) $(YACC_HH)

$(YACC_OBJ): $(YACC_CC)

$(LEX_CC): $(LEX_SRC) $(YACC_HH)
	$(LEX) -P$(PARSER_PREFIX) -o$(LEX_CC) $(LEX_SRC)

$(YACC_CC) $(YACC_HH): $(YACC_SRC)
	$(YACC) -p $(PARSER_PREFIX) --output-file=$(YACC_CC) $(YACC_SRC)
	if test -e $(YACC_CC).h; then \
		$(MV) $(YACC_CC).h $(YACC_HH); \
	fi


clean_parser:
	@$(RM) *.yacc.cc *.yacc.hh *.lex.cc

