aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-07-27 06:55:36 +0000
committerRob Landley <rob@landley.net>2005-07-27 06:55:36 +0000
commit193c8c73834b701f93c421fc88a2ecb715fd6fe5 (patch)
tree8467a696b1990e665391d4fcde21c8f176f27cd1
parent77804ce53d2a83d89e272a20763f2e6f5fc25d8c (diff)
downloadbusybox-w32-193c8c73834b701f93c421fc88a2ecb715fd6fe5.tar.gz
busybox-w32-193c8c73834b701f93c421fc88a2ecb715fd6fe5.tar.bz2
busybox-w32-193c8c73834b701f93c421fc88a2ecb715fd6fe5.zip
#ifdef reduction infrastructure, based on an argument between Shaun Jackman,
Rob Landley, and others. Currently CONFIG options are defined or undefined, so we chop out code with #ifdefs, ala: #ifdef CONFIG_THING stuff(); #endif This creates a new header file, bb_config.h, which sets the CONFIG entry to 1 or 0, and lets us do: if(CONFIG_THING) stuff(); And let the compiler do dead code elimination to get rid of it. (Note: #ifdef will still work because for the 1 case it's a static const int, not a #define.)
-rw-r--r--Makefile9
-rw-r--r--include/busybox.h2
-rw-r--r--include/libbb.h2
-rw-r--r--networking/ifconfig.c2
4 files changed, 11 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index d205bb1b6..807ab5058 100644
--- a/Makefile
+++ b/Makefile
@@ -122,7 +122,7 @@ $(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
122include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) 122include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
123-include $(top_builddir)/.depend 123-include $(top_builddir)/.depend
124 124
125busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y) 125busybox: $(ALL_MAKEFILES) .depend include/bb_config.h $(libraries-y)
126 $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group 126 $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
127 $(STRIPCMD) $@ 127 $(STRIPCMD) $@
128 128
@@ -212,6 +212,11 @@ include/config.h: .config
212 fi; 212 fi;
213 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) 213 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
214 214
215include/bb_config.h: include/config.h
216 echo "#ifndef AUTOCONF_INCLUDED" > $@
217 sed -e 's/#undef \(.*\)/static const int \1 = 0;/' < $< >> $@
218 echo "#endif" >> $@
219
215finished2: 220finished2:
216 @echo 221 @echo
217 @echo Finished installing... 222 @echo Finished installing...
@@ -279,7 +284,7 @@ clean:
279 284
280distclean: clean 285distclean: clean
281 - rm -f scripts/split-include scripts/mkdep 286 - rm -f scripts/split-include scripts/mkdep
282 - rm -rf include/config include/config.h 287 - rm -rf include/config include/config.h include/bb_config.h
283 - find . -name .depend -exec rm -f {} \; 288 - find . -name .depend -exec rm -f {} \;
284 rm -f .config .config.old .config.cmd 289 rm -f .config .config.old .config.cmd
285 - $(MAKE) -C scripts/config clean 290 - $(MAKE) -C scripts/config clean
diff --git a/include/busybox.h b/include/busybox.h
index 3ff3d8a37..e7ed135c0 100644
--- a/include/busybox.h
+++ b/include/busybox.h
@@ -24,7 +24,7 @@
24#ifndef _BB_INTERNAL_H_ 24#ifndef _BB_INTERNAL_H_
25#define _BB_INTERNAL_H_ 1 25#define _BB_INTERNAL_H_ 1
26 26
27#include "config.h" 27#include "bb_config.h"
28 28
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
diff --git a/include/libbb.h b/include/libbb.h
index 1aa7b41bd..a544465fe 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -41,7 +41,7 @@
41 41
42#include <features.h> 42#include <features.h>
43 43
44#include "config.h" 44#include "bb_config.h"
45#ifdef CONFIG_SELINUX 45#ifdef CONFIG_SELINUX
46#include <selinux/selinux.h> 46#include <selinux/selinux.h>
47#endif 47#endif
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index fc7798f2d..1b43a0825 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -37,6 +37,7 @@
37#include <string.h> /* strcmp and friends */ 37#include <string.h> /* strcmp and friends */
38#include <ctype.h> /* isdigit and friends */ 38#include <ctype.h> /* isdigit and friends */
39#include <stddef.h> /* offsetof */ 39#include <stddef.h> /* offsetof */
40#include <unistd.h>
40#include <netdb.h> 41#include <netdb.h>
41#include <sys/ioctl.h> 42#include <sys/ioctl.h>
42#include <net/if.h> 43#include <net/if.h>
@@ -558,6 +559,7 @@ int ifconfig_main(int argc, char **argv)
558 continue; 559 continue;
559 } /* end of while-loop */ 560 } /* end of while-loop */
560 561
562 if (CONFIG_FEATURE_CLEAN_UP) close(sockfd);
561 return goterr; 563 return goterr;
562} 564}
563 565