cp: FEATURE_CP_LONG_OPTIONS depends on LONG_OPTS
[oweals/busybox.git] / scripts / Makefile.IMA
index 29399178eb3ce808108d5c5ebfdb00ec1349c6eb..a34db50f473d5ad936bbcb59d5bef301ba61ebeb 100644 (file)
@@ -1,4 +1,7 @@
 # This is completely unsupported.
+#
+# Uasge: make -f scripts/Makefile.IMA
+#
 # Fix COMBINED_COMPILE upstream (in the Kbuild) and propagate
 # the changes back
 srctree                := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
@@ -11,6 +14,24 @@ MAKEFLAGS += --include-dir=$(srctree)
 
 default: busybox
 
+include .config
+
+# Cross compiling and selecting different set of gcc/bin-utils
+ifeq ($(CROSS_COMPILE),)
+CROSS_COMPILE := $(subst ",,$(CONFIG_CROSS_COMPILER_PREFIX))
+endif
+
+ifneq ($(CROSS_COMPILE),)
+SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
+else
+SUBARCH := $(shell uname -m)
+endif
+SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+                                         -e s/arm.*/arm/ -e s/sa110/arm/ \
+                                         -e s/s390x/s390/ -e s/parisc64/parisc/ \
+                                         -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
+ARCH ?= $(SUBARCH)
+
 ifndef HOSTCC
 HOSTCC = cc
 endif
@@ -24,14 +45,15 @@ STRIP           = $(CROSS_COMPILE)strip
 OBJCOPY         = $(CROSS_COMPILE)objcopy
 OBJDUMP         = $(CROSS_COMPILE)objdump
 
-CFLAGS := $(CFLAGS)
-CPPFLAGS+= -D"KBUILD_STR(s)=\#s" #-Q
+CFLAGS   := $(CFLAGS)
+CPPFLAGS += -D"KBUILD_STR(s)=\#s" #-Q
 
-include .config
 # We need some generic definitions
 include $(srctree)/scripts/Kbuild.include
 
 include Makefile.flags
+
+-include $(srctree)/arch/$(ARCH)/Makefile
 ifdef CONFIG_FEATURE_COMPRESS_USAGE
 usage_stuff = include/usage_compressed.h
 endif
@@ -158,7 +180,7 @@ busybox_unstripped.o: $(usage_stuff) include/applet_tables.h include/autoconf.h
 busybox: busybox_unstripped.o
        $(srctree)/scripts/trylink \
                busybox_unstripped \
-               "$(CC)" \
+               "$(CC) $(CFLAGS_busybox)" \
                "$(CFLAGS)" \
                "$(LDFLAGS)" \
                "busybox_unstripped.o" \