[PATCH] LDFLAGS configuration

Shaun Jackman sjackman at gmail.com
Thu Jun 8 09:11:25 PDT 2006


On 6/8/06, Rob Landley <rob at landley.net> wrote:
> On Wednesday 07 June 2006 7:48 pm, Shaun Jackman wrote:
> > There needs to be some mechanism to configure both features and the
> > build environment. If we want to reserve make config for features
> > alone, let's have Rules.mak include .config.mak if it exists, and
> > allow the user to edit .config.mak and add CFLAGS, LDFLAGS, LDLIBS,
> > and whatever else tickles his or her fancy, there.
>
> As long as we document that in the FAQ and the README, it would work for me...

I haven't included the documentation changes, yet, but here's my
proposed patch. It removes EXTRA_CFLAGS, instead preferring the user
simply add to CFLAGS using CFLAGS+= in .config.mak. I haven't yet
removed CROSS_COMPILER_PREFIX, but it should go as well.

Rob, you've convinced me. Now that I've seen it, I prefer this
implementation over 1001 .config options.

Cheers,
Shaun

2006-06-08  Shaun Jackman  <sjackman at gmail.com>

	* Config.in (EXTRA_CFLAGS_OPTIONS): Remove.
	* Rules.mak: Remove the build environment configuration. Instead,
	source $(top_builddir)/.config.mak.

============================================================
--- Config.in	279307d739f02a96ab25828c9363fd1a1a001333
+++ Config.in	a12fb232bfded0dbdffb3493616ffc93ad6e1eb6
@@ -294,15 +294,6 @@
  	  then I would enter '/usr/i386-linux-uclibc/bin/i386-uclibc-' here,
 	  which will ensure the correct compiler is used.

-config EXTRA_CFLAGS_OPTIONS
-	string "Any extra CFLAGS options for the compiler?"
-	default ""
-	help
-	  Do you want to pass any extra CFLAGS options to the compiler as
-	  you build BusyBox? If so, this is the option for you...  For example,
-	  if you want to add some simple compiler switches (like -march=i686),
-	  or check for warnings using -Werror, just those options here.
-
  config CONFIG_BUILD_AT_ONCE
  	bool "Compile all sources at once"
 	default n
============================================================
--- Rules.mak	fd8ab5152aaf143bfc13accfaf6aacb22ec73c57
+++ Rules.mak	366d8d75b8bf8dba9807c6783ce520ac964183de
@@ -52,28 +52,9 @@
  # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
 LC_ALL:= C

-# If you want to add some simple compiler switches (like -march=i686),
-# especially from the command line, use this instead of CFLAGS directly.
-# For optimization overrides, it's better still to set OPTIMIZATION.
-CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
-
-# To compile vs some other alternative libc, you may need to use/adjust
-# the following lines to meet your needs...
-#
-# If you are using Red Hat 6.x with the compatible RPMs (for developing under
-# Red Hat 5.x and glibc 2.0) uncomment the following.  Be sure to read about
-# using the compatible RPMs (compat-*) at http://www.redhat.com !
-#LIBCDIR:=/usr/i386-glibc20-linux
-#
-# For other libraries, you are on your own.  But these may (or may not) help...
-#LDFLAGS+=-nostdlib
-#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
-#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
-#GCCINCDIR:=$(shell gcc -print-search-dirs | $(SED) -ne "s/install:
\(.*\)/\1include/gp")
-
  # This must bind late because srcdir is reset for every source subdirectory.
 INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
-CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
+CFLAGS+=$(INCS) -I$(srcdir) -D_GNU_SOURCE
  CFLAGS+=$(CHECKED_CFLAGS)
  ARFLAGS=cru

@@ -329,7 +310,7 @@

 # Put user-supplied flags at the end, where they
 # have a chance of winning.
-CFLAGS += $(CFLAGS_EXTRA)
+-include $(top_builddir)/.config.mak

 #------------------------------------------------------------
 # Installation options
@@ -395,10 +376,10 @@
  disp_gen           = $(SECHO) "  "GEN $@ ; true
  disp_doc           = $(SECHO) "  "DOC $(subst docs/,,$@) ; true
  disp_elf2flt       = $($(DISP)_disp_elf2flt)
-cmd_compile.c      = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
+cmd_compile.c      = $(CC) $(CFLAGS) -c -o $@ $<
 cmd_compile.h      = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
 cmd_strip          = $(STRIPCMD) $@
-cmd_link           = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
+cmd_link           = $(CC) $(CFLAGS) $(LDFLAGS)
 cmd_link.h         = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
  cmd_ar             = $(AR) $(ARFLAGS) $@ $^
 cmd_elf2flt        = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@
-------------- next part --------------
2006-06-08  Shaun Jackman  <sjackman at gmail.com>

	* Config.in (EXTRA_CFLAGS_OPTIONS): Remove.
	* Rules.mak: Remove the build environment configuration. Instead,
	source $(top_builddir)/.config.mak.

============================================================
--- Config.in	279307d739f02a96ab25828c9363fd1a1a001333
+++ Config.in	a12fb232bfded0dbdffb3493616ffc93ad6e1eb6
@@ -294,15 +294,6 @@
 	  then I would enter '/usr/i386-linux-uclibc/bin/i386-uclibc-' here,
 	  which will ensure the correct compiler is used.
 
-config EXTRA_CFLAGS_OPTIONS
-	string "Any extra CFLAGS options for the compiler?"
-	default ""
-	help
-	  Do you want to pass any extra CFLAGS options to the compiler as
-	  you build BusyBox? If so, this is the option for you...  For example,
-	  if you want to add some simple compiler switches (like -march=i686),
-	  or check for warnings using -Werror, just those options here.
-
 config CONFIG_BUILD_AT_ONCE
 	bool "Compile all sources at once"
 	default n
============================================================
--- Rules.mak	fd8ab5152aaf143bfc13accfaf6aacb22ec73c57
+++ Rules.mak	366d8d75b8bf8dba9807c6783ce520ac964183de
@@ -52,28 +52,9 @@
 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
 LC_ALL:= C
 
-# If you want to add some simple compiler switches (like -march=i686),
-# especially from the command line, use this instead of CFLAGS directly.
-# For optimization overrides, it's better still to set OPTIMIZATION.
-CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
-
-# To compile vs some other alternative libc, you may need to use/adjust
-# the following lines to meet your needs...
-#
-# If you are using Red Hat 6.x with the compatible RPMs (for developing under
-# Red Hat 5.x and glibc 2.0) uncomment the following.  Be sure to read about
-# using the compatible RPMs (compat-*) at http://www.redhat.com !
-#LIBCDIR:=/usr/i386-glibc20-linux
-#
-# For other libraries, you are on your own.  But these may (or may not) help...
-#LDFLAGS+=-nostdlib
-#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
-#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
-#GCCINCDIR:=$(shell gcc -print-search-dirs | $(SED) -ne "s/install: \(.*\)/\1include/gp")
-
 # This must bind late because srcdir is reset for every source subdirectory.
 INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
-CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
+CFLAGS+=$(INCS) -I$(srcdir) -D_GNU_SOURCE
 CFLAGS+=$(CHECKED_CFLAGS)
 ARFLAGS=cru
 
@@ -329,7 +310,7 @@
 
 # Put user-supplied flags at the end, where they
 # have a chance of winning.
-CFLAGS += $(CFLAGS_EXTRA)
+-include $(top_builddir)/.config.mak
 
 #------------------------------------------------------------
 # Installation options
@@ -395,10 +376,10 @@
 disp_gen           = $(SECHO) "  "GEN $@ ; true
 disp_doc           = $(SECHO) "  "DOC $(subst docs/,,$@) ; true
 disp_elf2flt       = $($(DISP)_disp_elf2flt)
-cmd_compile.c      = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
+cmd_compile.c      = $(CC) $(CFLAGS) -c -o $@ $<
 cmd_compile.h      = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
 cmd_strip          = $(STRIPCMD) $@
-cmd_link           = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
+cmd_link           = $(CC) $(CFLAGS) $(LDFLAGS)
 cmd_link.h         = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
 cmd_ar             = $(AR) $(ARFLAGS) $@ $^
 cmd_elf2flt        = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@


More information about the busybox mailing list