public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "David Byron" <dbyron@hheld.com>
To: "'Josh Boyer'" <jwboyer@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: RE: autoconf for mtd-utils
Date: Mon, 31 Jul 2006 10:47:12 -0700	[thread overview]
Message-ID: <002301c6b4c9$5aa3d3b0$a134800a@RudiDell> (raw)
In-Reply-To: AAAAAJOKoN+ryO5OkOyypB2eX+5E9yEA

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

On Sun, 2006-07-30 at 11:10a, Josh Boyer wrote:

> Something like that.  But leave the definition of CROSS alone.  It's
> better to leave the trailing '-' at the end so that if other cross
> tools are needed, you just specify $(CROSS)ld, etc.

How's this?

-DB

[-- Attachment #2: Makefile.patch.3 --]
[-- Type: application/octet-stream, Size: 2310 bytes --]

diff --git a/Makefile b/Makefile
index 37cd7f7..683ddbf 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,14 @@ #CROSS=arm-linux-
 CC := $(CROSS)gcc
 CFLAGS := -I./include -O2 -Wall
 
-TARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
+ifeq ($(origin CROSS),undefined)
+  BUILDDIR := .
+else
+# Remove the trailing slash to make the directory name
+  BUILDDIR := $(CROSS:-=)
+endif
+
+RAWTARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
 	mkfs.jffs ftl_check mkfs.jffs2 flash_lock flash_unlock flash_info \
 	flash_otp_info flash_otp_dump mtd_debug flashcp nandwrite \
 	jffs2dump \
@@ -18,40 +25,48 @@ TARGETS = ftl_format flash_erase flash_e
 	rfddump rfdformat \
 	sumtool #jffs2reader
 
+TARGETS = $(foreach target,$(RAWTARGETS),$(BUILDDIR)/$(target))
+
 SYMLINKS =
 
 %: %.o
-	$(CC) $(LDFLAGS) -g -o $@ $^
+	$(CC) $(CFLAGS) $(LDFLAGS) -g -o $@ $^
 
-%.o: %.c
-	$(CC) $(CFLAGS) -g -c -o $@ $< -g -Wp,-MD,.$<.dep
+$(BUILDDIR)/%.o: %.c
+	mkdir -p $(BUILDDIR)
+	$(CC) $(CFLAGS) -g -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(<F).dep
 
 .SUFFIXES:
 
 all: $(TARGETS)
 
-IGNORE=${wildcard .*.c.dep}
+IGNORE=${wildcard $(BUILDDIR)/.*.c.dep}
 -include ${IGNORE}
 
 clean:
-	rm -f *.o $(TARGETS) .*.c.dep $(SYMLINKS)
+	rm -f $(BUILDDIR)/*.o $(TARGETS) $(BUILDDIR)/.*.c.dep $(SYMLINKS)
+	if [ "$(BUILDDIR)x" != ".x" ]; then rm -rf $(BUILDDIR); fi
 
 $(SYMLINKS):
 	ln -sf ../fs/jffs2/$@ $@
 
-mkfs.jffs2: crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o compr.o
+$(BUILDDIR)/mkfs.jffs2: $(BUILDDIR)/crc32.o \
+			$(BUILDDIR)/compr_rtime.o \
+			$(BUILDDIR)/mkfs.jffs2.o \
+			$(BUILDDIR)/compr_zlib.o \
+			$(BUILDDIR)/compr.o
 	$(CC) $(LDFLAGS) -o $@ $^ -lz
 
-flash_eraseall: crc32.o flash_eraseall.o
+$(BUILDDIR)/flash_eraseall: $(BUILDDIR)/crc32.o $(BUILDDIR)/flash_eraseall.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-jffs2reader: jffs2reader.o
+$(BUILDDIR)/jffs2reader: $(BUILDDIR)/jffs2reader.o
 	$(CC) $(LDFLAGS) -o $@ $^ -lz
 
-jffs2dump: jffs2dump.o crc32.o
+$(BUILDDIR)/jffs2dump: $(BUILDDIR)/jffs2dump.o $(BUILDDIR)/crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
-sumtool: sumtool.o crc32.o
+$(BUILDDIR)/sumtool: $(BUILDDIR)/sumtool.o $(BUILDDIR)/crc32.o
 	$(CC) $(LDFLAGS) -o $@ $^
 
 install: ${TARGETS}

             reply	other threads:[~2006-07-31 17:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-31 17:47 David Byron [this message]
2006-08-01  0:50 ` autoconf for mtd-utils Josh Boyer
  -- strict thread matches above, loose matches on Subject: below --
2006-08-01 19:25 David Byron
2006-08-02 11:00 ` Josh Boyer
2006-08-03 12:22   ` Josh Boyer
2006-07-19 21:37 David Byron
2006-07-30 18:09 ` Josh Boyer
2006-07-19 18:52 David Byron
2006-07-19 19:24 ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='002301c6b4c9$5aa3d3b0$a134800a@RudiDell' \
    --to=dbyron@hheld.com \
    --cc=jwboyer@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox