Added variables and directory creations for installation rule

This commit is contained in:
Pierre Pronchery 2005-10-25 02:24:25 +00:00
parent 65760fdaaa
commit c06fbd3ac4

View File

@ -408,6 +408,11 @@ static int _variables_executables(Prefs * prefs, Config * config, FILE * fp)
} }
if(config_get(config, "", "package")) if(config_get(config, "", "package"))
fprintf(fp, "%s", "TAR\t= tar cfzv\n"); fprintf(fp, "%s", "TAR\t= tar cfzv\n");
if(targets != NULL)
{
fprintf(fp, "%s", "MKDIR\t= mkdir -p\n");
fprintf(fp, "%s", "INSTALL\t= install\n");
}
return 0; return 0;
} }
@ -937,6 +942,7 @@ static int _dist_subdir_dist(FILE * fp, String * path, String * dist)
static int _install_target(Config * config, FILE * fp, String * target); static int _install_target(Config * config, FILE * fp, String * target);
static int _write_install(Prefs * prefs, Config * config, FILE * fp) static int _write_install(Prefs * prefs, Config * config, FILE * fp)
{ {
int ret = 0;
String * subdirs; String * subdirs;
String * targets; String * targets;
int i; int i;
@ -949,36 +955,50 @@ static int _write_install(Prefs * prefs, Config * config, FILE * fp)
fprintf(fp, "%s", "\t@for i in $(SUBDIRS); do" fprintf(fp, "%s", "\t@for i in $(SUBDIRS); do"
" (cd $$i && $(MAKE) install) || exit; done\n"); " (cd $$i && $(MAKE) install) || exit; done\n");
if((targets = config_get(config, "", "targets")) != NULL) if((targets = config_get(config, "", "targets")) != NULL)
for(i = 0;; i++) for(i = 0; ret == 0; i++)
{ {
if(targets[i] != ',' && targets[i] != '\0') if(targets[i] != ',' && targets[i] != '\0')
continue; continue;
c = targets[i]; c = targets[i];
targets[i] = '\0'; targets[i] = '\0';
_install_target(config, fp, targets); ret = _install_target(config, fp, targets);
if(c == '\0') if(c == '\0')
break; break;
targets[i] = c; targets[i] = c;
targets+=i+1; targets+=i+1;
i = 0; i = 0;
} }
return 0; return ret;
} }
static int _install_target(Config * config, FILE * fp, String * target) static int _install_target(Config * config, FILE * fp, String * target)
{ {
String * type; String * type;
static Config * flag = NULL;
static int done[TT_LAST];
TargetType tt;
if((type = config_get(config, target, "type")) == NULL) if((type = config_get(config, target, "type")) == NULL)
return 1; return 1;
switch(_target_type(type)) if(flag != config)
{
flag = config;
memset(done, 0, sizeof(done));
}
switch((tt = _target_type(type)))
{ {
case TT_BINARY: case TT_BINARY:
if(!done[tt])
fprintf(fp, "%s", "\t$(MKDIR) $(DESTDIR)"
"$(BINDIR)\n");
fprintf(fp, "%s%s%s%s%s", "\t$(INSTALL) -m 0755 ", fprintf(fp, "%s%s%s%s%s", "\t$(INSTALL) -m 0755 ",
target, " $(DESTDIR)$(BINDIR)/", target, " $(DESTDIR)$(BINDIR)/",
target, "\n"); target, "\n");
break; break;
case TT_LIBRARY: case TT_LIBRARY:
if(!done[tt])
fprintf(fp, "%s", "\t$(MKDIR) $(DESTDIR)"
"$(LIBDIR)\n");
fprintf(fp, "%s%s%s%s%s", "\t$(INSTALL) -m 0644 ", fprintf(fp, "%s%s%s%s%s", "\t$(INSTALL) -m 0644 ",
target, ".a $(DESTDIR)$(LIBDIR)/", target, ".a $(DESTDIR)$(LIBDIR)/",
target, ".a\n"); target, ".a\n");
@ -990,6 +1010,7 @@ static int _install_target(Config * config, FILE * fp, String * target)
case TT_UNKNOWN: case TT_UNKNOWN:
break; break;
} }
done[tt] = 1;
return 0; return 0;
} }