-# This will choke on a non-debian system
-ARCH =`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
-
-CC = gcc
-
-GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p")
-GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p")
-
-
-GCCSUPPORTSOPTSIZE = $(shell \
-if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
- if ( test $(GCCMINVERSION) -ge 66 ) ; then \
- echo "true"; \
- else \
- echo "false"; \
- fi; \
-else \
- if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
- echo "true"; \
- else \
- echo "false"; \
- fi; \
-fi; )
-
-
-ifeq ($(GCCSUPPORTSOPTSIZE), true)
- OPTIMIZATION = -Os
-else
- OPTIMIZATION = -O2
-endif
-
-# Allow alternative stripping tools to be used...
-ifndef $(STRIPTOOL)
- STRIPTOOL = strip
+# Set the following to `true' to make a debuggable build.
+# Leave this set to `false' for production use.
+# eg: `make DODEBUG=true tests'
+# Do not enable this for production builds...
+DODEBUG = false
+
+# This enables compiling with dmalloc ( http://dmalloc.com/ )
+# which is an excellent public domain mem leak and malloc problem
+# detector. To enable dmalloc, before running busybox you will
+# want to first set up your environment.
+# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
+# Do not enable this for production builds...
+DODMALLOC = false
+
+# If you are running a cross compiler, you may want to set this
+# to something more interesting...
+CROSS =
+CC = $(CROSS)gcc
+STRIPTOOL = $(CROSS)strip
+
+# To compile vs an alternative libc, you may need to use/adjust
+# the following lines to meet your needs. This is how I make
+# busybox compile with uC-Libc...
+#LIBCDIR=/home/andersen/CVS/uC-libc
+#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
+#CFLAGS+=-nostdinc -fno-builtin -I$(LIBCDIR)/include -I$(GCCINCDIR)
+#LDFLAGS+=-nostdlib
+#LIBRARIES = $(LIBCDIR)/libc.a
+
+#--------------------------------------------------------
+
+# use '-Os' optimization if available, else use -O2
+OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+ then echo "-Os"; else echo "-O2" ; fi)
+
+WARNINGS = -Wall
+
+ifeq ($(DODMALLOC),true)
+ # For testing mem leaks with dmalloc
+ CFLAGS+=-DDMALLOC
+ LIBRARIES = -ldmalloc
+ # Force debug=true, since this is useless when not debugging...
+ DODEBUG = true