#
# Copyright (C) 2004 Stefan Seefeld
# All rights reserved.
# Licensed to the public under the terms of the GNU LGPL (>= 2),
# see the file COPYING for details.
#

SHELL	:= /bin/sh

srcdir	:= @srcdir@

PYTHON	:= @PYTHON@

CC	:= @CC@
CXX	:= @CXX@
LDSHARED:= @LDSHARED@
MAKEDEP	:= $(CXX) -M
CPPFLAGS:= @CPPFLAGS@ @BOOST_CPPFLAGS@ -I .
CPPFLAGS+= -I $(srcdir)
CPPFLAGS+= @SYN_CPP@
CFLAGS	:= @CFLAGS@
CXXFLAGS:= @CXXFLAGS@
LDFLAGS	:= @LDFLAGS@ @BOOST_LDFLAGS@
LIBS	:= @BOOST_LIBS@ @SYN_LIBS@ @LIBS@
LIBRARY_EXT := @LIBEXT@

SRC	:= ParserImpl.cc
OBJ	:= $(patsubst %.cc, %.o, $(SRC))
DEP	:= $(patsubst %.cc, %.d, $(SRC))

TARGET	:= ParserImpl$(LIBRARY_EXT)

vpath %.hh $(srcdir)
vpath %.cc $(srcdir)

all: $(TARGET)

%.d: %.cc
	@echo generating dependencies for $(<F)
	$(SHELL) -ec '$(MAKEDEP) $(CPPFLAGS) $< | sed "s,$(*F)\\.o[ :]*,$*\\.d $*\\.o : ,g" > $@'

%.o : %.cc
	@echo compiling $(@F)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<

Makefile: $(srcdir)/Makefile.in
	$(SHELL) -ec './config.status --file Makefile'

$(TARGET): $(OBJ)
	@echo linking $(@F)
	$(LDSHARED) $(LDFLAGS) -o $@ $^ $(LIBS)

clean :
	rm -rf *~ $(OBJ) $(DEP) $(TARGET) *.pyc *.pyo

ifeq (,$(filter $(MAKECMDGOALS), depend clean distclean))
-include $(DEP)
endif
