1*ebfedea0SLionel Sambuc#! /bin/sh 2*ebfedea0SLionel Sambuc 3*ebfedea0SLionel Sambuc# 4*ebfedea0SLionel Sambuc# Copyright (c) 2009 The NetBSD Foundation, Inc. 5*ebfedea0SLionel Sambuc# All rights reserved. 6*ebfedea0SLionel Sambuc# 7*ebfedea0SLionel Sambuc# This code is derived from software contributed to The NetBSD Foundation 8*ebfedea0SLionel Sambuc# by Alistair Crooks (agc@netbsd.org) 9*ebfedea0SLionel Sambuc# 10*ebfedea0SLionel Sambuc# Redistribution and use in source and binary forms, with or without 11*ebfedea0SLionel Sambuc# modification, are permitted provided that the following conditions 12*ebfedea0SLionel Sambuc# are met: 13*ebfedea0SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 14*ebfedea0SLionel Sambuc# notice, this list of conditions and the following disclaimer. 15*ebfedea0SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 16*ebfedea0SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 17*ebfedea0SLionel Sambuc# documentation and/or other materials provided with the distribution. 18*ebfedea0SLionel Sambuc# 19*ebfedea0SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*ebfedea0SLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*ebfedea0SLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*ebfedea0SLionel Sambuc# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*ebfedea0SLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*ebfedea0SLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*ebfedea0SLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*ebfedea0SLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*ebfedea0SLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*ebfedea0SLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*ebfedea0SLionel Sambuc# POSSIBILITY OF SUCH DAMAGE. 30*ebfedea0SLionel Sambuc# 31*ebfedea0SLionel Sambuc 32*ebfedea0SLionel Sambuc# rushed script to call swig and compile the output 33*ebfedea0SLionel Sambuc# Usage: swigit <lang> <module> 34*ebfedea0SLionel Sambuc 35*ebfedea0SLionel Sambucprefix=$(pkg_info -qp swig | awk '{ print $2 }') 36*ebfedea0SLionel Sambuc 37*ebfedea0SLionel Sambuclang=$1 38*ebfedea0SLionel Sambucmodule=$2 39*ebfedea0SLionel Sambuc 40*ebfedea0SLionel Sambuccase "$lang" in 41*ebfedea0SLionel Sambuc"") 42*ebfedea0SLionel Sambuc echo "You need to specify an interpreted language like perl or tcl" 43*ebfedea0SLionel Sambuc exit 1 44*ebfedea0SLionel Sambuc ;; 45*ebfedea0SLionel Sambucperl) 46*ebfedea0SLionel Sambuc dir=$(pkg_info -qL perl | awk '/EXTERN.h/ { gsub("/EXTERN.h$", ""); print }') 47*ebfedea0SLionel Sambuc cstrings1='#undef SvPOK' 48*ebfedea0SLionel Sambuc cstrings2='#define SvPOK(x) 1' 49*ebfedea0SLionel Sambuc incpath='CPPFLAGS+=-I'"$dir" 50*ebfedea0SLionel Sambuc ;; 51*ebfedea0SLionel Sambucpython) 52*ebfedea0SLionel Sambuc swigflags="-shadow" 53*ebfedea0SLionel Sambuc dir=$(pkg_info -qL 'python*' | awk '/Python.h/ { gsub("/Python.h$", ""); print }') 54*ebfedea0SLionel Sambuc incpath='CPPFLAGS+=-I'"$dir" 55*ebfedea0SLionel Sambuc ;; 56*ebfedea0SLionel Sambucesac 57*ebfedea0SLionel Sambuc 58*ebfedea0SLionel Sambuccase "$module" in 59*ebfedea0SLionel Sambuc"") 60*ebfedea0SLionel Sambuc echo "You need to specify a module" 61*ebfedea0SLionel Sambuc exit 1 62*ebfedea0SLionel Sambuc ;; 63*ebfedea0SLionel Sambucesac 64*ebfedea0SLionel Sambuc 65*ebfedea0SLionel Sambuccat << EOF > ${module}${lang}.i 66*ebfedea0SLionel Sambuc%module ${module}${lang} 67*ebfedea0SLionel Sambuc%{ 68*ebfedea0SLionel Sambuc#include <${module}.h> 69*ebfedea0SLionel Sambuc${cstrings1} 70*ebfedea0SLionel Sambuc${cstrings2} 71*ebfedea0SLionel Sambuc%} 72*ebfedea0SLionel Sambuc%include ${module}.h 73*ebfedea0SLionel SambucEOF 74*ebfedea0SLionel Sambuc 75*ebfedea0SLionel Sambuccp ../../include/${module}.h . 76*ebfedea0SLionel Sambuc 77*ebfedea0SLionel Sambucswig ${swigflags} -${lang} ${module}${lang}.i 78*ebfedea0SLionel Sambuc 79*ebfedea0SLionel Sambuccat << EOF > Makefile 80*ebfedea0SLionel Sambuc# \$NetBSD\$ 81*ebfedea0SLionel Sambuc# Automatically generated by swigit wrapper script 82*ebfedea0SLionel Sambuc 83*ebfedea0SLionel SambucPREFIX=${prefix} 84*ebfedea0SLionel Sambuc 85*ebfedea0SLionel SambucLIB=${module}${lang} 86*ebfedea0SLionel SambucSRCS=${module}${lang}_wrap.c 87*ebfedea0SLionel SambucWARNS=0 88*ebfedea0SLionel SambucMKMAN=no 89*ebfedea0SLionel SambucCPPFLAGS+=-I\${PREFIX}/include 90*ebfedea0SLionel Sambuc${incpath} 91*ebfedea0SLionel SambucLDFLAGS+=-L\${PREFIX}/lib 92*ebfedea0SLionel SambucLDADD+=-l${module} 93*ebfedea0SLionel Sambuc 94*ebfedea0SLionel Sambuc.include <bsd.lib.mk> 95*ebfedea0SLionel SambucEOF 96*ebfedea0SLionel Sambuc 97*ebfedea0SLionel Sambuccat << EOF > shlib_version 98*ebfedea0SLionel Sambucmajor=0 99*ebfedea0SLionel Sambucminor=0 100*ebfedea0SLionel SambucEOF 101*ebfedea0SLionel Sambuc 102*ebfedea0SLionel Sambucenv USETOOLS=no make 103*ebfedea0SLionel Sambuc 104*ebfedea0SLionel Sambuccase "${lang}" in 105*ebfedea0SLionel Sambucpython) 106*ebfedea0SLionel Sambuc ln -s lib${module}${lang}.so _${module}${lang}.so 107*ebfedea0SLionel Sambuc ;; 108*ebfedea0SLionel Sambucesac 109