# 
# 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.
#
# $Id: Makefile,v 1.24 2001/04/09 23:13:21 stevek Exp $

TOPDIR = ../..

include ${TOPDIR}/mak/config.mak

PROG = wrapc
OBJS = wrapc${OBJ} pathfind${OBJ}

.PHONY: wrapgeninstall
INSTALL_TARGET	= wrapgeninstall

CXXFLAGS	+= -D_CC="\"${WRAPCC}\""
CXXFLAGS	+= -D_LD="\"${LD}\""

UNIX_LDFLAGS	= -L${TOPDIR}/wr.lib/libwdl -L${TOPDIR}/wr.lib/libwrinit
UNIX_LDLIBS	+= -lwdl -lwrinit
UNIX_CXXFLAGS	+= -I${TOPDIR}/wr.lib/libwrinit
UNIX_CXXFLAGS	+= -g -Wall

WINNT_CXXFLAGS        += /GX -I${TOPDIR}/wr.lib/libgwmcomm
WINNT_LDLIBS	+= ${TOPDIR}/wr.lib/libwdl/${LIBPRFX}wdl${LIBEXT}
# For getopt()
WINNT_LDLIBS	+= ${TOPDIR}/wr.lib/libgwmcomm/${LIBPRFX}gwmcomm${LIBEXT}

PROGDEPENDS	+= ${TOPDIR}/wr.lib/libwdl/${LIBPRFX}wdl${LIBEXT}
UNIX_PROGDEPENDS	+= ${TOPDIR}/wr.lib/libwrinit/${LIBPRFX}wrinit${LIBEXT}

include ${TOPDIR}/mak/prog.mak

wrapgeninstall:
	@if [ -z "${INSTALLDIR}" ]; then \
	   if [ "${INSTALLSBIN}" = yes ]; then \
	      INSTALLDIR="${SBINDIR}"; export INSTALLDIR; \
	   else \
	      INSTALLDIR="${BINDIR}"; export INSTALLDIR; \
	   fi; \
	else \
	   INSTALLDIR="${INSTALLDIR}"; export INSTALLDIR; \
	fi; \
	if [ ! -z "${INSTALLROOT}" ]; then \
	   INSTALLDIR="${INSTALLROOT}/$${INSTALLDIR}"; \
	fi; \
	if [ ! -d "$${INSTALLDIR}" ]; then \
	   ${SHELL} -c "${TOPDIR}/mak/mkdirhier \"$${INSTALLDIR}\""; \
	fi; \
	RELOCOUT=`echo "${RELOC_OUT}" | sed 's!wrapgeninstall!\\\\\\\\$${wrapgen_link_out}!'`; \
	echo "${CP} wrapgen \"$${INSTALLDIR}\""; \
	sed -e "s!CONFIGPATH=!CONFIGPATH=\"${SYSCONFDIR}/wss.conf\"!" \
	    -e "s!CONFIGCOMPILEC=!CONFIGCOMPILEC=\"${WRAPCC} -c\"!" \
	    -e "s!CONFIGRELOC=!CONFIGRELOC=\"${RELOC_LINK} $${RELOCOUT}\"!" \
	    wrapgen > "$${INSTALLDIR}/wrapgen"; \
	chmod a+x "$${INSTALLDIR}/wrapgen"; \
	if [ "${BUILDPLATFORM}" = "Windows_NT" ]; then \
	   echo "${CP} wrapgen.bat \"$${INSTALLDIR}\""; \
	   ${CP} wrapgen.bat "$${INSTALLDIR}"; \
	fi

