Skip to contentSkip to conversation

pciutils: install static lib with shared

PATCH New ANDY KENNEDY 2 participants 3 messages Nov 18, 2013 – Nov 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pciutils: install static lib with shared

When building pciutils as shared, also include the static libraries for a more rounded staging directory (useful when PREFER_STATIC_LIB is not set, but should provide a static library for when static linking with libpci is preferred).

---

package/pciutils/pciutils.mk +21 -1
diff -Naur a/package/pciutils/pciutils.mk b/package/pciutils/pciutils.mk
@@ -17,7 +17,26 @@
 	PCIUTILS_ZLIB=no
 endif
 PCIUTILS_DNS=no
+ifeq ($(BR2_PREFER_STATIC_LIB),y)
+PCIUTILS_SHARED=no
+PCIUTILS_DO_SHARED_BUILD =
+else
 PCIUTILS_SHARED=yes
+define PCIUTILS_DO_SHARED_BUILD
+	$(TARGET_MAKE_ENV) $(MAKE) CC="$(TARGET_CC)" \
+		HOST="$(KERNEL_ARCH)-linux" \
+		OPT="$(TARGET_CFLAGS)" \
+		LDFLAGS="$(TARGET_LDFLAGS)" \
+		RANLIB=$(TARGET_RANLIB) \
+		AR=$(TARGET_AR) \
+		-C $(PCIUTILS_DIR) \
+		SHARED=yes \
+		ZLIB=$(PCIUTILS_ZLIB) \
+		DNS=$(PCIUTILS_DNS) \
+		LIBKMOD=$(PCIUTILS_KMOD) \
+		PREFIX=/usr
+endef
+endif
 
 # Build after busybox since it's got a lightweight lspci
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
@@ -47,11 +66,12 @@
 		RANLIB=$(TARGET_RANLIB) \
 		AR=$(TARGET_AR) \
 		-C $(PCIUTILS_DIR) \
-		SHARED=$(PCIUTILS_SHARED) \
+		SHARED=no \
 		ZLIB=$(PCIUTILS_ZLIB) \
 		DNS=$(PCIUTILS_DNS) \
 		LIBKMOD=$(PCIUTILS_KMOD) \
 		PREFIX=/usr
+	$(PCIUTILS_DO_SHARED_BUILD)
 endef
 
 # Ditch install-lib if SHARED is an option in the future
#1 lore raw

PATCH 1/1 pciutils: install static lib with shared

Quoted 22 lines · ANDY KENNEDY

When building pciutils as shared, also include the static libraries for a more rounded staging directory (useful when PREFER_STATIC_LIB is not set, but should provide a static library for when static linking with libpci is preferred).

---
diff -Naur a/package/pciutils/pciutils.mk b/package/pciutils/pciutils.mk

package/pciutils/pciutils.mk +7 -0
@@ -17,7 +17,26 @@
  	PCIUTILS_ZLIB=no
  endif
  PCIUTILS_DNS=no
+ifeq ($(BR2_PREFER_STATIC_LIB),y)
+PCIUTILS_SHARED=no
+PCIUTILS_DO_SHARED_BUILD =
+else
  PCIUTILS_SHARED=yes
+define PCIUTILS_DO_SHARED_BUILD
+	$(TARGET_MAKE_ENV) $(MAKE) CC="$(TARGET_CC)" \
+		HOST="$(KERNEL_ARCH)-linux" \

package/pciutils/pciutils.mk line 37

Quoted 10 lines
package/pciutils/pciutils.mk +10 -0
+		OPT="$(TARGET_CFLAGS)" \
+		LDFLAGS="$(TARGET_LDFLAGS)" \
+		RANLIB=$(TARGET_RANLIB) \
+		AR=$(TARGET_AR) \
+		-C $(PCIUTILS_DIR) \
+		SHARED=yes \
+		ZLIB=$(PCIUTILS_ZLIB) \
+		DNS=$(PCIUTILS_DNS) \
+		LIBKMOD=$(PCIUTILS_KMOD) \
+		PREFIX=/usr

This should be refactored so the long list of arguments isn't repeated.
E.g.

PCIUTILS_MAKE_OPTS = \
	CC="$(TARGET_CC)" \
	...

define PCIUTILS_DO_SHARED_BUILD

	$(TARGET_MAKE_ENV) $(MAKE) -C @(D) \
		$(PCIUTILS_MAKE_OPTS) SHARED=yes

endef

Quoted 9 lines
package/pciutils/pciutils.mk +2 -0
+endef
+endif
 
  # Build after busybox since it's got a lightweight lspci
  ifeq ($(BR2_PACKAGE_BUSYBOX),y)
@@ -47,11 +66,12 @@
  		RANLIB=$(TARGET_RANLIB) \
  		AR=$(TARGET_AR) \
  		-C $(PCIUTILS_DIR) \

package/pciutils/pciutils.mk line 77

Quoted 10 lines
package/pciutils/pciutils.mk +2 -1
-		SHARED=$(PCIUTILS_SHARED) \
+		SHARED=no \
  		ZLIB=$(PCIUTILS_ZLIB) \
  		DNS=$(PCIUTILS_DNS) \
  		LIBKMOD=$(PCIUTILS_KMOD) \
  		PREFIX=/usr
+	$(PCIUTILS_DO_SHARED_BUILD)
  endef
 
  # Ditch install-lib if SHARED is an option in the future

As this comment says, for the static case, install-lib is not necessary
for the target install.

Wouldn't the install commands have to be done twice as well for staging?

Regards,
Arnout

Quoted 5 lines

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#2 lore raw

PATCH 1/1 pciutils: install static lib with shared

<snip>

Quoted 8 lines
Quoted 8 lines
package/pciutils/pciutils.mk +8 -0
+define PCIUTILS_DO_SHARED_BUILD
+	$(TARGET_MAKE_ENV) $(MAKE) CC="$(TARGET_CC)" \
+		HOST="$(KERNEL_ARCH)-linux" \
+		OPT="$(TARGET_CFLAGS)" \
+		LDFLAGS="$(TARGET_LDFLAGS)" \
+		RANLIB=$(TARGET_RANLIB) \
+		AR=$(TARGET_AR) \
+		-C $(PCIUTILS_DIR) \
Quoted 9 lines

package/pciutils/pciutils.mk line 37

Quoted 5 lines
package/pciutils/pciutils.mk +5 -0
+		SHARED=yes \
+		ZLIB=$(PCIUTILS_ZLIB) \
+		DNS=$(PCIUTILS_DNS) \
+		LIBKMOD=$(PCIUTILS_KMOD) \
+		PREFIX=/usr

This should be refactored so the long list of arguments isn't repeated.
E.g.

Yeah, I had already started that one (with the intent to come back with a V2 patch). I'm in process right now of getting that a bit cleaner.

<snip>

Quoted 5 lines
Quoted 2 lines

# Ditch install-lib if SHARED is an option in the future

As this comment says, for the static case, install-lib is not necessary
for the target install.

Right. That is more stuff that I saw after I had done the initial work.

After looking at it more, I wonder if I can refactor the whole file to make it take advantage of autotools as well. It seems that including something like PCIUTIL_MAKE_OPTS+=install-lib may be a cleaner design.

Quoted 2 lines

Wouldn't the install commands have to be done twice as well for staging?

No, I don't think so. I wonder if it grabs up the two files at the same time (perhaps with a wildcard of some kind) during the copy. It did pull both into my staging.

Quoted 4 lines

Regards,
Arnout

Thanks for the review. I'll make the changes I've stated above in the next few days and resubmit.

Andy