From patchwork Thu Dec 18 14:16:12 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/2] Makefile export shared libraries Date: Thu, 18 Dec 2008 04:16:12 -0000 From: Sidney Amani X-Patchwork-Id: 14673 Message-Id: <52e42efe0812180616q28c10c72nae087e214c014676@mail.gmail.com> To: linux-mtd@lists.infradead.org >From b557d3f22d16fc61788a85f5ec6cc02e0195c810 Mon Sep 17 00:00:00 2001 From: Sidney Amani Date: Wed, 17 Dec 2008 12:46:42 +0100 Subject: [PATCH] Makefile export shared libraries Export shared libraries. Other userspace tools might use them. Signed-off-by: Sidney Amani Signed-off-by: Corentin Chary --- ubi-utils/new-utils/Makefile | 32 +++++++++++++++++++++----------- 1 files changed, 21 insertions(+), 11 deletions(-) # in order to force make using our rule defined below @@ -32,6 +35,11 @@ all: $(UTILS) %.o: %.c $(CC) $(CFLAGS) $(CPPFLAGS) $< -c -o $@ +# The below is for shared libraries +%.pic.o: %.c + $(CC) $(CFLAGS) -fPIC $(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) $(LDFLAGS) $(filter %.o, $^) -lubi -o $@ @@ -45,15 +53,7 @@ ubinize: ubinize.o common.o crc32.o libiniparser.a libubigen.a 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 $@ -libubi.a: libubi.o - $(AR) crv $@ $^ - $(RANLIB) $@ - -libmtd.a: libmtd.o - $(AR) crv $@ $^ - $(RANLIB) $@ - -libubigen.a: libubigen.o +%.a: %.o $(AR) crv $@ $^ $(RANLIB) $@ @@ -65,14 +65,24 @@ libscan.a: libscan.o crc32.o $(AR) crv $@ $^ $(RANLIB) $@ +%.so: %.pic.o + $(CC) $(LDFLAGS) -shared -o $@ $^ + clean: - rm -rf *.o $(addsuffix .a, $(LIBS)) $(UTILS) .*.c.dep + rm -rf *.o $(addsuffix .a, $(LIBS)) $(addsuffix .so, $(LIBS)) $(UTILS) .*.c.dep install: ${UTILS} mkdir -p ${DESTDIR}/${SBINDIR} install -m 0755 ${UTILS} ${DESTDIR}/${SBINDIR}/ + for i in $(addsuffix .so, $(LIBS)); do \ + [ -f $$i ] && install -m 0755 $$i ${DESTDIR}/${LIBDIR}/; \ + done uninstall: for file in ${UTILS}; do \ $(RM) ${DESTDIR}/${SBINDIR}/$$file; \ done + for file in $(addsuffix .so, $(LIBS)); do \ + $(RM) -f ${DESTDIR}/${LIBDIR}/$$file.so; \ + done + diff --git a/ubi-utils/new-utils/Makefile b/ubi-utils/new-utils/Makefile index 9ba0d95..a975a99 100644 --- a/ubi-utils/new-utils/Makefile +++ b/ubi-utils/new-utils/Makefile @@ -7,6 +7,7 @@ DESTDIR := /usr/local SBINDIR=/usr/sbin MANDIR=/usr/man INCLUDEDIR=/usr/include +LIBDIR=/lib CC := $(CROSS)gcc AR := $(CROSS)ar @@ -22,7 +23,9 @@ UTILS = ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \ vpath %.c src -all: $(UTILS) +all: $(UTILS) shared + +shared: $(addsuffix .so, $(LIBS)) # The below cancels existing implicite rule to make programs from .c files,