[master] 6d3fe4d Keep a fall-back for -i, if we don't have a Makefile

Poul-Henning Kamp phk at varnish-cache.org
Thu Nov 14 09:45:57 CET 2013


commit 6d3fe4da961022259b71e741380a1a8e4e965b30
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Nov 14 08:45:42 2013 +0000

    Keep a fall-back for -i, if we don't have a Makefile

diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 951dc17..d6169e6 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -326,7 +326,8 @@ start_test(void)
 /**********************************************************************
  * i-mode = "we're inside a src-tree"
  *
- * Find the abs path to top of source dir from Makefile
+ * Find the abs path to top of source dir from Makefile, if that
+ * fails, fall back on "../../"
  *
  * Set path to all programs build directories
  *
@@ -337,7 +338,7 @@ i_mode(void)
 {
 	const char *sep;
 	struct vsb *vsb;
-	char *p;
+	char *p, *q;
 	char *topbuild;
 
 	/*
@@ -345,37 +346,45 @@ i_mode(void)
 	 * makefiles.
 	 */
 
-	p = read_file("Makefile");
-	if (p == NULL) {
-		fprintf(stderr, "No Makefile for -i flag\n");
-		exit(2);
-	}
-	p = strstr(p, "\nabs_top_builddir");
+	vsb = VSB_new_auto();
+
+	q = p = read_file("Makefile_");
 	if (p == NULL) {
-		fprintf(stderr,
-		    "could not find 'abs_top_builddir' in Makefile\n");
-		exit(2);
-	}
-	topbuild =  strchr(p + 1, '\n');
-	if (topbuild == NULL) {
-		fprintf(stderr,
-		    "No NL after 'abs_top_builddir' in Makefile\n");
-		exit(2);
-	}
-	*topbuild = '\0';
-	topbuild = strchr(p, '/');
-	if (topbuild == NULL) {
-		fprintf(stderr,
-		    "No '/' after 'abs_top_builddir' in Makefile\n");
-		exit(2);
-	}
+		fprintf(stderr, "No Makefile to search for -i flag.\n");
+		VSB_printf(vsb, "%s/../..", cwd);
+		AZ(VSB_finish(vsb));
+		topbuild = strdup(VSB_data(vsb));
+		VSB_clear(vsb);
+	} else {
+		p = strstr(p, "\nabs_top_builddir");
+		if (p == NULL) {
+			fprintf(stderr,
+			    "could not find 'abs_top_builddir' in Makefile\n");
+			exit(2);
+		}
+		topbuild =  strchr(p + 1, '\n');
+		if (topbuild == NULL) {
+			fprintf(stderr,
+			    "No NL after 'abs_top_builddir' in Makefile\n");
+			exit(2);
+		}
+		*topbuild = '\0';
+		topbuild = strchr(p, '/');
+		if (topbuild == NULL) {
+			fprintf(stderr,
+			    "No '/' after 'abs_top_builddir' in Makefile\n");
+			exit(2);
+		}
+		topbuild = strdup(topbuild);
+		free(q);
 
+	}
+	AN(topbuild);
 	extmacro_def("topbuild", "%s", topbuild);
 
 	/*
 	 * Build $PATH which can find all programs in the build tree
 	 */
-	vsb = VSB_new_auto();
 	AN(vsb);
 	VSB_printf(vsb, "PATH=");
 	sep = "";



More information about the varnish-commit mailing list