# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# Filename: package/.../lua-pcre/lrexlib-conf.in
# Copyright (C) 2006 The OpenSDE Project
# Copyright (C) 2006 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This program 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; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---


build_lrexlib_module() {
	eval $MAKE so_$1

	pkglibdir=$root/`pkg-config --variable INSTALL_CMOD lua` ; mkdir -p $pkglibdir
	pkgdatadir=$root/`pkg-config --variable INSTALL_LMOD lua`/$1 ; mkdir -p $pkgdatadir

	cp -av $1.so $pkglibdir/l$1.so

	cat << EOF > $pkgdatadir/init.lua
-- Note: this is a modified version of lrexlib-$ver
require "l$1"

setmetatable($1, {__call =
  function (self, p, cf, lo)
    return self.new(p, cf, lo)
  end})

EOF
}

build_lrexlib_string_replacements() {
	pkgdatadir=$root/`pkg-config --variable INSTALL_LMOD lua`/$1
	sed "s,@RX@,$1,g" < $base/package/*/lua-pcre/string.lua > $pkgdatadir/string.lua
	cat gsub.lua >> $pkgdatadir/string.lua
}

build_lrexlib() {
	build_lrexlib_module $1
	build_lrexlib_string_replacements $1
}