Skip to content

Instantly share code, notes, and snippets.

@jperkin
Created January 29, 2021 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jperkin/c73739080c44bf20fa52375e7adf75f5 to your computer and use it in GitHub Desktop.
Save jperkin/c73739080c44bf20fa52375e7adf75f5 to your computer and use it in GitHub Desktop.

Tested on SunOS (with and without "disable-ld" option), and macOS (only supports "disable-ld").

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/devel/binutils/Makefile,v
retrieving revision 1.96
diff -u -r1.96 Makefile
--- Makefile	27 Jan 2021 15:21:21 -0000	1.96
+++ Makefile	29 Jan 2021 12:55:33 -0000
@@ -19,14 +19,6 @@
 USE_LIBTOOL=		yes
 USE_TOOLS+=		gmake
 
-# PR pkg/48504, ksh is sufficient for NetBSD 5.2 and NetBSD 6.1
-.include "../../mk/bsd.prefs.mk"
-.if !empty(MACHINE_PLATFORM:MNetBSD-[5-6].*-*) && \
-	empty(MACHINE_PLATFORM:MNetBSD-6.99.*-*)
-USE_TOOLS+=		ksh
-CONFIG_SHELL=		ksh
-.endif
-
 TOOLS_BROKEN+=		perl
 GNU_CONFIGURE=		yes
 GNU_CONFIGURE_STRICT=	no
@@ -52,27 +44,37 @@
 
 INSTALLATION_DIRS=	${PKGGNUDIR}bin ${PKGGNUDIR}${PKGMANDIR}/man1
 
-# gprof (XXX: and others?) cannot be built on all platforms
 #
-PLIST_VARS+=	gprof ld gold SunOS CTF
+# Supported utils and libraries differ quite a bit across platforms.
+#
+PLIST_VARS+=	ctf gas gold gprof ld
 
 .include "../../mk/bsd.prefs.mk"
 
-.if ${OPSYS} != "IRIX" && ${OPSYS} != "AIX" && ${OPSYS} != "Darwin"
-PLIST.gprof=	yes
+#
+# libctf does not build on thes platforms at present.
+#
+.if ${OPSYS} == "Darwin" || ${OPSYS} == "Linux"
+CONFIGURE_ARGS+=	--disable-libctf
+.else
+PLIST.ctf=		yes
 .endif
 
-.if ${OPSYS} != SunOS && ${OPSYS} != "Darwin"
-PLIST.ld=	yes
+.if ${OPSYS} != "Darwin"
+PLIST.gas=	yes
 .endif
 
-.if ${OPSYS} == SunOS
-PLIST.SunOS=	yes
+.if ${OPSYS} != "IRIX" && ${OPSYS} != "AIX" && ${OPSYS} != "Darwin"
+PLIST.gprof=	yes
 .endif
 
-# Temporary: libctf should be mature on Linux in the near future
-.if ${OPSYS} != Linux
-PLIST.CTF=	yes
+#
+# The PLIST.ld variable controls whether we install "ld -> gld" symlinks.  They
+# are excluded on SunOS to avoid accidentally using the wrong "ld", and on
+# Darwin as ld/gas are not built.
+#
+.if ${OPSYS} != SunOS && ${OPSYS} != "Darwin"
+PLIST.ld=	yes
 .endif
 
 .if ${OPSYS} == DragonFly \
@@ -80,7 +82,6 @@
 	|| (${OPSYS} == OpenBSD && empty(OS_VERSION:M[1234].*)) \
 	|| (${OPSYS} == NetBSD && empty(OS_VERSION:M[12345].*)) \
 	|| ${OPSYS} == Linux
-BUILD_GOLD=		yes
 PLIST.gold=		yes
 USE_TOOLS+=		bison
 CONFIGURE_ARGS+=	--enable-gold --enable-plugins
@@ -94,18 +95,12 @@
 		-Wno-error=unused-const-variable
 .endif
 
-SYMLINK_FILES=	addr2line ar as c++filt dlltool elfedit ld.bfd		\
-		nlmconv nm objcopy objdump ranlib readelf size strings	\
-		strip windmc windres
-.if defined(PLIST.gprof)
-SYMLINK_FILES+=	gprof
-.endif
-.if defined(PLIST.ld)
-SYMLINK_FILES+=	ld
-.endif
-.if defined(BUILD_GOLD)
-SYMLINK_FILES+=	ld.gold dwp
-.endif
+.include "options.mk"
+
+SYMLINK_FILES=	addr2line ar ${PLIST.gas:Das} c++filt dlltool elfedit \
+		${PLIST.gprof:Dgprof} ${PLIST.ld:Dld} ${PLIST.gld:Dld.bfd} \
+		${PLIST.gold:Dld.gold dwp} nlmconv nm objcopy objdump \
+		ranlib readelf size strings strip windmc windres
 
 post-install:
 	cd ${DESTDIR}${PREFIX} &&					\
Index: PLIST.common
===================================================================
RCS file: /cvsroot/pkgsrc/devel/binutils/PLIST.common,v
retrieving revision 1.35
diff -u -r1.35 PLIST.common
--- PLIST.common	28 Jan 2021 11:07:55 -0000	1.35
+++ PLIST.common	29 Jan 2021 12:55:33 -0000
@@ -1,8 +1,8 @@
 @comment $NetBSD: PLIST.common,v 1.35 2021/01/28 11:07:55 jperkin Exp $
 ${MACHINE_GNU_PLATFORM}/bin/ar
-${MACHINE_GNU_PLATFORM}/bin/as
-${MACHINE_GNU_PLATFORM}/bin/ld
-${MACHINE_GNU_PLATFORM}/bin/ld.bfd
+${PLIST.gas}${MACHINE_GNU_PLATFORM}/bin/as
+${PLIST.gld}${MACHINE_GNU_PLATFORM}/bin/ld
+${PLIST.gld}${MACHINE_GNU_PLATFORM}/bin/ld.bfd
 ${PLIST.gold}${MACHINE_GNU_PLATFORM}/bin/ld.gold
 ${MACHINE_GNU_PLATFORM}/bin/nm
 ${MACHINE_GNU_PLATFORM}/bin/objcopy
@@ -12,13 +12,13 @@
 ${MACHINE_GNU_PLATFORM}/bin/strip
 bin/gaddr2line
 bin/gar
-bin/gas
+${PLIST.gas}bin/gas
 bin/gc++filt
 ${PLIST.gold}bin/gdwp
 bin/gelfedit
 ${PLIST.gprof}bin/ggprof
-bin/gld
-bin/gld.bfd
+${PLIST.gld}bin/gld
+${PLIST.gld}bin/gld.bfd
 ${PLIST.gold}bin/gld.gold
 bin/gnm
 bin/gobjcopy
@@ -30,13 +30,13 @@
 bin/gstrip
 gnu/bin/addr2line
 gnu/bin/ar
-gnu/bin/as
+${PLIST.gas}gnu/bin/as
 gnu/bin/c++filt
 ${PLIST.gold}gnu/bin/dwp
 gnu/bin/elfedit
 ${PLIST.gprof}gnu/bin/gprof
 ${PLIST.ld}gnu/bin/ld
-gnu/bin/ld.bfd
+${PLIST.gld}gnu/bin/ld.bfd
 ${PLIST.gold}gnu/bin/ld.gold
 gnu/bin/nm
 gnu/bin/objcopy
@@ -48,7 +48,7 @@
 gnu/bin/strip
 gnu/man/man1/addr2line.1
 gnu/man/man1/ar.1
-gnu/man/man1/as.1
+${PLIST.gas}gnu/man/man1/as.1
 gnu/man/man1/c++filt.1
 gnu/man/man1/dlltool.1
 gnu/man/man1/elfedit.1
@@ -68,30 +68,30 @@
 include/bfd.h
 include/bfd_stdint.h
 include/bfdlink.h
-${PLIST.CTF}include/ctf-api.h
-${PLIST.CTF}include/ctf.h
+${PLIST.ctf}include/ctf-api.h
+${PLIST.ctf}include/ctf.h
 include/diagnostics.h
 include/dis-asm.h
 include/plugin-api.h
 include/symcat.h
-info/as.info
+${PLIST.gas}info/as.info
 info/bfd.info
 info/binutils.info
 ${PLIST.gprof}info/gprof.info
-info/ld.info
-lib/bfd-plugins/libdep.so
+${PLIST.gld}info/ld.info
+${PLIST.gld}lib/bfd-plugins/libdep.so
 lib/libbfd.la
-${PLIST.CTF}lib/libctf-nobfd.la
-${PLIST.CTF}lib/libctf.la
+${PLIST.ctf}lib/libctf-nobfd.la
+${PLIST.ctf}lib/libctf.la
 lib/libopcodes.la
 man/man1/gaddr2line.1
 man/man1/gar.1
-man/man1/gas.1
+${PLIST.gas}man/man1/gas.1
 man/man1/gc++filt.1
 man/man1/gdlltool.1
 man/man1/gelfedit.1
 ${PLIST.gprof}man/man1/ggprof.1
-man/man1/gld.1
+${PLIST.gld}man/man1/gld.1
 man/man1/gnm.1
 man/man1/gobjcopy.1
 man/man1/gobjdump.1
@@ -104,69 +104,69 @@
 man/man1/gwindres.1
 share/locale/bg/LC_MESSAGES/binutils.mo
 ${PLIST.gprof}share/locale/bg/LC_MESSAGES/gprof.mo
-share/locale/bg/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/bg/LC_MESSAGES/ld.mo
 share/locale/ca/LC_MESSAGES/binutils.mo
 share/locale/da/LC_MESSAGES/bfd.mo
 share/locale/da/LC_MESSAGES/binutils.mo
 ${PLIST.gprof}share/locale/da/LC_MESSAGES/gprof.mo
-share/locale/da/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/da/LC_MESSAGES/ld.mo
 share/locale/da/LC_MESSAGES/opcodes.mo
 ${PLIST.gprof}share/locale/de/LC_MESSAGES/gprof.mo
-share/locale/de/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/de/LC_MESSAGES/ld.mo
 share/locale/de/LC_MESSAGES/opcodes.mo
 ${PLIST.gprof}share/locale/eo/LC_MESSAGES/gprof.mo
 share/locale/es/LC_MESSAGES/bfd.mo
 share/locale/es/LC_MESSAGES/binutils.mo
-share/locale/es/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/es/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/es/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/es/LC_MESSAGES/gprof.mo
-share/locale/es/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/es/LC_MESSAGES/ld.mo
 share/locale/es/LC_MESSAGES/opcodes.mo
 share/locale/fi/LC_MESSAGES/bfd.mo
 share/locale/fi/LC_MESSAGES/binutils.mo
-share/locale/fi/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/fi/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/fi/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/fi/LC_MESSAGES/gprof.mo
-share/locale/fi/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/fi/LC_MESSAGES/ld.mo
 share/locale/fi/LC_MESSAGES/opcodes.mo
 share/locale/fr/LC_MESSAGES/bfd.mo
 share/locale/fr/LC_MESSAGES/binutils.mo
-share/locale/fr/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/fr/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/fr/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/fr/LC_MESSAGES/gprof.mo
-share/locale/fr/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/fr/LC_MESSAGES/ld.mo
 share/locale/fr/LC_MESSAGES/opcodes.mo
 ${PLIST.gprof}share/locale/ga/LC_MESSAGES/gprof.mo
-share/locale/ga/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/ga/LC_MESSAGES/ld.mo
 share/locale/ga/LC_MESSAGES/opcodes.mo
 share/locale/hr/LC_MESSAGES/bfd.mo
 share/locale/hr/LC_MESSAGES/binutils.mo
 ${PLIST.gprof}share/locale/hu/LC_MESSAGES/gprof.mo
 share/locale/id/LC_MESSAGES/bfd.mo
 share/locale/id/LC_MESSAGES/binutils.mo
-share/locale/id/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/id/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/id/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/id/LC_MESSAGES/gprof.mo
-share/locale/id/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/id/LC_MESSAGES/ld.mo
 share/locale/id/LC_MESSAGES/opcodes.mo
 share/locale/it/LC_MESSAGES/binutils.mo
 ${PLIST.gold}share/locale/it/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/it/LC_MESSAGES/gprof.mo
-share/locale/it/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/it/LC_MESSAGES/ld.mo
 share/locale/it/LC_MESSAGES/opcodes.mo
 share/locale/ja/LC_MESSAGES/bfd.mo
 share/locale/ja/LC_MESSAGES/binutils.mo
-share/locale/ja/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/ja/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/ja/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/ja/LC_MESSAGES/gprof.mo
-share/locale/ja/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/ja/LC_MESSAGES/ld.mo
 ${PLIST.gprof}share/locale/ms/LC_MESSAGES/gprof.mo
 ${PLIST.gprof}share/locale/nl/LC_MESSAGES/gprof.mo
 share/locale/nl/LC_MESSAGES/opcodes.mo
 share/locale/pt/LC_MESSAGES/bfd.mo
 share/locale/pt/LC_MESSAGES/binutils.mo
 ${PLIST.gprof}share/locale/pt_BR/LC_MESSAGES/gprof.mo
-share/locale/pt_BR/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/pt_BR/LC_MESSAGES/ld.mo
 share/locale/pt_BR/LC_MESSAGES/opcodes.mo
 share/locale/ro/LC_MESSAGES/bfd.mo
 share/locale/ro/LC_MESSAGES/binutils.mo
@@ -174,51 +174,51 @@
 share/locale/ro/LC_MESSAGES/opcodes.mo
 share/locale/ru/LC_MESSAGES/bfd.mo
 share/locale/ru/LC_MESSAGES/binutils.mo
-share/locale/ru/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/ru/LC_MESSAGES/gas.mo
 ${PLIST.gprof}share/locale/ru/LC_MESSAGES/gprof.mo
-share/locale/ru/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/ru/LC_MESSAGES/ld.mo
 share/locale/rw/LC_MESSAGES/bfd.mo
 share/locale/rw/LC_MESSAGES/binutils.mo
-share/locale/rw/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/rw/LC_MESSAGES/gas.mo
 ${PLIST.gprof}share/locale/rw/LC_MESSAGES/gprof.mo
 share/locale/sk/LC_MESSAGES/binutils.mo
 share/locale/sr/LC_MESSAGES/bfd.mo
 share/locale/sr/LC_MESSAGES/binutils.mo
 ${PLIST.gold}share/locale/sr/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/sr/LC_MESSAGES/gprof.mo
-share/locale/sr/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/sr/LC_MESSAGES/ld.mo
 share/locale/sr/LC_MESSAGES/opcodes.mo
 share/locale/sv/LC_MESSAGES/bfd.mo
 share/locale/sv/LC_MESSAGES/binutils.mo
-share/locale/sv/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/sv/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/sv/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/sv/LC_MESSAGES/gprof.mo
-share/locale/sv/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/sv/LC_MESSAGES/ld.mo
 share/locale/sv/LC_MESSAGES/opcodes.mo
 share/locale/tr/LC_MESSAGES/bfd.mo
 share/locale/tr/LC_MESSAGES/binutils.mo
-share/locale/tr/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/tr/LC_MESSAGES/gas.mo
 ${PLIST.gprof}share/locale/tr/LC_MESSAGES/gprof.mo
-share/locale/tr/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/tr/LC_MESSAGES/ld.mo
 share/locale/tr/LC_MESSAGES/opcodes.mo
 share/locale/uk/LC_MESSAGES/bfd.mo
 share/locale/uk/LC_MESSAGES/binutils.mo
-share/locale/uk/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/uk/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/uk/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/uk/LC_MESSAGES/gprof.mo
-share/locale/uk/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/uk/LC_MESSAGES/ld.mo
 share/locale/uk/LC_MESSAGES/opcodes.mo
 share/locale/vi/LC_MESSAGES/bfd.mo
 share/locale/vi/LC_MESSAGES/binutils.mo
 ${PLIST.gold}share/locale/vi/LC_MESSAGES/gold.mo
 ${PLIST.gprof}share/locale/vi/LC_MESSAGES/gprof.mo
-share/locale/vi/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/vi/LC_MESSAGES/ld.mo
 share/locale/vi/LC_MESSAGES/opcodes.mo
 share/locale/zh_CN/LC_MESSAGES/bfd.mo
 share/locale/zh_CN/LC_MESSAGES/binutils.mo
-share/locale/zh_CN/LC_MESSAGES/gas.mo
+${PLIST.gas}share/locale/zh_CN/LC_MESSAGES/gas.mo
 ${PLIST.gold}share/locale/zh_CN/LC_MESSAGES/gold.mo
-share/locale/zh_CN/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/zh_CN/LC_MESSAGES/ld.mo
 share/locale/zh_CN/LC_MESSAGES/opcodes.mo
 share/locale/zh_TW/LC_MESSAGES/binutils.mo
-share/locale/zh_TW/LC_MESSAGES/ld.mo
+${PLIST.gld}share/locale/zh_TW/LC_MESSAGES/ld.mo
Index: options.mk
===================================================================
RCS file: options.mk
diff -N options.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ options.mk	29 Jan 2021 12:55:33 -0000
@@ -0,0 +1,24 @@
+# $NetBSD$
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.binutils
+PKG_SUPPORTED_OPTIONS=	disable-ld
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${OPSYS} == "Darwin"
+PKG_SUGGESTED_OPTIONS=	disable-ld
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+PLIST_VARS+=	gld
+
+#
+# Disable ld completely.  With the introduction of "libdep.so" this may now be
+# required on some systems to avoid a dependency on libgcc.
+#
+.if !empty(PKG_OPTIONS:Mdisable-ld)
+CONFIGURE_ARGS+=	--disable-ld
+.else
+PLIST.gld=		yes
+.endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment