#  
#  Copyright (C) 1999, 2000, 2001  Network Associates, Incorporated (NAI)
#  All rights reserved.
# 
#  This file is part of the NAI Generic Software Wrappers Toolkit
#  (GSWTK).  See ftp://ftp.tislabs.com/pub/wrappers/ for the latest
#  distribution.
# 
#  The GSWTK 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, or (at your option)
#  any later version.
# 
#  The GSWTK 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 software; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#  02111-1307, USA.

TOPDIR = ../..

include ${TOPDIR}/mak/config.mak

BUILD_SHARED	= no
BUILD_STATIC	= yes

SHLIB_MAJOR	= 1
SHLIB_MINOR	= 0

LIBBASE		= wdl
OBJS		= headers${OBJ} wdl.tab${OBJ} codegen${OBJ} event${OBJ} \
		  type${OBJ} expr${OBJ}
UNIX_OBJS	= syscallnames${OBJ}
WINNT_OBJS	= syms_nt${OSVERS}${OBJ}
HEADERS		= libwdl.h

CXXFLAGS	+= -DLINKAGE=EXPORT
UNIX_CXXFLAGS	+= -g -Wall

UNIX_CFLAGS	+= -g -Wall -O2
WINNT_CFLAGS	+= -Zm900

CLEANFILES	+= lex.wdl.c wdl.tab.cc wdl.tab.cc.h wdl.tab.cc.output \
		   headers.[ch] syscallnames.c

include ${TOPDIR}/mak/library.mak

PROCESSED_HEADER =  \
	${TOPDIR}/wr.include/wrerrno.h			\
	${TOPDIR}/include/pdpi/queue.h 			\
	${TOPDIR}/include/wr_configuration.h		\
	${TOPDIR}/include/pdpi/${OSDIRECTORY}/pd_types.h	\
	${TOPDIR}/include/pdpi/${OSDIRECTORY}/pd_defs.h	\
	${TOPDIR}/include/pdpi/pi_defs.h		\
	${TOPDIR}/include/pdpi/${OSDIRECTORY}/pd_mutex.h	\
	${TOPDIR}/include/pdpi/pi_mutex.h		\
	${TOPDIR}/include/pdpi/${OSDIRECTORY}/pd_cv.h	\
	${TOPDIR}/include/pdpi/pi_cv.h			\
	${TOPDIR}/wr.include/wr_conf.h			\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_errno.h	\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_types.h	\
	${TOPDIR}/wss/include/wss_mutex.h		\
	${TOPDIR}/wss/include/wss_cv.h			\
	${TOPDIR}/wss/include/wss_ref.h			\
	${TOPDIR}/wss/include/wss_iface.h		\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_wrapper.h	\
	${TOPDIR}/wss/include/wss_wrapper.h		\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_file.h	\
	${TOPDIR}/wss/include/wss_file.h		\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_vm.h	\
	${TOPDIR}/wss/include/wss_vm.h			\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_fileutil.h	\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_process.h	\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_rw.h	\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_errno.h	\
	${TOPDIR}/wss/include/wss_process.h		\
	${TOPDIR}/wss/include/wss_criteria.h		\
	${TOPDIR}/wss/include/wss_library.h		\
	${TOPDIR}/wss/include/wss_linker.h		\
	${TOPDIR}/wsi/${BUILDDIR}/include/wsi_module.h	\
	${TOPDIR}/wss/include/wss_module.h		\
	${TOPDIR}/wr.include/wr_errno.h			\
	${TOPDIR}/wss/include/wss_db.h

headers.c: $(PROCESSED_HEADER) convert.pl Makefile
	@rm -f $@
	@echo Generating headers.{c,h}
	@cat ${PROCESSED_HEADER} | ${PERL} -- convert.pl $@

syscallnames.c: ${TOPDIR}/wsi/${BUILDDIR}/wsi_syscallnames.c
	${LN} ${TOPDIR}/wsi/${BUILDDIR}/wsi_syscallnames.c $@

wdl.tab.cc: wdl.y lex.wdl.c event.h
	${YACC} ${YACC_FLAGS} -t -v -p wdl -o wdl.tab.cc wdl.y

# for debugging...
#wdl.tab.cc: wdl.y lex.wdl.c
#	${YACC} ${YACC_FLAGS} -t -v -d -p wdl -o wdl.tab.cc wdl.y

codegen.cc event.cc expr.cc: event.h

lex.wdl.c: wdl.l
	${LEX} -Sflex.skl -Pwdl wdl.l

codegen${OBJ}: codefrags.h

wrapc:
	cd ${TOPDIR}/wr.bin/wrapc ; ${MAKE}

