[g-a-devel] gnome-mag patch: replace gettimeofday by g_timers



Hi,

I'm sending a patch that replace the use of gettimeofday by g_timers calls. I change the struct and the variable that hold the timing statistics to magnifier.h, because the GTimers need to be initialized and I realize that in the magnifier_init fuction is the best place to do it. I don't not change they to zoom-region.h because I think that magnifier.h is a better place to it, because the timing statistics are from the magnifier and not specific to the zoom-regions.

I made other minor changes to the code and added my name to the MAINTAINERS file.

Bill, if you find the code correct, please commit it, I only ask my CVS account today.

Thanks,
Carlos.

PS.: In the diff was marked various changes to po/Makefile.in.in, but I don't change anything in this file. I checkout the module, made the changes and make the diff. I really don't understand way these differences. Can anyone explaim me?
? autom4te.cache
? compile
? depcomp
? magnifier.patch
? cursors/Makefile.in
? cursors/1_32/Makefile.in
? docs/Makefile.in
? docs/reference/Makefile.in
? docs/reference/doxygen-output.txt
? docs/reference/doxygen-warnings.txt
? docs/reference/html
? docs/reference/xml
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mag/ChangeLog,v
retrieving revision 1.165
diff -u -p -r1.165 ChangeLog
--- ChangeLog	19 Jan 2006 13:14:33 -0000	1.165
+++ ChangeLog	7 Feb 2006 19:02:39 -0000
@@ -1,3 +1,14 @@
+2006-02-07  Carlos Eduardo Rodrigues Diogenes <cerdiogenes yahoo com br>
+
+	* magnifier.c: Initialize the GTimers in magnifier_init.
+
+	* zoom-region.c: Moved the TimingStruct to magnifier.h.
+
+	* zoom-region.c: Use of g_timers in place of gettimeofday.
+
+	* Others minor modifications to avoid compiler warnings and maintain
+	  the coding style
+
 2006-01-19  Bill Haneman <bill haneman sun com>
 
 	* configure.in: Revved to 0.12.3.
Index: MAINTAINERS
===================================================================
RCS file: /cvs/gnome/gnome-mag/MAINTAINERS,v
retrieving revision 1.1
diff -u -p -r1.1 MAINTAINERS
--- MAINTAINERS	9 Dec 2002 21:47:19 -0000	1.1
+++ MAINTAINERS	7 Feb 2006 19:02:39 -0000
@@ -1 +1,2 @@
 Bill Haneman     <bill haneman sun com>
+Carlos Eduardo Rodrigues Diógenes <cerdiogenes yahoo com br>
Index: magnifier/magnifier-main.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier-main.c,v
retrieving revision 1.35
diff -u -p -r1.35 magnifier-main.c
--- magnifier/magnifier-main.c	16 Jan 2005 20:49:14 -0000	1.35
+++ magnifier/magnifier-main.c	7 Feb 2006 19:02:39 -0000
@@ -368,6 +368,8 @@ main (int argc, char** argv)
   while (poptGetNextOpt (ctx) >= 0)
 	/**/;
 
+  poptFreeContext (ctx);
+
   /** 
    * slight hack, we set $DISPLAY if --target-display is set.
    * this is because I don't think GTK+ works well with across multiple 
@@ -569,6 +571,6 @@ main (int argc, char** argv)
   
   if (pan_handle)
 	  g_source_remove (pan_handle);
-  
+
   return 0;
 }
Index: magnifier/magnifier.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.c,v
retrieving revision 1.64
diff -u -p -r1.64 magnifier.c
--- magnifier/magnifier.c	21 Jun 2005 12:14:48 -0000	1.64
+++ magnifier/magnifier.c	7 Feb 2006 19:02:39 -0000
@@ -673,7 +673,8 @@ magnifier_get_display_rect_bounds (Magni
     }
 }
 
-static void magnifier_adjust_source_size (Magnifier *magnifier)
+static void
+magnifier_adjust_source_size (Magnifier *magnifier)
 {
 	GNOME_Magnifier_RectBounds rect_bounds;	
 	gdouble vfract_top, vfract_bottom, hfract_left, hfract_right;
@@ -1885,6 +1886,11 @@ magnifier_init (Magnifier *magnifier)
 			       gdk_display_get_screen (magnifier->target_display, 
 						       magnifier->target_screen_num));
 	magnifier_init_cursor_set (magnifier, "default");
+
+	mag_timing.process = g_timer_new ();
+	mag_timing.frame = g_timer_new ();
+	mag_timing.scale = g_timer_new ();
+	mag_timing.idle = g_timer_new ();
 #ifdef DEBUG_CLIENT_CALLS
 	client_debug = (g_getenv ("MAG_CLIENT_DEBUG") != NULL);
 #endif
Index: magnifier/magnifier.h
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.h,v
retrieving revision 1.16
diff -u -p -r1.16 magnifier.h
--- magnifier/magnifier.h	5 Oct 2004 12:04:56 -0000	1.16
+++ magnifier/magnifier.h	7 Feb 2006 19:02:39 -0000
@@ -33,6 +33,7 @@ extern "C" {
 #include <bonobo/bonobo-object.h>
 #include <bonobo/bonobo-property-bag.h>
 #include <login-helper/login-helper.h>
+#include <glib.h>
 #include "GNOME_Magnifier.h"
 
 #define MAGNIFIER_TYPE         (magnifier_get_type ())
@@ -74,6 +75,81 @@ typedef struct {
         BonoboObjectClass parent_class;
         POA_GNOME_Magnifier_Magnifier__epv epv;
 } MagnifierClass;
+
+/*
+ * When running the magnifier in timing test mode (--timing-pan-rate and/or
+ * --timing-iterations), then the following output is displayed:
+ *
+ * Pan Rate           = 200
+ * Frames Processed   = 1225
+ * Width/Height/Depth = 640/1024/8
+ * Zoom Factor (x/y)  = 3.000000/3.000000
+ * Update Duration    = (avg. 0.010232) (max. 0.002685) (tot. 1.084589) seconds
+ *   Update Pixels    = (avg. 3046) pixels/frame
+ *   Update Rate      = (avg. 97.732909) (max. 372.439485) updates/second
+ *   Net Update Rate  = (avg. 0.297724) (max. 0.457741) Mpex/second
+ * Pan Latency        = (avg. 0.008229) (max. 0.562326) seconds
+ * Tot Frame Duration = (avg. 0.008363) (max. 0.562485) (tot. 10.235981)seconds
+ * Frame Rate         = (avg. 119.578189) (max. 4854.369141) frames/second
+ * Scroll Delta (x)   = (avg. 0.000000) (tot. 0) lines
+ * Scroll Delta (y)   = (avg. 5.019608) (tot. 6144) lines
+ * Scroll Rate (x)    = (avg. 0.000000) lines/second
+ * Scroll Rate (y)    = (avg. 600.235657) lines/second
+ * Net Render Rate    = (avg. 8.685322) (max. 3181.359360) Mpex/second
+ *
+ * Pan Rate             - Displays the pan rate specified on the command line.
+ *                        Only displayed if --timing-pan-rate is used.
+ * Frames Processed     - Number of frames displayed
+ * Width/Height/Depth   - The width/height/depth of magnifier display.
+ * Zoom Factor (x/y)    - The zoom factor used.
+ * Update Duration      - Average and total time spent updating new sections of
+ *                        the screen.
+ *   Update Pixels      - Number of pixels updated
+ *   Update Rate        - Number of updates possible per second.
+ *   Net Update Rate    - Number of Megapixels updated per second.
+ * Pan Latency          - Time spent from the beginning of the setROI request
+ *                        until GTK+ has finished processing the update (in
+ *                        GDK's gdk_window_update_idle idle handler.
+ * Total Frame Duration - Average and total time processing frames.
+ * Frame Rate           - Number of frames per second.
+ * Scroll Delta         - Average and total number of lines scrolled.
+ * Scroll Rate          - Number of lines scrolled per second.  Note that this
+ *                        value will be equal to the --timing-pan-rate value
+ *                        times the y zoom factor.
+ * Net Render Rate      - Number of Megapixels processed per second.
+ *
+ * When running with the --timing-output argument, similar information is
+ * displayed for each frame plus timing information for the frame.  Update
+ * information is not displayed for frames where updates do not occur.  Pan 
+ * Rate, Frames Processed, and Width/Height/Depth is not displayed for each
+ * frame, only when displaying summary information.
+ */
+
+typedef struct timing {
+	GTimer *process;
+	GTimer *frame;
+	GTimer *scale;
+	GTimer *idle;
+	gdouble scale_val;
+	gdouble idle_val;
+	gdouble frame_val;
+	int   dx;
+	int   dy;
+	gdouble scale_total;
+	gdouble idle_total;
+	gdouble frame_total;
+	int   dx_total;
+	int   dy_total;
+	long  update_pixels_total;
+	long  num_scale_samples;
+	long  num_idle_samples;
+	long  num_frame_samples;
+	long  num_line_samples;
+	gdouble last_frame_val;
+	int   last_dy;
+} TimingStruct;
+
+TimingStruct mag_timing;
 
 GdkDrawable *magnifier_get_cursor    (Magnifier *magnifier);
 GType        magnifier_get_type      (void);
Index: magnifier/zoom-region.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/zoom-region.c,v
retrieving revision 1.58
diff -u -p -r1.58 zoom-region.c
--- magnifier/zoom-region.c	16 Dec 2005 16:10:22 -0000	1.58
+++ magnifier/zoom-region.c	7 Feb 2006 19:02:40 -0000
@@ -23,7 +23,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <popt.h>
-#include <sys/time.h> /* TODO: replace timeofday with g_timers */
 #include <gdk/gdkwindow.h>
 #include <gtk/gtk.h>
 #ifdef USE_GDKPIXBUF_RENDER_TO_DRAWABLE
@@ -107,82 +106,6 @@ typedef enum {
 	ZOOM_REGION_ERROR_TOO_BIG
 } ZoomRegionPixmapCreationError;
 
-/*
- * When running the magnifier in timing test mode (--timing-pan-rate and/or --timing-iterations),
- * then the following output is displayed:
- *
- *   Pan Rate                 = 200
- *   Frames Processed         = 1225
- *   Width/Height/Depth       = 640/1024/8
- *   Zoom Factor (x/y)        = 3.000000/3.000000
- *   Update Duration          = (avg. 0.010232) (max. 0.002685) (tot. 1.084589) seconds
- *     Update Pixels          = (avg. 3046) pixels/frame
- *     Update Rate            = (avg. 97.732909) (max. 372.439485) updates/second
- *     Net Update Rate        = (avg. 0.297724) (max. 0.457741) Mpex/second
- *   Pan Latency              = (avg. 0.008229) (max. 0.562326) seconds
- *   Total Frame Duration     = (avg. 0.008363) (max. 0.562485) (tot. 10.235981) seconds
- *   Frame Rate               = (avg. 119.578189) (max. 4854.369141) frames/second
- *   Scroll Delta (x)         = (avg. 0.000000) (tot. 0) lines
- *   Scroll Delta (y)         = (avg. 5.019608) (tot. 6144) lines
- *   Scroll Rate (x)          = (avg. 0.000000) lines/second
- *   Scroll Rate (y)          = (avg. 600.235657) lines/second
- *   Net Render Rate          = (avg. 8.685322) (max. 3181.359360) Mpex/second
- *
- * Pan Rate             - Displays the pan rate specified on the command line.
- *                        Only displayed if --timing-pan-rate is used.
- * Frames Processed     - Number of frames displayed
- * Width/Height/Depth   - The width/height/depth of magnifier display.
- * Zoom Factor (x/y)    - The zoom factor used.
- * Update Duration      - Average and total time spent updating new sections of the screen.
- *   Update Pixels      - Number of pixels updated
- *   Update Rate        - Number of updates possible per second.
- *   Net Update Rate    - Number of Megapixels updated per second.
- * Pan Latency          - Time spent from the beginning of the setROI request until GTK+
- *                        has finished processing the update (in GDK's
- *                        gdk_window_update_idle idle handler.
- * Total Frame Duration - Average and total time processing frames.
- * Frame Rate           - Number of frames per second.
- * Scroll Delta         - Average and total number of lines scrolled.
- * Scroll Rate          - Number of lines scrolled per second.  Note that this value
- *                        will be equal to the --timing-pan-rate value times the
- *                        y zoom factor.
- * Net Render Rate      - Number of Megapixels processed per second.
- *
- * When running with the --timing-output argument, similar information is displayed for
- * each frame plus timing information for the frame.  Update information is not
- * displayed for frames where updates do not occur.  Pan Rate, Frames Processed,
- * and Width/Height/Depth is not displayed for each frame, only when displaying
- * summary information.
- */
-
-typedef struct timing {
-	struct timeval process_start;
-	struct timeval process_end;
-	struct timeval frame_start;
-	struct timeval frame_end;
-	struct timeval scale_start;
-	struct timeval scale_end;
-	struct timeval idle_start;
-	struct timeval idle_end;
-	float scale_val;
-	float idle_val;
-	float frame_val;
-	int   dx;
-	int   dy;
-	float scale_total;
-	float idle_total;
-	float frame_total;
-	int   dx_total;
-	int   dy_total;
-	long  update_pixels_total;
-	long  num_scale_samples;
-	long  num_idle_samples;
-	long  num_frame_samples;
-	long  num_line_samples;
-	float last_frame_val;
-	int   last_dy;
-} TimingStruct;
-
 static float timing_scale_max  = 0;
 static float timing_idle_max   = 0;
 static float timing_frame_max  = 0;
@@ -193,7 +116,6 @@ static gboolean	reset_timing   = FALSE;
 static gboolean timing_test    = FALSE;
 
 static guint pending_idle_handler = 0;
-static TimingStruct mag_timing;
 static gboolean processing_updates = FALSE;
 static gboolean timing_start = FALSE;
 
@@ -243,7 +165,7 @@ reset_timing_stats()
 	mag_timing.dy_total            = 0;
 	mag_timing.last_frame_val      = 0;
 	mag_timing.last_dy             = 0;
-	gettimeofday(&mag_timing.process_start, NULL);
+	g_timer_start (mag_timing.process);
 }
 
 /** DEBUG STUFF **/
@@ -863,7 +785,6 @@ zoom_region_paint_crosswire_cursor (Zoom
 	GdkRectangle rect;
 	GdkDrawable *cursor;
 	GdkColor color = {0, 0, 0, 0};
-	GdkColor tmp_color;
 	int x_left_clip = 0, x_right_clip = 0, y_top_clip = 0, y_bottom_clip = 0;
 	int csize = 0;
 	
@@ -1283,8 +1204,9 @@ zoom_region_expose_handler (GtkWindow * 
 	zoom_region_paint (zoom_region, &event->area);
 }
 
-static void zoom_region_update_cursor (ZoomRegion *zoom_region, int dx, int dy,
-				       GdkRectangle *clip_rect)
+static void
+zoom_region_update_cursor (ZoomRegion *zoom_region, int dx, int dy,
+			   GdkRectangle *clip_rect)
 {
 #ifdef ZOOM_REGION_DEBUG
 	g_assert (zoom_region->alive);
@@ -1805,7 +1727,7 @@ zoom_region_update (ZoomRegion *zoom_reg
 	if (subimage && zoom_region->priv->w && zoom_region->priv->w->window)
 	{
 		GdkRectangle paint_rect;
-		gettimeofday(&mag_timing.scale_start, NULL);
+		g_timer_start (mag_timing.scale);
 		DEBUG_RECT ("source rect", source_rect);
 		paint_rect = zoom_region_view_rect_from_source_rect (zoom_region, source_rect);
 		/* paint_rect = zoom_region_clip_to_scaled_pixmap (zoom_region, paint_rect); */
@@ -1814,8 +1736,8 @@ zoom_region_update (ZoomRegion *zoom_reg
 			_zoom_region_invert_pixbuf (subimage);
 
 		/** 
-		 *   XXX: We seem to be breaking with the original intention here, which was to 
-		 *   keep a fullscreen scaled pixbuf in-sync.
+		 * XXX: We seem to be breaking with the original intention 
+		 * here, which was to keep a fullscreen scaled pixbuf in-sync.
 		 **/
 		gdk_pixbuf_scale (subimage,
 				  zoom_region->priv->scaled_pixbuf,
@@ -1870,13 +1792,15 @@ zoom_region_update (ZoomRegion *zoom_reg
 		gdk_window_begin_paint_rect (zoom_region->priv->w->window, &paint_rect);
 		zoom_region_paint (zoom_region, &paint_rect);
 		gdk_window_end_paint (zoom_region->priv->w->window);
-   		gettimeofday(&mag_timing.scale_end, NULL);
+		g_timer_stop (mag_timing.scale);
 		if (timing_test) {
 			mag_timing.num_scale_samples++;
+			
+			gulong microseconds;
+
 			mag_timing.scale_val =
-				(mag_timing.scale_end.tv_sec - mag_timing.scale_start.tv_sec) +
-				((float)(mag_timing.scale_end.tv_usec - mag_timing.scale_start.tv_usec) /
-				1000000.0);
+			        g_timer_elapsed (mag_timing.scale,
+						 &microseconds);
 			mag_timing.scale_total += mag_timing.scale_val;
 
 			if (mag_timing.scale_val != 0 && (timing_scale_max == 0 ||
@@ -2049,10 +1973,12 @@ zoom_region_time_frame(ZoomRegion *zoom_
 	int height = magnifier->target_bounds.y2 - magnifier->target_bounds.y1;
 
 	mag_timing.num_frame_samples++;
-	gettimeofday(&mag_timing.frame_end, NULL);
-	mag_timing.frame_val = (mag_timing.frame_end.tv_sec - mag_timing.frame_start.tv_sec) +
-		((float)(mag_timing.frame_end.tv_usec - mag_timing.frame_start.tv_usec) /
-		1000000.0);
+	g_timer_stop (mag_timing.frame);
+
+	gulong microseconds;
+
+	mag_timing.frame_val = g_timer_elapsed (mag_timing.frame,
+						&microseconds);
 
 	mag_timing.frame_total += mag_timing.frame_val;
 	if (mag_timing.frame_val > timing_frame_max)
@@ -2165,14 +2091,15 @@ gdk_timing_idle (gpointer data)
 
 	/* Now update has finished, reset processing_updates */
 	processing_updates = FALSE;
-	gettimeofday(&mag_timing.idle_end, NULL);
+	g_timer_stop (mag_timing.idle);
 
 	if (timing_test) {
 		mag_timing.num_idle_samples++;
-		mag_timing.idle_val =
-			(mag_timing.idle_end.tv_sec - mag_timing.idle_start.tv_sec) +
-			((float)(mag_timing.idle_end.tv_usec - mag_timing.idle_start.tv_usec) /
-			1000000.0);
+
+		gulong microseconds;
+
+		mag_timing.idle_val = g_timer_elapsed (mag_timing.idle,
+						       &microseconds);
 		mag_timing.idle_total += mag_timing.idle_val;
 
 		if (mag_timing.idle_val > timing_idle_max)
@@ -2199,7 +2126,7 @@ zoom_region_align (ZoomRegion *zoom_regi
 		zoom_region_time_frame(zoom_region, magnifier);
 
 	if (timing_test) {
-		gettimeofday(&mag_timing.frame_start, NULL);
+		g_timer_start (mag_timing.frame);
 
 		if (zoom_region->timing_output) {
 			gint x, y;
@@ -2221,12 +2148,12 @@ zoom_region_align (ZoomRegion *zoom_regi
 		 * until we have processed an entire frame.
 		 */
 		if (!timing_start)
-			gettimeofday(&mag_timing.process_start, NULL);
+		        g_timer_start (mag_timing.process);
 
 		timing_start = TRUE;
 	}
 
-	gettimeofday(&mag_timing.idle_start, NULL);
+	g_timer_start (mag_timing.idle);
 
 	/*
 	 * zoom_region_align calls
@@ -2556,10 +2483,11 @@ zoom_region_pan_test (gpointer data)
 	roi.x1 = zoom_region->roi.x1;
 	roi.x2 = zoom_region->roi.x2;
 
-	gettimeofday(&mag_timing.process_end, NULL);
-	total_time = (mag_timing.process_end.tv_sec - mag_timing.process_start.tv_sec) +
-		((float)(mag_timing.process_end.tv_usec - mag_timing.process_start.tv_usec) /
-		1000000.0);
+	g_timer_stop (mag_timing.process);
+
+	gulong microseconds;
+
+	total_time = g_timer_elapsed (mag_timing.process, &microseconds);
 
 	if (mag_timing.frame_total != 0.0)
 		pixels_at_speed = total_time * zoom_region->timing_pan_rate;
Index: po/Makefile.in.in
===================================================================
RCS file: /cvs/gnome/gnome-mag/po/Makefile.in.in,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile.in.in
--- po/Makefile.in.in	2 Apr 2003 13:33:15 -0000	1.2
+++ po/Makefile.in.in	7 Feb 2006 19:02:40 -0000
@@ -11,6 +11,11 @@
 #
 # - Modified by jacob berkman <jacob ximian com> to install
 #   Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
+#
+# - Modified by Rodney Dawes <dobey novell com> for use with intltool
+#
+# We have the following line for use by intltoolize:
+# INTLTOOL_MAKEFILE
 
 GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
 PACKAGE = @PACKAGE@
@@ -27,15 +32,17 @@ VPATH = @srcdir@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 datadir = @datadir@
+datarootdir = @datarootdir@
 libdir = @libdir@
 localedir = $(libdir)/locale
 gnulocaledir = $(datadir)/locale
 gettextsrcdir = $(datadir)/glib-2.0/gettext/po
 subdir = po
+install_sh = @install_sh@
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
-MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
 
 CC = @CC@
 GENCAT = @GENCAT@
@@ -44,8 +51,8 @@ MSGFMT = @MSGFMT@
 XGETTEXT = @XGETTEXT@
 INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
 INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
-MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
-GENPOT   = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
+MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
+GENPOT   = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
 
 DEFS = @DEFS@
 CFLAGS = @CFLAGS@
@@ -58,8 +65,9 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $
 SOURCES = 
 POFILES = @POFILES@
 GMOFILES = @GMOFILES@
-DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
-$(POFILES) $(GMOFILES) $(SOURCES)
+DISTFILES = ChangeLog Makefile.in.in POTFILES.in \
+$(POFILES) $(SOURCES)
+EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
 
 POTFILES = \
 
@@ -75,13 +83,13 @@ INSTOBJEXT = @INSTOBJEXT@
 
 .po.pox:
 	$(MAKE) $(GETTEXT_PACKAGE).pot
-	$(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*pox
+	$(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox
 
 .po.mo:
 	$(MSGFMT) -o $@ $<
 
 .po.gmo:
-	file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
+	file=`echo $* | sed 's,.*/,,'`.gmo \
 	  && rm -f $$file && $(GMSGFMT) -o $$file $<
 
 .po.cat:
@@ -94,7 +102,7 @@ all: all- USE_NLS@
 all-yes: $(CATALOGS)
 all-no:
 
-$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
+$(GETTEXT_PACKAGE).pot: $(POTFILES)
 	$(GENPOT)
 
 install: install-exec install-data
@@ -102,7 +110,7 @@ install-exec:
 install-data: install-data- USE_NLS@
 install-data-no: all
 install-data-yes: all
-	if test -r "$(MKINSTALLDIRS)"; then \
+	if test -n "$(MKINSTALLDIRS)"; then \
 	  $(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
 	else \
 	  $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
@@ -116,7 +124,7 @@ install-data-yes: all
 	  esac; \
 	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
 	  dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
-	  if test -r "$(MKINSTALLDIRS)"; then \
+	  if test -n "$(MKINSTALLDIRS)"; then \
 	    $(MKINSTALLDIRS) $$dir; \
 	  else \
 	    $(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
@@ -144,7 +152,7 @@ install-data-yes: all
 	  fi; \
 	done
 	if test "$(PACKAGE)" = "glib"; then \
-	  if test -r "$(MKINSTALLDIRS)"; then \
+	  if test -n "$(MKINSTALLDIRS)"; then \
 	    $(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
 	  else \
 	    $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
@@ -172,28 +180,33 @@ uninstall:
 	  rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
 	fi
 
-check: all
+check: all $(GETTEXT_PACKAGE).pot
 
 dvi info tags TAGS ID:
 
 mostlyclean:
-	rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp
+	rm -f core core.* *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
 	rm -fr *.o
 	rm -f .intltool-merge-cache
 
 clean: mostlyclean
 
 distclean: clean
-	rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
+	rm -f Makefile Makefile.in POTFILES
+	rm -f *.mo *.msg *.cat *.cat.m $(GMOFILES)
 
 maintainer-clean: distclean
 	@echo "This command is intended for maintainers to use;"
 	@echo "it deletes files that may require special tools to rebuild."
-	rm -f $(GMOFILES)
+	rm -f Makefile.in.in
 
 distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
-dist distdir: update-po $(DISTFILES)
+dist distdir: $(DISTFILES)
 	dists="$(DISTFILES)"; \
+	extra_dists="$(EXTRA_DISTFILES)"; \
+	for file in $$extra_dists; do \
+	  test -f $$file && dists="$$dists $$file"; \
+	done; \
 	for file in $$dists; do \
 	  ln $(srcdir)/$$file $(distdir) 2> /dev/null \
 	    || cp -p $(srcdir)/$$file $(distdir); \
@@ -202,14 +215,14 @@ dist distdir: update-po $(DISTFILES)
 update-po: Makefile
 	$(MAKE) $(GETTEXT_PACKAGE).pot
 	tmpdir=`pwd`; \
-	cd $(srcdir); \
 	catalogs='$(CATALOGS)'; \
 	for cat in $$catalogs; do \
 	  cat=`basename $$cat`; \
 	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
 	  echo "$$lang:"; \
-	  if $$tmpdir/$(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist -o $$tmpdir/$$lang.new.po $$lang; then \
-	    if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+	  result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
+	  if $$result; then \
+	    if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
 	      rm -f $$tmpdir/$$lang.new.po; \
             else \
 	      if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
@@ -230,17 +243,13 @@ update-po: Makefile
 # and Intltool tags (enclosed in square brackets), and appending a full
 # relative path to them
 POTFILES: POTFILES.in
-	( if test 'x$(srcdir)' != 'x.'; then \
-	    posrcprefix='$(top_srcdir)/'; \
-	  else \
-	    posrcprefix="../"; \
-	  fi; \
+	( posrcprefix='$(top_srcdir)/'; \
 	  rm -f $ -t $@ \
-	    && (sed -e '/^#/d' 						\
-		    -e "s/^\[.*\] +//" 					\
-		    -e '/^[ 	]*$$/d' 				\
-		    -e "s  *@	$$posrcprefix& \\\\@" < $(srcdir)/$  in	\
-		| sed -e '$$s/\\$$//') > $ -t \
+	    && (sed -e '/^#/d' 					\
+		    -e 's/^[[].*] *//' 				\
+		    -e '/^[ 	]*$$/d' 			\
+		    -e "s ^@	$$posrcprefix@" $(srcdir)/$  in	\
+		| sed -e '$$!s/$$/ \\/') > $ -t \
 	    && chmod a-w $ -t \
 	    && mv $ -t $@ )
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]