diff options
-rw-r--r-- | Makefile | 81 | ||||
-rw-r--r-- | common.mk | 48 | ||||
-rw-r--r-- | lib/Makefile | 22 | ||||
-rw-r--r-- | mkfs.ubifs/Makefile | 29 | ||||
-rw-r--r-- | tests/fs-tests/integrity/Makefile | 7 | ||||
-rw-r--r-- | tests/ubi-tests/Makefile | 10 | ||||
-rw-r--r-- | ubi-utils/Makefile | 60 | ||||
-rw-r--r-- | ubi-utils/dictionary.c (renamed from ubi-utils/src/dictionary.c) | 0 | ||||
-rw-r--r-- | ubi-utils/include/dictionary.h (renamed from ubi-utils/src/dictionary.h) | 0 | ||||
-rw-r--r-- | ubi-utils/libiniparser.c (renamed from ubi-utils/src/libiniparser.c) | 0 | ||||
-rw-r--r-- | ubi-utils/libscan.c (renamed from ubi-utils/src/libscan.c) | 0 | ||||
-rw-r--r-- | ubi-utils/libubi.c (renamed from ubi-utils/src/libubi.c) | 0 | ||||
-rw-r--r-- | ubi-utils/libubi_int.h (renamed from ubi-utils/src/libubi_int.h) | 0 | ||||
-rw-r--r-- | ubi-utils/libubigen.c (renamed from ubi-utils/src/libubigen.c) | 0 | ||||
-rw-r--r-- | ubi-utils/mtdinfo.c (renamed from ubi-utils/src/mtdinfo.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubiattach.c (renamed from ubi-utils/src/ubiattach.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubicrc32.c (renamed from ubi-utils/src/ubicrc32.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubidetach.c (renamed from ubi-utils/src/ubidetach.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubiformat.c (renamed from ubi-utils/src/ubiformat.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubimkvol.c (renamed from ubi-utils/src/ubimkvol.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubinfo.c (renamed from ubi-utils/src/ubinfo.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubinize.c (renamed from ubi-utils/src/ubinize.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubirename.c (renamed from ubi-utils/src/ubirename.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubirmvol.c (renamed from ubi-utils/src/ubirmvol.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubirsvol.c (renamed from ubi-utils/src/ubirsvol.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubiupdatevol.c (renamed from ubi-utils/src/ubiupdatevol.c) | 0 | ||||
-rw-r--r-- | ubi-utils/ubiutils-common.c (renamed from ubi-utils/src/ubiutils-common.c) | 0 |
27 files changed, 97 insertions, 160 deletions
@@ -1,7 +1,7 @@ # -*- sh -*- -CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) +CPPFLAGS += -I./include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) ifeq ($(WITHOUT_XATTR), 1) CPPFLAGS += -DWITHOUT_XATTR @@ -12,10 +12,10 @@ else LZOLDLIBS = -llzo2 endif -SUBDIRS = lib ubi-utils mkfs.ubifs TESTS = tests -TARGETS = ftl_format flash_erase nanddump doc_loadbios \ +MTD_BINS = \ + ftl_format flash_erase nanddump doc_loadbios \ ftl_check mkfs.jffs2 flash_lock flash_unlock flash_info \ flash_otp_info flash_otp_dump mtd_debug flashcp nandwrite nandtest \ jffs2dump \ @@ -23,16 +23,21 @@ TARGETS = ftl_format flash_erase nanddump doc_loadbios \ rfddump rfdformat \ serve_image recv_image \ sumtool #jffs2reader +UBI_BINS = \ + ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \ + ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol + +BINS = $(MTD_BINS) +BINS += mkfs.ubifs/mkfs.ubifs +BINS += $(addprefix ubi-utils/,$(UBI_BINS)) SCRIPTS = flash_eraseall -LDLIBS = -L$(BUILDDIR)/lib -lmtd -LDDEPS = $(BUILDDIR)/lib/libmtd.a +TARGETS = $(BINS) +TARGETS += lib/libmtd.a +TARGETS += ubi-utils/libubi.a include common.mk -# mkfs.ubifs needs -lubi which is in ubi-utils/ -subdirs_mkfs.ubifs_all: subdirs_ubi-utils_all - clean:: ifneq ($(BUILDDIR)/.git,) ifneq ($(BUILDDIR),.) @@ -41,23 +46,14 @@ ifneq ($(BUILDDIR),$(CURDIR)) endif endif endif + find $(BUILDDIR)/ -xdev \ + '(' -name '*.[ao]' -o -name '.*.c.dep' ')' \ + -exec rm -f {} + $(MAKE) -C $(TESTS) clean -$(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\ - compr_rtime.o mkfs.jffs2.o compr_zlib.o compr_lzo.o \ - compr.o rbtree.o) -LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS) -LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS) - -$(BUILDDIR)/jffs2reader: $(BUILDDIR)/jffs2reader.o -LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS) -LDLIBS_jffs2reader = -lz $(LZOLDLIBS) - -$(BUILDDIR)/lib/libmtd.a: subdirs_lib_all ; - -install:: ${TARGETS} ${SCRIPTS} +install:: ${BINS} ${SCRIPTS} mkdir -p ${DESTDIR}/${SBINDIR} - install -m 0755 ${TARGETS} ${SCRIPTS} ${DESTDIR}/${SBINDIR}/ + install -m 0755 ${BINS} ${SCRIPTS} ${DESTDIR}/${SBINDIR}/ mkdir -p ${DESTDIR}/${MANDIR}/man1 gzip -9c mkfs.jffs2.1 > ${DESTDIR}/${MANDIR}/man1/mkfs.jffs2.1.gz @@ -66,3 +62,44 @@ tests:: cscope: cscope -bR + +# +# Utils in top level +# +obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o compr_lzo.o compr.o rbtree.o +LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS) +LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS) + +LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS) +LDLIBS_jffs2reader = -lz $(LZOLDLIBS) + +$(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v)))) + +# +# Common libmtd +# +obj-libmtd.a = libmtd.o libmtd_legacy.o libcrc32.o libfec.o +$(call _mkdep,lib/,libmtd.a) + +# +# Utils in mkfs.ubifs subdir +# +obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \ + hashtable/hashtable.o hashtable/hashtable_itr.o +LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid +$(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a) + +# +# Utils in ubi-utils/ subdir +# +obj-libiniparser.a = libiniparser.o dictionary.o +obj-libscan.a = libscan.o +obj-libubi.a = libubi.o +obj-libubigen.a = libubigen.o + +obj-mtdinfo = libubigen.a +obj-ubinize = libubigen.a libiniparser.a +obj-ubiformat = libubigen.a libscan.a + +$(foreach v,libubi.a libubigen.a libiniparser.a libscan.a,$(eval $(call _mkdep,ubi-utils/,$(v)))) +$(foreach v,$(UBI_BINS),$(eval $(call mkdep,ubi-utils/,$(v),libubi.a ubiutils-common.o))) @@ -39,34 +39,48 @@ override BUILDDIR := $(patsubst %/,%,$(BUILDDIR)) override TARGETS := $(addprefix $(BUILDDIR)/,$(TARGETS)) -SUBDIRS_ALL = $(patsubst %,subdirs_%_all,$(SUBDIRS)) -SUBDIRS_CLEAN = $(patsubst %,subdirs_%_clean,$(SUBDIRS)) -SUBDIRS_INSTALL = $(patsubst %,subdirs_%_install,$(SUBDIRS)) +ifeq ($(V),1) +XECHO = @: +XPRINTF = @: +Q = +else +XECHO = @echo +XPRINTF = @printf +Q = @ +endif +define BECHO +$(XPRINTF) ' %-7s %s\n' "$1" "$(subst $(BUILDDIR)/,,$@)" +endef -all:: $(TARGETS) $(SUBDIRS_ALL) +all:: $(TARGETS) -clean:: $(SUBDIRS_CLEAN) +clean:: rm -f $(BUILDDIR)/*.o $(TARGETS) $(BUILDDIR)/.*.c.dep -install:: $(TARGETS) $(SUBDIRS_INSTALL) +install:: $(TARGETS) -%: %.o $(LDDEPS) $(LDDEPS_$(notdir $@)) - $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_$(notdir $@)) -g -o $@ $^ $(LDLIBS) $(LDLIBS_$(notdir $@)) +define _mkdep +$(BUILDDIR)/$1$2: $(addprefix $(BUILDDIR)/$1,$(obj-$2) $3) $(addprefix $(BUILDDIR)/,$4) +endef +define mkdep +$(call _mkdep,$1,$2,$3 $2.o,$4 lib/libmtd.a) +endef + +%: %.o $(LDDEPS) + $(call BECHO,LD) + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_$(notdir $@)) -g -o $@ $^ $(LDLIBS) $(LDLIBS_$(notdir $@)) $(BUILDDIR)/%.a: - $(AR) crv $@ $^ - $(RANLIB) $@ + $(call BECHO,AR) + $(Q)$(AR) cr $@ $^ + $(Q)$(RANLIB) $@ $(BUILDDIR)/%.o: %.c ifneq ($(BUILDDIR),$(CURDIR)) - mkdir -p $(dir $@) + $(Q)mkdir -p $(dir $@) endif - $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(<F).dep - -subdirs_%: - d=$(patsubst subdirs_%,%,$@); \ - t=`echo $$d | sed s:.*_::` d=`echo $$d | sed s:_.*::`; \ - $(MAKE) BUILDDIR=$(BUILDDIR)/$$d -C $$d $$t + $(call BECHO,CC) + $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(<F).dep .SUFFIXES: diff --git a/lib/Makefile b/lib/Makefile deleted file mode 100644 index 9b01d32..0000000 --- a/lib/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# -# Makefile for libmtd -# - -SUBDIRS = - -# CFLAGS += -Werror -CPPFLAGS += -I../include -LIBS = libmtd -TARGETS = libmtd.a - -include ../common.mk - -$(BUILDDIR)/libmtd.a: $(addprefix $(BUILDDIR)/,\ - libmtd.o libmtd_legacy.o libcrc32.o libfec.o) - -clean:: - rm -f $(addsuffix .a, $(LIBS)) - -install:: - -uninstall: diff --git a/mkfs.ubifs/Makefile b/mkfs.ubifs/Makefile deleted file mode 100644 index ba21a8c..0000000 --- a/mkfs.ubifs/Makefile +++ /dev/null @@ -1,29 +0,0 @@ - -CPPFLAGS += -I../include -I../ubi-utils/include -CPPFLAGS += $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) - -ALL_SOURCES=*.[ch] hashtable/*.[ch] - -TARGETS = mkfs.ubifs - -LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi -LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd -LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS) - -include ../common.mk - -$(BUILDDIR)/mkfs.ubifs: $(addprefix $(BUILDDIR)/,\ - crc16.o lpt.o compr.o devtable.o \ - hashtable/hashtable.o hashtable/hashtable_itr.o) - -clean:: - rm -f $(BUILDDIR)/hashtable/*.o cscope.* - -cscope: - @echo $(ALL_SOURCES) > cscope.files - @cscope -bR - @rm cscope.files - -install:: ${TARGETS} - mkdir -p ${DESTDIR}/${SBINDIR} - install -m 0755 ${TARGETS} ${DESTDIR}/${SBINDIR}/ diff --git a/tests/fs-tests/integrity/Makefile b/tests/fs-tests/integrity/Makefile index 509a94e..4d6fc7d 100644 --- a/tests/fs-tests/integrity/Makefile +++ b/tests/fs-tests/integrity/Makefile @@ -4,9 +4,8 @@ CC = gcc endif COMMON_HEADERS_DIR := ../../../include -LIBUBI_PATH=../../../ubi-utils/ -LIBUBI_SRC_PATH=../../../ubi-utils/src/ -LIBUBI_HEADER_PATH=../../../ubi-utils/include +LIBUBI_PATH = ../../../ubi-utils/ +LIBUBI_HEADER_PATH = $(LIBUBI_PATH)/include CFLAGS := $(CFLAGS) -Wall -g -O2 -I$(COMMON_HEADERS_DIR) -I$(LIBUBI_HEADER_PATH) @@ -18,7 +17,7 @@ all: $(TARGETS) # Compile ubilib libubi.a: - $(CC) $(CFLAGS) -I $(LIBUBI_SRC_PATH) -c $(LIBUBI_SRC_PATH)/libubi.c -o libubi.o + $(CC) $(CFLAGS) -c $(LIBUBI_PATH)/libubi.c -o libubi.o ar cr libubi.a libubi.o $(TARGETS): libubi.a diff --git a/tests/ubi-tests/Makefile b/tests/ubi-tests/Makefile index 741a5c2..2c47a9f 100644 --- a/tests/ubi-tests/Makefile +++ b/tests/ubi-tests/Makefile @@ -1,9 +1,7 @@ -LIBUBI_PATH=../../ubi-utils/ -LIBUBI_SRC_PATH=../../ubi-utils/src/ -LIBUBI_HEADER_PATH=../../ubi-utils/include +LIBUBI_PATH = ../../ubi-utils/ +LIBUBI_HEADER_PATH = $(LIBUBI_PATH)/include UBIUTILS_PATH=../../ubi-utils/ -LIBUBI_PATH=../../ubi-utils/ KERNELHDR := ../../include LIBS = libubi @@ -15,8 +13,8 @@ CFLAGS += -I$(LIBUBI_HEADER_PATH) -I $(KERNELHDR) -lpthread include ../../common.mk # Compile ubilib with the udevsettle hack -libubi.a: $(LIBUBI_SRC_PATH)/libubi.c $(LIBUBI_HEADER_PATH)/libubi.h $(LIBUBI_SRC_PATH)/libubi_int.h - $(CC) $(CFLAGS) -I $(LIBUBI_SRC_PATH) -I../../include -DUDEV_SETTLE_HACK -c $(LIBUBI_SRC_PATH)/libubi.c -o libubi.o +libubi.a: $(LIBUBI_PATH)/libubi.c $(LIBUBI_HEADER_PATH)/libubi.h $(LIBUBI_PATH)/libubi_int.h + $(CC) $(CFLAGS) -I $(LIBUBI_PATH) -I../../include -DUDEV_SETTLE_HACK -c $(LIBUBI_PATH)/libubi.c -o libubi.o ar cr libubi.a libubi.o $(TARGETS): $(addprefix $(BUILDDIR)/, common.o) libubi.a diff --git a/ubi-utils/Makefile b/ubi-utils/Makefile deleted file mode 100644 index df81cd9..0000000 --- a/ubi-utils/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# -# Makefile for ubi-utils -# - -KERNELHDR := ../include - -# CFLAGS += -Werror -CPPFLAGS += -Iinclude -Isrc -I$(KERNELHDR) - -LIBS = libubi libubigen libiniparser libscan -TARGETS = ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \ - ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol - -VPATH = src -LDLIBS = -L$(BUILDDIR)/../lib -lmtd - -include ../common.mk - -# And the below is the rule to get final executable from its .o and ubiutils-common.o -$(TARGETS): $(addprefix $(BUILDDIR)/,\ - libubi.a ubiutils-common.o) -# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lubi -o $@ - -$(BUILDDIR)/ubicrc32: $(addprefix $(BUILDDIR)/,\ - ubicrc32.o) -# $(CC) $(CFLAGS) -o $@ $^ - -$(BUILDDIR)/ubinize: $(addprefix $(BUILDDIR)/,\ - ubinize.o ubiutils-common.o libiniparser.a libubigen.a) -# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -liniparser -lubigen -o $@ - -$(BUILDDIR)/mtdinfo: $(addprefix $(BUILDDIR)/,\ - libubigen.a ubiutils-common.o) -# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lubigen -o $@ - -$(BUILDDIR)/ubiformat: $(addprefix $(BUILDDIR)/,\ - ubiformat.o ubiutils-common.o libscan.a libubi.a libubigen.a) -# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lscan -lubi -lubigen -o $@ - -$(BUILDDIR)/libubi.a: $(BUILDDIR)/libubi.o - -$(BUILDDIR)/libubigen.a: $(BUILDDIR)/libubigen.o - -$(BUILDDIR)/libiniparser.a: $(addprefix $(BUILDDIR)/,\ - libiniparser.o dictionary.o) - -$(BUILDDIR)/libscan.a: $(addprefix $(BUILDDIR)/,\ - libscan.o) - -clean:: - rm -f $(addsuffix .a, $(LIBS)) - -install:: - mkdir -p ${DESTDIR}/${SBINDIR} - install -m 0755 ${TARGETS} ${DESTDIR}/${SBINDIR}/ - -uninstall: - for file in ${TARGETS}; do \ - $(RM) ${DESTDIR}/${SBINDIR}/$$file; \ - done diff --git a/ubi-utils/src/dictionary.c b/ubi-utils/dictionary.c index b7c9ebf..b7c9ebf 100644 --- a/ubi-utils/src/dictionary.c +++ b/ubi-utils/dictionary.c diff --git a/ubi-utils/src/dictionary.h b/ubi-utils/include/dictionary.h index c7d1790..c7d1790 100644 --- a/ubi-utils/src/dictionary.h +++ b/ubi-utils/include/dictionary.h diff --git a/ubi-utils/src/libiniparser.c b/ubi-utils/libiniparser.c index 3bea51e..3bea51e 100644 --- a/ubi-utils/src/libiniparser.c +++ b/ubi-utils/libiniparser.c diff --git a/ubi-utils/src/libscan.c b/ubi-utils/libscan.c index dc47a89..dc47a89 100644 --- a/ubi-utils/src/libscan.c +++ b/ubi-utils/libscan.c diff --git a/ubi-utils/src/libubi.c b/ubi-utils/libubi.c index 4d5f316..4d5f316 100644 --- a/ubi-utils/src/libubi.c +++ b/ubi-utils/libubi.c diff --git a/ubi-utils/src/libubi_int.h b/ubi-utils/libubi_int.h index c3aa37a..c3aa37a 100644 --- a/ubi-utils/src/libubi_int.h +++ b/ubi-utils/libubi_int.h diff --git a/ubi-utils/src/libubigen.c b/ubi-utils/libubigen.c index 9eaa7f5..9eaa7f5 100644 --- a/ubi-utils/src/libubigen.c +++ b/ubi-utils/libubigen.c diff --git a/ubi-utils/src/mtdinfo.c b/ubi-utils/mtdinfo.c index bfd7e6d..bfd7e6d 100644 --- a/ubi-utils/src/mtdinfo.c +++ b/ubi-utils/mtdinfo.c diff --git a/ubi-utils/src/ubiattach.c b/ubi-utils/ubiattach.c index 4f18e99..4f18e99 100644 --- a/ubi-utils/src/ubiattach.c +++ b/ubi-utils/ubiattach.c diff --git a/ubi-utils/src/ubicrc32.c b/ubi-utils/ubicrc32.c index 73ec595..73ec595 100644 --- a/ubi-utils/src/ubicrc32.c +++ b/ubi-utils/ubicrc32.c diff --git a/ubi-utils/src/ubidetach.c b/ubi-utils/ubidetach.c index 668f1bd..668f1bd 100644 --- a/ubi-utils/src/ubidetach.c +++ b/ubi-utils/ubidetach.c diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/ubiformat.c index c4b944a..c4b944a 100644 --- a/ubi-utils/src/ubiformat.c +++ b/ubi-utils/ubiformat.c diff --git a/ubi-utils/src/ubimkvol.c b/ubi-utils/ubimkvol.c index 25065e3..25065e3 100644 --- a/ubi-utils/src/ubimkvol.c +++ b/ubi-utils/ubimkvol.c diff --git a/ubi-utils/src/ubinfo.c b/ubi-utils/ubinfo.c index 8e14e6e..8e14e6e 100644 --- a/ubi-utils/src/ubinfo.c +++ b/ubi-utils/ubinfo.c diff --git a/ubi-utils/src/ubinize.c b/ubi-utils/ubinize.c index 3085b66..3085b66 100644 --- a/ubi-utils/src/ubinize.c +++ b/ubi-utils/ubinize.c diff --git a/ubi-utils/src/ubirename.c b/ubi-utils/ubirename.c index 070e32e..070e32e 100644 --- a/ubi-utils/src/ubirename.c +++ b/ubi-utils/ubirename.c diff --git a/ubi-utils/src/ubirmvol.c b/ubi-utils/ubirmvol.c index 5725d90..5725d90 100644 --- a/ubi-utils/src/ubirmvol.c +++ b/ubi-utils/ubirmvol.c diff --git a/ubi-utils/src/ubirsvol.c b/ubi-utils/ubirsvol.c index 65f579c..65f579c 100644 --- a/ubi-utils/src/ubirsvol.c +++ b/ubi-utils/ubirsvol.c diff --git a/ubi-utils/src/ubiupdatevol.c b/ubi-utils/ubiupdatevol.c index 24f38fe..24f38fe 100644 --- a/ubi-utils/src/ubiupdatevol.c +++ b/ubi-utils/ubiupdatevol.c diff --git a/ubi-utils/src/ubiutils-common.c b/ubi-utils/ubiutils-common.c index 6609a6b..6609a6b 100644 --- a/ubi-utils/src/ubiutils-common.c +++ b/ubi-utils/ubiutils-common.c |