full removed config.h, use bb_config.h only

This commit is contained in:
"Vladimir N. Oleynik" 2006-02-15 12:29:37 +00:00
parent 02794e1516
commit 6732af2766
4 changed files with 49 additions and 32 deletions

View File

@ -386,7 +386,7 @@ docs/busybox.net/BusyBox.html: docs/busybox.pod
scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $< $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
DEP_INCLUDES := include/config.h include/bb_config.h DEP_INCLUDES := include/bb_config.h
ifeq ($(strip $(CONFIG_BBCONFIG)),y) ifeq ($(strip $(CONFIG_BBCONFIG)),y)
DEP_INCLUDES += include/bbconfigopts.h DEP_INCLUDES += include/bbconfigopts.h
@ -401,25 +401,15 @@ depend dep: .depend
$(disp_gen) $(disp_gen)
$(Q)$(RM_F) .depend $(Q)$(RM_F) .depend
$(Q)mkdir -p include/config $(Q)mkdir -p include/config
$(Q)scripts/bb_mkdep -c include/config.h -c include/bb_config.h \ $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
-I $(top_srcdir)/include $(top_srcdir) > $@.tmp
$(Q)mv $@.tmp $@ $(Q)mv $@.tmp $@
include/config.h: .config include/bb_config.h: .config
@if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \ @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
$(MAKE) -C scripts/config conf; \ $(MAKE) -C scripts/config conf; \
fi; fi;
@$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
include/bb_config.h: include/config.h
@echo -e "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H" > $@
@sed -e h -e 's/#undef CONFIG_\(.*\)/#define ENABLE_\1 0/p' -e g \
-e 's/#undef CONFIG_\(.*\)/#define USE_\1(...)/p' -e g \
-e 's/#define CONFIG_\([^ ]*\).*/#define ENABLE_\1 1/p' -e g -e \
's/#define CONFIG_\([^ ]*\).*/#define USE_\1(...) __VA_ARGS__/p' \
-e g $< >> $@
@echo "#endif" >> $@
clean: clean:
- $(MAKE) -C scripts/config $@ - $(MAKE) -C scripts/config $@
- $(RM_F) docs/busybox.dvi docs/busybox.ps \ - $(RM_F) docs/busybox.dvi docs/busybox.ps \

View File

@ -1,2 +1,3 @@
config config
config.h bb_config.h
bbconfigopts.h

View File

@ -1,5 +1,5 @@
/* /*
* Another fast dependencies generator for Makefiles, Version 4.0 * Another fast dependencies generator for Makefiles, Version 4.1
* *
* Copyright (C) 2005,2006 by Vladimir Oleynik <dzo@simtreas.ru> * Copyright (C) 2005,2006 by Vladimir Oleynik <dzo@simtreas.ru>
* *
@ -26,7 +26,7 @@
* - more verbose --help output. * - more verbose --help output.
* *
* This program does: * This program does:
* 1) find #define KEY VALUE or #undef KEY from include/config.h * 1) find #define KEY VALUE or #undef KEY from include/bb_config.h
* 2) recursive find and scan *.[ch] files, but skips scan of include/config/ * 2) recursive find and scan *.[ch] files, but skips scan of include/config/
* 3) find #include "*.h" and KEYs using, if not as #define and #undef * 3) find #include "*.h" and KEYs using, if not as #define and #undef
* 4) generate dependencies to stdout * 4) generate dependencies to stdout
@ -39,7 +39,7 @@
#define LOCAL_INCLUDE_PATH "include" #define LOCAL_INCLUDE_PATH "include"
#define INCLUDE_CONFIG_PATH LOCAL_INCLUDE_PATH"/config" #define INCLUDE_CONFIG_PATH LOCAL_INCLUDE_PATH"/config"
#define INCLUDE_CONFIG_KEYS_PATH LOCAL_INCLUDE_PATH"/config.h" #define INCLUDE_CONFIG_KEYS_PATH LOCAL_INCLUDE_PATH"/bb_config.h"
#define bb_mkdep_full_options \ #define bb_mkdep_full_options \
"\nOptions:" \ "\nOptions:" \
@ -308,7 +308,7 @@ typedef unsigned char operator;
#define TOK_UMINUS tok_decl(UNARYPREC+1,0) #define TOK_UMINUS tok_decl(UNARYPREC+1,0)
#define TOK_UPLUS tok_decl(UNARYPREC+1,1) #define TOK_UPLUS tok_decl(UNARYPREC+1,1)
#define SPEC_PREC (UNARYPREC+1) #define SPEC_PREC (UNARYPREC+2)
#define TOK_NUM tok_decl(SPEC_PREC, 0) #define TOK_NUM tok_decl(SPEC_PREC, 0)
#define TOK_RPAREN tok_decl(SPEC_PREC, 1) #define TOK_RPAREN tok_decl(SPEC_PREC, 1)
@ -521,13 +521,6 @@ endofname(const char *name)
} }
/* Like strncpy but make sure the resulting string is always 0 terminated. */
static inline char * safe_strncpy(char *dst, const char *src, size_t size)
{
dst[size-1] = '\0';
return strncpy(dst, src, size-1);
}
static arith_t arith (const char *expr, int *perrcode) static arith_t arith (const char *expr, int *perrcode)
{ {
char arithval; /* Current character under analysis */ char arithval; /* Current character under analysis */
@ -1400,7 +1393,10 @@ static void store_keys(void)
if(*val == '\0') { if(*val == '\0') {
recordsz = sprintf(record_buf, "#define %s\n", k); recordsz = sprintf(record_buf, "#define %s\n", k);
} else { } else {
if(val[0] != '(')
recordsz = sprintf(record_buf, "#define %s %s\n", k, val); recordsz = sprintf(record_buf, "#define %s %s\n", k, val);
else
recordsz = sprintf(record_buf, "#define %s%s\n", k, val);
} }
} }
/* size_t -> ssize_t :( */ /* size_t -> ssize_t :( */

View File

@ -279,6 +279,7 @@ int conf_write(const char *name)
char dirname[128], tmpname[128], newname[128]; char dirname[128], tmpname[128], newname[128];
int type, l; int type, l;
const char *str; const char *str;
const char *opt_name;
dirname[0] = 0; dirname[0] = 0;
if (name && name[0]) { if (name && name[0]) {
@ -316,6 +317,7 @@ int conf_write(const char *name)
"# Automatically generated make config: don't edit\n" "# Automatically generated make config: don't edit\n"
"#\n"); "#\n");
if (out_h) { if (out_h) {
fprintf(out_h, "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H\n");
fprintf(out_h, "/*\n" fprintf(out_h, "/*\n"
" * Automatically generated header file: don't edit\n" " * Automatically generated header file: don't edit\n"
" */\n\n" " */\n\n"
@ -367,14 +369,23 @@ int conf_write(const char *name)
if (modules_sym->curr.tri == no) if (modules_sym->curr.tri == no)
type = S_BOOLEAN; type = S_BOOLEAN;
} }
opt_name = strchr(sym->name, '_');
if(opt_name == NULL)
opt_name = sym->name;
else
opt_name++;
switch (type) { switch (type) {
case S_BOOLEAN: case S_BOOLEAN:
case S_TRISTATE: case S_TRISTATE:
switch (sym_get_tristate_value(sym)) { switch (sym_get_tristate_value(sym)) {
case no: case no:
fprintf(out, "# %s is not set\n", sym->name); fprintf(out, "# %s is not set\n", sym->name);
if (out_h) if (out_h) {
fprintf(out_h, "#undef %s\n", sym->name); fprintf(out_h, "#undef %s\n", sym->name);
fprintf(out_h, "#define ENABLE_%s 0\n", opt_name);
fprintf(out_h, "#define USE_%s(...)\n", opt_name);
fprintf(out_h, "#define UNUSE_%s(...) __VA_ARGS__\n", opt_name);
}
break; break;
case mod: case mod:
#if 0 #if 0
@ -385,8 +396,12 @@ int conf_write(const char *name)
break; break;
case yes: case yes:
fprintf(out, "%s=y\n", sym->name); fprintf(out, "%s=y\n", sym->name);
if (out_h) if (out_h) {
fprintf(out_h, "#define %s 1\n", sym->name); fprintf(out_h, "#define %s 1\n", sym->name);
fprintf(out_h, "#define ENABLE_%s 1\n", opt_name);
fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", opt_name);
fprintf(out_h, "#define UNUSE_%s(...)\n", opt_name);
}
break; break;
} }
break; break;
@ -412,32 +427,47 @@ int conf_write(const char *name)
} }
} while (*str); } while (*str);
fputs("\"\n", out); fputs("\"\n", out);
if (out_h) if (out_h) {
fputs("\"\n", out_h); fputs("\"\n", out_h);
fprintf(out_h, "#define ENABLE_%s 1\n", opt_name);
fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", opt_name);
fprintf(out_h, "#define UNUSE_%s(...)\n", opt_name);
}
break; break;
case S_HEX: case S_HEX:
str = sym_get_string_value(sym); str = sym_get_string_value(sym);
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
if (out_h) if (out_h) {
fprintf(out_h, "#define %s 0x%s\n", sym->name, str); fprintf(out_h, "#define %s 0x%s\n", sym->name, str);
fprintf(out_h, "#define ENABLE_%s 1\n", opt_name);
fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", opt_name);
fprintf(out_h, "#define UNUSE_%s(...)\n", opt_name);
}
break; break;
} }
case S_INT: case S_INT:
str = sym_get_string_value(sym); str = sym_get_string_value(sym);
fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
if (out_h) if (out_h) {
fprintf(out_h, "#define %s %s\n", sym->name, str); fprintf(out_h, "#define %s %s\n", sym->name, str);
fprintf(out_h, "#define ENABLE_%s 1\n", opt_name);
fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", opt_name);
fprintf(out_h, "#define UNUSE_%s(...)\n", opt_name);
}
break; break;
} }
if (out_h)
fprintf(out_h, "\n");
} }
next: next:
menu = next_menu(menu); menu = next_menu(menu);
} }
fclose(out); fclose(out);
if (out_h) { if (out_h) {
fprintf(out_h, "#endif /* BB_CONFIG_H */\n");
fclose(out_h); fclose(out_h);
rename(".tmpconfig.h", "include/config.h"); rename(".tmpconfig.h", "include/bb_config.h");
file_write_dep(NULL); file_write_dep(NULL);
} }
if (!name || basename != conf_def_filename) { if (!name || basename != conf_def_filename) {