rpms/nspluginwrapper/devel nspluginwrapper-0.9.91.4-rh.patch, NONE, 1.1 nspluginwrapper.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Martin Stransky (stransky) fedora-extras-commits at redhat.com
Mon Jul 30 09:52:44 UTC 2007


Author: stransky

Update of /cvs/pkgs/rpms/nspluginwrapper/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31926

Modified Files:
	.cvsignore sources 
Added Files:
	nspluginwrapper-0.9.91.4-rh.patch nspluginwrapper.spec 
Log Message:
initial update

nspluginwrapper-0.9.91.4-rh.patch:

--- NEW FILE nspluginwrapper-0.9.91.4-rh.patch ---
--- nspluginwrapper-0.9.91.4/Makefile.rh	2007-04-03 07:31:22.000000000 +0200
+++ nspluginwrapper-0.9.91.4/Makefile	2007-07-11 16:44:19.000000000 +0200
@@ -52,23 +52,6 @@ ifneq (,$(findstring $(OS),netbsd dragon
 X_LDFLAGS += -Wl,--rpath,$(x11prefix)/$(lib64)
 endif
 
-ARCH_32 = $(ARCH)
-ifeq ($(biarch), yes)
-ARCH_32 = $(TARGET_ARCH)
-LSB_LIBS = $(LSB_OBJ_DIR)/libc.so $(LSB_OBJ_DIR)/libgcc_s_32.so
-LSB_LIBS += $(LSB_CORE_STUBS:%=$(LSB_OBJ_DIR)/%.so)
-LSB_LIBS += $(LSB_CORE_STATIC_STUBS:%=$(LSB_OBJ_DIR)/%.a)
-LSB_LIBS += $(LSB_DESKTOP_STUBS:%=$(LSB_OBJ_DIR)/%.so)
-endif
-
-LSB_TOP_DIR = $(SRC_PATH)/lsb-build
-LSB_INC_DIR = $(LSB_TOP_DIR)/headers
-LSB_SRC_DIR = $(LSB_TOP_DIR)/stub_libs
-LSB_OBJ_DIR = lsb-build-$(ARCH_32)
-LSB_CORE_STUBS = $(shell cat $(LSB_SRC_DIR)/core_filelist)
-LSB_CORE_STATIC_STUBS = $(shell cat $(LSB_SRC_DIR)/core_static_filelist)
-LSB_DESKTOP_STUBS = $(shell cat $(LSB_SRC_DIR)/desktop_filelist)
-
 ifeq (i386,$(TARGET_ARCH))
 TARGET_ELF_ARCH = elf32-i386
 endif
@@ -76,33 +59,22 @@ ifeq (ppc,$(TARGET_ARCH))
 TARGET_ELF_ARCH = elf32-powerpc
 endif
 
-MOZILLA_CFLAGS = -I$(SRC_PATH)/npapi -I$(SRC_PATH)/npapi/nspr
+MOZILLA_CFLAGS = $(GECKO_CFLAGS)
+MOZILLA_LDFLAGS = $(GECKO_LDFLAGS)
 
 npwrapper_LIBRARY = npwrapper.so
-npwrapper_RAWSRCS = npw-wrapper.c npw-rpc.c rpc.c debug.c utils.c npruntime.c
+npwrapper_RAWSRCS = npw-wrapper.c npw-rpc.c rpc.c debug.c utils.c npruntime.c npw-dir.c
 npwrapper_SOURCES = $(npwrapper_RAWSRCS:%.c=$(SRC_PATH)/src/%.c)
 npwrapper_OBJECTS = $(npwrapper_RAWSRCS:%.c=npwrapper-%.os)
 npwrapper_CFLAGS  = $(CFLAGS) $(X_CFLAGS) $(MOZILLA_CFLAGS) $(GLIB_CFLAGS)
-npwrapper_LDFLAGS = $(X_LDFLAGS) $(libpthread_LDFLAGS)
-npwrapper_LDFLAGS += $(GLIB_LDFLAGS)
+npwrapper_LDFLAGS = $(LDFLAGS) $(X_LDFLAGS) $(libpthread_LDFLAGS) $(GLIB_LDFLAGS) $(MOZILLA_LDFLAGS)
 
 npviewer_PROGRAM = npviewer.bin
 npviewer_RAWSRCS = npw-viewer.c npw-rpc.c rpc.c debug.c utils.c npruntime.c
 npviewer_SOURCES = $(npviewer_RAWSRCS:%.c=$(SRC_PATH)/src/%.c)
 npviewer_OBJECTS = $(npviewer_RAWSRCS:%.c=npviewer-%.o)
-ifeq ($(biarch),yes)
-npviewer_CFLAGS  = $(CFLAGS_32)
-npviewer_CFLAGS += -I$(LSB_INC_DIR)
-npviewer_CFLAGS += -I$(LSB_INC_DIR)/glib-2.0
-npviewer_CFLAGS += -I$(LSB_INC_DIR)/gtk-2.0
-npviewer_LDFLAGS = $(LDFLAGS_32) -L$(LSB_OBJ_DIR)
-npviewer_LDFLAGS += -lgtk-x11-2.0 -lgdk-x11-2.0 -lgobject-2.0 -ldl -lglib-2.0 -lX11 -lXt
-else
-npviewer_CFLAGS += $(GTK_CFLAGS)
-npviewer_LDFLAGS = $(GTK_LDFLAGS) $(X_LDFLAGS)
-endif
-npviewer_CFLAGS  += $(MOZILLA_CFLAGS)
-npviewer_LDFLAGS += $(libdl_LDFLAGS) $(libpthread_LDFLAGS)
+npviewer_CFLAGS  = $(CFLAGS) $(GTK_CFLAGS) $(MOZILLA_CFLAGS)
+npviewer_LDFLAGS = $(LDFLAGS) $(GTK_LDFLAGS) $(X_LDFLAGS) $(libdl_LDFLAGS) $(libpthread_LDFLAGS) $(MOZILLA_LDFLAGS)
 ifeq ($(TARGET_ARCH),i386)
 npviewer_MAPFILE = $(SRC_PATH)/src/npw-viewer.map
 endif
@@ -120,13 +92,15 @@ libxpcom_LIBRARY = libxpcom.so
 libxpcom_RAWSRCS = libxpcom.c debug.c
 libxpcom_SOURCES = $(libxpcom_RAWSRCS:%.c=$(SRC_PATH)/src/%.c)
 libxpcom_OBJECTS = $(libxpcom_RAWSRCS:%.c=libxpcom-%.o)
-libxpcom_CFLAGS  = -fPIC
+libxpcom_CFLAGS  = $(CFLAGS) -fPIC
+libxpcom_LDFLAGS = $(LDFLAGS)
 
 npconfig_PROGRAM = npconfig
-npconfig_RAWSRCS = npw-config.c
+npconfig_RAWSRCS = npw-config.c npw-dir.c
 npconfig_SOURCES = $(npconfig_RAWSRCS:%.c=$(SRC_PATH)/src/%.c)
 npconfig_OBJECTS = $(npconfig_RAWSRCS:%.c=npconfig-%.o)
-npconfig_LDFLAGS = $(libdl_LDFLAGS)
+npconfig_CFLAGS  = $(CFLAGS)
+npconfig_LDFLAGS = $(LDFLAGS) $(libdl_LDFLAGS)
 ifneq (,$(findstring $(OS),netbsd dragonfly))
 # We will try to dlopen() the native plugin library. If that lib is
 # linked against libpthread, then so must our program too.
@@ -142,10 +116,8 @@ CPPFLAGS	= -I. -I$(SRC_PATH)
 TARGETS		= $(npconfig_PROGRAM)
 TARGETS		+= $(nploader_PROGRAM)
 TARGETS		+= $(npwrapper_LIBRARY)
-ifeq ($(build_viewer),yes)
 TARGETS		+= $(npviewer_PROGRAM)
 TARGETS		+= $(libxpcom_LIBRARY)
-endif
 
 archivedir	= files/
 SRCARCHIVE	= $(PACKAGE)-$(VERSION)$(VERSION_SUFFIX).tar
@@ -183,67 +155,35 @@ clean:
 distclean: clean
 	rm -f config-host.* config.*
 
-uninstall: uninstall.wrapper uninstall.viewer uninstall.libxpcom uninstall.loader uninstall.config uninstall.mkruntime uninstall.dirs
-uninstall.dirs:
-	rmdir $(DESTDIR)$(pkglibdir)/noarch
-	rmdir $(DESTDIR)$(pkglibdir)/$(ARCH)/$(OS)
-	rmdir $(DESTDIR)$(pkglibdir)/$(ARCH)
-ifneq ($(ARCH),$(ARCH_32))
-	rmdir $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)
-	rmdir $(DESTDIR)$(pkglibdir)/$(ARCH_32)
-endif
+uninstall: uninstall.wrapper uninstall.viewer uninstall.libxpcom uninstall.loader uninstall.config
 uninstall.wrapper:
-	rm -f $(DESTDIR)$(pkglibdir)/$(ARCH)/$(OS)/$(npwrapper_LIBRARY)
+	rm -f $(DESTDIR)$(pkglibdir)/$(npwrapper_LIBRARY)
 uninstall.viewer:
-	rm -f $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)/$(npviewer_PROGRAM)
-	rm -f $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)/$(npviewer_PROGRAM:%.bin=%)
+	rm -f $(DESTDIR)$(pkglibdir)/$(npviewer_PROGRAM)
+	rm -f $(DESTDIR)$(pkglibdir)/$(npviewer_PROGRAM:%.bin=%)
 uninstall.libxpcom:
-	rm -f $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)/$(libxpcom_LIBRARY)
+	rm -f $(DESTDIR)$(pkglibdir)/$(libxpcom_LIBRARY)
 uninstall.loader:
-	rm -f $(DESTDIR)$(pkglibdir)/noarch/$(nploader_PROGRAM)
+	rm -f $(DESTDIR)$(pkglibdir)/$(nploader_PROGRAM)
 uninstall.config:
-	rm -f $(DESTDIR)$(bindir)/nspluginwrapper
-	rm -f $(DESTDIR)$(pkglibdir)/$(ARCH)/$(OS)/$(npconfig_PROGRAM)
-uninstall.mkruntime:
-	rm -f $(DESTDIR)$(pkglibdir)/noarch/mkruntime
+	rm -f $(DESTDIR)$(pkglibdir)/$(npconfig_PROGRAM)
 
-install: install.dirs install.wrapper install.viewer install.libxpcom install.loader install.config install.mkruntime
+install: install.dirs install.wrapper install.viewer install.libxpcom install.loader install.config
 install.dirs:
-	mkdir -p $(DESTDIR)$(pkglibdir)/noarch
-	mkdir -p $(DESTDIR)$(pkglibdir)/$(ARCH)
-	mkdir -p $(DESTDIR)$(pkglibdir)/$(ARCH)/$(OS)
-ifneq ($(ARCH),$(ARCH_32))
-	mkdir -p $(DESTDIR)$(pkglibdir)/$(ARCH_32)
-	mkdir -p $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)
-endif
+	mkdir -p $(DESTDIR)$(pkglibdir)
 install.wrapper: $(npwrapper_LIBRARY)
-	install -m 755 $(STRIP_OPT) $(npwrapper_LIBRARY) $(DESTDIR)$(pkglibdir)/$(ARCH)/$(OS)/$(npwrapper_LIBRARY)
-ifeq ($(build_viewer),yes)
-install.viewer: install.viewer.bin install.viewer.glue
+	install -m 755 $(STRIP_OPT) $(npwrapper_LIBRARY) $(DESTDIR)$(pkglibdir)/$(npwrapper_LIBRARY)
+install.viewer: install.viewer.bin
 install.libxpcom: do.install.libxpcom
-else
-install.viewer:
-install.libxpcom:
-endif
+
 install.viewer.bin: $(npviewer_PROGRAM)
-	install -m 755 $(STRIP_OPT) $(npviewer_PROGRAM) $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)/$(npviewer_PROGRAM)
-install.viewer.glue::
-	p=$(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)/$(npviewer_PROGRAM:%.bin=%);	\
-	echo "#!/bin/sh" > $$p;								\
-	echo "TARGET_OS=$(TARGET_OS)" >> $$p;						\
-	echo "TARGET_ARCH=$(TARGET_ARCH)" >> $$p;					\
-	echo ". $(pkglibdir)/noarch/$(nploader_PROGRAM)" >> $$p;			\
-	chmod 755 $$p
+	install -m 755 $(STRIP_OPT) $(npviewer_PROGRAM) $(DESTDIR)$(pkglibdir)/$(npviewer_PROGRAM)
 do.install.libxpcom: $(libxpcom_LIBRARY)
-	install -m 755 $(STRIP_OPT) $(libxpcom_LIBRARY) $(DESTDIR)$(pkglibdir)/$(ARCH_32)/$(TARGET_OS)/$(libxpcom_LIBRARY)
+	install -m 755 $(STRIP_OPT) $(libxpcom_LIBRARY) $(DESTDIR)$(pkglibdir)/$(libxpcom_LIBRARY)
 install.config: $(npconfig_PROGRAM)
-	install -m 755 $(STRIP_OPT) $(npconfig_PROGRAM) $(DESTDIR)$(pkglibdir)/$(ARCH)/$(OS)/$(npconfig_PROGRAM)
-	mkdir -p $(DESTDIR)$(bindir)
-	ln -sf $(pkglibdir)/$(ARCH)/$(OS)/$(npconfig_PROGRAM) $(DESTDIR)$(bindir)/nspluginwrapper
+	install -m 755 $(STRIP_OPT) $(npconfig_PROGRAM) $(DESTDIR)$(pkglibdir)/$(npconfig_PROGRAM)
 install.loader: $(nploader_PROGRAM)
-	install -m 755 $(nploader_PROGRAM) $(DESTDIR)$(pkglibdir)/noarch/$(nploader_PROGRAM)
-install.mkruntime: $(SRC_PATH)/utils/mkruntime.sh
-	install -m 755 $< $(DESTDIR)$(pkglibdir)/noarch/mkruntime
+	install -m 755 $(nploader_PROGRAM) $(DESTDIR)$(pkglibdir)/$(nploader_PROGRAM)
 
 $(archivedir)::
 	[ -d $(archivedir) ] || mkdir $(archivedir) > /dev/null 2>&1
@@ -291,35 +231,40 @@ npwrapper-%.os: $(SRC_PATH)/src/%.c
 	$(CC) -o $@ -c $< -fPIC $(CPPFLAGS) $(npwrapper_CFLAGS) -DBUILD_WRAPPER
 
 $(npviewer_PROGRAM): $(npviewer_OBJECTS) $(npviewer_MAPFILE) $(LSB_OBJ_DIR) $(LSB_LIBS)
-	$(CC) $(LDFLAGS_32) -o $@ $(npviewer_OBJECTS) $(npviewer_LDFLAGS)
+	$(CC) -o $@ $(npviewer_OBJECTS) $(npviewer_LDFLAGS)
 
 npviewer-%.o: $(SRC_PATH)/src/%.c
-	$(CC) $(CFLAGS_32) -o $@ -c $< $(CPPFLAGS) $(npviewer_CFLAGS) -DBUILD_VIEWER
+	$(CC) -o $@ -c $< $(CPPFLAGS) $(npviewer_CFLAGS) -DBUILD_VIEWER
 
 npviewer-%.o: $(SRC_PATH)/src/%.cpp
-	$(CXX) $(CFLAGS_32) -o $@ -c $< $(CPPFLAGS) $(npviewer_CFLAGS) -DBUILD_VIEWER
+	$(CXX) -o $@ -c $< $(CPPFLAGS) $(npviewer_CFLAGS) -DBUILD_VIEWER
 
 $(libxpcom_LIBRARY): $(libxpcom_OBJECTS) $(LSB_OBJ_DIR) $(LSB_LIBS)
-	$(CC) $(LDFLAGS_32) -shared -o $@ $(libxpcom_OBJECTS) $(libxpcom_LDFLAGS) -Wl,--soname,libxpcom.so
+	$(CC) -shared -o $@ $(libxpcom_OBJECTS) $(libxpcom_LDFLAGS) -Wl,--soname,libxpcom.so
 
 libxpcom-%.o: $(SRC_PATH)/src/%.c
-	$(CC) $(CFLAGS_32) -o $@ -c $< $(CPPFLAGS) $(libxpcom_CFLAGS) -DBUILD_XPCOM
+	$(CC) -o $@ -c $< $(CPPFLAGS) $(libxpcom_CFLAGS) -DBUILD_XPCOM
 
 $(npconfig_PROGRAM): $(npconfig_OBJECTS)
 	$(CC) -o $@ $(npconfig_OBJECTS) $(npconfig_LDFLAGS)
 
 npconfig-%.o: $(SRC_PATH)/src/%.c
-	$(CC) -o $@ -c $< $(CPPFLAGS) $(CFLAGS)
+	$(CC) -o $@ -c $< $(CPPFLAGS) $(npconfig_CFLAGS)
 
 $(nploader_PROGRAM): $(nploader_SOURCES)
-	sed -e "s|%NPW_LIBDIR%|$(pkglibdir)|" $< > $@
+	sed -e "s|%NPW_PREFIX%|$(prefix)|" 	\
+	    -e "s|%NPW_LIB32%|$(lib32)|" 	\
+	    -e "s|%NPW_LIB64%|$(lib64)|" 	\
+	    -e "s|%TARGET_OS%|$(TARGET_OS)|" 	\
+	    -e "s|%TARGET_ARCH%|$(TARGET_ARCH)|" \
+	    -e "s|%NPW_DIR%|$(pkgdir)|" $< > $@
 	chmod 755 $@
 
 $(LSB_OBJ_DIR)::
 	@[ -d $(LSB_OBJ_DIR) ] || mkdir $(LSB_OBJ_DIR) > /dev/null 2>&1
 
 $(LSB_OBJ_DIR)/%.o: $(LSB_SRC_DIR)/%.c
-	$(CC) $(CFLAGS_32) -nostdinc -fno-builtin -I. -I$(LSB_INC_DIR) -c $< -o $@
+	$(CC) $(CFLAGS) -nostdinc -fno-builtin -I. -I$(LSB_INC_DIR) -c $< -o $@
 
 $(LSB_OBJ_DIR)/%.a: $(LSB_OBJ_DIR)/%.o
 	$(AR) rc $@ $<
@@ -332,6 +277,6 @@ $(LSB_OBJ_DIR)/libgcc_s_32.so: $(LSB_OBJ
 	ln -sf libgcc_s.so $@
 
 $(LSB_OBJ_DIR)/%.so: $(LSB_OBJ_DIR)/%.o
-	$(CC) $(LDFLAGS_32) -nostdlib -shared $< -o $@ \
+	$(CC) $(LDFLAGS) -nostdlib -shared $< -o $@ \
 		-Wl,--version-script,$(patsubst $(LSB_OBJ_DIR)/%.o,$(LSB_SRC_DIR)/%.Version,$<) \
 		-Wl,-soname,`grep "$(patsubst $(LSB_OBJ_DIR)/%.o,%,$<) " $(LSB_SRC_DIR)/LibNameMap.txt | cut -f2 -d' '`
--- nspluginwrapper-0.9.91.4/configure.rh	2007-04-02 23:42:24.000000000 +0200
+++ nspluginwrapper-0.9.91.4/configure	2007-07-11 16:44:19.000000000 +0200
@@ -21,44 +21,16 @@ TMPS="${TMPDIR1}/npw-conf-${RANDOM}-$$-$
 
 # default parameters
 prefix="/usr"
+base_lib=""
+base_libdir=""
 lib32=""
 lib64=""
-x_base_dirs=""
-biarch="guess"
-build_viewer="guess"
-linux_only="guess"
+pkglibdir=""
+x_base_dir=""
 cc="gcc -std=c99"
 cxx="g++"
-host_os=`uname -s | tr '[A-Z]' '[a-z]'`
-host_cpu=`uname -m`
 target_os="linux"
 target_cpu="i386"
-case "$host_cpu" in
-i386|i486|i586|i686|i86pc|BePC)
-    host_cpu="i386"
-    ;;
-ia64)
-    host_cpu="ia64"
-    ;;
-"Power Macintosh"|ppc)
-    host_cpu="ppc"
-    ;;
-ppc64)
-    host_cpu="ppc64"
-    ;;
-sparc)
-    host_cpu="sparc"
-    ;;
-sparc64)
-    host_cpu="sparc64"
-    ;;
-x86_64|amd64)
-    host_cpu="x86_64"
-    ;;
-*)
-    host_cpu="unknown"
-    ;;
-esac
 bigendian="no"
 
 # find source path
@@ -77,6 +49,9 @@ case "$opt" in
 --prefix=*)
     prefix=`echo $opt | cut -d '=' -f 2`
     ;;
+--pkgdir=*)
+    pkgdir=`echo $opt | cut -d '=' -f 2`
+    ;;
 --pkglibdir=*)
     pkglibdir=`echo $opt | cut -d '=' -f 2`
     ;;
@@ -86,20 +61,11 @@ case "$opt" in
 --target-cpu=*)
     target_cpu=`echo $opt | cut -d '=' -f 2 | sed -e 's/^i.86$/i386/'`
     ;;
---generic-build)
-    linux_only="no"
-    ;;
---with-biarch)
-    biarch="yes"
-    ;;
---without-biarch)
-    biarch="no"
+--with-base-lib=*)
+    base_lib=`echo $opt | cut -d '=' -f 2`
     ;;
---with-viewer)
-    build_viewer="yes"
-    ;;
---without-viewer)
-    build_viewer="no"
+--with-base-libdir=*)
+    base_libdir=`echo $opt | cut -d '=' -f 2`
     ;;
 --with-lib32=*)
     lib32=`echo $opt | cut -d '=' -f 2`
@@ -108,7 +74,7 @@ case "$opt" in
     lib64=`echo $opt | cut -d '=' -f 2`
     ;;
 --with-x11-prefix=*)
-    x_base_dirs=`echo $opt | cut -d '=' -f 2`
+    x_base_dir=`echo $opt | cut -d '=' -f 2`
     ;;
 --with-cc=*)
     cc=`echo $opt | cut -d '=' -f 2`
@@ -119,72 +85,30 @@ case "$opt" in
 esac
 done
 
-# check for linux only build
-if test "$linux_only" = "guess"; then
-    if test "$host_os" = "linux" -a "$target_os" = "linux"; then
-	linux_only="yes"
-    else
-	linux_only="no"
-    fi
-fi
-
-# check for biarch build
-if test "$biarch" = "guess"; then
-    case $host_cpu:$target_cpu in
-    x86_64:i386 | ppc64:ppc)
-	biarch="yes"
-	;;
-    *)
-	biarch="no"
-	;;
-    esac
-fi
-
-# check for viewer builds
-if test "$build_viewer" = "guess"; then
-    build_viewer="no"
-    case $host_os in
-    linux)
-	if test "$host_cpu" = "$target_cpu" -o "$biarch" = "yes"; then
-	    build_viewer="yes"
-	fi
-	;;
-    esac
+if test -z "$lib32"; then
+    lib32="lib"
 fi
-
-# check for libdir name
 if test -z "$lib64"; then
-    case $host_os in
-    linux)
-	# test if the compiler is 64bit
-        echo 'int i;' > $TMPC
-	nspluginwrapper_64bit_output=no
-	if $cc -o $TMPO -c $TMPC; then
-	    case `/usr/bin/file $TMPO` in
-	    *"ELF 64"*)
-		nspluginwrapper_64bit_output=yes
-		;;
-	    esac
-	fi
-	rm -f $TMPC $TMPO
-	;;
-    esac
-    case $host_cpu:$nspluginwrapper_64bit_output in
-    ppc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
-	lib64="lib64"
-	;;
-    *)
-	lib64="lib"
-	;;
-    esac
+    lib32="lib64"
 fi
-if test -z "$lib32"; then
-    lib32="lib"
+if test -z "$base_lib"; then
+    base_lib="lib"
+fi
+if test -z "$base_libdir"; then
+    base_libdir="/usr/lib"
 fi
 
 # check for installation root
+if test -z "$pkgdir"; then
+    pkgdir="$PACKAGE"
+fi
 if test -z "$pkglibdir"; then
-    pkglibdir="$prefix/lib/$PACKAGE"
+    pkglibdir="/usr/lib/$PACKAGE"
+fi
+
+# check prefix
+if test -z "$prefix"; then
+    prefix="/usr"
 fi
 
 # check for __attribute__((visibility())) support
@@ -261,12 +185,6 @@ if test -z "$CFLAGS"; then
 	CFLAGS="$CFLAGS -mtune=generic"
     fi
 fi
-if test "$biarch" = "yes" -a -z "$CFLAGS_32"; then
-    CFLAGS_32="-m32 -O2 -g"
-    if check_cc_option -mtune=generic $CFLAGS_32; then
-	CFLAGS_32="$CFLAGS_32 -mtune=generic"
-    fi
-fi
 
 # check for pkg-config
 pkgconfig=`which pkg-config`
@@ -298,7 +216,7 @@ fi
 rm -f $TMPC $TMPE
 
 # check for GTK+ 2.0 compile CFLAGS
-if test "$build_viewer" = "yes"; then
+#if test "$build_viewer" = "yes"; then
     if $pkgconfig --exists gtk+-2.0; then
 	GTK_CFLAGS=`$pkgconfig --cflags gtk+-2.0`
 	GTK_LDFLAGS=`$pkgconfig --libs gtk+-2.0`
@@ -319,27 +237,18 @@ EOF
 	exit 1
     fi
     rm -f $TMPC $TMPE
+#fi
+
+# check for Gecko compile CFLAGS
+if $pkgconfig --exists firefox-plugin; then
+    GECKO_CFLAGS=`$pkgconfig --cflags firefox-plugin`
+    GECKO_LDFLAGS=`$pkgconfig --libs firefox-plugin`
+else
+    echo "gecko-devel not found"
+    exit 1
 fi
 
 # check for X11 base dir
-if test -z "$x_base_dirs"; then
-    x_base_dirs="
-	/usr
-	/usr/X11R6
-	/usr/local/X11R6
-	$prefix
-    "
-fi
-for dir in $x_base_dirs; do
-    x_include_dir="$dir/include"
-    if test -f $x_include_dir/X11/Intrinsic.h; then
-	x_lib_dir="$dir/$lib64"
-	if test -f $x_lib_dir/libX11.so; then
-	    x_base_dir=$dir
-	    break
-	fi
-    fi
-done
 if test -z "$x_base_dir"; then
     echo "X11 environment not found"
     exit 1
@@ -450,15 +359,14 @@ EOF
 echo "Standard options:"
 echo "  --help                      print this message"
 echo "  --prefix=PREFIX             install in PREFIX [$prefix]"
+echo "  --pkgdir=name               name of package directory [$pkgdir]"
 echo "  --pkglibdir=ROOT            install private files in ROOT [$pkglibdir]"
 echo "  --target-os=OS              build plugin support for target OS [$target_os]"
 echo "  --target-cpu=CPU            build plugin support for target CPU [$target_cpu]"
-echo "  --with-viewer               build viewer [$build_viewer]"
 echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH          path of source code [$source_path]"
 echo "  --generic-build             don't use system-specific additions"
-echo "  --with-biarch               build both 32-bit and 64-bit components at once"
 echo "  --with-lib32=NAME           use NAME as the 32-bit library dir name [$lib32]"
 echo "  --with-lib64=NAME           use NAME as the 64-bit library dir name [$lib64]"
 echo "  --with-x11-prefix=PREFIX    use PREFIX as the X11 base dir [autodetect]"
@@ -470,17 +378,13 @@ exit 1
 fi
 
 echo "Install prefix            $prefix"
+echo "nspluginwrapper dir       $pkgdir"
 echo "nspluginwrapper root dir  $pkglibdir"
-echo "Bi-arch build             $biarch"
-echo "Build viewer              $build_viewer"
-echo "Build for Linux only      $linux_only"
 echo "32-bit library dir name   $lib32"
 echo "64-bit library dir name   $lib64"
 echo "Source path               $source_path"
 echo "C compiler                $cc"
 echo "C++ compiler              $cxx"
-echo "host OS                   $host_os"
-echo "host CPU                  $host_cpu"
 echo "host big endian           $bigendian"
 echo "target OS                 $target_os"
 echo "target CPU                $target_cpu"
@@ -494,16 +398,15 @@ echo "/* Automatically generated by conf
 echo "CC=$cc" >> $config_mak
 echo "CXX=$cxx" >> $config_mak
 echo "CFLAGS=$CFLAGS" >> $config_mak
+echo "LDFLAGS=$LDFLAGS" >> $config_mak
 echo "GLIB_CFLAGS=$GLIB_CFLAGS" >> $config_mak
 echo "GLIB_LDFLAGS=$GLIB_LDFLAGS" >> $config_mak
 echo "GTK_CFLAGS=$GTK_CFLAGS" >> $config_mak
 echo "GTK_LDFLAGS=$GTK_LDFLAGS" >> $config_mak
-if test "$biarch" = "yes"; then
-echo "LDFLAGS_32=-m32" >> $config_mak
-echo "CFLAGS_32=$CFLAGS_32" >> $config_mak
-else
-echo 'CFLAGS_32=$(CFLAGS)' >> $config_mak
-fi
+echo "GECKO_CFLAGS=$GECKO_CFLAGS" >> $config_mak
+echo "GECKO_LDFLAGS=$GECKO_LDFLAGS" >> $config_mak
+
+host_os=$target_os
 if test "$host_os" = "linux"; then
     echo "OS=linux" >> $config_mak
     echo "#define HOST_LINUX 1" >> $config_h
@@ -524,6 +427,8 @@ else
     echo "Unsupported OS"
     exit 1
 fi
+
+host_cpu=$target_cpu
 if test "$host_cpu" = "i386" ; then
     echo "ARCH=i386" >> $config_mak
     echo "#define HOST_I386 1" >> $config_h
@@ -565,16 +470,13 @@ if test -n "$fbigendian" ; then
 fi
 
 echo "SRC_PATH=$source_path" >> $config_mak
-echo "build_viewer=$build_viewer" >> $config_mak
-echo "biarch=$biarch" >> $config_mak
 echo "lib32=$lib32" >> $config_mak
 echo "lib64=$lib64" >> $config_mak
 echo "prefix=$prefix" >> $config_mak
 echo "bindir=$prefix/bin" >> $config_mak
-libdir="$prefix/$lib64"
-echo "libdir=$libdir" >> $config_mak
-echo "#define LIB \"$lib64\"" >> $config_h
-echo "#define LIBDIR \"$libdir\"" >> $config_h
+echo "base_libdir=$base_libdir" >> $config_mak
+echo "#define LIB \"$base_lib\"" >> $config_h
+echo "#define LIBDIR \"$base_libdir\"" >> $config_h
 echo "x11prefix=$x_base_dir" >> $config_mak
 
 VERSION=`sed < $source_path/$PACKAGE.spec -n '/^\%define version[	]*/s///p'`
@@ -597,8 +499,14 @@ else
     echo "#define NPW_VERSION \"$VERSION\"" >> $config_h
 fi
 
+echo "#define NPW_PREFIX \"$prefix\"" >> $config_h
+echo "#define NPW_LIB32 \"$lib32\"" >> $config_h
+echo "#define NPW_LIB64 \"$lib64\"" >> $config_h
+
+echo "pkgdir=$pkgdir" >> $config_mak
+echo "#define NPW_DIR \"$pkgdir\"" >> $config_h
+
 echo "pkglibdir=$pkglibdir" >> $config_mak
-echo "#define NPW_LIBDIR \"$pkglibdir\"" >> $config_h
 
 if test "$has_visibility_attribute" = "yes"; then
     echo "#define attribute_hidden __attribute__((visibility(\"hidden\")))" >> $config_h
@@ -626,9 +534,8 @@ config_h="config.h"
 echo "/* Automatically generated by configure - do not modify */" > $config_h
 echo "#include \"config-host.h\"" >> $config_h
 
-if test "$linux_only" = "yes"; then
-    echo "#define BUILD_LINUX_ONLY 1" >> $config_h
-fi
+# Linux only by default
+echo "#define BUILD_LINUX_ONLY 1" >> $config_h
 
 if test "$target_os" = "linux"; then
     echo "TARGET_OS=linux" >> $config_mak
@@ -647,6 +554,10 @@ if test "$target_cpu" = "i386" ; then
     echo "TARGET_ARCH=i386" >> $config_mak
     echo "#define TARGET_ARCH \"i386\"" >> $config_h
     echo "#define TARGET_I386 1" >> $config_h
+elif test "$target_cpu" = "x86_64" ; then
+    echo "TARGET_ARCH=x86_64" >> $config_mak
+    echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
+    echo "#define TARGET_X86_64 1" >> $config_h
 elif test "$target_cpu" = "ppc" ; then
     echo "TARGET_ARCH=ppc" >> $config_mak
     echo "#define TARGET_ARCH \"ppc\"" >> $config_h
@@ -665,3 +576,7 @@ if test "$source_path_used" = "yes" ; th
     esac
     ln -sf $source_path/Makefile Makefile
 fi
+
+# Don't strip binaries
+echo "DONT_STRIP=yes" >> $config_mak
+
--- nspluginwrapper-0.9.91.4/src/npw-wrapper.c.rh	2007-04-02 21:52:57.000000000 +0200
+++ nspluginwrapper-0.9.91.4/src/npw-wrapper.c	2007-07-11 16:44:19.000000000 +0200
@@ -42,6 +42,7 @@
 
 #include "rpc.h"
 #include "npw-rpc.h"
+#include "npw-dir.h"
 #include "utils.h"
 
 #define XP_UNIX 1
@@ -1742,9 +1743,9 @@ static void do_plugin_init(int is_NP_Ini
   static int init_count = 0;
   ++init_count;
   char viewer_path[PATH_MAX];
-  sprintf(viewer_path, "%s/%s/%s/%s", NPW_LIBDIR, NPW_Plugin.target_arch, NPW_Plugin.target_os, NPW_VIEWER);
+  get_viewer(viewer_path,PATH_MAX,NPW_Plugin.target_arch,NPW_VIEWER);
   char connection_path[128];
-  sprintf(connection_path, "%s/%s/%d-%d", NPW_CONNECTION_PATH, plugin_file_name, getpid(), init_count);
+  get_connection_path(connection_path, 128, plugin_file_name, init_count);  
 
   // Cache MIME info and plugin name/description
   if (g_plugin.name == NULL && g_plugin.description == NULL && g_plugin.formats == NULL) {
--- /dev/null	2007-07-11 09:36:28.615752132 +0200
+++ nspluginwrapper-0.9.91.4/src/npw-dir.c	2007-07-11 16:44:19.000000000 +0200
@@ -0,0 +1,97 @@
+/*
+ *  npw-dir.h - Directory management for nspluginwrapper
+ *
+ *  by Martin Stransky <stransky at redhat.com>
+ *
+ *  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 "sysdeps.h"
+#include "npw-dir.h"
+
+#include <assert.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/*
+Expect defined:
+#define NPW_PREFIX  (/usr)
+#define NPW_LIB32   (lib)
+#define NPW_LIB64   (lib64)
+#define NPW_DIR     (nspluginwrapper)
+*/
+
+char * get_plugin_path(char *p_path, int max_path, const char *p_arch)
+{
+  char *p_arch_lib = NULL;
+  
+  if(!strcmp(p_arch, "i386")) {    
+    p_arch_lib = NPW_LIB32;
+  }
+  else if(!strcmp(p_arch, "x86_64")) {
+    p_arch_lib = NPW_LIB64;
+  } 
+  else {
+    assert(0);
+  }    
+  snprintf(p_path,max_path,"%s/%s/%s",NPW_PREFIX,p_arch_lib,NPW_DIR);
+  return(p_path); 
+}
+
+char * get_plugin(char *p_path, int max_path, const char *p_arch, const char *p_plugin)
+{
+  char *p_arch_lib = NULL;
+  
+  if(!strcmp(p_arch, "i386")) {    
+    p_arch_lib = NPW_LIB32;
+  }
+  else if(!strcmp(p_arch, "x86_64")) {
+    p_arch_lib = NPW_LIB64;
+  } 
+  else {
+    assert(0);
+  }    
+  snprintf(p_path,max_path,"%s/%s/%s/%s",NPW_PREFIX,p_arch_lib,NPW_DIR,p_plugin);
+  return(p_path);  
+}
+
+//#define NPW_DEFAULT_PLUGIN_PATH NPW_LIBDIR "/" HOST_ARCH "/" HOST_OS "/" NPW_WRAPPER
+char * get_default_plugin(char *p_path, int max_path)
+{
+  snprintf(p_path,max_path,"%s/%s/%s",LIBDIR,NPW_DIR,NPW_WRAPPER);
+  return(p_path);
+}
+
+//#define NPW_OLD_DEFAULT_PLUGIN_PATH NPW_LIBDIR "/" HOST_ARCH "/" NPW_WRAPPER
+char * get_old_default_plugin(char *p_path, int max_path)
+{
+  return(get_default_plugin(p_path, max_path));
+}
+
+char * get_viewer_path(char *p_path, int max_path, const char *p_arch)
+{
+  return(get_plugin_path(p_path, max_path, p_arch));
+}
+
+char * get_viewer(char *p_path, int max_path, const char *p_arch, const char *p_viewer)
+{
+  return(get_plugin(p_path, max_path, p_arch, p_viewer));
+}
+
+char * get_connection_path(char *p_path, int max_path, const char *p_plugin, int init_count)
+{
+  snprintf(p_path, max_path, "%s/%s/%d-%d", NPW_CONNECTION_PATH, p_plugin, getpid(), init_count);
+  return(p_path);
+}
--- nspluginwrapper-0.9.91.4/src/debug.h.rh	2007-03-04 16:01:22.000000000 +0100
+++ nspluginwrapper-0.9.91.4/src/debug.h	2007-07-11 16:44:19.000000000 +0200
@@ -29,7 +29,7 @@ extern void npw_printf(const char *forma
 extern void npw_vprintf(const char *format, va_list args) attribute_hidden;
 
 #if DEBUG
-#define bug npw_dprintf
+#define bug npw_dprintf("%s:%d",__FILE__,__LINE__);npw_dprintf
 #define D(x) x
 #else
 #define D(x) ;
--- nspluginwrapper-0.9.91.4/src/sysdeps.h.rh	2007-03-04 16:01:22.000000000 +0100
+++ nspluginwrapper-0.9.91.4/src/sysdeps.h	2007-07-11 16:44:19.000000000 +0200
@@ -43,8 +43,8 @@
 #define NPW_VIEWER NPW_VIEWER_BASE
 #define NPW_WRAPPER_BASE "npwrapper"
 #define NPW_WRAPPER NPW_WRAPPER_BASE ".so"
-#define NPW_OLD_DEFAULT_PLUGIN_PATH NPW_LIBDIR "/" HOST_ARCH "/" NPW_WRAPPER
-#define NPW_DEFAULT_PLUGIN_PATH NPW_LIBDIR "/" HOST_ARCH "/" HOST_OS "/" NPW_WRAPPER
+#define NPW_OLD_DEFAULT_PLUGIN_PATH LIBDIR "/" NPW_DIR "/" NPW_WRAPPER
+#define NPW_DEFAULT_PLUGIN_PATH LIBDIR "/" NPW_DIR "/" NPW_WRAPPER
 #define NPW_PLUGIN_IDENT "NPW:" NPW_VERSION
 #define NPW_PLUGIN_IDENT_SIZE 32
 typedef struct __attribute__((packed)) {
--- nspluginwrapper-0.9.91.4/src/npw-viewer.sh.rh	2007-04-02 21:52:57.000000000 +0200
+++ nspluginwrapper-0.9.91.4/src/npw-viewer.sh	2007-07-11 16:44:19.000000000 +0200
@@ -4,7 +4,12 @@
 #
 OS="`uname -s`"
 ARCH="`uname -m`"
-NPW_LIBDIR="%NPW_LIBDIR%"
+NPW_PREFIX="%NPW_PREFIX%"
+NPW_LIB32="%NPW_LIB32%"
+NPW_LIB64="%NPW_LIB64%"
+TARGET_OS="%TARGET_OS%"
+TARGET_ARCH="%TARGET_ARCH%"
+NPW_DIR="%NPW_DIR%"
 
 if test -z "$TARGET_OS"; then
     echo "*** NSPlugin Viewer *** error, TARGET_OS not initialized"
@@ -16,11 +21,6 @@ if test -z "$TARGET_ARCH"; then
     exit 1
 fi
 
-NPW_VIEWER_DIR=$NPW_LIBDIR/$TARGET_ARCH/$TARGET_OS
-
-# Set a new LD_LIBRARY_PATH that is TARGET specific
-export LD_LIBRARY_PATH=$NPW_VIEWER_DIR
-
 case $ARCH in
 i?86)
     ARCH=i386
@@ -51,6 +51,9 @@ if test "$ARCH" != "$TARGET_ARCH"; then
 	    LOADER=`which qemu-i386`
 	fi
 	;;
+    x86_64)
+	LOADER=""
+	;;
     ppc)
 	if test "$ARCH" = "ppc64"; then
 	    case "$OS" in
@@ -71,15 +74,24 @@ if test "$ARCH" != "$TARGET_ARCH"; then
     fi
 fi
 
-# Don't wrap host plugins
-case " $@ " in
-*" --test "*|*" -t "*)
-    if test "$TARGET_OS" = "$OS" -a "$TARGET_ARCH" = "$ARCH"; then
-	exit 20 # EXIT_VIEWER_NATIVE
-    fi
-    ;;
+case $TARGET_ARCH in
+	i386)
+	NPW_VIEWER_DIR=$NPW_PREFIX/$NPW_LIB32/$NPW_DIR
+	;;
+	x86_64)
+	NPW_VIEWER_DIR=$NPW_PREFIX/$NPW_LIB64/$NPW_DIR
+	;;
+	ppc)
+	NPW_VIEWER_DIR=$NPW_PREFIX/$NPW_LIB32/$NPW_DIR
+	;;
+	ppc64)
+	NPW_VIEWER_DIR=$NPW_PREFIX/$NPW_LIB64/$NPW_DIR
+	;;
 esac
 
+# Set a new LD_LIBRARY_PATH that is TARGET specific
+export LD_LIBRARY_PATH=$NPW_VIEWER_DIR
+
 # Expand PATH for RealPlayer package on NetBSD (realplay)
 if test "$OS" = "NetBSD"; then
     REALPLAYER_HOME="/usr/pkg/lib/RealPlayer"
--- /dev/null	2007-07-11 09:36:28.615752132 +0200
+++ nspluginwrapper-0.9.91.4/src/npw-dir.h	2007-07-11 16:44:19.000000000 +0200
@@ -0,0 +1,35 @@
+/*
+ *  npw-dir.h - Directory management for nspluginwrapper
+ *
+ *  by Martin Stransky <stransky at redhat.com>
+ *
+ *  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
+ */
+
+#ifndef NPW_DIR_H
+#define NPW_DIR_H
+
+char * get_plugin_path(char *p_path, int max_path, const char *p_arch);
+char * get_plugin(char *p_path, int max_path, const char *p_arch, const char *p_plugin);
+
+char * get_viewer_path(char *p_path, int max_path, const char *p_arch);
+char * get_viewer(char *p_path, int max_path, const char *p_arch, const char *p_viewer);
+
+char * get_default_plugin(char *p_path, int max_path);
+char * get_old_default_plugin(char *p_path, int max_path);
+
+char * get_connection_path(char *p_path, int max_path, const char *p_plugin, int init_count);
+
+#endif
--- nspluginwrapper-0.9.91.4/src/npw-config.c.rh	2007-04-02 22:42:15.000000000 +0200
+++ nspluginwrapper-0.9.91.4/src/npw-config.c	2007-07-11 16:59:11.000000000 +0200
@@ -38,10 +38,15 @@
 #include <pwd.h>
 #include <dirent.h>
 
+#include <asm/types.h>
+
+#include "npw-dir.h"
 
 static bool g_auto = false;
 static bool g_verbose = false;
 static const char NPW_CONFIG[] = "nspluginwrapper";
+static char *p_plugin_dir = NULL;
+static char *p_plugin_prefix = NULL;
 
 static void error(const char *format, ...)
 {
@@ -254,11 +259,31 @@ static const char **get_mozilla_plugin_d
      ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
       (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
 
-/* 32-bit ELF base types.  */
-typedef uint16_t Elf32_Half;
-typedef uint32_t Elf32_Word;
-typedef uint32_t Elf32_Addr;
-typedef uint32_t Elf32_Off;
+#undef bswap_64
+#define bswap_64(x) \
+     (              \
+      (((x) & 0xff00000000000000) >> 56)  | (((x) & 0x00ff000000000000) >> 40) | \
+      (((x) & 0x00000000000000ff) << 56)  | (((x) & 0x000000000000ff00) << 40) | \
+      (((x) & 0x0000ff0000000000) >> 24)  | (((x) & 0x000000ff00000000) >>  8) | \
+      (((x) & 0x0000000000ff0000) << 24)  | (((x) & 0x00000000ff000000) <<  8) \
+     )
+
+/* 32-bit ELF base types. */
+typedef uint32_t	Elf32_Addr;
+typedef uint16_t   	Elf32_Half;
+typedef uint32_t	Elf32_Off;
+typedef int32_t	Elf32_Sword;
+typedef uint32_t	Elf32_Word;
+
+/* 64-bit ELF base types. */
+typedef uint64_t	Elf64_Addr;
+typedef uint16_t	Elf64_Half;
+typedef int16_t	Elf64_SHalf;
+typedef uint64_t	Elf64_Off;
+typedef int32_t	Elf64_Sword;
+typedef uint32_t	Elf64_Word;
+typedef uint64_t	Elf64_Xword;
+typedef int64_t	Elf64_Sxword;
 
 /* The ELF file header.  This appears at the start of every ELF file.  */
 #define EI_NIDENT (16)
@@ -281,6 +306,30 @@ typedef struct
   Elf32_Half	e_shstrndx;		/* Section header string table index */
 } Elf32_Ehdr;
 
+typedef struct elf64_hdr {
+  unsigned char e_ident[EI_NIDENT];     /* ELF "magic number" */
+  Elf64_Half 	e_type;
+  Elf64_Half 	e_machine;
+  Elf64_Word 	e_version;
+  Elf64_Addr 	e_entry;           /* Entry point virtual address */
+  Elf64_Off 	e_phoff;            /* Program header table file offset */
+  Elf64_Off 	e_shoff;            /* Section header table file offset */
+  Elf64_Word 	e_flags;
+  Elf64_Half 	e_ehsize;
+  Elf64_Half 	e_phentsize;
+  Elf64_Half 	e_phnum;
+  Elf64_Half 	e_shentsize;
+  Elf64_Half 	e_shnum;
+  Elf64_Half 	e_shstrndx;
+} Elf64_Ehdr;
+
+/* Base structure - used to distinguish between 32/64 bit version */
+typedef struct elf_hdr_base {
+
+  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
+
+} Elf_hdr_base;
+
 #define EI_MAG0		0		/* File identification byte 0 index */
 #define ELFMAG0		0x7f		/* Magic number byte 0 */
 #define EI_MAG1		1		/* File identification byte 1 index */
@@ -326,6 +375,20 @@ typedef struct
   Elf32_Word	sh_entsize;		/* Entry size if section holds table */
 } Elf32_Shdr;
 
+typedef struct elf64_shdr {
+  Elf64_Word 	sh_name;           	/* Section name, index in string tbl */
+  Elf64_Word 	sh_type;           	/* Type of section */
+  Elf64_Xword 	sh_flags;         	/* Miscellaneous section attributes */
+  Elf64_Addr 	sh_addr;           	/* Section virtual addr at execution */
+  Elf64_Off 	sh_offset;          	/* Section file offset */
+  Elf64_Xword 	sh_size;          	/* Size of section in bytes */
+  Elf64_Word 	sh_link;           	/* Index of another section */
+  Elf64_Word 	sh_info;           	/* Additional section information */
+  Elf64_Xword 	sh_addralign;     	/* Section alignment */
+  Elf64_Xword 	sh_entsize;       	/* Entry size if section holds table */
+} Elf64_Shdr;
+
+
 #define SHT_NOBITS	  8		/* Program space with no data (bss) */
 #define SHT_DYNSYM	  11		/* Dynamic linker symbol table */
 
@@ -340,17 +403,32 @@ typedef struct
   Elf32_Half	st_shndx;		/* Section index */
 } Elf32_Sym;
 
-#define ELF32_ST_BIND(val)		(((unsigned char) (val)) >> 4)
-#define ELF32_ST_TYPE(val)		((val) & 0xf)
+typedef struct elf64_sym {
+  Elf64_Word 	st_name;       		/* Symbol name, index in string tbl */
+  unsigned char st_info;    	   	/* Type and binding attributes */
+  unsigned char st_other;	      	/* No defined meaning, 0 */
+  Elf64_Half 	st_shndx;         	/* Associated section index */
+  Elf64_Addr 	st_value;          	/* Value of the symbol */
+  Elf64_Xword 	st_size;          	/* Associated symbol size */
+} Elf64_Sym;
+
+#define ELF_ST_BIND(x)          ((x) >> 4)
+#define ELF_ST_TYPE(x)          (((unsigned int) x) & 0xf)
+#define ELF32_ST_BIND(x)        ELF_ST_BIND(x)
+#define ELF32_ST_TYPE(x)        ELF_ST_TYPE(x)
+#define ELF64_ST_BIND(x)        ELF_ST_BIND(x)
+#define ELF64_ST_TYPE(x)        ELF_ST_TYPE(x)
+
 #define STB_GLOBAL	1		/* Global symbol */
 #define STT_OBJECT	1		/* Symbol is a data object */
 #define STT_FUNC	2		/* Symbol is a code object */
 
-/* We handle 32-bit ELF plugins only */
-#undef  ELF_CLASS
-#define ELF_CLASS	ELFCLASS32
-#define ElfW(x)		Elf32_ ## x
-#define ELFW(x)		ELF32_ ## x
+/* We handle 32-bit and 64-bit ELF plugins */
+#define ElfW32(x)		Elf32_ ## x
+#define ELFW32(x)		ELF32_ ## x
+
+#define ElfW64(x)		Elf64_ ## x
+#define ELFW64(x)		ELF64_ ## x
 
 void *load_data(int fd, long offset, unsigned int size)
 {
@@ -374,7 +452,7 @@ static bool is_little_endian(void)
   return x.b[0] == 0x04;
 }
 
-static void elf_swap_ehdr(ElfW(Ehdr) *hdr)
+static void elf_swap_ehdr_32(ElfW32(Ehdr) *hdr)
 {
   hdr->e_type			= bswap_16(hdr->e_type);
   hdr->e_machine		= bswap_16(hdr->e_machine);
@@ -391,7 +469,24 @@ static void elf_swap_ehdr(ElfW(Ehdr) *hd
   hdr->e_shstrndx		= bswap_16(hdr->e_shstrndx);
 }
 
-static void elf_swap_shdr(ElfW(Shdr) *shdr)
+static void elf_swap_ehdr_64(ElfW64(Ehdr) *hdr)
+{
+  hdr->e_type			= bswap_16(hdr->e_type);
+  hdr->e_machine		= bswap_16(hdr->e_machine);
+  hdr->e_version		= bswap_32(hdr->e_version);
+  hdr->e_entry			= bswap_64(hdr->e_entry);
+  hdr->e_phoff			= bswap_64(hdr->e_phoff);
+  hdr->e_shoff			= bswap_64(hdr->e_shoff);
+  hdr->e_flags			= bswap_32(hdr->e_flags);
+  hdr->e_ehsize			= bswap_16(hdr->e_ehsize);
+  hdr->e_phentsize		= bswap_16(hdr->e_phentsize);
+  hdr->e_phnum			= bswap_16(hdr->e_phnum);
+  hdr->e_shentsize		= bswap_16(hdr->e_shentsize);
+  hdr->e_shnum			= bswap_16(hdr->e_shnum);
+  hdr->e_shstrndx		= bswap_16(hdr->e_shstrndx);
+}
+
+static void elf_swap_shdr_32(ElfW32(Shdr) *shdr)
 {
   shdr->sh_name			= bswap_32(shdr->sh_name);
   shdr->sh_type			= bswap_32(shdr->sh_type);
@@ -405,35 +500,49 @@ static void elf_swap_shdr(ElfW(Shdr) *sh
   shdr->sh_entsize		= bswap_32(shdr->sh_entsize);
 }
 
-static void elf_swap_sym(ElfW(Sym) *sym)
+static void elf_swap_shdr_64(ElfW64(Shdr) *shdr)
+{
+  shdr->sh_name			= bswap_32(shdr->sh_name);
+  shdr->sh_type			= bswap_32(shdr->sh_type);
+  shdr->sh_flags		= bswap_64(shdr->sh_flags);
+  shdr->sh_addr			= bswap_64(shdr->sh_addr);
+  shdr->sh_offset		= bswap_64(shdr->sh_offset);
+  shdr->sh_size			= bswap_64(shdr->sh_size);
+  shdr->sh_link			= bswap_32(shdr->sh_link);
+  shdr->sh_info			= bswap_32(shdr->sh_info);
+  shdr->sh_addralign	= bswap_64(shdr->sh_addralign);
+  shdr->sh_entsize		= bswap_64(shdr->sh_entsize);
+}
+
+static void elf_swap_sym_32(ElfW32(Sym) *sym)
 {
   sym->st_name			= bswap_32(sym->st_name);
   sym->st_value			= bswap_32(sym->st_value);
   sym->st_size			= bswap_32(sym->st_size);
-  sym->st_shndx			= bswap_32(sym->st_shndx);
+  sym->st_shndx			= bswap_16(sym->st_shndx);
 }
 
-static bool is_plugin_fd(int fd, NPW_PluginInfo *out_plugin_info)
+static void elf_swap_sym_64(ElfW64(Sym) *sym)
+{
+  sym->st_name			= bswap_32(sym->st_name);
+  sym->st_value			= bswap_64(sym->st_value);
+  sym->st_size			= bswap_64(sym->st_size);
+  sym->st_shndx			= bswap_16(sym->st_shndx);
+}
+
+static bool is_plugin_fd_32(int fd, NPW_PluginInfo *out_plugin_info)
 {
   int i;
   bool ret = false;
 
-  ElfW(Ehdr) ehdr;
+  ElfW32(Ehdr) ehdr;
   if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
 	return false;
 
-  if (ehdr.e_ident[EI_MAG0] != ELFMAG0
-	  || ehdr.e_ident[EI_MAG1] != ELFMAG1
-	  || ehdr.e_ident[EI_MAG2] != ELFMAG2
-	  || ehdr.e_ident[EI_MAG3] != ELFMAG3)
-	return false;
-
   bool do_swap = (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) && !is_little_endian();
   if (do_swap)
-	elf_swap_ehdr(&ehdr);
+	elf_swap_ehdr_32(&ehdr);
 
-  if (ehdr.e_ident[EI_CLASS] != ELF_CLASS)
-	return false;
   if (ehdr.e_type != ET_DYN)
 	return false;
   if (ehdr.e_version != EV_CURRENT)
@@ -456,22 +565,22 @@ static bool is_plugin_fd(int fd, NPW_Plu
 	strcpy(out_plugin_info->target_os, target_os);
   }
 
-  ElfW(Shdr) *shdr = (ElfW(Shdr) *)load_data(fd, ehdr.e_shoff, ehdr.e_shnum * sizeof(*shdr));
+  ElfW32(Shdr) *shdr = (ElfW32(Shdr) *)load_data(fd, ehdr.e_shoff, ehdr.e_shnum * sizeof(*shdr));
   if (do_swap) {
 	for (i = 0; i < ehdr.e_shnum; i++)
-	  elf_swap_shdr(&shdr[i]);
+	  elf_swap_shdr_32(&shdr[i]);
   }
 
   char **sdata = (char **)calloc(ehdr.e_shnum, sizeof(*sdata));
   for (i = 0; i < ehdr.e_shnum; i++) {
-	ElfW(Shdr) *sec = &shdr[i];
+	ElfW32(Shdr) *sec = &shdr[i];
 	if (sec->sh_type != SHT_NOBITS)
 	  sdata[i] =  (char *)load_data(fd, sec->sh_offset, sec->sh_size);
   }
 
-  ElfW(Shdr) *symtab_sec = NULL;
+  ElfW32(Shdr) *symtab_sec = NULL;
   for (i = 0; i < ehdr.e_shnum; i++) {
-	ElfW(Shdr) *sec = &shdr[i];
+	ElfW32(Shdr) *sec = &shdr[i];
 	if (sec->sh_type == SHT_DYNSYM
 		&& strcmp(sdata[ehdr.e_shstrndx] + sec->sh_name, ".dynsym") == 0) {
 	  symtab_sec = sec;
@@ -480,25 +589,25 @@ static bool is_plugin_fd(int fd, NPW_Plu
   }
   if (symtab_sec == NULL)
 	goto done;
-  ElfW(Sym) *symtab = (ElfW(Sym) *)sdata[symtab_sec - shdr];
+  ElfW32(Sym) *symtab = (ElfW32(Sym) *)sdata[symtab_sec - shdr];
   char *strtab = sdata[symtab_sec->sh_link];
 
   int nb_syms = symtab_sec->sh_size / sizeof(*symtab);
   if (do_swap) {
 	for (i = 0; i < nb_syms; i++)
-	  elf_swap_sym(&symtab[i]);
+	  elf_swap_sym_32(&symtab[i]);
   }
 
   int nb_np_syms;
   int is_wrapper_plugin = 0;
   for (i = 0, nb_np_syms = 0; i < nb_syms; i++) {
-	ElfW(Sym) *sym = &symtab[i];
+	ElfW32(Sym) *sym = &symtab[i];
 	const char *name = strtab + sym->st_name;
-	if (ELFW(ST_BIND)(sym->st_info) != STB_GLOBAL)
+	if (ELFW32(ST_BIND)(sym->st_info) != STB_GLOBAL)
 	  continue;
-	if (ELFW(ST_TYPE)(sym->st_info) == STT_OBJECT && strcmp(name, "NPW_Plugin") == 0)
+	if (ELFW32(ST_TYPE)(sym->st_info) == STT_OBJECT && strcmp(name, "NPW_Plugin") == 0)
 	  is_wrapper_plugin = 1;
-	if (ELFW(ST_TYPE)(sym->st_info) != STT_FUNC)
+	if (ELFW32(ST_TYPE)(sym->st_info) != STT_FUNC)
 	  continue;
 	if (!strcmp(name, "NP_GetMIMEDescription") ||
 		!strcmp(name, "NP_Initialize") ||
@@ -515,11 +624,126 @@ static bool is_plugin_fd(int fd, NPW_Plu
   return ret;
 }
 
+static bool is_plugin_fd_64(int fd, NPW_PluginInfo *out_plugin_info)
+{
+  int i;
+  bool ret = false;
+
+  ElfW64(Ehdr) ehdr;
+  if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
+	return false;
+
+  bool do_swap = (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) && !is_little_endian();
+  if (do_swap)
+	elf_swap_ehdr_64(&ehdr);
+
+  if (ehdr.e_type != ET_DYN)
+	return false;
+  if (ehdr.e_version != EV_CURRENT)
+	return false;
+
+  if (out_plugin_info) {
+	const char *target_arch = "";
+	switch (ehdr.e_machine) {
+	case EM_X86_64:			target_arch = "x86_64";	break;
+	case EM_PPC64:			target_arch = "ppc64";	break;
+	}
+	strcpy(out_plugin_info->target_arch, target_arch);
+	const char *target_os = "";
+	switch (ehdr.e_ident[EI_OSABI]) {
+	case ELFOSABI_LINUX:	target_os = "linux";	break;
+	case ELFOSABI_SOLARIS:	target_os = "solaris";	break;
+	case ELFOSABI_FREEBSD:	target_os = "freebsd";	break;
+	}
+	strcpy(out_plugin_info->target_os, target_os);
+  }
+
+  ElfW64(Shdr) *shdr = (ElfW64(Shdr) *)load_data(fd, ehdr.e_shoff, ehdr.e_shnum * sizeof(*shdr));
+  if (do_swap) {
+	for (i = 0; i < ehdr.e_shnum; i++)
+	  elf_swap_shdr_64(&shdr[i]);
+  }
+
+  char **sdata = (char **)calloc(ehdr.e_shnum, sizeof(*sdata));
+  for (i = 0; i < ehdr.e_shnum; i++) {
+	ElfW64(Shdr) *sec = &shdr[i];
+	if (sec->sh_type != SHT_NOBITS)
+	  sdata[i] =  (char *)load_data(fd, sec->sh_offset, sec->sh_size);
+  }
+
+  ElfW64(Shdr) *symtab_sec = NULL;
+  for (i = 0; i < ehdr.e_shnum; i++) {
+	ElfW64(Shdr) *sec = &shdr[i];
+	if (sec->sh_type == SHT_DYNSYM
+		&& strcmp(sdata[ehdr.e_shstrndx] + sec->sh_name, ".dynsym") == 0) {
+	  symtab_sec = sec;
+	  break;
+	}
+  }
+  if (symtab_sec == NULL)
+	goto done;
+  ElfW64(Sym) *symtab = (ElfW64(Sym) *)sdata[symtab_sec - shdr];
+  char *strtab = sdata[symtab_sec->sh_link];
+
+  int nb_syms = symtab_sec->sh_size / sizeof(*symtab);
+  if (do_swap) {
+	for (i = 0; i < nb_syms; i++)
+	  elf_swap_sym_64(&symtab[i]);
+  }
+
+  int nb_np_syms;
+  int is_wrapper_plugin = 0;
+  for (i = 0, nb_np_syms = 0; i < nb_syms; i++) {
+	ElfW64(Sym) *sym = &symtab[i];
+	const char *name = strtab + sym->st_name;
+	if (ELFW64(ST_BIND)(sym->st_info) != STB_GLOBAL)
+	  continue;
+	if (ELFW64(ST_TYPE)(sym->st_info) == STT_OBJECT && strcmp(name, "NPW_Plugin") == 0)
+	  is_wrapper_plugin = 1;
+	if (ELFW64(ST_TYPE)(sym->st_info) != STT_FUNC)
+	  continue;
+	if (!strcmp(name, "NP_GetMIMEDescription") ||
+		!strcmp(name, "NP_Initialize") ||
+		!strcmp(name, "NP_Shutdown"))
+	  nb_np_syms++;
+  }
+  ret = (nb_np_syms == 3) && !is_wrapper_plugin;
+
+ done:
+  for (i = 0; i < ehdr.e_shnum; i++)
+	free(sdata[i]);
+  free(sdata);
+  free(shdr);
+  return ret;
+}
+
+static bool is_plugin_fd(int fd, NPW_PluginInfo *out_plugin_info)
+{
+  Elf_hdr_base ehdr;
+	
+  if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
+	return false;
+
+  if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+	  || ehdr.e_ident[EI_MAG1] != ELFMAG1
+	  || ehdr.e_ident[EI_MAG2] != ELFMAG2
+	  || ehdr.e_ident[EI_MAG3] != ELFMAG3)
+	return false;
+  
+  lseek(fd,0,SEEK_SET);
+  
+  if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
+	return(is_plugin_fd_32(fd,out_plugin_info));
+  else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
+	return(is_plugin_fd_64(fd,out_plugin_info));
+  
+  return false;
+}
+
 enum {
   EXIT_VIEWER_NOT_FOUND	= -2,
   EXIT_VIEWER_ERROR		= -1,
-  EXIT_VIEWER_OK		= 0,
-  EXIT_VIEWER_NATIVE	= 20
+  EXIT_VIEWER_OK		= 0,  
 };
 
 static int detect_plugin_viewer(const char *filename, NPW_PluginInfo *out_plugin_info)
@@ -527,6 +751,7 @@ static int detect_plugin_viewer(const ch
   static const char *target_arch_table[] = {
 	NULL,
 	"i386",
+	"x86_64",
 	NULL
   };
   const int target_arch_table_size = sizeof(target_arch_table) / sizeof(target_arch_table[0]);
@@ -552,8 +777,8 @@ static int detect_plugin_viewer(const ch
 	const char *target_arch = target_arch_table[i];
 	if (target_arch == NULL)
 	  continue;
-	char viewer_arch_path[PATH_MAX];
-	sprintf(viewer_arch_path, "%s/%s", NPW_LIBDIR, target_arch);
+	char viewer_arch_path[PATH_MAX];	
+	get_viewer_path(viewer_arch_path,PATH_MAX,target_arch);
 	if (access(viewer_arch_path, F_OK) != 0) {
 	  target_arch_table[i] = NULL;		// this target ARCH is not available, skip it for good
 	  continue;
@@ -562,10 +787,8 @@ static int detect_plugin_viewer(const ch
 	  const char *target_os = target_os_table[j];
 	  if (target_os == NULL)
 		continue;
-	  if (strcmp(target_arch, HOST_ARCH) == 0 && strcmp(target_os, HOST_OS) == 0)
-		return EXIT_VIEWER_NATIVE;		// don't wrap plugins for host OS/ARCH
 	  char viewer_path[PATH_MAX];
-	  sprintf(viewer_path, "%s/%s/%s", viewer_arch_path, target_os, NPW_VIEWER);
+	  sprintf(viewer_path, "%s/%s", viewer_arch_path, NPW_VIEWER);
 	  if (access(viewer_path, F_OK) != 0)
 		continue;
 	  int pid = fork();
@@ -727,7 +950,9 @@ static int do_install_plugin(const char 
   plugin_base += 1;
 
   char d_plugin_path[PATH_MAX];
-  int n = snprintf(d_plugin_path, sizeof(d_plugin_path), "%s/%s.%s", plugin_dir, NPW_WRAPPER_BASE, plugin_base);
+  int n = snprintf(d_plugin_path, sizeof(d_plugin_path), 
+                   "%s/%s.%s", plugin_dir, p_plugin_prefix ? p_plugin_prefix : NPW_WRAPPER_BASE, 
+                   plugin_base);
   if (n < 0 || n >= sizeof(d_plugin_path))
 	return 3;
 
@@ -813,24 +1038,30 @@ static int install_plugin(const char *pl
   if (g_verbose)
 	printf("Install plugin %s\n", plugin_path);
 
-  ret = do_install_plugin(plugin_path, get_system_mozilla_plugin_dir(), plugin_info);
-  if (ret == 0)
-	return 0;
-
-  // don't install plugin in user home dir if already available system-wide
-  if (is_system_wide_wrapper_plugin(plugin_path)) {
-	if (g_verbose)
-	  printf(" ... already installed system-wide, skipping\n");
-	return 0;
+  if(p_plugin_dir) {
+  	ret = do_install_plugin(plugin_path, p_plugin_dir, plugin_info);
   }
+  else {
 
-  const char *user_plugin_dir = get_user_mozilla_plugin_dir();
-  if (access(user_plugin_dir, R_OK | W_OK) < 0 && mkdir_p(user_plugin_dir) < 0)
-	return 1;
+  	ret = do_install_plugin(plugin_path, get_system_mozilla_plugin_dir(), plugin_info);
+	  if (ret == 0)
+		return 0;
+
+	  // don't install plugin in user home dir if already available system-wide
+	  if (is_system_wide_wrapper_plugin(plugin_path)) {
+		if (g_verbose)
+		  printf(" ... already installed system-wide, skipping\n");
+		return 0;
+	  }
 
-  ret = do_install_plugin(plugin_path, user_plugin_dir, plugin_info);
-  if (ret == 0)
-	return 0;
+	  const char *user_plugin_dir = get_user_mozilla_plugin_dir();
+	  if (access(user_plugin_dir, R_OK | W_OK) < 0 && mkdir_p(user_plugin_dir) < 0)
+		return 1;
+
+	  ret = do_install_plugin(plugin_path, user_plugin_dir, plugin_info);
+	  if (ret == 0)
+		return 0;
+  }
 
   return ret;
 }
@@ -961,6 +1192,8 @@ static void print_usage(void)
   printf("   -h --help               print this message\n");
   printf("   -v --verbose            flag: set verbose mode\n");
   printf("   -a --auto               flag: set automatic mode for plugins discovery\n");
+  printf("   -d --dir plugin-dir     flag: target plugin(s) directory\n");
+  printf("   -p --prefix prefix      flag: a prefix of wrapped plugin file\n");
   printf("   -l --list               list plugins currently installed\n");
   printf("   -u --update             update plugin(s) currently installed\n");
   printf("   -i --install [FILE(S)]  install plugin(s)\n");
@@ -986,6 +1219,18 @@ static int process_auto(int argc, char *
   return 0;
 }
 
+static int process_dir(int argc, char *argv[])
+{ 
+  p_plugin_dir = argv[0];
+  return 0;
+}
+
+static int process_prefix(int argc, char *argv[])
+{ 
+  p_plugin_prefix = argv[0];
+  return 0;
+}
+
 static int process_list(int argvc, char *argv[])
 {
   const char **plugin_dirs = get_mozilla_plugin_dirs();
@@ -1041,8 +1286,6 @@ static int process_install(int argc, cha
 	  error("%s is not a valid NPAPI plugin", plugin_path);
 	ret = detect_plugin_viewer(plugin_path, &plugin_info);
 	if (ret != EXIT_VIEWER_OK) {
-	  if (ret == EXIT_VIEWER_NATIVE)
-		return 0; /* silently ignore exit status */
 	  error("no appropriate viewer found for %s", plugin_path);
 	}
 	ret = install_plugin(plugin_path, &plugin_info);
@@ -1077,55 +1320,54 @@ static int process_remove(int argc, char
 
 int main(int argc, char *argv[])
 {
-  char **args;
-  int i, j, n_args;
-
-  n_args = argc - 1;
-  args = argv + 1;
+  int i, j;
 
-  if (n_args < 1) {
+  if (argc < 2) {
 	print_usage();
 	return 1;
   }
 
-  if (args[0][0] != '-') {
+  if (argv[1][0] != '-') {
 	print_usage();
 	return 1;
   }
 
   static const struct option {
-	char short_option;
+	const char *short_option;
 	const char *long_option;
 	int (*process_callback)(int argc, char *argv[]);
 	bool terminal;
+	int  extra_args;
   }
   options[] = {
-	{ 'h', "help",		process_help,		1 },
-	{ 'v', "verbose",	process_verbose,	0 },
-	{ 'a', "auto",		process_auto,		0 },
-	{ 'l', "list",		process_list,		1 },
-	{ 'u', "update",	process_update,		1 },
-	{ 'i', "install",	process_install,	1 },
-	{ 'r', "remove",	process_remove,		1 },
-	{  0,   NULL,		NULL,				1 }
+	{ "-h", "--help",          process_help,           1, 0 },
+        { "-v", "--verbose",       process_verbose,        0, 0 },
+        { "-a", "--auto",          process_auto,           0, 0 },
+        { "-d", "--dir",           process_dir,            0, 1 },
+        { "-p", "--prefix",        process_prefix,         0, 1 },
+        { "-l", "--list",          process_list,           1, 0 },
+        { "-u", "--update",        process_update,         1, 0 },
+        { "-i", "--install",       process_install,        1, 0 },
+        { "-r", "--remove",        process_remove,         1, 0 }
   };
 
-  for (i = 0; i < n_args; i++) {
-	const char *arg = args[i];
+  for (i = 1; i < argc; i++) {
 	const struct option *opt = NULL;
-	for (j = 0; opt == NULL && options[j].process_callback != NULL; j++) {
-	  if ((arg[0] == '-' && arg[1] == options[j].short_option && arg[2] == '\0') ||
-		  (arg[0] == '-' && arg[1] == '-' && strcmp(&arg[2], options[j].long_option) == 0))
-		opt = &options[j];
+	for (j = 0; j < sizeof(options)/sizeof(options[0]); j++) {
+	  if (!strcmp(options[j].short_option,argv[i]) || !strcmp(options[j].long_option,argv[i])) {
+	     opt = &options[j];
+       	     break;
+	  }
 	}
 	if (opt == NULL) {
-	  fprintf(stderr, "invalid option %s\n", arg);
+	  fprintf(stderr, "invalid option %s\n", argv[i]);
 	  print_usage();
 	  return 1;
 	}
-	int ret = opt->process_callback(n_args - i - 1, args + i + 1);
+	int ret = opt->process_callback(argc - i - 1, argv + i + 1);
 	if (opt->terminal)
 	  return ret;
+	i += opt->extra_args;
   }
 
   return 0;


--- NEW FILE nspluginwrapper.spec ---
# Compile as a debug package?
%define make_debug_package 0

# Target defines
%if "%{_target_cpu}" == "i386"
%define target_bits	32
%endif

%if "%{_target_cpu}" == "ppc"
%define target_bits	32
%endif

%if "%{_target_cpu}" == "x86_64"
%define target_bits	64
%endif

# Define libraries for 32/64 arches
%define lib32			lib
%define lib64			lib64
%define libdir32		/usr/lib
%define libdir64		/usr/lib64

# define nspluginswrapper libdir (invariant, including libdir)
%define pkglibdir32		%{libdir32}/%{name}
%define pkglibdir64		%{libdir64}/%{name}

# define mozilla plugin dir and back up dir for 32-bit browsers
%define plugindir32 		%{libdir32}/mozilla/plugins-wrapped

# define mozilla plugin dir and back up dir for 64-bit browsers
%define plugindir64 		%{libdir64}/mozilla/plugins-wrapped

%define build_dir 		objs-%{target_bits}

%if "%{target_bits}" == "32"
%define lib	  	%{lib32}
%define libdir  	%{libdir32}
%define pkglibdir  	%{pkglibdir32}
%define plugindir	%{plugindir32}
%else
%define lib	  	%{lib64}
%define libdir  	%{libdir64}
%define pkglibdir  	%{pkglibdir64}
%define plugindir	%{plugindir64}
%endif

Summary:	A compatibility layer for Netscape 4 plugins
Name:		nspluginwrapper
Version:	0.9.91.4
Release:	8%{?dist}
Source0:	%{name}-%{version}%{?svndate:-%{svndate}}.tar.bz2
Patch0:		nspluginwrapper-0.9.91.4-rh.patch
License:	GPL
Group:		Networking/WWW
Url:		http://gwenole.beauchesne.info/projects/nspluginwrapper/
Provides:	%{name} = %{version}-%{release}
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-buildroot
Requires:	%{_bindir}/linux32
BuildRequires:	pkgconfig gtk2-devel glib
BuildRequires:	libXt-devel cairo-devel
BuildRequires:	gecko-devel
ExclusiveArch:	i386 x86_64 ppc

%description
nspluginwrapper makes it possible to use Netscape 4 compatible plugins
compiled for %{_arch} into Mozilla for another architecture, e.g. x86_64.

This package consists in:
  * npviewer: the plugin viewer
  * npwrapper.so: the browser-side plugin
  * nspluginwrapper: a tool to manage plugins installation and update

%prep
%setup  -q
%patch0 -p1 -b .rh

# remove old/incompatibile stuff
rm -rf npapi
rm -rf lsb-build

%build
# set the propper built options
%if %{make_debug_package}
    %if "%{target_bits}" == "64"
	export CFLAGS="-g -m64 -DDEBUG"
    %else
	export CFLAGS="-g -m32 -DDEBUG"
    %endif
%else
    export CFLAGS="$RPM_OPT_FLAGS"
%endif

# set the propper built options
%if "%{target_bits}" == "64"
    export LDFLAGS="-m64 -L%{libdir64}"
%else
    export LDFLAGS="-m32 -L%{libdir32}"
%endif

mkdir %{build_dir}
pushd %{build_dir}
../configure 					\
	    --prefix=%{_prefix} 		\
	    --target-cpu=%{_target_cpu}		\
	    --pkgdir=%{name}			\
	    --pkglibdir=%{pkglibdir}	        \
	    --with-lib32=%{lib32}		\
	    --with-lib64=%{lib64}		\
	    --with-base-lib=%{lib}		\
	    --with-base-libdir=%{libdir}	\
	    --with-x11-prefix=/usr	    
	    
make
popd
	
%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{plugindir}

make -C %{build_dir} install DESTDIR=$RPM_BUILD_ROOT

ln -s %{pkglibdir}/npwrapper.so $RPM_BUILD_ROOT/%{plugindir}/npwrapper.so

%clean
rm -rf $RPM_BUILD_ROOT

%post
if [ -x /usr/bin/firefox-plugin-config ]; then
    /usr/bin/firefox-plugin-config
fi
if [ -x /usr/bin/seamonkey-plugin-config ]; then
    /usr/bin/seamonkey-plugin-config
fi

%postun
if [ -x /usr/bin/firefox-plugin-config ]; then
    /usr/bin/firefox-plugin-config
fi
if [ -x /usr/bin/seamonkey-plugin-config ]; then
    /usr/bin/seamonkey-plugin-config
fi

%files
%defattr(-,root,root)
%doc README COPYING NEWS
%dir %{pkglibdir}
%{pkglibdir}/*
%{plugindir}/*

%changelog
* Fri Jul 27 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-8
- added switch for creating debug packages

* Thu Jul 19 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-7
- integrated with firefox / seamonkey

* Tue Jul 11 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-6
- added new options to the configuration utility
- modified along new plug-ins concept

* Thu Jun 19 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-5
- updated nspluginsetup script
- added support for x86_64 plug-ins

* Thu Jun 14 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-4
- added ppc arch
- silenced installation scripts
- moved configuration to /etc/sysconfig

* Thu Jun 12 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-3
- updated nspluginsetup script and package install/uninstall scripts
- added cross-compilation support
- removed binaries stripping

* Fri Jun 8 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-2
- added BuildRequires - pkgconfig, gtk2-devel, glib, libXt-devel

* Fri Jun 8 2007 Martin Stransky <stransky at redhat.com> 0.9.91.4-1
- initial build


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/nspluginwrapper/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	27 Jul 2007 15:47:53 -0000	1.1
+++ .cvsignore	30 Jul 2007 09:52:11 -0000	1.2
@@ -0,0 +1 @@
+nspluginwrapper-0.9.91.4.tar.bz2


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/nspluginwrapper/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources	27 Jul 2007 15:47:53 -0000	1.1
+++ sources	30 Jul 2007 09:52:11 -0000	1.2
@@ -0,0 +1 @@
+76df5586c229844d28b5db40368e8912  nspluginwrapper-0.9.91.4.tar.bz2




More information about the fedora-extras-commits mailing list