public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [RFC] mtd-utils: make cross build functional again
@ 2008-08-26 22:07 Sebastian Siewior
  2008-08-27  5:50 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Siewior @ 2008-08-26 22:07 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: linux-mtd

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?

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
---
 Makefile            |    6 ++++--
 mkfs.ubifs/Makefile |    6 ++++--
 ubi-utils/Makefile  |   26 ++++++++++++++------------
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 796c31b..d54e170 100644
--- a/Makefile
+++ b/Makefile
@@ -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}
diff --git a/mkfs.ubifs/Makefile b/mkfs.ubifs/Makefile
index a327eee..81ef429 100644
--- a/mkfs.ubifs/Makefile
+++ b/mkfs.ubifs/Makefile
@@ -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:
diff --git a/ubi-utils/Makefile b/ubi-utils/Makefile
index 4cca316..bdcd444 100644
--- a/ubi-utils/Makefile
+++ b/ubi-utils/Makefile
@@ -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 $@ $^
 
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] mtd-utils: make cross build functional again
  2008-08-26 22:07 [RFC] mtd-utils: make cross build functional again Sebastian Siewior
@ 2008-08-27  5:50 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2008-08-27  5:50 UTC (permalink / raw)
  To: Sebastian Siewior; +Cc: linux-mtd

Hi,

On Wed, 2008-08-27 at 00:07 +0200, Sebastian Siewior wrote:
> 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?
> 
> Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>

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.
 
-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-27  5:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-26 22:07 [RFC] mtd-utils: make cross build functional again Sebastian Siewior
2008-08-27  5:50 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox