summaryrefslogtreecommitdiff
path: root/adk
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-12-13 17:18:40 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2015-12-13 17:18:44 +0100
commita94d74d9c875b4a1c07945bf9af282221d0178b3 (patch)
treedaa2be873d758ad77006696efde6e76982f24d20 /adk
parent74663fdbbd1dc92dd91f6f88dbc4f972df12c404 (diff)
rework prereq check
The new prereq check is completely implemented in POSIX shell in scripts/prereq.sh. It combines the old features from Makefile, scan-tools.sh, scan-pkgs.sh, reloc.sh and some wrappers for tools. The big benefit is to have all portability stuff in one place. Furthermore we can compile GNU make and bash on the fly, for systems lacking the required tools. All changes on the host are detected on the fly, no make prereq required anymore. The build process is separated in following three phases: 1. small wrapper Makefile is used for BSD make or GNU make 2. prereq.sh is called, doing all checking, calling Makefile.adk 3. old logic in Makefile.adk or mk/build.mk is used Tested successfully on Linux, MacOS X, Cygwin, FreeBSD, OpenBSD and NetBSD. An old depmaker bug was fixed, only optional host tools are compiled. For example, even when a host provides xz, a local xz was compiled in the past, because other packages had a build dependency on it. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Diffstat (limited to 'adk')
-rw-r--r--adk/config/Makefile10
-rw-r--r--adk/tools/depmaker.c52
2 files changed, 54 insertions, 8 deletions
diff --git a/adk/config/Makefile b/adk/config/Makefile
index 8481e3bff..48e10983b 100644
--- a/adk/config/Makefile
+++ b/adk/config/Makefile
@@ -69,19 +69,19 @@ MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
conf: $(CONF_OBJS) $(SHARED_OBJS)
- @$(HOST_CC) $(HOST_CFLAGS) $^ -o $@
+ @$(HOST_CC) $(HOST_CFLAGS) $^ -o $@ 2>/dev/null
mconf: $(MCONF_OBJS) $(SHARED_OBJS)
- @$(HOST_CC) $(HOST_CFLAGS) $^ -o $@ $(LIBS)
+ @$(HOST_CC) $(HOST_CFLAGS) $^ -o $@ $(LIBS) 2>/dev/null
$(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
- @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@
+ @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@ 2>/dev/null
$(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
- @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@
+ @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@ 2>/dev/null
glob.o: glob.c $(SHARED_DEPS)
- @$(HOST_CC) $(HOST_CFLAGS) -I. -c glob.c -o $@
+ @$(HOST_CC) $(HOST_CFLAGS) -I. -c glob.c -o $@ 2>/dev/null
lkc_defs.h: lkc_proto.h
@sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
diff --git a/adk/tools/depmaker.c b/adk/tools/depmaker.c
index d5ef100a8..275fa4ed5 100644
--- a/adk/tools/depmaker.c
+++ b/adk/tools/depmaker.c
@@ -1,7 +1,7 @@
/*
* depmaker - create package/Depends.mk for OpenADK buildsystem
*
- * Copyright (C) 2010-2014 Waldemar Brodkorb <wbx@openadk.org>
+ * Copyright (C) 2010-2015 Waldemar Brodkorb <wbx@openadk.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -67,8 +67,9 @@ static int check_symbol(char *symbol) {
/*@null@*/
static char *parse_line(char *package, char *pkgvar, char *string, int checksym, int pprefix, int system, int *prefixp) {
- char *key, *value, *dep, *key_sym, *pkgdeps;
+ char *key, *value, *dep, *key_sym, *pkgdeps, *depvar;
char temp[MAXLINE];
+ int i;
string[strlen(string)-1] = '\0';
if ((key = strtok(string, ":=")) == NULL) {
@@ -121,6 +122,51 @@ static char *parse_line(char *package, char *pkgvar, char *string, int checksym,
value = strtok(NULL, "=\t");
dep = strtok(value, " ");
while (dep != NULL) {
+ /* check only for optional host tools, if they are required to build */
+ if (checksym == 2) {
+ if ((depvar = malloc(MAXLINE)) != NULL)
+ memset(depvar, 0, MAXLINE);
+ else {
+ perror("Can not allocate memory.");
+ exit(EXIT_FAILURE);
+ }
+ strncat(depvar, dep, strlen(dep)-5);
+ if ((strncmp(depvar, "bc", 2) == 0) ||
+ (strncmp(depvar, "file", 4) == 0) ||
+ (strncmp(depvar, "gawk", 4) == 0) ||
+ (strncmp(depvar, "grep", 4) == 0) ||
+ (strncmp(depvar, "patch", 5) == 0) ||
+ (strncmp(depvar, "sed", 3) == 0) ||
+ (strncmp(depvar, "xz", 2) == 0)) {
+
+ /* transform to uppercase variable name */
+ for (i=0; i<(int)strlen(depvar); i++) {
+ if (depvar[i] == '+')
+ depvar[i] = 'X';
+ if (depvar[i] == '-')
+ depvar[i] = '_';
+ depvar[i] = toupper(depvar[i]);
+ }
+
+ /* extract symbol */
+ if ((key_sym = malloc(MAXLINE)) != NULL)
+ memset(key_sym, 0, MAXLINE);
+ else {
+ perror("Can not allocate memory.");
+ exit(EXIT_FAILURE);
+ }
+ if (snprintf(key_sym, MAXLINE, "ADK_HOST_BUILD_%s", depvar) < 0)
+ perror("Can not create string variable.");
+
+ if (check_symbol(key_sym) != 0) {
+ free(key_sym);
+ free(depvar);
+ return(NULL);
+ }
+ free(key_sym);
+ free(depvar);
+ }
+ }
if (*prefixp == 0) {
*prefixp = 1;
if (snprintf(temp, MAXLINE, "%s-compile: %s-compile", package, dep) < 0)
@@ -295,7 +341,7 @@ int main() {
} else if (strncmp(buf, "HOST_BUILDDEP", 13) == 0) {
asprintf(&string, "%s-host", pkgdirp->d_name);
// check retval; string for NULL
- tmp = parse_line(string, NULL, buf, 0, 0, 0, &hprefix);
+ tmp = parse_line(string, NULL, buf, 2, 0, 0, &hprefix);
if (tmp && *tmp) {
asprintf(&string, "%s%s",
hpkgdeps ? hpkgdeps : "",