Blob Blame History Raw
--- vala-0.1.5/gen-project/valaprojectgenerator.vala.orig	2007-11-25 11:50:25.000000000 -0500
+++ vala-0.1.5/gen-project/valaprojectgenerator.vala	2007-12-04 15:59:57.000000000 -0500
@@ -193,16 +193,24 @@
 			FileUtils.set_contents (project_path + "/po/ChangeLog", "", -1);
 
 			string s;
-			FileUtils.get_contents ("/usr/share/automake/INSTALL", out s);
-			FileUtils.set_contents (project_path + "/INSTALL", s, -1);
+			string automake_path = get_automake_path ();
+			if (automake_path != null) {
+				string install_filename = automake_path + "/INSTALL";
+				if (FileUtils.test (install_filename, FileTest.EXISTS)) {
+					FileUtils.get_contents (install_filename, out s);
+					FileUtils.set_contents (project_path + "/INSTALL", s, -1);
+				}
+			}
 
 			string license_filename = null;
 			if (project_license == ProjectLicense.GPL2) {
-				license_filename = "/usr/share/automake/COPYING";
+				if (automake_path != null) {
+					license_filename = automake_path + "/COPYING";
+				}
 			} else if (project_license == ProjectLicense.LGPL2) {
 				license_filename = "/usr/share/libtool/libltdl/COPYING.LIB";
 			}
-			if (license_filename != null) {
+			if (license_filename != null && FileUtils.test (license_filename, FileTest.EXISTS)) {
 				FileUtils.get_contents (license_filename, out s);
 				FileUtils.set_contents (project_path + "/COPYING", s, -1);
 			}
@@ -558,6 +566,20 @@
 		FileUtils.set_contents (project_path + "/MAINTAINERS", s, -1);
 	}
 
+	private string get_automake_path () {
+		var automake_paths = new string[] { "/usr/share/automake",
+		                                    "/usr/share/automake-1.10",
+		                                    "/usr/share/automake-1.9" };
+
+		foreach (string automake_path in automake_paths) {
+			if (FileUtils.test (automake_path, FileTest.IS_DIR)) {
+				return automake_path;
+			}
+		}
+
+		return null;
+	}
+
 	static void main (string[] args) {
 		Gtk.init (ref args);
 
--- vala-0.1.5/gen-project/valaprojectgenerator.c.orig	2007-11-25 11:50:27.000000000 -0500
+++ vala-0.1.5/gen-project/valaprojectgenerator.c	2007-12-04 17:33:21.000000000 -0500
@@ -77,11 +77,13 @@
 static void vala_project_generator_write_linguas (ValaProjectGenerator* self, GError** error);
 static void vala_project_generator_write_authors (ValaProjectGenerator* self, GError** error);
 static void vala_project_generator_write_maintainers (ValaProjectGenerator* self, GError** error);
+static char* vala_project_generator_get_automake_path (ValaProjectGenerator* self);
 static void vala_project_generator_main (int args_length1, char** args);
 static GObject * vala_project_generator_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
 static gpointer vala_project_generator_parent_class = NULL;
 static void vala_project_generator_dispose (GObject * obj);
 static GType vala_project_generator_get_type (void);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
 
 static ValaProjectGenerator* vala_project_generator_new (void) {
@@ -206,7 +208,7 @@
 		char* _tmp22;
 		char* _tmp23;
 		char* s;
-		char* _tmp24;
+		char* automake_path;
 		char* license_filename;
 		vala_project_generator_write_autogen_sh (self, &inner_error);
 		if (inner_error != NULL) {
@@ -332,29 +334,40 @@
 		}
 		(_tmp23 = (g_free (_tmp23), NULL));
 		s = NULL;
-		g_file_get_contents ("/usr/share/automake/INSTALL", &s, NULL, &inner_error);
-		if (inner_error != NULL) {
-			if (inner_error->domain == G_FILE_ERROR) {
-				goto __catch0_g_file_error;
-			}
-			g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, inner_error->message);
-			g_clear_error (&inner_error);
-		}
-		_tmp24 = NULL;
-		g_file_set_contents ((_tmp24 = g_strconcat (self->priv->project_path, "/INSTALL", NULL)), s, -1, &inner_error);
-		if (inner_error != NULL) {
-			if (inner_error->domain == G_FILE_ERROR) {
-				goto __catch0_g_file_error;
+		automake_path = vala_project_generator_get_automake_path (self);
+		if (automake_path != NULL) {
+			char* install_filename;
+			install_filename = g_strconcat (automake_path, "/INSTALL", NULL);
+			if (g_file_test (install_filename, G_FILE_TEST_EXISTS)) {
+				char* _tmp24;
+				g_file_get_contents (install_filename, &s, NULL, &inner_error);
+				if (inner_error != NULL) {
+					if (inner_error->domain == G_FILE_ERROR) {
+						goto __catch0_g_file_error;
+					}
+					g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, inner_error->message);
+					g_clear_error (&inner_error);
+				}
+				_tmp24 = NULL;
+				g_file_set_contents ((_tmp24 = g_strconcat (self->priv->project_path, "/INSTALL", NULL)), s, -1, &inner_error);
+				if (inner_error != NULL) {
+					if (inner_error->domain == G_FILE_ERROR) {
+						goto __catch0_g_file_error;
+					}
+					g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, inner_error->message);
+					g_clear_error (&inner_error);
+				}
+				(_tmp24 = (g_free (_tmp24), NULL));
 			}
-			g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, inner_error->message);
-			g_clear_error (&inner_error);
+			(install_filename = (g_free (install_filename), NULL));
 		}
-		(_tmp24 = (g_free (_tmp24), NULL));
 		license_filename = NULL;
 		if (self->priv->project_license == VALA_PROJECT_LICENSE_GPL2) {
-			char* _tmp25;
-			_tmp25 = NULL;
-			license_filename = (_tmp25 = g_strdup ("/usr/share/automake/COPYING"), (license_filename = (g_free (license_filename), NULL)), _tmp25);
+			if (automake_path != NULL) {
+				char* _tmp25;
+				_tmp25 = NULL;
+				license_filename = (_tmp25 = g_strconcat (automake_path, "/COPYING", NULL), (license_filename = (g_free (license_filename), NULL)), _tmp25);
+			}
 		} else {
 			if (self->priv->project_license == VALA_PROJECT_LICENSE_LGPL2) {
 				char* _tmp26;
@@ -362,7 +375,7 @@
 				license_filename = (_tmp26 = g_strdup ("/usr/share/libtool/libltdl/COPYING.LIB"), (license_filename = (g_free (license_filename), NULL)), _tmp26);
 			}
 		}
-		if (license_filename != NULL) {
+		if (license_filename != NULL && g_file_test (license_filename, G_FILE_TEST_EXISTS)) {
 			char* _tmp27;
 			g_file_get_contents (license_filename, &s, NULL, &inner_error);
 			if (inner_error != NULL) {
@@ -384,6 +397,7 @@
 			(_tmp27 = (g_free (_tmp27), NULL));
 		}
 		(s = (g_free (s), NULL));
+		(automake_path = (g_free (automake_path), NULL));
 		(license_filename = (g_free (license_filename), NULL));
 	}
 	goto __finally0;
@@ -393,7 +407,7 @@
 		e = inner_error;
 		inner_error = NULL;
 		{
-			g_critical ("/home/juerg/svn/vala/gen-project/valaprojectgenerator.vala:210: Error while creating project: %s", e->message);
+			g_critical ("/local/data/builder/packages/vala/vala-0.1.5/gen-project/valaprojectgenerator.vala:218: Error while creating project: %s", e->message);
 		}
 	}
 	__finally0:
@@ -861,6 +875,40 @@
 }
 
 
+static char* vala_project_generator_get_automake_path (ValaProjectGenerator* self) {
+	char** _tmp1;
+	gint automake_paths_length1;
+	char** _tmp0;
+	char** automake_paths;
+	gpointer _tmp4;
+	g_return_val_if_fail (VALA_IS_PROJECT_GENERATOR (self), NULL);
+	_tmp1 = NULL;
+	_tmp0 = NULL;
+	automake_paths = (_tmp1 = (_tmp0 = g_new0 (char*, 3 + 1), _tmp0[0] = g_strdup ("/usr/share/automake"), _tmp0[1] = g_strdup ("/usr/share/automake-1.10"), _tmp0[2] = g_strdup ("/usr/share/automake-1.9"), _tmp0), automake_paths_length1 = 3, _tmp1);
+	{
+		char** automake_path_collection;
+		int automake_path_it;
+		automake_path_collection = automake_paths;
+		for (automake_path_it = 0; (automake_paths_length1 != -1 && automake_path_it < automake_paths_length1) || (automake_paths_length1 == -1 && automake_path_collection[automake_path_it] != NULL); automake_path_it = automake_path_it + 1) {
+			const char* _tmp3;
+			char* automake_path;
+			_tmp3 = NULL;
+			automake_path = (_tmp3 = automake_path_collection[automake_path_it], (_tmp3 == NULL ? NULL : g_strdup (_tmp3)));
+			{
+				if (g_file_test (automake_path, G_FILE_TEST_IS_DIR)) {
+					char* _tmp2;
+					_tmp2 = NULL;
+					return (_tmp2 = automake_path, (automake_paths = (_vala_array_free (automake_paths, automake_paths_length1, ((GDestroyNotify) g_free)), NULL)), _tmp2);
+				}
+				(automake_path = (g_free (automake_path), NULL));
+			}
+		}
+	}
+	return (_tmp4 = NULL, (automake_paths = (_vala_array_free (automake_paths, automake_paths_length1, ((GDestroyNotify) g_free)), NULL)), _tmp4);
+	(automake_paths = (_vala_array_free (automake_paths, automake_paths_length1, ((GDestroyNotify) g_free)), NULL));
+}
+
+
 static void vala_project_generator_main (int args_length1, char** args) {
 	ValaProjectGenerator* generator;
 	gtk_init (&args_length1, &args);
@@ -1038,5 +1086,22 @@
 }
 
 
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+	if (array != NULL && destroy_func != NULL) {
+		int i;
+		if (array_length >= 0)
+		for (i = 0; i < array_length; i = i + 1) {
+			if (((gpointer*) array)[i] != NULL)
+			destroy_func (((gpointer*) array)[i]);
+		}
+		else
+		for (i = 0; ((gpointer*) array)[i] != NULL; i = i + 1) {
+			destroy_func (((gpointer*) array)[i]);
+		}
+	}
+	g_free (array);
+}
+
+