/*
- * Another fast dependencies generator for Makefiles, Version 2.4
+ * Another fast dependencies generator for Makefiles, Version 2.5
*
* Copyright (C) 2005 by Vladimir Oleynik <dzo@simtreas.ru>
* mmaping file may be originally by Linus Torvalds.
static char first_chars[257]; /* + L_EOF */
static char isalnums[257]; /* + L_EOF */
/* trick for fast find "define", "include", "undef" */
-static char first_chars_diu[256];
+static char first_chars_diu[256] = {
+ [(int)'d'] = (char)5, /* strlen("define") - 1; */
+ [(int)'i'] = (char)6, /* strlen("include") - 1; */
+ [(int)'u'] = (char)4, /* strlen("undef") - 1; */
+};
static int pagesizem1;
static size_t mema_id = 128; /* first allocated for id */
id[id_len++] = c; } while(0)
-
/* stupid C lexical analyser */
static void c_lex(const char *fname, long fsize)
{
}
}
-static int show_dep(int first, bb_key_t *k, const char *name)
+static char *pwd;
+
+static int show_dep(int first, bb_key_t *k, const char *name, const char *f)
{
bb_key_t *cur;
for(cur = k; cur; cur = cur->next) {
if(cur->checked) {
if(first) {
- printf("\n%s:", name);
+ if(f == NULL)
+ printf("\n%s:", name);
+ else
+ printf("\n%s/%s:", pwd, name);
first = 0;
} else {
printf(" \\\n ");
return first;
}
-static char *pwd;
-static char *replace;
+static size_t replace;
static struct stat st_kp;
static int dontgenerate_dep;
if(*e == 'c') {
/* *.c -> *.o */
*e = 'o';
- if(replace) {
- /* /src_dir/path/file.o to path/file.o */
- e = fp + strlen(replace);
- while(*e == '/')
- e++;
- /* path/file.o to pwd/path/file.o */
- e = fp = bb_asprint("%s/%s", pwd, e);
- }
+ /* /src_dir/path/file.o to path/file.o */
+ fp += replace;
+ if(*fp == '/')
+ fp++;
} else {
e = NULL;
}
- first = show_dep(1, Ifound, fp);
- first = show_dep(first, key_top, fp);
+ first = show_dep(1, Ifound, fp, e);
+ first = show_dep(first, key_top, fp, e);
if(first == 0)
putchar('\n');
- if(replace && e)
- free(e);
}
return NULL;
} else if(S_ISDIR(st.st_mode)) {
size_t dirlen;
dirs = llist_add_to(NULL, bb_simplify_path(p));
- if(strcmp(dirs->data, pwd))
- replace = bb_xstrdup(dirs->data);
- else
- replace = NULL;
+ replace = strlen(dirs->data);
/* emulate recursive */
while(dirs) {
d_add = NULL;
}
dirs = d_add;
}
- free(replace);
- replace = NULL;
}
first_chars[i] = ANY;
}
first_chars[i] = '-'; /* L_EOF */
- /* trick for fast find "define", "include", "undef" */
- first_chars_diu[(int)'d'] = (char)5; /* strlen("define") - 1; */
- first_chars_diu[(int)'i'] = (char)6; /* strlen("include") - 1; */
- first_chars_diu[(int)'u'] = (char)4; /* strlen("undef") - 1; */
/* parse configs */
for(fl = configs; fl; fl = fl->link) {