[PATCH skeleton 7/9] libopenbmc_intf rules simplification

OpenBMC Patches openbmc-patches at stwcx.xyz
Tue Jun 28 04:50:52 AEST 2016


From: Brad Bishop <bradleyb at fuzziesquirrel.com>

Don't use rules.mk for libopenbmc_intf.  There isn't enough
overlap here to warrant the extra complexity.

Fix an issue where the library is rebuilt for every make invocation.

Signed-off-by: Brad Bishop <bradleyb at fuzziesquirrel.com>
---
 libopenbmc_intf/Makefile | 43 +++++++++++++++++++++++++------------------
 rules.mk                 | 12 +++---------
 2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/libopenbmc_intf/Makefile b/libopenbmc_intf/Makefile
index f82bce5..cd86906 100644
--- a/libopenbmc_intf/Makefile
+++ b/libopenbmc_intf/Makefile
@@ -1,26 +1,33 @@
+libdir=/usr/lib
+includedir=/usr/include
+
 PACKAGE_DEPS=gio-unix-2.0 glib-2.0
-INSTALLDEPS=install-lib install-headers
-CLEANDEPS=clean-lib
-DEFAULT_ALL=$(LIBOBMC)
-LIBOBMC=openbmc_intf
+SONAME=libopenbmc_intf.so
+VERSION=1
+LIBOBMC=$(SONAME).$(VERSION)
 INCLUDES=openbmc_intf.h openbmc.h gpio.h
 
-$(LIBOBMC): %: %.o gpio.o
-	$(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,lib$(LIBOBMC).so \
-		-o lib$@.so.1 $^ $(LDLIBS)
-	ln -sf lib$(LIBOBMC).so.1 lib$(LIBOBMC).so
+LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS))
+ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS)
+
+all: $(SONAME)
+
+%.o: %.c
+	$(CC) -c $(ALL_CFLAGS) -o $@ $<
+
+$(SONAME): $(LIBOBMC)
+	ln -sf $^ $@
 
-install-headers:
+$(LIBOBMC): lib%.so.$(VERSION): %.o gpio.o
+	$(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(SONAME) \
+		-o $@ $^ $(LDLIBS)
+
+install: $(SONAME) $(LIBOBMC)
 	@mkdir -p $(DESTDIR)$(includedir)
 	install $(INCLUDES) $(DESTDIR)$(includedir)
-
-install-lib:
 	@mkdir -p $(DESTDIR)$(libdir)
-	install lib$(LIBOBMC).so.1 $(DESTDIR)$(libdir)
-	ln -sf lib$(LIBOBMC).so.1 $(DESTDIR)$(libdir)/lib$(LIBOBMC).so
-
-clean-lib:
-	rm -f lib$(LIBOBMC).so.1
-	rm -f lib$(LIBOBMC).so
+	install $(LIBOBMC) $(DESTDIR)$(libdir)
+	ln -sf $(LIBOBMC) $(DESTDIR)$(libdir)/$(SONAME)
 
-include ../rules.mk
+clean:
+	rm -f *.o $(LIBOBMC) $(SONAME)
diff --git a/rules.mk b/rules.mk
index c7075c1..dec78b8 100644
--- a/rules.mk
+++ b/rules.mk
@@ -2,17 +2,13 @@ TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
 
 .DEFAULT_GOAL := all
 sbindir=/usr/sbin
-libdir=/usr/lib
-includedir=/usr/include
 
 LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS))
 ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS)
 
-INSTALLDEPS?=install-bins
 BIN_SUFFIX?=.exe
-DEFAULT_ALL?=$(BINS)
 
-all: $(DEFAULT_ALL)
+all: $(BINS)
 
 %.o: %.c
 	$(CC) -c $(ALL_CFLAGS) -o $@ $<
@@ -20,13 +16,11 @@ all: $(DEFAULT_ALL)
 $(BINS): %: %.o $(EXTRA_OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(BIN_SUFFIX) $^ $(LDLIBS)
 
-install-bins: $(BINS)
+install: $(BINS)
 	@mkdir -p $(DESTDIR)$(sbindir)
 	@for b in $(BINS); do \
 		install $$b$(BIN_SUFFIX) $(DESTDIR)$(sbindir) || exit 1; \
 	done
 
-install: all $(INSTALLDEPS)
-
-clean: $(CLEANDEPS)
+clean:
 	rm -rf *.o $(BINS:=$(BIN_SUFFIX))
-- 
2.9.0




More information about the openbmc mailing list