Merge branch 'khorben/project-mode' into master

This commit is contained in:
Pierre Pronchery 2021-01-09 19:51:05 +01:00
commit fc8836828b
9 changed files with 231 additions and 80 deletions

View File

@ -126,6 +126,8 @@ dist:
$(PACKAGE)-$(VERSION)/tests/libtool/Makefile.Linux \ $(PACKAGE)-$(VERSION)/tests/libtool/Makefile.Linux \
$(PACKAGE)-$(VERSION)/tests/libtool/Makefile.NetBSD \ $(PACKAGE)-$(VERSION)/tests/libtool/Makefile.NetBSD \
$(PACKAGE)-$(VERSION)/tests/libtool/Makefile.Windows \ $(PACKAGE)-$(VERSION)/tests/libtool/Makefile.Windows \
$(PACKAGE)-$(VERSION)/tests/mode/project.conf \
$(PACKAGE)-$(VERSION)/tests/mode/Makefile.NetBSD \
$(PACKAGE)-$(VERSION)/tests/object/project.conf \ $(PACKAGE)-$(VERSION)/tests/object/project.conf \
$(PACKAGE)-$(VERSION)/tests/object/Makefile.NetBSD \ $(PACKAGE)-$(VERSION)/tests/object/Makefile.NetBSD \
$(PACKAGE)-$(VERSION)/tests/package/project.conf \ $(PACKAGE)-$(VERSION)/tests/package/project.conf \

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2004-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2004-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel configure */ /* This file is part of DeforaOS Devel configure */
/* All rights reserved. /* All rights reserved.
* *
@ -72,6 +72,7 @@ struct _Configure
/* prefs */ /* prefs */
String * prefs_os; String * prefs_os;
String * prefs_mode;
}; };
@ -161,6 +162,9 @@ Configure * configure_new(ConfigurePrefs * prefs)
if((configure = object_new(sizeof(*configure))) == NULL) if((configure = object_new(sizeof(*configure))) == NULL)
return NULL; return NULL;
configure->config = NULL;
configure->prefs_mode = NULL;
configure->prefs_os = NULL;
if(prefs != NULL) if(prefs != NULL)
{ {
/* copy the strings */ /* copy the strings */
@ -173,8 +177,15 @@ Configure * configure_new(ConfigurePrefs * prefs)
return NULL; return NULL;
} }
} }
else if(prefs->mode != NULL && string_get_length(prefs->mode) > 0)
configure->prefs_os = NULL; {
if((configure->prefs_mode = string_new(prefs->mode))
== NULL)
{
configure_delete(configure);
return NULL;
}
}
configure->prefs = *prefs; configure->prefs = *prefs;
configure->prefs.os = configure->prefs_os; configure->prefs.os = configure->prefs_os;
} }
@ -298,6 +309,8 @@ static int _new_load_config(Configure * configure)
/* configure_delete */ /* configure_delete */
void configure_delete(Configure * configure) void configure_delete(Configure * configure)
{ {
if(configure->prefs_mode != NULL)
string_delete(configure->prefs_mode);
if(configure->prefs_os != NULL) if(configure->prefs_os != NULL)
string_delete(configure->prefs_os); string_delete(configure->prefs_os);
if(configure->config != NULL) if(configure->config != NULL)
@ -328,6 +341,27 @@ String const * configure_get_config(Configure * configure,
} }
/* configure_get_config_mode */
String const * configure_get_config_mode(Configure * configure,
String const * mode, String const * variable)
{
String const * ret;
String * section;
if(mode == NULL || string_get_length(mode) == 0)
mode = configure_get_mode(configure);
if(mode == NULL)
return configure_get_config(configure, NULL, variable);
if((section = string_new_append("mode::", mode, NULL)) == NULL)
return NULL;
ret = configure_get_config(configure, section, variable);
string_delete(section);
if(ret != NULL)
return ret;
return configure_get_config(configure, NULL, variable);
}
/* configure_get_exeext */ /* configure_get_exeext */
String const * configure_get_extension(Configure * configure, String const * configure_get_extension(Configure * configure,
String const * extension) String const * extension)
@ -338,6 +372,32 @@ String const * configure_get_extension(Configure * configure,
} }
/* configure_get_mode */
String const * configure_get_mode(Configure * configure)
{
if(configure->prefs.mode != NULL)
return configure->prefs.mode;
return configure_get_config(configure, NULL, "mode");
}
/* configure_get_mode_title */
String const * configure_get_mode_title(Configure * configure,
String const * mode)
{
String const * title;
String * section;
if(mode == NULL)
return NULL;
if((section = string_new_append("mode::", mode, NULL)) == NULL)
return NULL;
title = config_get(configure->config, section, "title");
string_delete(section);
return title;
}
/* configure_get_os */ /* configure_get_os */
HostOS configure_get_os(Configure * configure) HostOS configure_get_os(Configure * configure)
{ {
@ -380,6 +440,21 @@ unsigned int configure_is_flag_set(Configure * configure, unsigned int flags)
} }
/* configure_set_mode */
int configure_set_mode(Configure * configure, String const * mode)
{
String * m;
if(mode == NULL || string_get_length(mode) == 0)
m = NULL;
else if((m = string_new(mode)) == NULL)
return -1;
string_delete(configure->prefs_mode);
configure->prefs.mode = configure->prefs_mode = m;
return 0;
}
/* configure_set_path */ /* configure_set_path */
int configure_set_path(Configure * configure, String const * path, int configure_set_path(Configure * configure, String const * path,
String const * value) String const * value)

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2006-2019 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2006-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel configure */ /* This file is part of DeforaOS Devel configure */
/* All rights reserved. /* All rights reserved.
* *
@ -133,6 +133,7 @@ extern const struct ExtensionType * sExtensionType;
typedef struct _ConfigurePrefs typedef struct _ConfigurePrefs
{ {
unsigned int flags; unsigned int flags;
String const * mode;
String const * os; String const * os;
} ConfigurePrefs; } ConfigurePrefs;
# define PREFS_n 0x1 # define PREFS_n 0x1
@ -151,8 +152,13 @@ int configure_can_library_static(Configure * configure);
String const * configure_get_config(Configure * configure, String const * configure_get_config(Configure * configure,
String const * section, String const * variable); String const * section, String const * variable);
String const * configure_get_config_mode(Configure * configure,
String const * mode, String const * variable);
String const * configure_get_extension(Configure * configure, String const * configure_get_extension(Configure * configure,
String const * extension); String const * extension);
String const * configure_get_mode(Configure * configure);
String const * configure_get_mode_title(Configure * configure,
String const * mode);
String const * configure_get_path(Configure * configure, String const * path); String const * configure_get_path(Configure * configure, String const * path);
HostOS configure_get_os(Configure * configure); HostOS configure_get_os(Configure * configure);
ConfigurePrefs const * configure_get_prefs(Configure * configure); ConfigurePrefs const * configure_get_prefs(Configure * configure);
@ -161,6 +167,7 @@ String const * configure_get_program(Configure * configure,
unsigned int configure_is_flag_set(Configure * configure, unsigned int flags); unsigned int configure_is_flag_set(Configure * configure, unsigned int flags);
int configure_set_mode(Configure * configure, String const * mode);
int configure_set_path(Configure * configure, String const * path, int configure_set_path(Configure * configure, String const * path,
String const * value); String const * value);

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2014-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2014-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel configure */ /* This file is part of DeforaOS Devel configure */
/* All rights reserved. /* All rights reserved.
* *
@ -92,7 +92,7 @@ static int _usage(void)
return configure_error(2, "%s", error_get(NULL)); return configure_error(2, "%s", error_get(NULL));
fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s%s%s%s", fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s%s%s%s",
"Usage: " PROGNAME " [-nqSv][-b bindir][-d destdir][-i includedir][-l libdir]\n" "Usage: " PROGNAME " [-nqSv][-b bindir][-d destdir][-i includedir][-l libdir]\n"
" [-O system][-p prefix][-s sbindir][directory...]\n" " [-M mode][-O system][-p prefix][-s sbindir][directory...]\n"
" -n Do not actually write Makefiles\n" " -n Do not actually write Makefiles\n"
" -q Quiet mode (default)\n" " -q Quiet mode (default)\n"
" -v Verbose mode\n" " -v Verbose mode\n"
@ -139,7 +139,7 @@ int main(int argc, char * argv[])
memset(&prefs, 0, sizeof(prefs)); memset(&prefs, 0, sizeof(prefs));
memset(&paths, 0, sizeof(paths)); memset(&paths, 0, sizeof(paths));
while((o = getopt(argc, argv, "b:d:i:l:nO:p:qSs:v")) != -1) while((o = getopt(argc, argv, "b:d:i:l:M:nO:p:qSs:v")) != -1)
switch(o) switch(o)
{ {
case 'b': case 'b':
@ -154,6 +154,9 @@ int main(int argc, char * argv[])
case 'l': case 'l':
paths.libdir = optarg; paths.libdir = optarg;
break; break;
case 'M':
prefs.mode = optarg;
break;
case 'n': case 'n':
prefs.flags |= PREFS_n; prefs.flags |= PREFS_n;
break; break;

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2006-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2006-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel configure */ /* This file is part of DeforaOS Devel configure */
/* All rights reserved. /* All rights reserved.
* *
@ -60,6 +60,8 @@ typedef struct _Makefile
/* accessors */ /* accessors */
static String const * _makefile_get_config(Makefile * makefile, static String const * _makefile_get_config(Makefile * makefile,
String const * section, String const * variable); String const * section, String const * variable);
static String const * _makefile_get_config_mode(Makefile * makefile,
String const * mode, String const * variable);
static TargetType _makefile_get_type(Makefile * makefile, static TargetType _makefile_get_type(Makefile * makefile,
String const * target); String const * target);
@ -157,12 +159,12 @@ static int _makefile_write(Makefile * makefile, configArray * ca,
|| _write_install(makefile) != 0 || _write_install(makefile) != 0
|| _write_uninstall(makefile) != 0) || _write_uninstall(makefile) != 0)
return 1; return 1;
if(_makefile_get_config(makefile, NULL, "subdirs") != NULL) if(_makefile_get_config_mode(makefile, NULL, "subdirs") != NULL)
depends[i++] = "subdirs"; depends[i++] = "subdirs";
depends[i++] = "clean"; depends[i++] = "clean";
depends[i++] = "distclean"; depends[i++] = "distclean";
if(_makefile_get_config(makefile, NULL, "package") != NULL if(_makefile_get_config_mode(makefile, NULL, "package") != NULL
&& _makefile_get_config(makefile, NULL, && _makefile_get_config_mode(makefile, NULL,
"version") != NULL) "version") != NULL)
{ {
depends[i++] = "dist"; depends[i++] = "dist";
@ -190,7 +192,7 @@ static int _write_variables(Makefile * makefile)
char done[TT_LAST]; /* FIXME even better if'd be variable by variable */ char done[TT_LAST]; /* FIXME even better if'd be variable by variable */
memset(&done, 0, sizeof(done)); memset(&done, 0, sizeof(done));
directory = _makefile_get_config(makefile, NULL, "directory"); directory = _makefile_get_config_mode(makefile, NULL, "directory");
ret |= _variables_package(makefile, directory); ret |= _variables_package(makefile, directory);
ret |= _variables_print(makefile, "subdirs", "SUBDIRS"); ret |= _variables_print(makefile, "subdirs", "SUBDIRS");
ret |= _variables_dist(makefile, done); ret |= _variables_dist(makefile, done);
@ -210,11 +212,13 @@ static int _variables_package(Makefile * makefile,
String const * vendor; String const * vendor;
String const * p; String const * p;
if((package = _makefile_get_config(makefile, NULL, "package")) == NULL) if((package = _makefile_get_config_mode(makefile, NULL, "package"))
== NULL)
return 0; return 0;
if(_makefile_is_flag_set(makefile, PREFS_v)) if(_makefile_is_flag_set(makefile, PREFS_v))
printf("%s%s", "Package: ", package); printf("%s%s", "Package: ", package);
if((version = _makefile_get_config(makefile, NULL, "version")) == NULL) if((version = _makefile_get_config_mode(makefile, NULL, "version"))
== NULL)
{ {
if(_makefile_is_flag_set(makefile, PREFS_v)) if(_makefile_is_flag_set(makefile, PREFS_v))
fputc('\n', stdout); fputc('\n', stdout);
@ -224,12 +228,13 @@ static int _variables_package(Makefile * makefile,
} }
if(_makefile_is_flag_set(makefile, PREFS_v)) if(_makefile_is_flag_set(makefile, PREFS_v))
printf(" %s\n", version); printf(" %s\n", version);
if((vendor = _makefile_get_config(makefile, NULL, "vendor")) == NULL) if((vendor = _makefile_get_config_mode(makefile, NULL, "vendor"))
== NULL)
vendor = "DeforaOS"; vendor = "DeforaOS";
_makefile_output_variable(makefile, "PACKAGE", package); _makefile_output_variable(makefile, "PACKAGE", package);
_makefile_output_variable(makefile, "VERSION", version); _makefile_output_variable(makefile, "VERSION", version);
_makefile_output_variable(makefile, "VENDOR", vendor); _makefile_output_variable(makefile, "VENDOR", vendor);
if((p = _makefile_get_config(makefile, NULL, "config")) != NULL) if((p = _makefile_get_config_mode(makefile, NULL, "config")) != NULL)
return settings(makefile->configure, directory, package, return settings(makefile->configure, directory, package,
version, vendor); version, vendor);
return 0; return 0;
@ -244,7 +249,7 @@ static int _variables_print(Makefile * makefile,
unsigned long i; unsigned long i;
char c; char c;
if((p = _makefile_get_config(makefile, NULL, input)) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, input)) == NULL)
return 0; return 0;
if((prints = string_new(p)) == NULL) if((prints = string_new(p)) == NULL)
return 1; return 1;
@ -278,7 +283,7 @@ static int _variables_dist(Makefile * makefile, char * done)
size_t i; size_t i;
char c; char c;
if((p = _makefile_get_config(makefile, NULL, "dist")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "dist")) == NULL)
return 0; return 0;
if((dist = string_new(p)) == NULL) if((dist = string_new(p)) == NULL)
return 1; return 1;
@ -318,7 +323,7 @@ static int _variables_targets(Makefile * makefile)
size_t i; size_t i;
char c; char c;
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((prints = string_new(p)) == NULL) if((prints = string_new(p)) == NULL)
return 1; return 1;
@ -354,9 +359,9 @@ static int _variables_executables(Makefile * makefile, char * done)
size_t i; size_t i;
char c; char c;
targets = _makefile_get_config(makefile, NULL, "targets"); targets = _makefile_get_config_mode(makefile, NULL, "targets");
includes = _makefile_get_config(makefile, NULL, "includes"); includes = _makefile_get_config_mode(makefile, NULL, "includes");
package = _makefile_get_config(makefile, NULL, "package"); package = _makefile_get_config_mode(makefile, NULL, "package");
if(targets != NULL) if(targets != NULL)
{ {
if((p = string_new(targets)) == NULL) if((p = string_new(targets)) == NULL)
@ -487,9 +492,9 @@ static void _targets_asflags(Makefile * makefile)
String const * asf; String const * asf;
String const * asff; String const * asff;
as = _makefile_get_config(makefile, NULL, "as"); as = _makefile_get_config_mode(makefile, NULL, "as");
asff = _makefile_get_config(makefile, NULL, "asflags_force"); asff = _makefile_get_config_mode(makefile, NULL, "asflags_force");
asf = _makefile_get_config(makefile, NULL, "asflags"); asf = _makefile_get_config_mode(makefile, NULL, "asflags");
if(as != NULL || asff != NULL || asf != NULL) if(as != NULL || asff != NULL || asf != NULL)
{ {
_makefile_output_variable(makefile, "AS", (as != NULL) ? as _makefile_output_variable(makefile, "AS", (as != NULL) ? as
@ -510,11 +515,11 @@ static void _targets_cflags(Makefile * makefile)
String * p; String * p;
HostOS os; HostOS os;
cppf = _makefile_get_config(makefile, NULL, "cppflags_force"); cppf = _makefile_get_config_mode(makefile, NULL, "cppflags_force");
cpp = _makefile_get_config(makefile, NULL, "cppflags"); cpp = _makefile_get_config_mode(makefile, NULL, "cppflags");
cff = _makefile_get_config(makefile, NULL, "cflags_force"); cff = _makefile_get_config_mode(makefile, NULL, "cflags_force");
cf = _makefile_get_config(makefile, NULL, "cflags"); cf = _makefile_get_config_mode(makefile, NULL, "cflags");
cc = _makefile_get_config(makefile, NULL, "cc"); cc = _makefile_get_config_mode(makefile, NULL, "cc");
if(cppf == NULL && cpp == NULL && cff == NULL && cf == NULL if(cppf == NULL && cpp == NULL && cff == NULL && cf == NULL
&& cc == NULL) && cc == NULL)
return; return;
@ -540,9 +545,9 @@ static void _targets_cxxflags(Makefile * makefile)
String const * cxxff; String const * cxxff;
String const * cxxf; String const * cxxf;
cxx = _makefile_get_config(makefile, NULL, "cxx"); cxx = _makefile_get_config_mode(makefile, NULL, "cxx");
cxxff = _makefile_get_config(makefile, NULL, "cxxflags_force"); cxxff = _makefile_get_config_mode(makefile, NULL, "cxxflags_force");
cxxf = _makefile_get_config(makefile, NULL, "cxxflags"); cxxf = _makefile_get_config_mode(makefile, NULL, "cxxflags");
if(cxx != NULL || cxxff != NULL || cxxf != NULL) if(cxx != NULL || cxxff != NULL || cxxf != NULL)
_makefile_output_program(makefile, "cxx", 1); _makefile_output_program(makefile, "cxx", 1);
if(cxxff != NULL) if(cxxff != NULL)
@ -572,13 +577,14 @@ static void _targets_ldflags(Makefile * makefile)
{ {
String const * p; String const * p;
if((p = _makefile_get_config(makefile, NULL, "ldflags_force")) != NULL) if((p = _makefile_get_config_mode(makefile, NULL, "ldflags_force"))
!= NULL)
{ {
_makefile_print(makefile, "%s", "LDFLAGSF="); _makefile_print(makefile, "%s", "LDFLAGSF=");
_binary_ldflags(makefile, p); _binary_ldflags(makefile, p);
_makefile_print(makefile, "\n"); _makefile_print(makefile, "\n");
} }
if((p = _makefile_get_config(makefile, NULL, "ldflags")) != NULL) if((p = _makefile_get_config_mode(makefile, NULL, "ldflags")) != NULL)
{ {
_makefile_print(makefile, "%s", "LDFLAGS\t="); _makefile_print(makefile, "%s", "LDFLAGS\t=");
_binary_ldflags(makefile, p); _binary_ldflags(makefile, p);
@ -592,9 +598,9 @@ static void _targets_jflags(Makefile * makefile)
String const * jff; String const * jff;
String const * jf; String const * jf;
j = _makefile_get_config(makefile, NULL, "javac"); j = _makefile_get_config_mode(makefile, NULL, "javac");
jff = _makefile_get_config(makefile, NULL, "jflags_force"); jff = _makefile_get_config_mode(makefile, NULL, "jflags_force");
jf = _makefile_get_config(makefile, NULL, "jflags"); jf = _makefile_get_config_mode(makefile, NULL, "jflags");
if(j != NULL || jff != NULL || jf != NULL) if(j != NULL || jff != NULL || jf != NULL)
_makefile_output_program(makefile, "javac", 1); _makefile_output_program(makefile, "javac", 1);
if(jff != NULL) if(jff != NULL)
@ -609,9 +615,9 @@ static void _targets_vflags(Makefile * makefile)
String const * vff; String const * vff;
String const * vf; String const * vf;
v = _makefile_get_config(makefile, NULL, "verilog"); v = _makefile_get_config_mode(makefile, NULL, "verilog");
vff = _makefile_get_config(makefile, NULL, "vflags_force"); vff = _makefile_get_config_mode(makefile, NULL, "vflags_force");
vf = _makefile_get_config(makefile, NULL, "vflags"); vf = _makefile_get_config_mode(makefile, NULL, "vflags");
if(v != NULL || vff != NULL || vf != NULL) if(v != NULL || vff != NULL || vf != NULL)
_makefile_output_program(makefile, "verilog", 1); _makefile_output_program(makefile, "verilog", 1);
if(vff != NULL) if(vff != NULL)
@ -706,7 +712,7 @@ static void _variables_library(Makefile * makefile, char * done)
} }
if(configure_can_library_static(makefile->configure)) if(configure_can_library_static(makefile->configure))
_variables_library_static(makefile); _variables_library_static(makefile);
if((p = _makefile_get_config(makefile, NULL, "ld")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "ld")) == NULL)
_makefile_output_program(makefile, "ccshared", 0); _makefile_output_program(makefile, "ccshared", 0);
else else
_makefile_output_variable(makefile, "CCSHARED", p); _makefile_output_variable(makefile, "CCSHARED", p);
@ -717,12 +723,12 @@ static void _variables_library_static(Makefile * makefile)
{ {
String const * p; String const * p;
if((p = _makefile_get_config(makefile, NULL, "ar")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "ar")) == NULL)
_makefile_output_program(makefile, "ar", 0); _makefile_output_program(makefile, "ar", 0);
else else
_makefile_output_variable(makefile, "AR", p); _makefile_output_variable(makefile, "AR", p);
_makefile_output_variable(makefile, "ARFLAGS", "-rc"); _makefile_output_variable(makefile, "ARFLAGS", "-rc");
if((p = _makefile_get_config(makefile, NULL, "ranlib")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "ranlib")) == NULL)
_makefile_output_program(makefile, "ranlib", 0); _makefile_output_program(makefile, "ranlib", 0);
else else
_makefile_output_variable(makefile, "RANLIB", p); _makefile_output_variable(makefile, "RANLIB", p);
@ -749,7 +755,7 @@ static int _variables_includes(Makefile * makefile)
{ {
String const * includes; String const * includes;
if((includes = _makefile_get_config(makefile, NULL, "includes")) if((includes = _makefile_get_config_mode(makefile, NULL, "includes"))
== NULL) == NULL)
return 0; return 0;
if(makefile->fp == NULL) if(makefile->fp == NULL)
@ -765,21 +771,23 @@ static int _variables_subdirs(Makefile * makefile)
String * p; String * p;
String const * q; String const * q;
if(_makefile_get_config(makefile, NULL, "subdirs") == NULL if(_makefile_get_config_mode(makefile, NULL, "subdirs") == NULL
|| _makefile_get_config(makefile, NULL, "package") != NULL || _makefile_get_config_mode(makefile, NULL,
|| _makefile_get_config(makefile, NULL, "targets") != NULL "package") != NULL
|| _makefile_get_config(makefile, NULL, "includes") != NULL) || _makefile_get_config_mode(makefile, NULL,
"targets") != NULL
|| _makefile_get_config_mode(makefile, NULL,
"includes") != NULL)
return 0; return 0;
for(i = 0; i < sizeof(sections) / sizeof(*sections); i++) for(i = 0; i < sizeof(sections) / sizeof(*sections); i++)
{ {
if((q = _makefile_get_config(makefile, NULL, sections[i])) if((q = _makefile_get_config_mode(makefile, NULL, sections[i]))
== NULL) == NULL)
continue; continue;
if((p = strdup(q)) == NULL) if((p = strdup(q)) == NULL)
return -1; return -1;
for(q = strtok(p, ","); q != NULL; q = strtok(NULL, ",")) for(q = strtok(p, ","); q != NULL; q = strtok(NULL, ","))
if(_makefile_get_config(makefile, q, "install") if(_makefile_get_config(makefile, q, "install") != NULL)
!= NULL)
break; break;
free(p); free(p);
if(q != NULL) if(q != NULL)
@ -803,7 +811,7 @@ static int _write_targets(Makefile * makefile)
if(_targets_all(makefile) != 0 if(_targets_all(makefile) != 0
|| _targets_subdirs(makefile) != 0) || _targets_subdirs(makefile) != 0)
return 1; return 1;
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((targets = string_new(p)) == NULL) if((targets = string_new(p)) == NULL)
return 1; return 1;
@ -838,9 +846,10 @@ static int _targets_all(Makefile * makefile)
if(_makefile_get_config(makefile, "all", "type") != NULL) if(_makefile_get_config(makefile, "all", "type") != NULL)
return _targets_target(makefile, "all"); return _targets_target(makefile, "all");
if((subdirs = _makefile_get_config(makefile, NULL, "subdirs")) != NULL) if((subdirs = _makefile_get_config_mode(makefile, NULL, "subdirs"))
!= NULL)
depends[j++] = "subdirs"; depends[j++] = "subdirs";
if((p = _makefile_get_config(makefile, NULL, "targets")) != NULL if((p = _makefile_get_config_mode(makefile, NULL, "targets")) != NULL
&& string_get_length(p) > 0) && string_get_length(p) > 0)
depends[j++] = "$(TARGETS)"; depends[j++] = "$(TARGETS)";
if(p == NULL || string_get_length(p) == 0) if(p == NULL || string_get_length(p) == 0)
@ -898,7 +907,8 @@ static int _targets_subdirs(Makefile * makefile)
{ {
String const * subdirs; String const * subdirs;
if((subdirs = _makefile_get_config(makefile, NULL, "subdirs")) != NULL) if((subdirs = _makefile_get_config_mode(makefile, NULL, "subdirs"))
!= NULL)
{ {
_makefile_target(makefile, "subdirs", NULL); _makefile_target(makefile, "subdirs", NULL);
_makefile_subdirs(makefile, NULL); _makefile_subdirs(makefile, NULL);
@ -1638,7 +1648,7 @@ static int _write_objects(Makefile * makefile)
size_t i; size_t i;
int ret = 0; int ret = 0;
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((targets = string_new(p)) == NULL) if((targets = string_new(p)) == NULL)
return 1; return 1;
@ -1740,7 +1750,7 @@ static String * _script_path(Makefile * makefile, String const * script)
ssize_t i; ssize_t i;
String * p = NULL; String * p = NULL;
if((directory = _makefile_get_config(makefile, NULL, "directory")) if((directory = _makefile_get_config_mode(makefile, NULL, "directory"))
== NULL) == NULL)
{ {
error_print(PROGNAME); error_print(PROGNAME);
@ -2113,7 +2123,7 @@ static int _clean_targets(Makefile * makefile);
static int _write_clean(Makefile * makefile) static int _write_clean(Makefile * makefile)
{ {
_makefile_target(makefile, "clean", NULL); _makefile_target(makefile, "clean", NULL);
if(_makefile_get_config(makefile, NULL, "subdirs") != NULL) if(_makefile_get_config_mode(makefile, NULL, "subdirs") != NULL)
_makefile_subdirs(makefile, "clean"); _makefile_subdirs(makefile, "clean");
return _clean_targets(makefile); return _clean_targets(makefile);
} }
@ -2130,7 +2140,7 @@ static int _clean_targets(Makefile * makefile)
char c; char c;
int phony; int phony;
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((targets = string_new(p)) == NULL) if((targets = string_new(p)) == NULL)
return 1; return 1;
@ -2211,7 +2221,8 @@ static int _write_distclean(Makefile * makefile)
int phony = 0; int phony = 0;
/* only depend on the "clean" target if we do not have subfolders */ /* only depend on the "clean" target if we do not have subfolders */
if((subdirs = _makefile_get_config(makefile, NULL, "subdirs")) == NULL) if((subdirs = _makefile_get_config_mode(makefile, NULL, "subdirs"))
== NULL)
_makefile_target(makefile, "distclean", "clean", NULL); _makefile_target(makefile, "distclean", "clean", NULL);
else else
{ {
@ -2220,7 +2231,7 @@ static int _write_distclean(Makefile * makefile)
_clean_targets(makefile); _clean_targets(makefile);
} }
/* XXX do not erase phony targets */ /* XXX do not erase phony targets */
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((targets = string_new(p)) == NULL) if((targets = string_new(p)) == NULL)
return 1; return 1;
@ -2280,8 +2291,8 @@ static int _write_dist(Makefile * makefile, configArray * ca, int from, int to)
Config * p; Config * p;
int i; int i;
package = _makefile_get_config(makefile, NULL, "package"); package = _makefile_get_config_mode(makefile, NULL, "package");
version = _makefile_get_config(makefile, NULL, "version"); version = _makefile_get_config_mode(makefile, NULL, "version");
if(package == NULL || version == NULL) if(package == NULL || version == NULL)
return 0; return 0;
_makefile_target(makefile, "dist", NULL); _makefile_target(makefile, "dist", NULL);
@ -2321,8 +2332,8 @@ static int _write_distcheck(Makefile * makefile)
"\tcd \"$(PACKAGE)-$(VERSION)\" && $(MAKE) dist\n"; "\tcd \"$(PACKAGE)-$(VERSION)\" && $(MAKE) dist\n";
const char posttarget[] = "\t$(RM) -r -- $(PACKAGE)-$(VERSION)\n"; const char posttarget[] = "\t$(RM) -r -- $(PACKAGE)-$(VERSION)\n";
package = _makefile_get_config(makefile, NULL, "package"); package = _makefile_get_config_mode(makefile, NULL, "package");
version = _makefile_get_config(makefile, NULL, "version"); version = _makefile_get_config_mode(makefile, NULL, "version");
if(package == NULL || version == NULL) if(package == NULL || version == NULL)
return 0; return 0;
_makefile_print(makefile, "%s%s%s", pretarget, target, posttarget); _makefile_print(makefile, "%s%s%s", pretarget, target, posttarget);
@ -2344,7 +2355,7 @@ static int _dist_subdir(Makefile * makefile, Config * subdir)
char c; char c;
String const * quote; String const * quote;
path = _makefile_get_config(makefile, NULL, "directory"); path = _makefile_get_config_mode(makefile, NULL, "directory");
len = (path != NULL) ? string_get_length(path) : 0; len = (path != NULL) ? string_get_length(path) : 0;
if((path = config_get(subdir, NULL, "directory")) == NULL) if((path = config_get(subdir, NULL, "directory")) == NULL)
path = ""; path = "";
@ -2428,7 +2439,7 @@ static int _write_install(Makefile * makefile)
int ret = 0; int ret = 0;
_makefile_target(makefile, "install", "all", NULL); _makefile_target(makefile, "install", "all", NULL);
if(_makefile_get_config(makefile, NULL, "subdirs") != NULL) if(_makefile_get_config_mode(makefile, NULL, "subdirs") != NULL)
_makefile_subdirs(makefile, "install"); _makefile_subdirs(makefile, "install");
ret |= _install_targets(makefile); ret |= _install_targets(makefile);
ret |= _install_includes(makefile); ret |= _install_includes(makefile);
@ -2446,7 +2457,7 @@ static int _install_targets(Makefile * makefile)
size_t i; size_t i;
char c; char c;
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((targets = string_new(p)) == NULL) if((targets = string_new(p)) == NULL)
return 1; return 1;
@ -2747,7 +2758,7 @@ static int _install_includes(Makefile * makefile)
size_t i; size_t i;
char c; char c;
if((p = _makefile_get_config(makefile, NULL, "includes")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "includes")) == NULL)
return 0; return 0;
if((includes = string_new(p)) == NULL) if((includes = string_new(p)) == NULL)
return 1; return 1;
@ -2819,7 +2830,7 @@ static int _install_dist(Makefile * makefile)
String const * d; String const * d;
String const * mode; String const * mode;
if((p = _makefile_get_config(makefile, NULL, "dist")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "dist")) == NULL)
return 0; return 0;
if((dist = string_new(p)) == NULL) if((dist = string_new(p)) == NULL)
return 1; return 1;
@ -2927,7 +2938,7 @@ static int _write_phony_targets(Makefile * makefile)
char c; char c;
String const * type; String const * type;
if((p = _makefile_get_config(makefile, NULL, "targets")) == NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) == NULL)
return 0; return 0;
if((prints = string_new(p)) == NULL) if((prints = string_new(p)) == NULL)
return 1; return 1;
@ -2974,9 +2985,9 @@ static int _write_uninstall(Makefile * makefile)
char c; char c;
_makefile_target(makefile, "uninstall", NULL); _makefile_target(makefile, "uninstall", NULL);
if(_makefile_get_config(makefile, NULL, "subdirs") != NULL) if(_makefile_get_config_mode(makefile, NULL, "subdirs") != NULL)
_makefile_subdirs(makefile, "uninstall"); _makefile_subdirs(makefile, "uninstall");
if((p = _makefile_get_config(makefile, NULL, "targets")) != NULL) if((p = _makefile_get_config_mode(makefile, NULL, "targets")) != NULL)
{ {
if((targets = string_new(p)) == NULL) if((targets = string_new(p)) == NULL)
return 1; return 1;
@ -2996,7 +3007,7 @@ static int _write_uninstall(Makefile * makefile)
} }
string_delete(q); string_delete(q);
} }
if((p = _makefile_get_config(makefile, NULL, "includes")) != NULL) if((p = _makefile_get_config_mode(makefile, NULL, "includes")) != NULL)
{ {
if((includes = string_new(p)) == NULL) if((includes = string_new(p)) == NULL)
return 1; return 1;
@ -3015,7 +3026,7 @@ static int _write_uninstall(Makefile * makefile)
} }
string_delete(q); string_delete(q);
} }
if((p = _makefile_get_config(makefile, NULL, "dist")) != NULL) if((p = _makefile_get_config_mode(makefile, NULL, "dist")) != NULL)
{ {
if((dist = string_new(p)) == NULL) if((dist = string_new(p)) == NULL)
return 1; return 1;
@ -3228,6 +3239,14 @@ static String const * _makefile_get_config(Makefile * makefile,
} }
/* makefile_get_config_mode */
static String const * _makefile_get_config_mode(Makefile * makefile,
String const * mode, String const * variable)
{
return configure_get_config_mode(makefile->configure, mode, variable);
}
/* makefile_get_type */ /* makefile_get_type */
static TargetType _makefile_get_type(Makefile * makefile, static TargetType _makefile_get_type(Makefile * makefile,
String const * target) String const * target)
@ -3364,7 +3383,7 @@ static int _makefile_output_program(Makefile * makefile, String const * name,
return -1; return -1;
string_toupper(upper); string_toupper(upper);
if(override) if(override)
value = _makefile_get_config(makefile, NULL, name); value = _makefile_get_config_mode(makefile, NULL, name);
else else
value = NULL; value = NULL;
if(value == NULL) if(value == NULL)

View File

@ -45,7 +45,7 @@ $(OBJDIR)shlint.log: ../src/scripts/data/pkgconfig.sh ../src/scripts/doc/docbook
$(OBJDIR)template-test.md: template.md.in test.db ../src/scripts/tools/template.sh ../config.sh $(OBJDIR)template-test.md: template.md.in test.db ../src/scripts/tools/template.sh ../config.sh
../src/scripts/tools/template.sh -P "$(PREFIX)" -O DATABASEDIR=. -- "$(OBJDIR)template-test.md" ../src/scripts/tools/template.sh -P "$(PREFIX)" -O DATABASEDIR=. -- "$(OBJDIR)template-test.md"
$(OBJDIR)tests.log: $(OBJDIR)../tools/configure$(EXEEXT) binary/project.conf binary/Makefile.Darwin binary/Makefile.DeforaOS binary/Makefile.NetBSD binary/Makefile.Windows command/project.conf command/Makefile.NetBSD include/project.conf include/Makefile.NetBSD java/project.conf java/Makefile.NetBSD library/project.conf library/Makefile.Darwin library/Makefile.Linux library/Makefile.NetBSD library/Makefile.Windows libtool/project.conf libtool/Makefile.Darwin libtool/Makefile.Linux libtool/Makefile.NetBSD libtool/Makefile.Windows object/project.conf object/Makefile.NetBSD package/project.conf package/Makefile.NetBSD package/config.ent.NetBSD package/config.h.NetBSD package/config.sh.NetBSD plugin/project.conf plugin/Makefile.Darwin plugin/Makefile.NetBSD script/project.conf script/Makefile.NetBSD verilog/project.conf verilog/Makefile.NetBSD tests.sh $(OBJDIR)tests.log: $(OBJDIR)../tools/configure$(EXEEXT) binary/project.conf binary/Makefile.Darwin binary/Makefile.DeforaOS binary/Makefile.NetBSD binary/Makefile.Windows command/project.conf command/Makefile.NetBSD include/project.conf include/Makefile.NetBSD java/project.conf java/Makefile.NetBSD library/project.conf library/Makefile.Darwin library/Makefile.Linux library/Makefile.NetBSD library/Makefile.Windows libtool/project.conf libtool/Makefile.Darwin libtool/Makefile.Linux libtool/Makefile.NetBSD libtool/Makefile.Windows mode/project.conf mode/Makefile.NetBSD object/project.conf object/Makefile.NetBSD package/project.conf package/Makefile.NetBSD package/config.ent.NetBSD package/config.h.NetBSD package/config.sh.NetBSD plugin/project.conf plugin/Makefile.Darwin plugin/Makefile.NetBSD script/project.conf script/Makefile.NetBSD verilog/project.conf verilog/Makefile.NetBSD tests.sh
./tests.sh -P "$(PREFIX)" -- "$(OBJDIR)tests.log" ./tests.sh -P "$(PREFIX)" -- "$(OBJDIR)tests.log"
$(OBJDIR)xmllint.log: ../src/scripts/tests/xmllint.sh $(OBJDIR)xmllint.log: ../src/scripts/tests/xmllint.sh

View File

@ -0,0 +1,39 @@
PACKAGE = test-debug
VERSION = 0.0.0
VENDOR = DeforaOS
RM = rm -f
LN = ln -f
TAR = tar
TGZEXT = .tar.gz
MKDIR = mkdir -m 0755 -p
all:
clean:
distclean: clean
dist:
$(RM) -r -- $(OBJDIR)$(PACKAGE)-$(VERSION)
$(LN) -s -- "$$PWD" $(OBJDIR)$(PACKAGE)-$(VERSION)
@cd $(OBJDIR). && $(TAR) -czvf $(PACKAGE)-$(VERSION)$(TGZEXT) -- \
$(PACKAGE)-$(VERSION)/project.conf
$(RM) -- $(OBJDIR)$(PACKAGE)-$(VERSION)
distcheck: dist
$(TAR) -xzvf $(OBJDIR)$(PACKAGE)-$(VERSION)$(TGZEXT)
$(MKDIR) -- $(PACKAGE)-$(VERSION)/objdir
$(MKDIR) -- $(PACKAGE)-$(VERSION)/destdir
cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/"
cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/" DESTDIR="$$PWD/destdir" install
cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/" DESTDIR="$$PWD/destdir" uninstall
cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/" distclean
cd "$(PACKAGE)-$(VERSION)" && $(MAKE) dist
$(RM) -r -- $(PACKAGE)-$(VERSION)
install: all
uninstall:
.PHONY: all clean distclean dist distcheck install uninstall

6
tests/mode/project.conf Normal file
View File

@ -0,0 +1,6 @@
package=test
version=0.0.0
mode=debug
[mode::debug]
package=test-debug

View File

@ -1,6 +1,6 @@
subdirs=gtkdoc subdirs=gtkdoc
targets=clint.log,coverage.log,distcheck.log,fixme.log,htmllint.log,phplint.log,pylint.log,shlint.log,template-test.md,tests.log,xmllint.log targets=clint.log,coverage.log,distcheck.log,fixme.log,htmllint.log,phplint.log,pylint.log,shlint.log,template-test.md,tests.log,xmllint.log
dist=Makefile,binary/project.conf,binary/Makefile.Darwin,binary/Makefile.DeforaOS,binary/Makefile.NetBSD,binary/Makefile.Windows,command/project.conf,command/Makefile.NetBSD,config.sh,include/project.conf,include/Makefile.NetBSD,java/project.conf,java/Makefile.NetBSD,library/project.conf,library/Makefile.Darwin,library/Makefile.Linux,library/Makefile.NetBSD,library/Makefile.Windows,libtool/project.conf,libtool/Makefile.Darwin,libtool/Makefile.Linux,libtool/Makefile.NetBSD,libtool/Makefile.Windows,object/project.conf,object/Makefile.NetBSD,package/project.conf,package/Makefile.NetBSD,package/config.ent.NetBSD,package/config.h.NetBSD,package/config.sh.NetBSD,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/project.conf,script/Makefile.NetBSD,template.md.in,test.db,tests.sh,verilog/project.conf,verilog/Makefile.NetBSD dist=Makefile,binary/project.conf,binary/Makefile.Darwin,binary/Makefile.DeforaOS,binary/Makefile.NetBSD,binary/Makefile.Windows,command/project.conf,command/Makefile.NetBSD,config.sh,include/project.conf,include/Makefile.NetBSD,java/project.conf,java/Makefile.NetBSD,library/project.conf,library/Makefile.Darwin,library/Makefile.Linux,library/Makefile.NetBSD,library/Makefile.Windows,libtool/project.conf,libtool/Makefile.Darwin,libtool/Makefile.Linux,libtool/Makefile.NetBSD,libtool/Makefile.Windows,mode/project.conf,mode/Makefile.NetBSD,object/project.conf,object/Makefile.NetBSD,package/project.conf,package/Makefile.NetBSD,package/config.ent.NetBSD,package/config.h.NetBSD,package/config.sh.NetBSD,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/project.conf,script/Makefile.NetBSD,template.md.in,test.db,tests.sh,verilog/project.conf,verilog/Makefile.NetBSD
#targets #targets
[clint.log] [clint.log]
@ -61,7 +61,7 @@ depends=template.md.in,test.db,../src/scripts/tools/template.sh,../config.sh
type=script type=script
script=./tests.sh script=./tests.sh
enabled=0 enabled=0
depends=$(OBJDIR)../tools/configure$(EXEEXT),binary/project.conf,binary/Makefile.Darwin,binary/Makefile.DeforaOS,binary/Makefile.NetBSD,binary/Makefile.Windows,command/project.conf,command/Makefile.NetBSD,include/project.conf,include/Makefile.NetBSD,java/project.conf,java/Makefile.NetBSD,library/project.conf,library/Makefile.Darwin,library/Makefile.Linux,library/Makefile.NetBSD,library/Makefile.Windows,libtool/project.conf,libtool/Makefile.Darwin,libtool/Makefile.Linux,libtool/Makefile.NetBSD,libtool/Makefile.Windows,object/project.conf,object/Makefile.NetBSD,package/project.conf,package/Makefile.NetBSD,package/config.ent.NetBSD,package/config.h.NetBSD,package/config.sh.NetBSD,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/project.conf,script/Makefile.NetBSD,verilog/project.conf,verilog/Makefile.NetBSD,tests.sh depends=$(OBJDIR)../tools/configure$(EXEEXT),binary/project.conf,binary/Makefile.Darwin,binary/Makefile.DeforaOS,binary/Makefile.NetBSD,binary/Makefile.Windows,command/project.conf,command/Makefile.NetBSD,include/project.conf,include/Makefile.NetBSD,java/project.conf,java/Makefile.NetBSD,library/project.conf,library/Makefile.Darwin,library/Makefile.Linux,library/Makefile.NetBSD,library/Makefile.Windows,libtool/project.conf,libtool/Makefile.Darwin,libtool/Makefile.Linux,libtool/Makefile.NetBSD,libtool/Makefile.Windows,mode/project.conf,mode/Makefile.NetBSD,object/project.conf,object/Makefile.NetBSD,package/project.conf,package/Makefile.NetBSD,package/config.ent.NetBSD,package/config.h.NetBSD,package/config.sh.NetBSD,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/project.conf,script/Makefile.NetBSD,verilog/project.conf,verilog/Makefile.NetBSD,tests.sh
[xmllint.log] [xmllint.log]
type=script type=script