-CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
-# For debugging only
-#CFLAGS=-Wall -g -D_GNU_SOURCE
-LIBRARIES=-lc
-OBJECTS=$(shell ./busybox.obj) utility.o
+ifeq ($(DODEBUG),true)
+ CFLAGS += -Wall -g -fno-builtin -D_GNU_SOURCE
+ LDFLAGS +=
+ STRIP =
+else
+ CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
+ LDFLAGS += -s
+ STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
+ #Only staticly link when _not_ debugging
+ ifeq ($(DOSTATIC),true)
+ LDFLAGS += --static
+ #
+ #use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work
+ #to try and strip out any unused junk. Doesn't do much for me, but you may
+ #want to give it a shot...
+ #
+ #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
+ # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
+ # CFLAGS += -ffunction-sections -fdata-sections
+ # LDFLAGS += --gc-sections
+ #endif
+ endif
+endif
+
+ifndef $(PREFIX)
+ PREFIX = `pwd`/_install
+endif
+
+
+OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
+CFLAGS += -DBB_VER='"$(VERSION)"'
+CFLAGS += -DBB_BT='"$(BUILDTIME)"'
+ifdef BB_INIT_SCRIPT
+ CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
+endif