diff mbox

new-utils: fix up build system

Message ID 1228829890-27302-1-git-send-email-vapier@gentoo.org
State Accepted, archived
Commit 47c791bdea3aee5de01f3718e5aa6b76f6dab08a
Headers show

Commit Message

Mike Frysinger Dec. 9, 2008, 1:38 p.m. UTC
The previous change with CFLAGS handling was not entirely correct.  So fix
CFLAGS/CPPFLAGS/LDFLAGS to work like standard build systems (i.e. autotools)
and change `ranlib` to $(RANLIB) to fix cross-compiling.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 ubi-utils/new-utils/Makefile |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

Comments

Artem Bityutskiy Dec. 9, 2008, 1:44 p.m. UTC | #1
On Tue, 2008-12-09 at 08:38 -0500, Mike Frysinger wrote:
> The previous change with CFLAGS handling was not entirely correct.  So fix
> CFLAGS/CPPFLAGS/LDFLAGS to work like standard build systems (i.e. autotools)
> and change `ranlib` to $(RANLIB) to fix cross-compiling.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
>  ubi-utils/new-utils/Makefile |   28 ++++++++++++++++------------
>  1 files changed, 16 insertions(+), 12 deletions(-)

This looks OK for me and I'll push it later unless there are complaints.
Artem Bityutskiy Dec. 10, 2008, 10:45 a.m. UTC | #2
On Tue, 2008-12-09 at 08:38 -0500, Mike Frysinger wrote:
> The previous change with CFLAGS handling was not entirely correct.  So fix
> CFLAGS/CPPFLAGS/LDFLAGS to work like standard build systems (i.e. autotools)
> and change `ranlib` to $(RANLIB) to fix cross-compiling.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Pushed, thanks.
diff mbox

Patch

diff --git a/ubi-utils/new-utils/Makefile b/ubi-utils/new-utils/Makefile
index 133dd66..9ba0d95 100644
--- a/ubi-utils/new-utils/Makefile
+++ b/ubi-utils/new-utils/Makefile
@@ -9,8 +9,12 @@  MANDIR=/usr/man
 INCLUDEDIR=/usr/include
 
 CC := $(CROSS)gcc
-CFLAGS ?= -O2 -Wall
-CPPFLAGS := -Iinclude -Isrc -I$(KERNELHDR) $(CFLAGS) -Werror -Wall
+AR := $(CROSS)ar
+RANLIB := $(CROSS)ranlib
+CFLAGS ?= -O2
+CFLAGS += -Werror -Wall
+CPPFLAGS += -Iinclude -Isrc -I$(KERNELHDR)
+LDFLAGS += -L.
 
 LIBS = libubi libmtd libubigen libiniparser libscan
 UTILS = ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
@@ -26,40 +30,40 @@  all: $(UTILS)
 
 # The below is the rule to get an .o file from a .c file
 %.o: %.c
-	$(CC) $(CPPFLAGS) $< -c -o $@
+	$(CC) $(CFLAGS) $(CPPFLAGS) $< -c -o $@
 
 # And the below is the rule to get final executable from its .o and common.o
 %: libubi.a %.o common.o
-	$(CC) $(CFLAGS) $(filter %.o, $^) -L. -lubi -o $@
+	$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.o, $^) -lubi -o $@
 
 ubicrc32: ubicrc32.o crc32.o
-	$(CC) $(CFLAGS) -o $@ $^
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
 ubinize: ubinize.o common.o crc32.o libiniparser.a libubigen.a
-	$(CC) $(CFLAGS) $(filter %.o, $^) -L. -liniparser -lubigen -o $@
+	$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.o, $^) -liniparser -lubigen -o $@
 
 ubiformat: ubiformat.o common.o crc32.o libmtd.a libscan.a libubi.a libubigen.a
-	$(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lscan -lubi -lubigen -o $@
+	$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.o, $^) -lmtd -lscan -lubi -lubigen -o $@
 
 libubi.a: libubi.o
 	$(AR) crv $@ $^
-	ranlib $@
+	$(RANLIB) $@
 
 libmtd.a: libmtd.o
 	$(AR) crv $@ $^
-	ranlib $@
+	$(RANLIB) $@
 
 libubigen.a: libubigen.o
 	$(AR) crv $@ $^
-	ranlib $@
+	$(RANLIB) $@
 
 libiniparser.a: libiniparser.o dictionary.o
 	$(AR) crv $@ $^
-	ranlib $@
+	$(RANLIB) $@
 
 libscan.a: libscan.o crc32.o
 	$(AR) crv $@ $^
-	ranlib $@
+	$(RANLIB) $@
 
 clean:
 	rm -rf *.o $(addsuffix .a, $(LIBS)) $(UTILS) .*.c.dep