pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: emulators/simh: make test, and MacOS issues



Two things:

1) How  can I make that "make test" does not do a "make build" first?
Due to the way that the tests are intermingled with the build, a "make
test" needs to wipe the binaries first, thus making a build a waste of
time.

2) I tried building the simh package on my $WORK macbook with MacOS Big
Sur 11.6. I found that the VAX selftests fail.

I also found the cause: the packaging is messing too much with the
compiler options, and the essential option -fno-strict-overflow went
missing.

I can fix that by messing less with the flags. The main reason seems to
be to avoid LTO (link-time optimization), but that is already avoided
with the BUILDLINK_TRANSFORM. Also, the current package makefile doesn't
use it anyway: it is disabled for all common paths, as far as I can see.
On top of that, it is unclear to me why LTO has to be avoided at all.

There are some further problems related to the use of "builtin"
packages. libpcap, zlib and freetype2 seem to be affected here.
If those packages are installed they will be used, but they don't
register as dependencies.

For libpcap it improves if I set PREFER.libpcap=pkgsrc but I'm not sure
if it is a clean thing to do in the Makefile. I can't seem to make it
depend on ${OPSYS}, because it seems you have to put it before including
bsd.prefs.mk.

The packages's makefile also finds stuff from MacPorts and Homebrew, but
I can patch that out.

I'm attaching my current Makefile and the patch-makefile, which I intend
to commit soon (but not immediately). Possibly someone with more MacOS
experience already knows how to fix those dependency problems.

-Olaf.
-- 
___ "Buying carbon credits is a bit like a serial killer paying someone else to
\X/  have kids to make his activity cost neutral." -The BOFH    falu.nl@rhialto

$NetBSD: patch-makefile,v 1.4 2021/10/14 19:12:56 rhialto Exp $

Exclude -flto for gcc 4.1.3 (used in NetBSD/vax 6)
Exclude -flto for clang on NetBSD
Exclude -flto for gcc 4.4.7 (Used in DragonFly 2.13 - 3.1)
NO_LTO=1 is in effect for gcc and clang, except Darwin.
Make -O2 conditional so can be overridden by environment
Fix png16 detection

--- makefile.orig	2021-10-13 01:53:56.000000000 +0000
+++ makefile
@@ -298,7 +298,7 @@ ifeq (${WIN32},)  #*nix Environments (&&
       $(shell git log -1 --pretty="SIM_GIT_COMMIT_ID %H$(GIT_EXTRA_FILES)%nSIM_GIT_COMMIT_TIME $(isodate)" >.git-commit-id)
     endif
   endif
-  LTO_EXCLUDE_VERSIONS = 
+  LTO_EXCLUDE_VERSIONS = 4.1.3 4.4.7 4.8.3 4.8.4 4.8.5 5.3.0 5.4.0
   PCAPLIB = pcap
   ifeq (agcc,$(findstring agcc,${GCC})) # Android target build?
     OS_CCDEFS = -D_GNU_SOURCE -DSIM_ASYNCH_IO 
@@ -343,12 +343,12 @@ ifeq (${WIN32},)  #*nix Environments (&&
         INCPATH:=$(shell LANG=C; ${GCC} -x c -v -E /dev/null 2>&1 | grep -A 10 '> search starts here' | grep '^ ' | grep -v 'framework directory' | tr -d '\n')
       endif
       ifeq (incopt,$(shell if ${TEST} -d /opt/local/include; then echo incopt; fi))
-        INCPATH += /opt/local/include
-        OS_CCDEFS += -I/opt/local/include
+        # INCPATH += /opt/local/include
+        # OS_CCDEFS += -I/opt/local/include
       endif
       ifeq (libopt,$(shell if ${TEST} -d /opt/local/lib; then echo libopt; fi))
-        LIBPATH += /opt/local/lib
-        OS_LDFLAGS += -L/opt/local/lib
+        # LIBPATH += /opt/local/lib
+        # OS_LDFLAGS += -L/opt/local/lib
       endif
       ifeq (HomeBrew,$(or $(shell if ${TEST} -d /usr/local/Cellar; then echo HomeBrew; fi),$(shell if ${TEST} -d /opt/homebrew/Cellar; then echo HomeBrew; fi)))
         ifeq (local,$(shell if $(TEST) -d /usr/local/Cellar; then echo local; fi))
@@ -356,8 +356,8 @@ ifeq (${WIN32},)  #*nix Environments (&&
         else
           HBPATH = /opt/homebrew
         endif
-        INCPATH += $(foreach dir,$(wildcard $(HBPATH)/Cellar/*/*),$(realpath $(dir)/include))
-        LIBPATH += $(foreach dir,$(wildcard $(HBPATH)/Cellar/*/*),$(realpath $(dir)/lib))
+        # INCPATH += $(foreach dir,$(wildcard $(HBPATH)/Cellar/*/*),$(realpath $(dir)/include))
+        # LIBPATH += $(foreach dir,$(wildcard $(HBPATH)/Cellar/*/*),$(realpath $(dir)/lib))
       endif
     else
       ifeq (Linux,$(OSTYPE))
@@ -598,9 +598,9 @@ ifeq (${WIN32},)  #*nix Environments (&&
     OS_CCDEFS += -DHAVE_UTIME
   endif
   ifneq (,$(call find_include,png))
-    ifneq (,$(call find_lib,png))
+    ifneq (,$(call find_lib,png16))
       OS_CCDEFS += -DHAVE_LIBPNG
-      OS_LDFLAGS += -lpng
+      OS_LDFLAGS += -lpng16
       $(info using libpng: $(call find_lib,png) $(call find_include,png))
       ifneq (,$(call find_include,zlib))
         ifneq (,$(call find_lib,z))
@@ -1185,11 +1185,11 @@ ifneq (,$(UNSUPPORTED_BUILD))
 endif
 ifneq ($(DEBUG),)
   CFLAGS_G = -g -ggdb -g3
-  CFLAGS_O = -O0
+  CFLAGS_O ?= -O0
   BUILD_FEATURES = - debugging support
 else
   ifneq (,$(findstring clang,$(COMPILER_NAME))$(findstring LLVM,$(COMPILER_NAME)))
-    CFLAGS_O = -O2 -fno-strict-overflow
+    CFLAGS_O ?= -O2 -fno-strict-overflow
     GCC_OPTIMIZERS_CMD = ${GCC} --help
     NO_LTO = 1
   else
@@ -1197,7 +1197,7 @@ else
     ifeq (Darwin,$(OSTYPE))
       CFLAGS_O += -O4 -flto -fwhole-program
     else
-      CFLAGS_O := -O2
+      CFLAGS_O ?= -O2
     endif
   endif
   LDFLAGS_O = 
# $NetBSD: Makefile,v 1.57 2021/10/14 19:12:55 rhialto Exp $

DISTNAME=	simh-4.0.0
PKGREVISION=	1
PKGNAME=	simh-4.0.0.20211012
CATEGORIES=	emulators
MASTER_SITES=	${MASTER_SITE_GITHUB:=simh/}
GITHUB_PROJECT=	simh
GITHUB_TAG=	06a8447d26810110a8b168d7525955479bcd3f3a

MAINTAINER=	rhialto%NetBSD.org@localhost
HOMEPAGE=	http://simh.trailing-edge.com/
COMMENT=	Bob Supniks historical computer simulator
LICENSE=	mit

DEPENDS+=	dejavu-ttf-[0-9]*:../../fonts/dejavu-ttf

USE_TOOLS+=	gmake

# TODO: for MacOS:
# uses non-pkgsrc VDE, if present from another source
# does not install net/libpcap if not already installed (BUILTIN failure?)
# same for zlib, freetype2

BUILDLINK_API_DEPENDS.libpcap+=	libpcap>=0.9
PREFER.libpcap=         pkgsrc
PREFER.zlib=            pkgsrc

.include "../../mk/bsd.prefs.mk"

BUILDLINK_TRANSFORM+=	rm:-flto
BUILDLINK_TRANSFORM+=	rm:-fwhole-program

.if (${MACHINE_ARCH} == "arm")
BUILDLINK_TRANSFORM+=	rm:-O2
.endif

# Needed for PDP11/pdp11_dc.c on gcc 4.1.3
.if (${MACHINE_ARCH} == "vax")
CFLAGS+=	-fforce-addr
.endif

CFLAGS.SunOS+=	-DBSD_COMP
LDFLAGS.SunOS+=	-lm

LDFLAGS.Linux+=	-lm -pthread -lrt

INSTALLATION_DIRS=	bin share/simh share/simh/TX-0 share/doc/simh

MAKE_FILE=		makefile
INCLUDES=		${PREFIX:Q}/include:\
			${BUILDLINK_PREFIX.SDL2:Q}/include/SDL2:\
			${BUILDLINK_PREFIX.libpcap:Q}/include/pcap:\
			${BUILDLINK_PREFIX.pcre:Q}/include/pcre:\
			${BUILDLINK_PREFIX.png:Q}/include:\
			/usr/include
LIBRARIES=		${PREFIX:Q}/lib:\
			${BUILDLINK_PREFIX.SDL2:Q}/lib${LIBABISUFFIX}:\
			${BUILDLINK_PREFIX.libpcap:Q}/lib${LIBABISUFFIX}:\
			${BUILDLINK_PREFIX.pcre:Q}/lib${LIBABISUFFIX}:\
			${BUILDLINK_PREFIX.png:Q}/lib${LIBABISUFFIX}:\
			/usr/lib${LIBABISUFFIX}
MAKE_ENV+=		INCLUDES=${INCLUDES:Q}
MAKE_ENV+=		LIBRARIES=${LIBRARIES:Q}
MAKE_ENV+=		GCC=${CC:Q}
MAKE_ENV+=		OS_LDFLAGS=${LDFLAGS:Q}
#MAKE_ENV+=		CFLAGS_O=${CFLAGS:Q}
MAKE_ENV+=		FONTPATH=${PREFIX}/share/fonts/X11/TTF

BUILD_MAKE_FLAGS=	TESTS=0

SUBST_CLASSES+=         pcap
SUBST_STAGE.pcap=       post-patch
SUBST_FILES.pcap=       sim_ether.c
SUBST_SED.pcap=         -e "s:/usr/lib/libpcap.A.dylib:${BUILDLINK_PREFIX.libpcap}/lib/libpcap.dylib:"


post-extract:
	${MKDIR} ${WRKSRC}/BIN

do-install:
	(cd ${WRKSRC}/BIN && for BIN in *; do				\
		if [ -f $$BIN ] ; then					\
		${INSTALL_PROGRAM} $$BIN ${DESTDIR}${PREFIX}/bin/simh-$$BIN; \
		fi ;							\
	done)

	${INSTALL_DATA} ${WRKSRC}/TX-0/*.bin ${DESTDIR}${PREFIX}/share/simh/TX-0
	(cd ${WRKSRC} && for TXT in *.txt */*.txt; do			\
		${INSTALL_DATA} "$$TXT" ${DESTDIR}${PREFIX}/share/doc/simh;		\
	done)

# Note: tests require shm (/var/shm is a tmpfs) for the uc15.
# They are part of the build and can't be run separately.
do-test:
	cd ${WRKSRC} && ${TEST_MAKE_CMD} clean
	cd ${WRKSRC} && ${TEST_MAKE_CMD} all

.include "../../devel/SDL2/buildlink3.mk"
.include "../../fonts/SDL2_ttf/buildlink3.mk"
.include "../../devel/pcre/buildlink3.mk"
.include "../../graphics/png/buildlink3.mk"
.include "../../net/libpcap/buildlink3.mk"
.include "../../mk/dlopen.buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index