$NetBSD: patch-src_Makefile,v 1.5 2025/09/08 15:03:40 adam Exp $

Set preferences.
Don't override CC nor optimisation flags in CFLAGS.
Defined IS_ARM in externally.
Remove sed magic; we'll use nbsed.
Don't build universal binary on Darwin.

--- src/Makefile.orig	2025-08-18 05:23:33.000000000 +0000
+++ src/Makefile
@@ -69,8 +69,6 @@ BRIDGE_INTERFACE_VERSION := 700
 ## Native compiler paths
 ##
 
-CC                      := gcc
-CXX                     := g++
 AR                      := ar
 FIND                    := find
 INSTALL                 := install
@@ -79,18 +77,10 @@ SED                     := sed
 SED_IN_PLACE            := -i
 
 ifeq ($(UNAME),Darwin)
-CC                      := clang
-CXX                     := clang++
-# the sed -i option of macOS requires a parameter for the backup file (we just use "")
-AR                      := /usr/bin/ar
-SED                     := /usr/bin/sed
-SED_IN_PLACE            := -i ""
 DARWIN_VERSION          := $(shell uname -r | cut -d. -f1)
 IS_APPLE_SILICON        := $(shell [ "$$(sysctl -in hw.optional.arm64 2>/dev/null)" = "1" ] && echo 1 || echo 0)
 endif
 
-IS_AARCH64              := $(shell [ "$$(arch 2>/dev/null)" = "aarch64" ] && echo 1 || echo 0)
-IS_ARM                  := $(or $(filter 1,$(IS_APPLE_SILICON)),$(filter 1,$(IS_AARCH64)))
 
 ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
 CC                      := cc
@@ -275,7 +265,6 @@ endif
 endif
 
 ifeq ($(DEBUG),0)
-CFLAGS                  += -O2
 ifneq ($(UNAME),Darwin)
 LFLAGS                  += -s
 endif
@@ -355,6 +344,7 @@ ifeq ($(UNAME),Linux)
 CFLAGS_NATIVE           := $(CFLAGS)
 CFLAGS_NATIVE           += -DWITH_HWMON
 LFLAGS_NATIVE           := $(LFLAGS)
+LFLAGS_NATIVE           += -lm
 LFLAGS_NATIVE           += -lpthread
 LFLAGS_NATIVE           += -ldl
 LFLAGS_NATIVE           += -lrt
@@ -414,14 +404,6 @@ LFLAGS_NATIVE           += -lIOReport
 LFLAGS_NATIVE           += -lpthread
 LFLAGS_NATIVE           += -liconv
 
-ifeq ($(IS_APPLE_SILICON),1)
-CFLAGS_NATIVE           += -arch arm64
-CFLAGS_NATIVE           += -arch x86_64
-ifeq ($(SHARED),1)
-LFLAGS_NATIVE           += -arch arm64
-LFLAGS_NATIVE           += -arch x86_64
-endif
-endif
 
 endif # Darwin
 
