From 96a4f76f2e9dad7fdbd6fd7740de44bc90d5769e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 18 Dec 2008 16:05:18 -0500 Subject: Unify all common build system parts Rather than duplicating the same thing over and over in every Makefile, move it all to common.mk. Other things fixed here: - doing subdirs in parallel - fix src!=build compiling in subdirs Signed-off-by: Mike Frysinger Signed-off-by: Artem Bityutskiy --- ubi-utils/Makefile | 77 +++++++++++++++--------------------------- ubi-utils/new-utils/Makefile | 79 ++++++++++++++++---------------------------- 2 files changed, 56 insertions(+), 100 deletions(-) (limited to 'ubi-utils') diff --git a/ubi-utils/Makefile b/ubi-utils/Makefile index 63058e1..3be813a 100644 --- a/ubi-utils/Makefile +++ b/ubi-utils/Makefile @@ -3,77 +3,54 @@ # KERNELHDR := ../include -DESTDIR := /usr/local -SBINDIR=/usr/sbin -MANDIR=/usr/share/man -INCLUDEDIR=/usr/include -CC := $(CROSS)gcc CFLAGS ?= -O2 -g -Werror -CFLAGS += -Wall -Wwrite-strings -W CPPFLAGS += -I./inc -I./src -I$(KERNELHDR) \ -std=gnu99 -DPACKAGE_VERSION=\"1.0\" PERLPROGS = mkpfi ubicrc32.pl -NTARGETS = ubiattach ubicrc32 ubidetach ubimkvol ubinfo ubinize \ - ubirmvol ubiupdatevol ubiformat +SUBDIRS = new-utils + TARGETS = pfiflash pddcustomize ubimirror bin2nand nand2bin ubigen \ - mkbootenv unubi pfi2bin $(NTARGETS) + mkbootenv unubi pfi2bin vpath %.c ./src -%: %.o - $(CC) $(LDFLAGS) -g -o $@ $^ - -%.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,.$(shell basename $<).dep - -all: $(TARGETS) - -IGNORE=${wildcard .*.c.dep} --include ${IGNORE} - -$(NTARGETS): - $(MAKE) -C new-utils $@ - mv new-utils/$@ $@ - -clean: - rm -rf *.o $(TARGETS) .*.c.dep - $(MAKE) -C new-utils clean +include ../common.mk -pddcustomize: pddcustomize.o error.o libubimirror.o bootenv.o hashmap.o \ - libubi.o crc32.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/pddcustomize: $(addprefix $(BUILDDIR)/,\ + pddcustomize.o error.o libubimirror.o bootenv.o hashmap.o \ + libubi.o crc32.o) -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 $@ $^ +$(BUILDDIR)/pfiflash: $(addprefix $(BUILDDIR)/,\ + pfiflash.o libpfiflash.o list.o reader.o error.o libubimirror.o \ + bootenv.o hashmap.o pfi.o libubi.o crc32.o) -ubimirror: ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \ - libubi.o crc32.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/ubimirror: $(addprefix $(BUILDDIR)/,\ + ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \ + libubi.o crc32.o) -nand2bin: nand2bin.o nandecc.o nandcorr.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/nand2bin: $(addprefix $(BUILDDIR)/,\ + nand2bin.o nandecc.o nandcorr.o) -bin2nand: bin2nand.o error.o nandecc.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/bin2nand: $(addprefix $(BUILDDIR)/,\ + bin2nand.o error.o nandecc.o) -ubigen: ubigen.o libubigen.o crc32.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/ubigen: $(addprefix $(BUILDDIR)/,\ + ubigen.o libubigen.o crc32.o) -mkbootenv: mkbootenv.o bootenv.o hashmap.o error.o crc32.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/mkbootenv: $(addprefix $(BUILDDIR)/,\ + mkbootenv.o bootenv.o hashmap.o error.o crc32.o) -unubi: unubi.o crc32.o unubi_analyze.o eb_chain.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/unubi: $(addprefix $(BUILDDIR)/,\ + unubi.o crc32.o unubi_analyze.o eb_chain.o) -pfi2bin: pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o \ - hashmap.o reader.o pfi.o - $(CC) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/pfi2bin: $(addprefix $(BUILDDIR)/,\ + pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o \ + hashmap.o reader.o pfi.o) -install: ${TARGETS} +install:: mkdir -p ${DESTDIR}/${SBINDIR} install -m 0755 ${TARGETS} ${DESTDIR}/${SBINDIR}/ (cd perl && install ${PERLPROGS} ${DESTDIR}/${SBINDIR}/) diff --git a/ubi-utils/new-utils/Makefile b/ubi-utils/new-utils/Makefile index 9ba0d95..6ae60b3 100644 --- a/ubi-utils/new-utils/Makefile +++ b/ubi-utils/new-utils/Makefile @@ -3,76 +3,55 @@ # KERNELHDR := ../../include -DESTDIR := /usr/local -SBINDIR=/usr/sbin -MANDIR=/usr/man -INCLUDEDIR=/usr/include - -CC := $(CROSS)gcc -AR := $(CROSS)ar -RANLIB := $(CROSS)ranlib -CFLAGS ?= -O2 -CFLAGS += -Werror -Wall + +#CFLAGS += -Werror CPPFLAGS += -Iinclude -Isrc -I$(KERNELHDR) -LDFLAGS += -L. LIBS = libubi libmtd libubigen libiniparser libscan -UTILS = ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \ - ubidetach ubinize ubiformat +TARGETS = ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \ + ubidetach ubinize ubiformat vpath %.c src -all: $(UTILS) - -# The below cancels existing implicite rule to make programs from .c files, -# in order to force make using our rule defined below -%: %.c - -# The below is the rule to get an .o file from a .c file -%.o: %.c - $(CC) $(CFLAGS) $(CPPFLAGS) $< -c -o $@ +include ../../common.mk # And the below is the rule to get final executable from its .o and common.o -%: libubi.a %.o common.o - $(CC) $(CFLAGS) $(LDFLAGS) $(filter %.o, $^) -lubi -o $@ +$(TARGETS): $(addprefix $(BUILDDIR)/,\ + libubi.a common.o) +# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lubi -o $@ -ubicrc32: ubicrc32.o crc32.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ +$(BUILDDIR)/ubicrc32: $(addprefix $(BUILDDIR)/,\ + ubicrc32.o crc32.o) +# $(CC) $(CFLAGS) -o $@ $^ -ubinize: ubinize.o common.o crc32.o libiniparser.a libubigen.a - $(CC) $(CFLAGS) $(LDFLAGS) $(filter %.o, $^) -liniparser -lubigen -o $@ +$(BUILDDIR)/ubinize: $(addprefix $(BUILDDIR)/,\ + ubinize.o common.o crc32.o libiniparser.a libubigen.a) +# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -liniparser -lubigen -o $@ -ubiformat: ubiformat.o common.o crc32.o libmtd.a libscan.a libubi.a libubigen.a - $(CC) $(CFLAGS) $(LDFLAGS) $(filter %.o, $^) -lmtd -lscan -lubi -lubigen -o $@ +$(BUILDDIR)/ubiformat: $(addprefix $(BUILDDIR)/,\ + ubiformat.o common.o crc32.o libmtd.a libscan.a libubi.a libubigen.a) +# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lscan -lubi -lubigen -o $@ -libubi.a: libubi.o - $(AR) crv $@ $^ - $(RANLIB) $@ +$(BUILDDIR)/libubi.a: $(BUILDDIR)/libubi.o -libmtd.a: libmtd.o - $(AR) crv $@ $^ - $(RANLIB) $@ +$(BUILDDIR)/libmtd.a: $(BUILDDIR)/libmtd.o -libubigen.a: libubigen.o - $(AR) crv $@ $^ - $(RANLIB) $@ +$(BUILDDIR)/libubigen.a: $(BUILDDIR)/libubigen.o -libiniparser.a: libiniparser.o dictionary.o - $(AR) crv $@ $^ - $(RANLIB) $@ +$(BUILDDIR)/libiniparser.a: $(addprefix $(BUILDDIR)/,\ + libiniparser.o dictionary.o) -libscan.a: libscan.o crc32.o - $(AR) crv $@ $^ - $(RANLIB) $@ +$(BUILDDIR)/libscan.a: $(addprefix $(BUILDDIR)/,\ + libscan.o crc32.o) -clean: - rm -rf *.o $(addsuffix .a, $(LIBS)) $(UTILS) .*.c.dep +clean:: + rm -f $(addsuffix .a, $(LIBS)) -install: ${UTILS} +install:: mkdir -p ${DESTDIR}/${SBINDIR} - install -m 0755 ${UTILS} ${DESTDIR}/${SBINDIR}/ + install -m 0755 ${TARGETS} ${DESTDIR}/${SBINDIR}/ uninstall: - for file in ${UTILS}; do \ + for file in ${TARGETS}; do \ $(RM) ${DESTDIR}/${SBINDIR}/$$file; \ done -- cgit v1.2.3