Skip to contentSkip to conversation

mtd-utils: make cross build functional again

RFC In review Sebastian Siewior 2 participants 2 messages Aug 26, 2008 – Aug 27, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 mtd-utils: make cross build functional again

as of current HEAD "make CROSS=whatever-" breaks once we leave the main Makefile.
With this patch everything builds except NTARGETS in ubi-utils and with CROSS being undefined.

The problem with CROSS being undefined could be solved by setting BUILDDIR explicit to "native" for instance.
The NTARGETS thing is a little tricky. The easiest solution would be probably to move the NTARGETS targets into its own Makefile.

Anyway, is this something worth to fix since it is almost a year broken? Should the BUILDDIR thing be removed or is it used?

---
 Makefile            |    6 ++++--
 mkfs.ubifs/Makefile |    6 ++++--
 ubi-utils/Makefile  |   26 ++++++++++++++------------
 3 files changed, 22 insertions(+), 16 deletions(-)
Makefile +4 -2
index 796c31b..d54e170 100644
@@ -47,8 +47,10 @@ $(BUILDDIR)/%.o: %.c
 .SUFFIXES:
 
 all: $(TARGETS)
-	$(MAKE) -C $(BUILDDIR)/ubi-utils
-	$(MAKE) -C $(BUILDDIR)/mkfs.ubifs
+	mkdir -p $(BUILDDIR)/ubi-utils
+	mkdir -p $(BUILDDIR)/mkfs.ubifs
+	$(MAKE) -C ubi-utils BUILDDIR=../$(BUILDDIR)/ubi-utils
+	$(MAKE) -C mkfs.ubifs BUILDDIR=../$(BUILDDIR)/mkfs.ubifs
 
 IGNORE=${wildcard $(BUILDDIR)/.*.c.dep}
 -include ${IGNORE}
mkfs.ubifs/Makefile +4 -2
index a327eee..81ef429 100644
@@ -3,11 +3,13 @@ SBINDIR=/usr/sbin
 ALL_SOURCES=*.[ch] hashtable/*.[ch]
 CFLAGS += -Wall
 LDLIBS += -lz -llzo2 -lm -luuid
-TARGETS = mkfs.ubifs
+RAWTARGETS = mkfs.ubifs
+
+TARGETS = $(foreach target,$(RAWTARGETS),$(BUILDDIR)/$(target))
 
 all: $(TARGETS)
 
-mkfs.ubifs: crc16.o crc32.o lpt.o compr.o hashtable/hashtable.o \
+$(BUILDDIR)/mkfs.ubifs: crc16.o crc32.o lpt.o compr.o hashtable/hashtable.o \
             hashtable/hashtable_itr.o devtable.o
 
 clean:
ubi-utils/Makefile +14 -12
index 4cca316..bdcd444 100644
@@ -18,16 +18,18 @@ PERLPROGS = mkpfi ubicrc32.pl
 
 NTARGETS = ubiattach ubicrc32 ubidetach ubimkvol ubinfo ubinize \
 	ubirmvol ubiupdatevol ubiformat
-TARGETS = pfiflash pddcustomize ubimirror bin2nand nand2bin ubigen \
+RAWTARGETS = pfiflash pddcustomize ubimirror bin2nand nand2bin ubigen \
 	mkbootenv unubi pfi2bin $(NTARGETS)
 
+TARGETS = $(foreach target,$(RAWTARGETS),$(BUILDDIR)/$(target))
+
 vpath   %.c ./src
 
 %: %.o
 	$(CC) $(LDFLAGS) -g -o $@ $^
 
-%.o: %.c
-	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,.$(shell basename $<).dep
+$(BUILDDIR)/%.o: %.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(shell basename $<).dep
 
 all: $(TARGETS)
 
@@ -42,34 +44,34 @@ clean:
 	rm -rf *.o $(TARGETS) .*.c.dep
 	$(MAKE) -C new-utils clean
 
-pddcustomize: pddcustomize.o error.o libubimirror.o bootenv.o hashmap.o \
+$(BUILDDIR)/pddcustomize: pddcustomize.o error.o libubimirror.o bootenv.o hashmap.o \
 		libubi.o crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-pfiflash: pfiflash.o libpfiflash.o list.o reader.o error.o libubimirror.o \
+$(BUILDDIR)/pfiflash: pfiflash.o libpfiflash.o list.o reader.o error.o libubimirror.o \
 		bootenv.o hashmap.o pfi.o libubi.o crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-ubimirror: ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \
+$(BUILDDIR)/ubimirror: ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \
 		libubi.o crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-nand2bin: nand2bin.o nandecc.o nandcorr.o
+$(BUILDDIR)/nand2bin: nand2bin.o nandecc.o nandcorr.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-bin2nand: bin2nand.o error.o nandecc.o
+$(BUILDDIR)/bin2nand: bin2nand.o error.o nandecc.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-ubigen: ubigen.o libubigen.o crc32.o
+$(BUILDDIR)/ubigen: ubigen.o libubigen.o crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-mkbootenv: mkbootenv.o bootenv.o hashmap.o error.o crc32.o
+$(BUILDDIR)/mkbootenv: mkbootenv.o bootenv.o hashmap.o error.o crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-unubi: unubi.o crc32.o unubi_analyze.o eb_chain.o
+$(BUILDDIR)/unubi: unubi.o crc32.o unubi_analyze.o eb_chain.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-pfi2bin: pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o \
+$(BUILDDIR)/pfi2bin: pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o \
 		hashmap.o reader.o pfi.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
Signature · 1 line
1.5.6.5
#1 lore raw

Hi,

Quoted 10 lines · Sebastian Siewior

as of current HEAD "make CROSS=whatever-" breaks once we leave the main Makefile.
With this patch everything builds except NTARGETS in ubi-utils and with CROSS being undefined.

The problem with CROSS being undefined could be solved by setting BUILDDIR explicit to "native" for instance.
The NTARGETS thing is a little tricky. The easiest solution would be probably to move the NTARGETS targets into its own Makefile.

Quoted 4 lines

Anyway, is this something worth to fix since it is almost a year broken? Should the BUILDDIR thing be removed or is it used?

I'm very bad in Makefile, so I am not sure what is all this BUILDDIR stuff about. However, your patch breaks build on x86:

[dedekind@gollum mtd-utils]$ make
gcc -o .././ubi-utils/pfi2bin pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o hashmap.o reader.o pfi.o
make[1]: *** No rule to make target .././ubi-utils/ubiattach', needed by all'. Stop.
make[1]: Leaving directory `/home/dedekind/git/mtd-utils/ubi-utils'
make: *** [all] Error 2
rm doc_loadbios.o flash_info.o docfdisk.o ftl_check.o rfdformat.o nandwrite.o mtd_debug.o flash_otp_dump.o nftldump.o flash_lock.o flash_otp_info.o rfddump.o flash_unlock.o nftl_format.o flashcp.o flash_erase.o ftl_format.o nandtest.o nanddump.o

Also, please, make sure your patch does not break make install.

Thanks.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)