#############################################################################
# Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997.
# Unpublished work.  All Rights Reserved.
#
# The software contained on this media is the property of the
# DSTC Pty Ltd.  Use of this software is strictly in accordance
# with the license agreement in the accompanying LICENSE.DOC file.
# If your distribution of this software does not contain a
# LICENSE.DOC file then you have no rights to use this software
# in any manner and should contact DSTC at the address below
# to determine an appropriate licensing arrangement.
# 
#      DSTC Pty Ltd
#      Level 7, Gehrmann Labs
#      University of Queensland
#      St Lucia, 4072
#      Australia
#      Tel: +61 7 3365 4310
#      Fax: +61 7 3365 4311
#      Email: enquiries@dstc.edu.au
# 
# This software is being provided "AS IS" without warranty of
# any kind.  In no event shall DSTC Pty Ltd be liable for
# damage of any kind arising out of or in connection with
# the use or performance of this software.
#
# Project:  Fnorb
# File:     $Source: /cvsroot/fnorb/fnorb/src/Makefile,v $
#
#############################################################################
#-- configure project build stuff
#############################################################################

.PHONY: config depend build unbuild undepend unconfig

#-- ensure files exist
DUMMY1:=$(shell touch depend.inc)
DUMMY2:=$(shell touch Makefile.conf)

#-- import declarations
include $(DSTCDIR)/install/Makefile.base
include Makefile.conf

#-- pointer to source
VPATH=../../src

#-- local command overrides
CPPFLAGS := $(CPPFLAGS) $(THREAD_CPPFLAGS) -D_SHARED_LIBRARIES \
	-I. -I../../src \
	-I$(PYTHON_INCL_DIR) -I$(PYTHON_CONFIG_DIR) \
	-I$(DSTCDIR)/units/util/python1.5/Python-1.5/Include

CFLAGS :=  $(OPT) $(CFLAGS) $(THREAD_CFLAGS)
LDFLAGS := $(LDFLAGS)
LDLIBS := $(LDLIBS) -lObjects -L$(PYTHON_LIB_DIR) $(THREAD_LDLIBS) 

SRCS = bisonmodule.c
OBJS = $(SRCS:.c=.o)
SHLIBS = bisonmodule.$(LDEXT)

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

config:
	@($(ECHO) "Configure $(PACKAGE) for $(ARCHITECTURE)" ; \
	$(RM) Makefile.conf.in; \
	ln -s ../../src/Makefile.conf.in; \
	cd ../../install; \
	./configure)

depend:
	@(cd ../../src; \
	$(DEPEND) $(CPPFLAGS) $(SRCS) > ../$(ARCHITECTURE)/obj/depend.inc)

build: bisonmodule.$(LDEXT) grammar.c lexer.c
	@($(ECHO) "Build $(PACKAGE) for $(ARCHITECTURE)"; \
	$(MV) bisonmodule.$(LDEXT) ../lib)

unbuild:
	@($(ECHO) "UnBuild $(PACKAGE) for $(ARCHITECTURE)"; \
	$(RM) *.o so_locations; \
	$(RM) *.c *.h; \
	$(RM) ../lib/bisonmodule.$(LDEXT))

undepend:
	@($(ECHO) "UnDepend $(PACKAGE) for $(ARCHITECTURE)"; \
	$(RM) depend.inc depend.inc.bak)

unconfig:
	@($(ECHO) "UnConfigured $(PACKAGE) for $(ARCHITECTURE)"; \
	$(RM) Makefile* depend.inc; \
	cd ../../install; \
	$(RM) config.*)

#############################################################################
#  real Make rules for package
#############################################################################

# The 'bison' helper module.
bisonmodule.o: bisonmodule.c bisonmodule.h
bisonmodule.$(LDEXT): bisonmodule.o grammar.o lexer.o

# The IDL lexer/parser engines.
grammar.c: grammar.y
	bison -o grammar.c -d ../../src/grammar.y

lexer.c: lexer.l grammar.h
	flex -olexer.c ../../src/lexer.l

#############################################################################
include depend.inc
#############################################################################
