Common subdirectories: make-3.81.orig/.git and make-3.81/.git diff --new-file -x TAGS -u make-3.81.orig/Makefile.am make-3.81/Makefile.am --- make-3.81.orig/Makefile.am 2006-04-01 08:36:40.000000000 +0200 +++ make-3.81/Makefile.am 2007-06-08 06:53:47.000000000 +0200 @@ -41,7 +41,7 @@ make_SOURCES = ar.c arscan.c commands.c default.c dir.c expand.c file.c \ function.c getopt.c getopt1.c implicit.c job.c main.c \ - misc.c read.c remake.c $(remote) rule.c signame.c \ + misc.c read.c remake.c user_dep.c $(remote) rule.c signame.c \ strcache.c variable.c version.c vpath.c hash.c EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c diff --new-file -x TAGS -u make-3.81.orig/Makefile.in make-3.81/Makefile.in --- make-3.81.orig/Makefile.in 2006-04-01 08:40:04.000000000 +0200 +++ make-3.81/Makefile.in 2007-06-08 06:56:11.000000000 +0200 @@ -91,7 +91,7 @@ loadavg_DEPENDENCIES = am__make_SOURCES_DIST = ar.c arscan.c commands.c default.c dir.c \ expand.c file.c function.c getopt.c getopt1.c implicit.c job.c \ - main.c misc.c read.c remake.c remote-stub.c remote-cstms.c \ + main.c misc.c read.c remake.c user_dep.c remote-stub.c remote-cstms.c \ rule.c signame.c strcache.c variable.c version.c vpath.c \ hash.c @address@hidden = remote-stub$U.$(OBJEXT) @@ -101,7 +101,7 @@ expand$U.$(OBJEXT) file$U.$(OBJEXT) function$U.$(OBJEXT) \ getopt$U.$(OBJEXT) getopt1$U.$(OBJEXT) implicit$U.$(OBJEXT) \ job$U.$(OBJEXT) main$U.$(OBJEXT) misc$U.$(OBJEXT) \ - read$U.$(OBJEXT) remake$U.$(OBJEXT) $(am__objects_1) \ + read$U.$(OBJEXT) remake$U.$(OBJEXT) user_dep$U.$(OBJEXT) $(am__objects_1) \ rule$U.$(OBJEXT) signame$U.$(OBJEXT) strcache$U.$(OBJEXT) \ variable$U.$(OBJEXT) version$U.$(OBJEXT) vpath$U.$(OBJEXT) \ hash$U.$(OBJEXT) @@ -266,7 +266,7 @@ @address@hidden = remote-cstms.c make_SOURCES = ar.c arscan.c commands.c default.c dir.c expand.c file.c \ function.c getopt.c getopt1.c implicit.c job.c main.c \ - misc.c read.c remake.c $(remote) rule.c signame.c \ + misc.c read.c remake.c user_dep.c $(remote) rule.c signame.c \ strcache.c variable.c version.c vpath.c hash.c EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c @@ -445,6 +445,7 @@ @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ address@hidden@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@ @@ -520,6 +521,8 @@ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/read.c; then echo $(srcdir)/read.c; else echo read.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ remake_.c: remake.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/remake.c; then echo $(srcdir)/remake.c; else echo remake.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +user_dep_.c: .c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/user_dep.c; then echo $(srcdir)/user_dep.c; else echo user_dep.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ remote-cstms_.c: remote-cstms.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/remote-cstms.c; then echo $(srcdir)/remote-cstms.c; else echo remote-cstms.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ remote-stub_.c: remote-stub.c $(ANSI2KNR) @@ -542,7 +545,7 @@ default_.$(OBJEXT) dir_.$(OBJEXT) expand_.$(OBJEXT) file_.$(OBJEXT) \ function_.$(OBJEXT) getloadavg_.$(OBJEXT) getopt_.$(OBJEXT) \ getopt1_.$(OBJEXT) hash_.$(OBJEXT) implicit_.$(OBJEXT) job_.$(OBJEXT) \ -main_.$(OBJEXT) misc_.$(OBJEXT) read_.$(OBJEXT) remake_.$(OBJEXT) \ +main_.$(OBJEXT) misc_.$(OBJEXT) read_.$(OBJEXT) remake_.$(OBJEXT) user_dep_.$(OBJEXT) \ remote-cstms_.$(OBJEXT) remote-stub_.$(OBJEXT) rule_.$(OBJEXT) \ signame_.$(OBJEXT) strcache_.$(OBJEXT) variable_.$(OBJEXT) \ version_.$(OBJEXT) vmsjobs_.$(OBJEXT) vpath_.$(OBJEXT) : $(ANSI2KNR) Common subdirectories: make-3.81.orig/config and make-3.81/config Common subdirectories: make-3.81.orig/doc and make-3.81/doc diff --new-file -x TAGS -u make-3.81.orig/expand.c make-3.81/expand.c --- make-3.81.orig/expand.c 2006-03-15 04:31:30.000000000 +0100 +++ make-3.81/expand.c 2007-06-30 15:48:32.000000000 +0200 @@ -165,7 +165,50 @@ register struct variable *v; char *value; - v = lookup_variable (name, length); + char *dcolon; + struct variable_set_list *context = current_variable_set_list; + struct variable_set_list *save = current_variable_set_list; + + /* if the name is of the form xxx::var, the expand var in the context of target xxx */ + dcolon = lindex(name, name + length, ':'); + if (!(dcolon != NULL && dcolon + 1 < name + length && *(dcolon + 1) == ':')) { + dcolon = NULL; + } + if (dcolon != NULL) { + /* detected :: */ + const char *var_name; + unsigned int var_length; + char *context_name; + const char *context_name_s; + unsigned int context_length; + struct file *context_f; + struct variable_set_list *save; + var_name = dcolon + 2; + var_length = length - (var_name - name); + context_name_s = name; + context_length = dcolon - name; + context_name = xmalloc(context_length + 1); + memcpy(context_name, context_name_s, context_length); + context_name[context_length] = '\0'; + context_f = lookup_file(context_name); + free(context_name); + if (!context_f) { + warn_undefined (context_name_s, context_length); + return o; + } + save = current_variable_set_list; + /* FIXME: This should not be done here, but it appears that the target variables are not + initialized at this stage. A clearner solution should be found */ + initialize_file_variables(context_f, 0); + set_file_variables(context_f); + context = context_f->variables; + current_variable_set_list = context; + v = lookup_variable (var_name, var_length); + current_variable_set_list = save; + } else { + v = lookup_variable (name, length); + } + if (v == 0) warn_undefined (name, length); @@ -174,7 +217,13 @@ if (v == 0 || (*v->value == '\0' && !v->append)) return o; - value = (v->recursive ? recursively_expand (v) : v->value); + if (v->recursive) { + current_variable_set_list = context; + value = recursively_expand(v); + current_variable_set_list = save; + } else { + value = v->value; + } o = variable_buffer_output (o, value, strlen (value)); @@ -298,6 +347,9 @@ Is the resultant text a substitution reference? */ colon = lindex (beg, end, ':'); + if (colon != NULL && colon + 1 < end && *(colon + 1) == ':') { + colon = lindex(colon + 2, end, ':'); + } if (colon) { /* This looks like a substitution reference: $(FOO:A=B). */ @@ -368,6 +420,7 @@ free (value); } } + } if (colon == 0) diff --new-file -x TAGS -u make-3.81.orig/function.c make-3.81/function.c --- make-3.81.orig/function.c 2006-04-01 08:36:40.000000000 +0200 +++ make-3.81/function.c 2007-06-30 22:00:19.000000000 +0200 @@ -1387,6 +1387,65 @@ return o; } + +static char * +func_changed_value (char *o, char **argv, const char *funcname UNUSED) +{ + const char* var_name = argv[0]; + const char* new_value = argv[1]; + char* old_value = NULL; + char* result; + char* filename; + FILE* file; + unsigned int new_value_size = strlen(new_value); + unsigned int old_value_size = 0; + unsigned int old_value_alloc_size = 0; + filename = xmalloc(1 + strlen(var_name) + 1); + filename[0] = '.'; + strcpy(&filename[1], var_name); + file = fopen(filename, "r"); + if (file != NULL) { + while (1) { + int old_value_alloc_size_2 = BUFSIZ + old_value_alloc_size; + char* old_value_buf = xmalloc(old_value_alloc_size_2); + int nread; + memcpy(old_value_buf, old_value, old_value_alloc_size); + nread = + fread(&old_value_buf[old_value_size], 1, old_value_alloc_size_2 - old_value_alloc_size, file); + old_value_size += nread; + old_value_alloc_size = old_value_alloc_size_2; + if (old_value != NULL) { + free(old_value); + } + old_value = old_value_buf; + if (old_value_size < old_value_alloc_size) { + break; + } + } + } + if (old_value_size == new_value_size && + (old_value_size == 0 || memcmp(old_value, new_value, old_value_size) == 0)) { + result = o; + } else { + if (file != NULL) { + fclose(file); + } + file = fopen(filename, "w"); + fwrite(new_value, 1, new_value_size, file); + result = variable_buffer_output(o, "true", sizeof("true")); + } + + if (old_value != NULL) { + free(old_value); + } + if (file != NULL) { + fclose(file); + } + free(filename); + return result; +} + + /* \r is replaced on UNIX as well. Is this desirable? */ @@ -2081,6 +2140,7 @@ { STRING_SIZE_TUPLE("and"), 1, 0, 0, func_and}, { STRING_SIZE_TUPLE("value"), 0, 1, 1, func_value}, { STRING_SIZE_TUPLE("eval"), 0, 1, 1, func_eval}, + { STRING_SIZE_TUPLE("changed-value"), 2, 2, 1, func_changed_value}, #ifdef EXPERIMENTAL { STRING_SIZE_TUPLE("eq"), 2, 2, 1, func_eq}, { STRING_SIZE_TUPLE("not"), 0, 1, 1, func_not}, Common subdirectories: make-3.81.orig/glob and make-3.81/glob Common subdirectories: make-3.81.orig/po and make-3.81/po diff --new-file -x TAGS -u make-3.81.orig/remake.c make-3.81/remake.c --- make-3.81.orig/remake.c 2006-03-20 03:36:37.000000000 +0100 +++ make-3.81/remake.c 2007-06-10 00:06:00.000000000 +0200 @@ -23,6 +23,7 @@ #include "dep.h" #include "variable.h" #include "debug.h" +#include "user_dep.h" #include @@ -62,7 +63,7 @@ static int update_file PARAMS ((struct file *file, unsigned int depth)); static int update_file_1 PARAMS ((struct file *file, unsigned int depth)); -static int check_dep PARAMS ((struct file *file, unsigned int depth, FILE_TIMESTAMP this_mtime, int *must_make_ptr)); +static int check_dep PARAMS ((struct file *file, unsigned int depth, struct file *this_file, FILE_TIMESTAMP this_mtime, int *must_make_ptr)); static int touch_file PARAMS ((struct file *file)); static void remake_file PARAMS ((struct file *file)); static FILE_TIMESTAMP name_mtime PARAMS ((char *name)); @@ -505,7 +506,7 @@ } - dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); + dep_status |= check_dep (d->file, depth, file, this_mtime, &maybe_make); /* Restore original dontcare flag. */ if (rebuilding_makefiles) @@ -931,10 +932,11 @@ static int check_dep (struct file *file, unsigned int depth, - FILE_TIMESTAMP this_mtime, int *must_make_ptr) + struct file *this_file, FILE_TIMESTAMP this_mtime, int *must_make_ptr) { struct dep *d; int dep_status = 0; + int ood; ++depth; start_updating (file); @@ -946,10 +948,14 @@ FILE_TIMESTAMP mtime; dep_status = update_file (file, depth); check_renamed (file); - mtime = file_mtime (file); + if (has_user_dep(this_file)) { + *must_make_ptr = check_user_dep(this_file, file); + } else { + mtime = file_mtime (file); + if (mtime == NONEXISTENT_MTIME || mtime > this_mtime) + *must_make_ptr = 1; + } check_renamed (file); - if (mtime == NONEXISTENT_MTIME || mtime > this_mtime) - *must_make_ptr = 1; } else { @@ -976,7 +982,19 @@ check_renamed (file); mtime = file_mtime (file); check_renamed (file); - if (mtime != NONEXISTENT_MTIME && mtime > this_mtime) + + + /* NOTE user_dependencies: what should we do if there are intermediate files + * I decided to compare the parent non-intermediate target with the prerequisite + * this is the current make behaviour, but with mtime comparison + */ + if (has_user_dep(this_file)) { + ood = check_user_dep(this_file, file); + } else { + ood = mtime != NONEXISTENT_MTIME && mtime > this_mtime; + } + + if (ood) *must_make_ptr = 1; /* Otherwise, update all non-intermediate files we depend on, if necessary, and see whether any of them is more @@ -1012,7 +1030,7 @@ d->file->parent = file; maybe_make = *must_make_ptr; - dep_status |= check_dep (d->file, depth, this_mtime, + dep_status |= check_dep (d->file, depth, this_file, this_mtime, &maybe_make); if (! d->ignore_mtime) *must_make_ptr = maybe_make; Common subdirectories: make-3.81.orig/tests and make-3.81/tests diff --new-file -x TAGS -u make-3.81.orig/user_dep.c make-3.81/user_dep.c --- make-3.81.orig/user_dep.c 1970-01-01 01:00:00.000000000 +0100 +++ make-3.81/user_dep.c 2007-06-10 12:51:23.000000000 +0200 @@ -0,0 +1,53 @@ +#include "make.h" +#include "filedef.h" +#include "user_dep.h" +#include "variable.h" + + + +/* Determinate if there are user defined dependencies for target target */ +int has_user_dep(struct file* target) +{ + int ret; + struct variable_set_list *save; + save = current_variable_set_list; + current_variable_set_list = target->variables; + ret = lookup_variable(".OUT_OF_DATE", sizeof(".OUT_OF_DATE") - 1) != NULL; + current_variable_set_list = save; + return ret; +} + +/* Determinate if target is out of date compared to src, using user defined dependencies */ +int check_user_dep(struct file* target, struct file* src) +{ + int ret = 0; + struct variable_set_list* save; + char* cmd_eval = NULL; + int cmd_eval_len; + struct variable* ood = NULL; + struct variable_set_list* context = NULL; + save = current_variable_set_list; + current_variable_set_list = target->variables; + ood = lookup_variable(".OUT_OF_DATE", sizeof(".OUT_OF_DATE") - 1); + if (ood == NULL) { + fprintf(stderr, "Bug: if .OUT_OF_DATE not defined, this function should not have been invoked"); + goto out; + } + context = create_new_variable_set(); + define_variable_in_set("<", 1, src->name, + o_automatic, 0, + context->set, NILF); + current_variable_set_list = context; + cmd_eval = allocated_variable_expand (ood->value); + cmd_eval_len = strlen(cmd_eval); + ret = (cmd_eval_len > 0); + out: + if (context != NULL) { + free_variable_set(context); + } + if (cmd_eval != NULL) { + free(cmd_eval); + } + current_variable_set_list = save; + return ret; +} diff --new-file -x TAGS -u make-3.81.orig/user_dep.h make-3.81/user_dep.h --- make-3.81.orig/user_dep.h 1970-01-01 01:00:00.000000000 +0100 +++ make-3.81/user_dep.h 2007-06-10 00:06:48.000000000 +0200 @@ -0,0 +1,3 @@ +int check_user_dep(struct file* target, struct file* src); + +int has_user_dep(struct file* target); Common subdirectories: make-3.81.orig/w32 and make-3.81/w32