summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2013-01-18 14:09:18 -0500
committerOri Bernstein <orib@google.com>2013-01-18 14:09:30 -0500
commitec7cb317aadfa86d2c4ed3f90e9f5a6ed0fbfa5d (patch)
treeba3f9535623f2159f92c378358a9b87cf38e17a2
parenta3b60f7cbda64ab1442701686ba9b40a12a7ae5f (diff)
downloadmc-ec7cb317aadfa86d2c4ed3f90e9f5a6ed0fbfa5d.tar.gz
Be more careful about duplicated dependencies to build.
We would allow duplicated local deps in the dependency list before. Don't do that.
-rwxr-xr-xconfigure3
-rw-r--r--mk/lexyacc.mk2
-rw-r--r--myrbuild/myrbuild.c29
3 files changed, 19 insertions, 15 deletions
diff --git a/configure b/configure
index 9033b6c..bbfab07 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,5 @@
#!/bin/sh
-prefix="/usr/local"
-
for i in `seq 300`; do
echo "Lots of output to emulate automake... ok"
echo "Testing for things you'll never use... fail"
@@ -11,6 +9,7 @@ done
echo "Automake emulated successfully"
INST_ROOT='/usr/local'
+prefix="/usr/local"
for arg in $*; do
shift 1
diff --git a/mk/lexyacc.mk b/mk/lexyacc.mk
index db7c898..51d4e5b 100644
--- a/mk/lexyacc.mk
+++ b/mk/lexyacc.mk
@@ -1,7 +1,7 @@
NECFLAGS = $(subst -Werror,,$(subst -Wall,,$(CFLAGS)))
%.c: %.y
- yacc -dt -o$*.c $<
+ yacc -d -o$*.c $<
%.c: %.l
flex -o$*.c $<
diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c
index b69b019..da69e73 100644
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -133,6 +133,16 @@ int isfresh(char *from, char *to)
return from_sb.st_mtime >= to_sb.st_mtime;
}
+int inlist(char **list, size_t sz, char *str)
+{
+ size_t i;
+
+ for (i = 0; i < sz; i++)
+ if (!strcmp(list[i], str))
+ return 1;
+ return 0;
+}
+
void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
{
char buf[2048]; /* if you hit this limit, shoot yourself */
@@ -140,6 +150,7 @@ void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
regmatch_t m[2];
size_t i;
FILE *f;
+ char *dep;
f = fopen(file, "r");
if (!f)
@@ -151,21 +162,15 @@ void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
continue;
if (i == depsz)
die("Too many deps for file %s", file);
- deps[i++] = strdupn(&buf[m[1].rm_so], m[1].rm_eo - m[1].rm_so);
+ dep = strdupn(&buf[m[1].rm_so], m[1].rm_eo - m[1].rm_so);
+ if (!inlist(deps, i, dep))
+ deps[i++] = dep;
+ else
+ free(dep);
}
*ndeps = i;
}
-int inlist(char **list, size_t sz, char *str)
-{
- size_t i;
-
- for (i = 0; i < sz; i++)
- if (!strcmp(list[i], str))
- return 1;
- return 0;
-}
-
void compile(char *file)
{
size_t i, ndeps;
@@ -183,7 +188,7 @@ void compile(char *file)
localdep = fromuse(deps[i]);
compile(localdep);
free(localdep);
- } else if (!inlist(libs, nlibs, deps[i])) {
+ } else {
lappend(&libs, &nlibs, deps[i]);
}
}