-ifneq ($(CONFIG_BIG_ENDIAN),y)
-JFFS2OPTS := --pad --little-endian --squash
-SQUASHFS_OPTS := -le
+.NOTPARALLEL:
+override MAKEFLAGS=
+override MAKE:=$(SUBMAKE)
+KDIR=$(KERNEL_BUILD_DIR)
+
+IMG_PREFIX:=openwrt-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
+
+ifneq ($(CONFIG_BIG_ENDIAN),)
+ JFFS2OPTS := --pad --big-endian --squash -v
+ SQUASHFS_OPTS := -be
+else
+ JFFS2OPTS := --pad --little-endian --squash -v
+ SQUASHFS_OPTS := -le
+endif
+
+ifeq ($(CONFIG_JFFS2_RTIME),y)
+ JFFS2OPTS += -X rtime
+endif
+ifeq ($(CONFIG_JFFS2_ZLIB),y)
+ JFFS2OPTS += -X zlib
+endif
+ifeq ($(CONFIG_JFFS2_LZMA),y)
+ JFFS2OPTS += -X lzma --compression-mode=size
+endif
+ifneq ($(CONFIG_JFFS2_RTIME),y)
+ JFFS2OPTS += -x rtime
+endif
+ifneq ($(CONFIG_JFFS2_ZLIB),y)
+ JFFS2OPTS += -x zlib
+endif
+ifneq ($(CONFIG_JFFS2_LZMA),y)
+ JFFS2OPTS += -x lzma
+endif
+
+ifneq ($(CONFIG_LINUX_2_4)$(CONFIG_LINUX_2_6_25),)
+ USE_SQUASHFS3 := y
+endif
+
+ifneq ($(USE_SQUASHFS3),)
+ MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs-lzma