? abi-stable-apkg.diff ? po/.cvsignore ? po/.new.en-GB.po ? src/pkg/GNUmakefile.in ? src/pkg/linux/GNUmakefile.in ? src/pkg/linux/apkg/GNUmakefile.in Index: configure.ac =================================================================== RCS file: /cvsroot/abi/configure.ac,v retrieving revision 1.135.2.4 diff -u -r1.135.2.4 configure.ac --- configure.ac 4 Apr 2005 15:55:54 -0000 1.135.2.4 +++ configure.ac 10 Apr 2005 13:59:46 -0000 @@ -79,6 +79,7 @@ with_unix=true dnl locate glib and gtk ABI_GTK2 + AM_BINRELOC elif test "$PLATFORM" = "cocoa" ; then ABI_GLIB2 ABI_FE="Cocoa" @@ -103,6 +104,7 @@ AM_CONDITIONAL(WITH_MACOSX,$with_macosx) AM_CONDITIONAL(WITH_COCOA,$with_cocoa) AM_CONDITIONAL(WITH_QNX,$with_qnx) +AM_CONDITIONAL(WITH_BINRELOC, test "x$br_cv_binreloc" = "xyes") AC_SUBST(OBJCXX) AC_SUBST(OBJCXXFLAGS) AC_SUBST(OBJCXXDEPMODE) @@ -424,6 +426,9 @@ src/other/spell/xp/GNUmakefile src/other/ttftool/GNUmakefile src/other/ttftool/unix/GNUmakefile + src/pkg/GNUmakefile + src/pkg/linux/GNUmakefile + src/pkg/linux/apkg/GNUmakefile src/text/GNUmakefile src/text/fmt/GNUmakefile src/text/fmt/xp/GNUmakefile @@ -466,6 +471,8 @@ src/tools/scripts/unix/GNUmakefile src/bindings/GNUmakefile src/bindings/perl/GNUmakefile + autopackage/abiword-gnome.apspec + autopackage/abiword-gtk.apspec ]) AC_OUTPUT Index: includes.mk =================================================================== RCS file: /cvsroot/abi/includes.mk,v retrieving revision 1.52 diff -u -r1.52 includes.mk --- includes.mk 15 Feb 2004 17:04:35 -0000 1.52 +++ includes.mk 10 Apr 2005 13:59:47 -0000 @@ -53,11 +53,13 @@ WP_INCLUDES+=-I'$(top_srcdir)/src/wp/ap/@PLATFORM@' WP_INCLUDES+=-I'$(top_srcdir)/src/wp/ap/xp/ToolbarIcons' WP_INCLUDES+=-I'$(top_srcdir)/src/wp/ap/@PLATFORM@/gnome' +WP_INCLUDES+=-I'$(top_srcdir)/src/pkg/linux/apkg' else WP_INCLUDES=-I'$(top_srcdir)/src/wp/ap/xp' WP_INCLUDES+=-I'$(top_srcdir)/src/wp/impexp/xp' WP_INCLUDES+=-I'$(top_srcdir)/src/wp/ap/@PLATFORM@' WP_INCLUDES+=-I'$(top_srcdir)/src/wp/ap/xp/ToolbarIcons' +WP_INCLUDES+=-I'$(top_srcdir)/src/pkg/linux/apkg' endif OTHER_INCLUDES=-I'$(top_srcdir)/src/other/spell/xp' @@ -119,6 +121,7 @@ ABI_LIBS+=$(top_builddir)/src/af/ev/libEv.a ABI_LIBS+=$(top_builddir)/src/other/spell/xp/libSpell.a ABI_LIBS+=$(top_builddir)/src/other/ttftool/unix/libTtfTool.a +ABI_LIBS+=$(top_builddir)/src/pkg/linux/apkg/libApkg.a ABI_LIBS+=$(top_builddir)/src/text/fmt/xp/libFmt.a ABI_LIBS+=$(top_builddir)/src/text/ptbl/xp/libPtbl.a else @@ -129,6 +132,7 @@ ABI_LIBS+=$(top_builddir)/src/af/gr/libGr.a ABI_LIBS+=$(top_builddir)/src/af/ev/libEv.a ABI_LIBS+=$(top_builddir)/src/other/spell/xp/libSpell.a +ABI_LIBS+=$(top_builddir)/src/pkg/linux/apkg/libApkg.a ABI_LIBS+=$(top_builddir)/src/text/fmt/xp/libFmt.a ABI_LIBS+=$(top_builddir)/src/text/ptbl/xp/libPtbl.a endif Index: ac-helpers/binreloc.m4 =================================================================== RCS file: ac-helpers/binreloc.m4 diff -N ac-helpers/binreloc.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ac-helpers/binreloc.m4 10 Apr 2005 13:59:47 -0000 @@ -0,0 +1,77 @@ +# Check for binary relocation support +# Hongli Lai +# http://autopackage.org/ + +AC_DEFUN([AM_BINRELOC], +[ + AC_ARG_ENABLE(binreloc, + [ --enable-binreloc compile with binary relocation support + (default=enable when available)], + enable_binreloc=$enableval,enable_binreloc=auto) + + AC_ARG_ENABLE(binreloc-threads, + [ --enable-binreloc-threads compile binary relocation with threads support + (default=yes)], + enable_binreloc_threads=$enableval,enable_binreloc_threads=yes) + + BINRELOC_CFLAGS= + BINRELOC_LIBS= + if test "x$enable_binreloc" = "xauto"; then + AC_CHECK_FILE([/proc/self/maps]) + AC_CACHE_CHECK([whether everything is installed to the same prefix], + [br_cv_valid_prefixes], [ + if test "$bindir" = '${exec_prefix}/bin' -a "$sbindir" = '${exec_prefix}/sbin' -a \ + "$datadir" = '${prefix}/share' -a "$libdir" = '${exec_prefix}/lib' -a \ + "$libexecdir" = '${exec_prefix}/libexec' -a "$sysconfdir" = '${prefix}/etc' + then + br_cv_valid_prefixes=yes + else + br_cv_valid_prefixes=no + fi + ]) + fi + AC_CACHE_CHECK([whether binary relocation support should be enabled], + [br_cv_binreloc], + [if test "x$enable_binreloc" = "xyes"; then + br_cv_binreloc=yes + elif test "x$enable_binreloc" = "xauto"; then + if test "x$br_cv_valid_prefixes" = "xyes" -a \ + "x$ac_cv_file__proc_self_maps" = "xyes"; then + br_cv_binreloc=yes + else + br_cv_binreloc=no + fi + else + br_cv_binreloc=no + fi]) + + if test "x$br_cv_binreloc" = "xyes"; then + BINRELOC_CFLAGS="-DENABLE_BINRELOC" + AC_DEFINE(ENABLE_BINRELOC,,[Use binary relocation?]) + if test "x$enable_binreloc_threads" = "xyes"; then + AC_CHECK_LIB([pthread], [pthread_getspecific]) + fi + + AC_CACHE_CHECK([whether binary relocation should use threads], + [br_cv_binreloc_threads], + [if test "x$enable_binreloc_threads" = "xyes"; then + if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then + br_cv_binreloc_threads=yes + else + br_cv_binreloc_threads=no + fi + else + br_cv_binreloc_threads=no + fi]) + + if test "x$br_cv_binreloc_threads" = "xyes"; then + BINRELOC_LIBS="-lpthread" + AC_DEFINE(BR_PTHREAD,1,[Include pthread support for binary relocation?]) + else + BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0" + AC_DEFINE(BR_PTHREAD,0,[Include pthread support for binary relocation?]) + fi + fi + AC_SUBST(BINRELOC_CFLAGS) + AC_SUBST(BINRELOC_LIBS) +]) Index: autopackage/abiword-gnome.apspec.in =================================================================== RCS file: autopackage/abiword-gnome.apspec.in diff -N autopackage/abiword-gnome.apspec.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autopackage/abiword-gnome.apspec.in 10 Apr 2005 13:59:47 -0000 @@ -0,0 +1,63 @@ +# -*-shell-script-*- + +[Meta] +RootName: @abisource.org/abiword:@VERSION@ +DisplayName: AbiWord Word Processor +ShortName: abiword +Maintainer: Abi the Ant - http://www.abisource.com/ +Packager: Robert Staudinger +Summary: AbiWord is a lightweight word processing application. +SoftwareVersion: @VERSION@ +AutopackageTarget: 1.0 +#PackageVersion: 4 + +# Only uncomment InterfaceVersion if your package exposes interfaces to other software, +# for instance if it includes DSOs or python/perl modules. See the developer guide for more info, +# or ask on autopackage-dev if you don't understand interface versioning in autopackage. +# +# InterfaceVersion: 0.0 + +[Description] +AbiWord is a multi-platform word processor with a GTK+ interface on the UNIX platform. For extended functionality and integration this version is compiled with GNOME support. Abiword with the GNOME front-end is part of the GNOME Office Suite. AbiWord is made available under the GNU GPL license. + +[BuildPrepare] +echo '#!/bin/bash' > configure +echo '../abi/configure $@' >> configure +chmod +x configure +prepareBuild --prefix=/bail/if/binreloc/fails --enable-binreloc --enable-gnome --enable-gucharmap --disable-debug --disable-symbols + +[BuildUnprepare] +unprepareBuild + +[Imports] +echo '*' | import + +[Prepare] +require @gnu.org/libstdc++ 3 +require @rpm.org/popt 0.0 +require @libpng.org/libpng 3 +require @gtk.org/gtk 2.2 +require @xmlsoft.org/libxml2 2.0 +require @glade.gnome.org/libglade 2.0 +# working on removing this one +require @gnome.org/libbonobo2 0.0 +# working on removing this one +require @gnome.org/libgnomeui 2.0 +### my skels, use with care! +require @jig.org/libjpeg 62 +require @gnome.org/gucharmap 4 +require @gnome.org/libgnomeprint-2-2 0.0 +require @gnome.org/libgnomeprintui-2-2 0.0 +# actually 10.4 but the so seems not to be versioned properly +require @freedesktop.org/fribidi 0.0 +require @freedesktop.org/enchant 1.1 + +[Install] +installExe ./bin/AbiWord-@PACKAGE_VERSION@ +ln -s "$PREFIX/bin/AbiWord-@PACKAGE_VERSION@" "$PREFIX/bin/abiword" +installData ./share/AbiSuite-@PACKAGE_VERSION@ +installDesktop "Word Processing" share/applications/abiword.desktop + +[Uninstall] +rm "$PREFIX/bin/abiword" +uninstallFromLog Index: autopackage/abiword-gtk.apspec.in =================================================================== RCS file: autopackage/abiword-gtk.apspec.in diff -N autopackage/abiword-gtk.apspec.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autopackage/abiword-gtk.apspec.in 10 Apr 2005 13:59:48 -0000 @@ -0,0 +1,60 @@ +# -*-shell-script-*- + +### ATTENTION ### +This file is not maintained and should be brought up to par with abiword-gnome.apspec before an eventual release of an abiword-gtk autopackage. +################# + +[Meta] +RootName: @abisource.org/abiword-gtk:@VERSION@ +DisplayName: AbiWord Word Processor +ShortName: abiword-gtk +Maintainer: Abi the Ant - http://www.abisource.com/ +Packager: Robert Staudinger +Summary: AbiWord is a lightweight word processing application. +SoftwareVersion: @VERSION@ +AutopackageTarget: 1.0 +PackageVersion: 1 + +# Only uncomment InterfaceVersion if your package exposes interfaces to other software, +# for instance if it includes DSOs or python/perl modules. See the developer guide for more info, +# or ask on autopackage-dev if you don't understand interface versioning in autopackage. +# +# InterfaceVersion: 0.0 + +[Description] +AbiWord is a multi-platform word processor with a GTK+ interface on the UNIX platform. This version is built against gtk only to ensure maximum portability through a minimal set of dependencies. Abiword with the GNOME front-end is part of the GNOME Office Suite. AbiWord is made available under the GNU GPL license. + +[BuildPrepare] +echo '#!/bin/bash' > configure +echo '../abi/configure $@' >> configure +chmod +x configure +prepareBuild --prefix=/bail/if/binreloc/fails --enable-binreloc --disable-gnome --disable-gucharmap --disable-debug --disable-symbols + +[BuildUnprepare] +unprepareBuild + +[Imports] +echo '*' | import + +[Prepare] +require @gnu.org/libstdc++ 3 +require @rpm.org/popt 0.0 +require @libpng.org/libpng 3 +require @gtk.org/gtk 2.2 +require @xmlsoft.org/libxml2 2.0 +require @glade.gnome.org/libglade 2.0 +### my skels, use with care! +require @jig.org/libjpeg 62 +# actually 10.4 but the so seems not to be versioned properly +require @freedesktop.org/fribidi 0.0 +require @freedesktop.org/enchant 1.1 + +[Install] +# Put your installation script here +installExe bin/* +installData share/AbiSuite-@PACKAGE_VERSION@ +installDesktop "Word Processing" share/applications/abiword.desktop + +[Uninstall] +# Usually just the following line is enough to uninstall everything +uninstallFromLog Index: autopackage/@freedesktop.org/enchant/skeleton.1 =================================================================== RCS file: autopackage/@freedesktop.org/enchant/skeleton.1 diff -N autopackage/@freedesktop.org/enchant/skeleton.1 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autopackage/@freedesktop.org/enchant/skeleton.1 10 Apr 2005 13:59:48 -0000 @@ -0,0 +1,15 @@ +# Package skeleton for the enchant library + +[Meta] +RootName: @freedesktop.org/enchant +DisplayName: Enchant is a cross-platform abstract layer to spellchecking +ShortName: enchant +Skeleton-Author: Robert Staudinger +Skeleton-Version: 1 +Repository: http://www.abisource.org/~rob/repo/deps/enchant.xml + +[Notes] +Does not set SOFTWARE_VERSIONS + +[Test] +INTERFACE_VERSIONS=$( testForLib -i libenchant.so ) Index: autopackage/@gnome.org/gucharmap/skeleton.1 =================================================================== RCS file: autopackage/@gnome.org/gucharmap/skeleton.1 diff -N autopackage/@gnome.org/gucharmap/skeleton.1 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autopackage/@gnome.org/gucharmap/skeleton.1 10 Apr 2005 13:59:48 -0000 @@ -0,0 +1,15 @@ +# Package skeleton for the gucharmap library + +[Meta] +RootName: @gnome.org/gucharmap +DisplayName: Unicode character map +ShortName: gucharmap +Skeleton-Author: Robert Staudinger +Skeleton-Version: 1 +Repository: http://www.abisource.org/~rob/repo/deps/gucharmap.xml + +[Notes] +Does not set SOFTWARE_VERSIONS + +[Test] +INTERFACE_VERSIONS=$( testForLib -i libgucharmap.so ) Index: autopackage/@gnome.org/libgnomeprint-2-2/skeleton.1 =================================================================== RCS file: autopackage/@gnome.org/libgnomeprint-2-2/skeleton.1 diff -N autopackage/@gnome.org/libgnomeprint-2-2/skeleton.1 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autopackage/@gnome.org/libgnomeprint-2-2/skeleton.1 10 Apr 2005 13:59:48 -0000 @@ -0,0 +1,14 @@ +# Package skeleton for the gnomeprint library + +[Meta] +RootName: @gnome.org/libgnomeprint-2-2 +DisplayName: Gnome print dialogs. +ShortName: libgnomeprint-2-2 +Skeleton-Author: Robert Staudinger +Skeleton-Version: 1 + +[Notes] +Does not set SOFTWARE_VERSIONS + +[Test] +INTERFACE_VERSIONS=$( testForLib -i libgnomeprint-2-2.so ) Index: autopackage/@gnome.org/libgnomeprintui-2-2/skeleton.1 =================================================================== RCS file: autopackage/@gnome.org/libgnomeprintui-2-2/skeleton.1 diff -N autopackage/@gnome.org/libgnomeprintui-2-2/skeleton.1 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autopackage/@gnome.org/libgnomeprintui-2-2/skeleton.1 10 Apr 2005 13:59:48 -0000 @@ -0,0 +1,14 @@ +# Package skeleton for the gnomeprintui library + +[Meta] +RootName: @gnome.org/libgnomeprintui-2-2 +DisplayName: Gnome print dialogs. +ShortName: libgnomeprintui-2-2 +Skeleton-Author: Robert Staudinger +Skeleton-Version: 1 + +[Notes] +Does not set SOFTWARE_VERSIONS + +[Test] +INTERFACE_VERSIONS=$( testForLib -i libgnomeprintui-2-2.so ) Index: src/GNUmakefile.am =================================================================== RCS file: /cvsroot/abi/src/GNUmakefile.am,v retrieving revision 1.2 diff -u -r1.2 GNUmakefile.am --- src/GNUmakefile.am 23 Jun 2001 19:53:45 -0000 1.2 +++ src/GNUmakefile.am 10 Apr 2005 13:59:49 -0000 @@ -1,5 +1,5 @@ -SUBDIRS = tools af text other wp bindings +SUBDIRS = tools af text other pkg wp bindings Index: src/af/xap/unix/GNUmakefile.am =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/GNUmakefile.am,v retrieving revision 1.40 diff -u -r1.40 GNUmakefile.am --- src/af/xap/unix/GNUmakefile.am 17 Feb 2004 00:39:09 -0000 1.40 +++ src/af/xap/unix/GNUmakefile.am 10 Apr 2005 13:59:54 -0000 @@ -27,7 +27,7 @@ noinst_LIBRARIES = libXap_unix.a -gladedir=$(pkgdatadir)/AbiWord/glade +gladedir=$(datadir)/$(PACKAGE)/AbiWord/glade glade_DATA = \ xap_UnixDlg_About.glade \ Index: src/pkg/GNUmakefile.am =================================================================== RCS file: src/pkg/GNUmakefile.am diff -N src/pkg/GNUmakefile.am --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/pkg/GNUmakefile.am 10 Apr 2005 13:59:57 -0000 @@ -0,0 +1,3 @@ + +SUBDIRS = linux + Index: src/pkg/linux/GNUmakefile.am =================================================================== RCS file: src/pkg/linux/GNUmakefile.am diff -N src/pkg/linux/GNUmakefile.am --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/pkg/linux/GNUmakefile.am 10 Apr 2005 13:59:57 -0000 @@ -0,0 +1,3 @@ + +SUBDIRS = apkg + Index: src/pkg/linux/apkg/GNUmakefile.am =================================================================== RCS file: src/pkg/linux/apkg/GNUmakefile.am diff -N src/pkg/linux/apkg/GNUmakefile.am --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/pkg/linux/apkg/GNUmakefile.am 10 Apr 2005 13:59:57 -0000 @@ -0,0 +1,24 @@ +## AbiSource Applications +## Copyright (C) 2005 Robert Staudinger robsta@stereolyzer.net +## +## 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; either version 2 +## of the License, or (at your option) any later version. +## +## This program 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 program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. + +include $(top_srcdir)/includes.mk + +noinst_LIBRARIES = libApkg.a + +libApkg_a_SOURCES=\ + prefix.c Index: src/pkg/linux/apkg/prefix.c =================================================================== RCS file: src/pkg/linux/apkg/prefix.c diff -N src/pkg/linux/apkg/prefix.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/pkg/linux/apkg/prefix.c 10 Apr 2005 13:59:58 -0000 @@ -0,0 +1,482 @@ +/* + * BinReloc - a library for creating relocatable executables + * Written by: Mike Hearn + * Hongli Lai + * http://autopackage.org/ + * + * This source code is public domain. You can relicense this code + * under whatever license you want. + * + * NOTE: if you're using C++ and are getting "undefined reference + * to br_*", try renaming prefix.c to prefix.cpp + */ + +/* WARNING, BEFORE YOU MODIFY PREFIX.C: + * + * If you make changes to any of the functions in prefix.c, you MUST + * change the BR_NAMESPACE macro (in prefix.h). + * This way you can avoid symbol table conflicts with other libraries + * that also happen to use BinReloc. + * + * Example: + * #define BR_NAMESPACE(funcName) foobar_ ## funcName + * --> expands br_locate to foobar_br_locate + */ + +#ifndef _PREFIX_C_ +#define _PREFIX_C_ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#ifndef BR_PTHREADS + /* Change 1 to 0 if you don't want pthread support */ + #define BR_PTHREADS 1 +#endif /* BR_PTHREADS */ + +#include +#include +#include +#include +#include "prefix.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#undef NULL +#define NULL ((void *) 0) + +#ifdef __GNUC__ + #define br_return_val_if_fail(expr,val) if (!(expr)) {fprintf (stderr, "** BinReloc (%s): assertion %s failed\n", __PRETTY_FUNCTION__, #expr); return val;} +#else + #define br_return_val_if_fail(expr,val) if (!(expr)) return val +#endif /* __GNUC__ */ + + +static br_locate_fallback_func fallback_func = NULL; +static void *fallback_data = NULL; + + +#ifdef ENABLE_BINRELOC +#include +#include +#include +#include + + +/** + * br_locate: + * symbol: A symbol that belongs to the app/library you want to locate. + * Returns: A newly allocated string containing the full path of the + * app/library that func belongs to, or NULL on error. This + * string should be freed when not when no longer needed. + * + * Finds out to which application or library symbol belongs, then locate + * the full path of that application or library. + * Note that symbol cannot be a pointer to a function. That will not work. + * + * Example: + * --> main.c + * #include "prefix.h" + * #include "libfoo.h" + * + * int main (int argc, char *argv[]) { + * printf ("Full path of this app: %s\n", br_locate (&argc)); + * libfoo_start (); + * return 0; + * } + * + * --> libfoo.c starts here + * #include "prefix.h" + * + * void libfoo_start () { + * --> "" is a symbol that belongs to libfoo (because it's called + * --> from libfoo_start()); that's why this works. + * printf ("libfoo is located in: %s\n", br_locate ("")); + * } + */ +char * +br_locate (void *symbol) +{ + char line[5000]; + FILE *f; + char *path; + + br_return_val_if_fail (symbol != NULL, NULL); + + f = fopen ("/proc/self/maps", "r"); + if (!f) { + if (fallback_func) + return fallback_func(symbol, fallback_data); + else + return NULL; + } + + while (!feof (f)) + { + unsigned long start, end; + + if (!fgets (line, sizeof (line), f)) + continue; + if (!strstr (line, " r-xp ") || !strchr (line, '/')) + continue; + + sscanf (line, "%lx-%lx ", &start, &end); + if (symbol >= (void *) start && symbol < (void *) end) + { + char *tmp; + size_t len; + + /* Extract the filename; it is always an absolute path */ + path = strchr (line, '/'); + + /* Get rid of the newline */ + tmp = strrchr (path, '\n'); + if (tmp) *tmp = 0; + + /* Get rid of "(deleted)" */ + len = strlen (path); + if (len > 10 && strcmp (path + len - 10, " (deleted)") == 0) + { + tmp = path + len - 10; + *tmp = 0; + } + + fclose(f); + return strdup (path); + } + } + + fclose (f); + return NULL; +} + + +/** + * br_locate_prefix: + * symbol: A symbol that belongs to the app/library you want to locate. + * Returns: A prefix. This string should be freed when no longer needed. + * + * Locates the full path of the app/library that symbol belongs to, and return + * the prefix of that path, or NULL on error. + * Note that symbol cannot be a pointer to a function. That will not work. + * + * Example: + * --> This application is located in /usr/bin/foo + * br_locate_prefix (&argc); --> returns: "/usr" + */ +char * +br_locate_prefix (void *symbol) +{ + char *path, *prefix; + + br_return_val_if_fail (symbol != NULL, NULL); + + path = br_locate (symbol); + if (!path) return NULL; + + prefix = br_extract_prefix (path); + free (path); + return prefix; +} + + +/** + * br_prepend_prefix: + * symbol: A symbol that belongs to the app/library you want to locate. + * path: The path that you want to prepend the prefix to. + * Returns: The new path, or NULL on error. This string should be freed when no + * longer needed. + * + * Gets the prefix of the app/library that symbol belongs to. Prepend that prefix to path. + * Note that symbol cannot be a pointer to a function. That will not work. + * + * Example: + * --> The application is /usr/bin/foo + * br_prepend_prefix (&argc, "/share/foo/data.png"); --> Returns "/usr/share/foo/data.png" + */ +char * +br_prepend_prefix (void *symbol, char *path) +{ + char *tmp, *newpath; + + br_return_val_if_fail (symbol != NULL, NULL); + br_return_val_if_fail (path != NULL, NULL); + + tmp = br_locate_prefix (symbol); + if (!tmp) return NULL; + + if (strcmp (tmp, "/") == 0) + newpath = strdup (path); + else + newpath = br_strcat (tmp, path); + + /* Get rid of compiler warning ("br_prepend_prefix never used") */ + if (0) br_prepend_prefix (NULL, NULL); + + free (tmp); + return newpath; +} + +#endif /* ENABLE_BINRELOC */ + + +/* Pthread stuff for thread safetiness */ +#if BR_PTHREADS && defined(ENABLE_BINRELOC) + +#include + +static pthread_key_t br_thread_key; +static pthread_once_t br_thread_key_once = PTHREAD_ONCE_INIT; + + +static void +br_thread_local_store_fini () +{ + char *specific; + + specific = (char *) pthread_getspecific (br_thread_key); + if (specific) + { + free (specific); + pthread_setspecific (br_thread_key, NULL); + } + pthread_key_delete (br_thread_key); + br_thread_key = 0; +} + + +static void +br_str_free (void *str) +{ + if (str) + free (str); +} + + +static void +br_thread_local_store_init () +{ + if (pthread_key_create (&br_thread_key, br_str_free) == 0) + atexit (br_thread_local_store_fini); +} + +#else /* BR_PTHREADS */ +#ifdef ENABLE_BINRELOC + +static char *br_last_value = (char *) NULL; + +static void +br_free_last_value () +{ + if (br_last_value) + free (br_last_value); +} + +#endif /* ENABLE_BINRELOC */ +#endif /* BR_PTHREADS */ + + +#ifdef ENABLE_BINRELOC + +/** + * br_thread_local_store: + * str: A dynamically allocated string. + * Returns: str. This return value must not be freed. + * + * Store str in a thread-local variable and return str. The next + * you run this function, that variable is freed too. + * This function is created so you don't have to worry about freeing + * strings. Just be careful about doing this sort of thing: + * + * some_function( BR_DATADIR("/one.png"), BR_DATADIR("/two.png") ) + * + * Examples: + * char *foo; + * foo = br_thread_local_store (strdup ("hello")); --> foo == "hello" + * foo = br_thread_local_store (strdup ("world")); --> foo == "world"; "hello" is now freed. + */ +const char * +br_thread_local_store (char *str) +{ + #if BR_PTHREADS + char *specific; + + pthread_once (&br_thread_key_once, br_thread_local_store_init); + + specific = (char *) pthread_getspecific (br_thread_key); + br_str_free (specific); + pthread_setspecific (br_thread_key, str); + + #else /* BR_PTHREADS */ + static int initialized = 0; + + if (!initialized) + { + atexit (br_free_last_value); + initialized = 1; + } + + if (br_last_value) + free (br_last_value); + br_last_value = str; + #endif /* BR_PTHREADS */ + + return (const char *) str; +} + +#endif /* ENABLE_BINRELOC */ + + +/** + * br_strcat: + * str1: A string. + * str2: Another string. + * Returns: A newly-allocated string. This string should be freed when no longer needed. + * + * Concatenate str1 and str2 to a newly allocated string. + */ +char * +br_strcat (const char *str1, const char *str2) +{ + char *result; + size_t len1, len2; + + if (!str1) str1 = ""; + if (!str2) str2 = ""; + + len1 = strlen (str1); + len2 = strlen (str2); + + result = (char *) malloc (len1 + len2 + 1); + memcpy (result, str1, len1); + memcpy (result + len1, str2, len2); + result[len1 + len2] = '\0'; + + return result; +} + + +/* Emulates glibc's strndup() */ +static char * +br_strndup (char *str, size_t size) +{ + char *result = (char *) NULL; + size_t len; + + br_return_val_if_fail (str != (char *) NULL, (char *) NULL); + + len = strlen (str); + if (!len) return strdup (""); + if (size > len) size = len; + + result = (char *) calloc (sizeof (char), len + 1); + memcpy (result, str, size); + return result; +} + + +/** + * br_extract_dir: + * path: A path. + * Returns: A directory name. This string should be freed when no longer needed. + * + * Extracts the directory component of path. Similar to g_dirname() or the dirname + * commandline application. + * + * Example: + * br_extract_dir ("/usr/local/foobar"); --> Returns: "/usr/local" + */ +char * +br_extract_dir (const char *path) +{ + char *end, *result; + + br_return_val_if_fail (path != (char *) NULL, (char *) NULL); + + end = strrchr (path, '/'); + if (!end) return strdup ("."); + + while (end > path && *end == '/') + end--; + result = br_strndup ((char *) path, end - path + 1); + if (!*result) + { + free (result); + return strdup ("/"); + } else + return result; +} + + +/** + * br_extract_prefix: + * path: The full path of an executable or library. + * Returns: The prefix, or NULL on error. This string should be freed when no longer needed. + * + * Extracts the prefix from path. This function assumes that your executable + * or library is installed in an LSB-compatible directory structure. + * + * Example: + * br_extract_prefix ("/usr/bin/gnome-panel"); --> Returns "/usr" + * br_extract_prefix ("/usr/local/lib/libfoo.so"); --> Returns "/usr/local" + * br_extract_prefix ("/usr/local/libfoo.so"); --> Returns "/usr" + */ +char * +br_extract_prefix (const char *path) +{ + char *end, *tmp, *result; + + br_return_val_if_fail (path != (char *) NULL, (char *) NULL); + + if (!*path) return strdup ("/"); + end = strrchr (path, '/'); + if (!end) return strdup (path); + + tmp = br_strndup ((char *) path, end - path); + if (!*tmp) + { + free (tmp); + return strdup ("/"); + } + end = strrchr (tmp, '/'); + if (!end) return tmp; + + result = br_strndup (tmp, end - tmp); + free (tmp); + + if (!*result) + { + free (result); + result = strdup ("/"); + } + + return result; +} + + +/** + * br_set_fallback_function: + * func: A function to call to find the binary. + * data: User data to pass to func. + * + * Sets a function to call to find the path to the binary, in + * case "/proc/self/maps" can't be opened. The function set should + * return a string that is safe to free with free(). + */ +void +br_set_locate_fallback_func (br_locate_fallback_func func, void *data) +{ + fallback_func = func; + fallback_data = data; +} + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _PREFIX_C */ Index: src/pkg/linux/apkg/prefix.h =================================================================== RCS file: src/pkg/linux/apkg/prefix.h diff -N src/pkg/linux/apkg/prefix.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/pkg/linux/apkg/prefix.h 10 Apr 2005 13:59:58 -0000 @@ -0,0 +1,139 @@ +/* + * BinReloc - a library for creating relocatable executables + * Written by: Mike Hearn + * Hongli Lai + * http://autopackage.org/ + * + * This source code is public domain. You can relicense this code + * under whatever license you want. + * + * See http://autopackage.org/docs/binreloc/ for + * more information and how to use this. + * + * NOTE: if you're using C++ and are getting "undefined reference + * to br_*", try renaming prefix.c to prefix.cpp + */ + +#ifndef _PREFIX_H_ +#define _PREFIX_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* WARNING, BEFORE YOU MODIFY PREFIX.C: + * + * If you make changes to any of the functions in prefix.c, you MUST + * change the BR_NAMESPACE macro. + * This way you can avoid symbol table conflicts with other libraries + * that also happen to use BinReloc. + * + * Example: + * #define BR_NAMESPACE(funcName) foobar_ ## funcName + * --> expands br_locate to foobar_br_locate + */ +#undef BR_NAMESPACE +#define BR_NAMESPACE(funcName) funcName + + +#ifdef ENABLE_BINRELOC + +#define br_thread_local_store BR_NAMESPACE(br_thread_local_store) +#define br_locate BR_NAMESPACE(br_locate) +#define br_locate_prefix BR_NAMESPACE(br_locate_prefix) +#define br_prepend_prefix BR_NAMESPACE(br_prepend_prefix) + +#ifndef BR_NO_MACROS + /* These are convience macros that replace the ones usually used + in Autoconf/Automake projects */ + #undef SELFPATH + #undef PREFIX + #undef PREFIXDIR + #undef BINDIR + #undef SBINDIR + #undef DATADIR + #undef LIBDIR + #undef LIBEXECDIR + #undef ETCDIR + #undef SYSCONFDIR + #undef CONFDIR + #undef LOCALEDIR + + #define SELFPATH (br_thread_local_store (br_locate ((void *) ""))) + #define PREFIX (br_thread_local_store (br_locate_prefix ((void *) ""))) + #define PREFIXDIR (br_thread_local_store (br_locate_prefix ((void *) ""))) + #define BINDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/bin"))) + #define SBINDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/sbin"))) + #define DATADIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/share"))) + #define LIBDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/lib"))) + #define LIBEXECDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/libexec"))) + #define ETCDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc"))) + #define SYSCONFDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc"))) + #define CONFDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc"))) + #define LOCALEDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/share/locale"))) +#endif /* BR_NO_MACROS */ + + +/* The following functions are used internally by BinReloc + and shouldn't be used directly in applications. */ + +char *br_locate (void *symbol); +char *br_locate_prefix (void *symbol); +char *br_prepend_prefix (void *symbol, char *path); + +#endif /* ENABLE_BINRELOC */ + +const char *br_thread_local_store (char *str); + + +/* These macros and functions are not guarded by the ENABLE_BINRELOC + * macro because they are portable. You can use these functions. + */ + +#define br_strcat BR_NAMESPACE(br_strcat) +#define br_extract_dir BR_NAMESPACE(br_extract_dir) +#define br_extract_prefix BR_NAMESPACE(br_extract_prefix) +#define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func) + +#ifndef BR_NO_MACROS + #ifndef ENABLE_BINRELOC + #define BR_SELFPATH(suffix) SELFPATH suffix + #define BR_PREFIX(suffix) PREFIX suffix + #define BR_PREFIXDIR(suffix) BR_PREFIX suffix + #define BR_BINDIR(suffix) BINDIR suffix + #define BR_SBINDIR(suffix) SBINDIR suffix + #define BR_DATADIR(suffix) DATADIR suffix + #define BR_LIBDIR(suffix) LIBDIR suffix + #define BR_LIBEXECDIR(suffix) LIBEXECDIR suffix + #define BR_ETCDIR(suffix) ETCDIR suffix + #define BR_SYSCONFDIR(suffix) SYSCONFDIR suffix + #define BR_CONFDIR(suffix) CONFDIR suffix + #define BR_LOCALEDIR(suffix) LOCALEDIR suffix + #else + #define BR_SELFPATH(suffix) (br_thread_local_store (br_strcat (SELFPATH, suffix))) + #define BR_PREFIX(suffix) (br_thread_local_store (br_strcat (PREFIX, suffix))) + #define BR_PREFIXDIR(suffix) (br_thread_local_store (br_strcat (BR_PREFIX, suffix))) + #define BR_BINDIR(suffix) (br_thread_local_store (br_strcat (BINDIR, suffix))) + #define BR_SBINDIR(suffix) (br_thread_local_store (br_strcat (SBINDIR, suffix))) + #define BR_DATADIR(suffix) (br_thread_local_store (br_strcat (DATADIR, suffix))) + #define BR_LIBDIR(suffix) (br_thread_local_store (br_strcat (LIBDIR, suffix))) + #define BR_LIBEXECDIR(suffix) (br_thread_local_store (br_strcat (LIBEXECDIR, suffix))) + #define BR_ETCDIR(suffix) (br_thread_local_store (br_strcat (ETCDIR, suffix))) + #define BR_SYSCONFDIR(suffix) (br_thread_local_store (br_strcat (SYSCONFDIR, suffix))) + #define BR_CONFDIR(suffix) (br_thread_local_store (br_strcat (CONFDIR, suffix))) + #define BR_LOCALEDIR(suffix) (br_thread_local_store (br_strcat (LOCALEDIR, suffix))) + #endif +#endif + +char *br_strcat (const char *str1, const char *str2); +char *br_extract_dir (const char *path); +char *br_extract_prefix(const char *path); +typedef char *(*br_locate_fallback_func) (void *symbol, void *data); +void br_set_locate_fallback_func (br_locate_fallback_func func, void *data); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _PREFIX_H_ */ Index: src/wp/ap/unix/GNUmakefile.am =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/GNUmakefile.am,v retrieving revision 1.50.4.1 diff -u -r1.50.4.1 GNUmakefile.am --- src/wp/ap/unix/GNUmakefile.am 20 Feb 2005 22:46:06 -0000 1.50.4.1 +++ src/wp/ap/unix/GNUmakefile.am 10 Apr 2005 14:00:04 -0000 @@ -34,7 +34,7 @@ noinst_LIBRARIES = libWpAp_unix.a -gladedir=$(pkgdatadir)/AbiWord/glade +gladedir=$(datadir)/$(PACKAGE)/AbiWord/glade glade_DATA = \ ap_UnixDialog_Break.glade \ Index: src/wp/main/unix/GNUmakefile.am =================================================================== RCS file: /cvsroot/abi/src/wp/main/unix/GNUmakefile.am,v retrieving revision 1.27 diff -u -r1.27 GNUmakefile.am --- src/wp/main/unix/GNUmakefile.am 10 Nov 2003 12:46:55 -0000 1.27 +++ src/wp/main/unix/GNUmakefile.am 10 Apr 2005 14:00:10 -0000 @@ -26,7 +26,8 @@ -DABIWORD_APP_NAME="\"$(ABIWORD_APP_NAME)\"" \ -DABISUITE_HOME="\"$(pkgdatadir)\"" \ $(AF_INCLUDES) $(WP_INCLUDES) $(OTHER_INCLUDES) $(TEXT_INCLUDES) \ - $(PLUGIN_DEFS) -I$(top_srcdir)/../abiword-plugins + $(PLUGIN_DEFS) -I$(top_srcdir)/../abiword-plugins \ + $(BINRELOC_CFLAGS) REPEAT_LIBS = $(ABI_LIBS) $(ABI_LIBS) $(ABI_LIBS) $(ABI_LIBS) Index: src/wp/main/xp/GNUmakefile.am =================================================================== RCS file: /cvsroot/abi/src/wp/main/xp/GNUmakefile.am,v retrieving revision 1.1 diff -u -r1.1 GNUmakefile.am --- src/wp/main/xp/GNUmakefile.am 14 Apr 2001 19:53:24 -0000 1.1 +++ src/wp/main/xp/GNUmakefile.am 10 Apr 2005 14:00:10 -0000 @@ -1,3 +1,5 @@ +INCLUDES = \ + $(WP_INCLUDES) $(BINRELOC_CFLAGS) SOURCES = abi_ver.cpp Index: src/wp/main/xp/abi_ver.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/main/xp/abi_ver.cpp,v retrieving revision 1.10 diff -u -r1.10 abi_ver.cpp --- src/wp/main/xp/abi_ver.cpp 2 Jun 2003 00:17:17 -0000 1.10 +++ src/wp/main/xp/abi_ver.cpp 10 Apr 2005 14:00:10 -0000 @@ -16,7 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ - + +#ifdef ENABLE_BINRELOC +#include "prefix.h" +#endif // ENABLE_BINRELOC + #include "xap_App.h" #ifndef ABI_BUILD_ID @@ -39,7 +43,11 @@ #ifndef ABISUITE_HOME #error CRASH #endif +#ifdef ENABLE_BINRELOC +const char* XAP_App::s_szAbiSuite_Home = BR_DATADIR( "/" PACKAGE ); +#else const char* XAP_App::s_szAbiSuite_Home = ABISUITE_HOME; +#endif // ENABLE_BINRELOC const char* XAP_App::s_szBuild_Version = ABI_BUILD_VERSION; const char* XAP_App::s_szBuild_Options = ABI_BUILD_OPTIONS; const char* XAP_App::s_szBuild_Target = ABI_BUILD_TARGET;