Skip to contentSkip to conversation

tools/libs: fix build rules to correctly deal with multiple public headers

PATCH In review Jan Beulich 2 participants 7 messages Oct 19, 2020 – Nov 23, 2020

lore
Share & tools
lore
#0 lore raw

cover tools/libs: fix build rules to correctly deal with multiple public headers

1: fix header symlinking rule
2: fix uninstall rule for header files

Jan

#1 lore raw

PATCH 1/2 tools/libs: fix header symlinking rule

Unlike pattern rules, ordinary rules with multiple targets have their commands executed once per target. Hence when $(LIBHEADERS) expands to more than just one item, multiple identical commands would have been issued, which have been observed to cause build failures relatively frequently after libx{c,l} code was moved to tools/libs/{ctrl,light}/. Use a static pattern rule instead.

---
I'm aware Jürgen has a series pending to entirely remove the rule in question, but this being an isolated fix which ought to be easier to review, I thought I'd still post it. Re-basing his series over this change should be straightforward.
However, for the above reason I'm not bothering getting right the theoretical case of headers in subdirs of the respective include/ being mentioned in $(LIBHEADER).

tools/libs/libs.mk +2 -2
@@ -79,8 +79,8 @@ headers.chk: $(LIBHEADERSGLOB) $(AUTOINC
 libxen$(LIBNAME).map:
 	echo 'VERS_$(MAJOR).$(MINOR) { global: *; };' >$@
 
-$(LIBHEADERSGLOB): $(LIBHEADERS)
-	for i in $(realpath $(LIBHEADERS)); do ln -sf $$i $(XEN_ROOT)/tools/include; done
+$(LIBHEADERSGLOB): $(XEN_ROOT)/tools/include/%.h: include/%.h
+	ln -sf $(CURDIR)/$< $(XEN_ROOT)/tools/include/
 
 lib$(LIB_FILE_NAME).a: $(LIB_OBJS)
 	$(AR) rc $@ $^
#2 lore raw

PATCH 2/2 tools/libs: fix uninstall rule for header files

In reply to Jan Beulich

This again was working right only as long as $(LIBHEADER) consisted of just one entry.

---
An alternative would be to use $(addprefix ) without any shell loop.

tools/libs/libs.mk +1 -1
@@ -107,7 +107,7 @@ install: build
 .PHONY: uninstall
 uninstall:
 	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/$(LIB_FILE_NAME).pc
-	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$(LIBHEADER); done
+	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$$i; done
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR)
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
#3 lore raw

Ping: [PATCH 2/2] tools/libs: fix uninstall rule for header files

Quoted 4 lines · Jan Beulich

This again was working right only as long as $(LIBHEADER) consisted of just one entry.

While patch 1 has become irrelevant with Juergen's more complete change, this one is still applicable afaict.

Jan

Quoted 16 lines

---
An alternative would be to use $(addprefix ) without any shell loop.

tools/libs/libs.mk +1 -1
@@ -107,7 +107,7 @@ install: build
 .PHONY: uninstall
 uninstall:
 	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/$(LIB_FILE_NAME).pc
-	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$(LIBHEADER); done
+	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$$i; done
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR)
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] tools/libs: fix uninstall rule for header files

In reply to Jan Beulich
Quoted 8 lines · Jan Beulich

This again was working right only as long as $(LIBHEADER) consisted of just one entry.

The change is obviously fixing a bug :-) and the double $ is required to protect from make.

Cheers
Bertrand

Quoted 16 lines

---
An alternative would be to use $(addprefix ) without any shell loop.

tools/libs/libs.mk +0 -0
@@ -107,7 +107,7 @@ install: build

.PHONY: uninstall
uninstall:

	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/$(LIB_FILE_NAME).pc
tools/libs/libs.mk +1 -1
-	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$(LIBHEADER); done
+	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$$i; done
	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so
	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR)
	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
#5 lore raw

Ping²: [PATCH 2/2] tools/libs: fix uninstall rule for header files

Quoted 9 lines · Bertrand Marquis
Quoted 6 lines · Jan Beulich

This again was working right only as long as $(LIBHEADER) consisted of just one entry.

The change is obviously fixing a bug :-) and the double $ is required to protect from make.

I'll give it a day or two more to get an ack (or any negative form of feedback), but I guess I'll go ahead and commit this with just Bertrand's R-b otherwise.

Jan

#6 lore raw
In reply to Jan Beulich
Quoted 2 lines · Jan Beulich

1: fix header symlinking rule
2: fix uninstall rule for header files

Actually I've noticed these issues were introduced relatively recently only, in particular after 4.14. I've added

Fixes bc44e2fb3199 ("tools: add a copy of library headers in tools/include")

to both of them, albeit with the above they won't need even just considering of backport.

Jan