1# $Id: modules,v 1.1 2003/05/16 21:48:04 fredette Exp $ 2 3## This is an automake include file. 4 5# Copyright (c) 2003 Matt Fredette 6# All rights reserved. 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 2. Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in the 15# documentation and/or other materials provided with the distribution. 16# 3. All advertising materials mentioning features or use of this software 17# must display the following acknowledgement: 18# This product includes software developed by Matt Fredette. 19# 4. The name of the author may not be used to endorse or promote products 20# derived from this software without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 26# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32# POSSIBILITY OF SUCH DAMAGE. 33 34# this automake include file must be included in all directories that 35# build modules. it updates the modules index that will be installed 36# along with all of the modules, and also handles some static building 37# details. this is done with an all-local target: 38all-local: 39# 40# first, all source files in the current directory are searched for 41# element "new" function declarations. these declarations provide 42# enough information to determine the published module name, the 43# libtool module name, and "submodule" name. this information is 44# appended to a tme-plugins.txt file, which will be installed in 45# $(pkglibdir). 46# 47# the choice of $(top_builddir)/tme/tme-plugins.txt is important. 48# when debugging, the person doing the debugging is expected to have 49# the good sense to set LTDL_LIBRARY_PATH to $(top_builddir), so 50# module.c will correctly use the uninstalled plugins list for all 51# "tme/" modules. 52# 53# this is abuse of the $(top_builddir)/tme directory, yes, since 54# this directory was originally just for include files and to make 55# #include <tme/FOO.h> work right when building: 56 @echo updating tme modules list.. 57 @grep TME_ELEMENT_NEW_DECL $(srcdir)/*.c | \ 58 sed -e 's%.*TME_ELEMENT_NEW_DECL(\(.*\)).*%\1%' \ 59 >> $(top_builddir)/tme/tme-plugins.txt 60 @grep TME_ELEMENT_SUB_NEW_DECL $(srcdir)/*.c | \ 61 sed -e 's%.*TME_ELEMENT_SUB_NEW_DECL(\(.*\),\(.*\)).*%\1_\2 \1 \2%' \ 62 >> $(top_builddir)/tme/tme-plugins.txt 63 @grep TME_ELEMENT_X_NEW_DECL $(srcdir)/*.c | \ 64 sed -e 's%.*TME_ELEMENT_X_NEW_DECL(\(.*\),\(.*\),\(.*\)).*%\1\3 \1\2 \3%' \ 65 >> $(top_builddir)/tme/tme-plugins.txt 66# 67# next, when building statically, either for debugging purposes or 68# because we're on a weak platform, we have to use libtool's "preopen" 69# mechanism. 70# 71# this means at least specifying all of the modules that could 72# potentially be lt_dlopen'ed on any main program's link command line, 73# using libtool's -dlpreopen option. 74# 75# so we append suitable -dlpreopen options for all modules built in 76# this directory to a file, in this case 77# $(top_builddir)/tme-preopen.txt. when building statically, 78# configure.in will then substitute @TME_PREOPEN@ with: 79# 80# `cat $(top_builddir)/tme-preopen.txt` 81# 82# else it will substitute the empty string. when linking programs, 83# @TME_PREOPEN@ is then used on the program's link command line. 84# 85# additionally, libtool, at least through version 1.5, has a 86# limitation in that the pseudo-library (the .la file) must be present 87# even for a preloaded module. if we aren't debugging, everything is 88# installed, so this is not a problem. 89# 90# however, if we are debugging, nothing is installed, so we have to do 91# something to make sure that the .la files can be found. 92# 93# the person doing the debugging is already expected to set 94# LTDL_LIBRARY_PATH to the top of the build directory, so that 95# module.c can find the uninstalled tme-plugins.txt file, and libtool 96# will want to look in this directory for .la files, so we simply copy 97# all of the .la files into that same directory: 98 @if test "x$(pkglib_LTLIBRARIES)" != x; then \ 99 for module in $(pkglib_LTLIBRARIES); do \ 100 echo $$module ; \ 101 echo -dlpreopen ../$(subdir)/$$module >> $(top_builddir)/tme-preopen.txt ; \ 102 cp $$module $(top_builddir)/tme ; \ 103 done ; \ 104 fi 105