-# $Cambridge: exim/src/OS/Makefile-FreeBSD,v 1.1 2004/10/06 15:07:39 ph10 Exp $
-
# Exim: OS-specific make file for FreeBSD
-# There's no setting of CFLAGS here, to allow the system default
-# for "make" to be the default.
-
-PORTOBJFORMAT!= test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
+#
+# Copyright (c) The Exim Maintainers 2020
+# SPDX-License-Identifier: GPL-2.0-or-later
CHOWN_COMMAND=/usr/sbin/chown
+#STRIP_COMMAND=/usr/bin/strip
+CHMOD_COMMAND=/bin/chmod
+
+
+# FreeBSD Ports no longer insert compatibility symlinks into /usr/bin for
+# scripting languages which traditionally have had them.
+PERL_COMMAND=/usr/local/bin/perl
HAVE_SA_LEN=YES
# crypt() is in a separate library
-LIBS=-lcrypt
+LIBS=-lcrypt -lm -lutil -lexecinfo
+
+# Dynamically loaded modules need to be built with -fPIC
+CFLAGS_DYNAMIC=-shared -rdynamic -fPIC
# FreeBSD always ships with Berkeley DB
USE_DB=yes
-# This setting changed on Sheldon Hearn's recommendation
-# X11=/usr/X11R6
-X11=$(X11BASE)
+# This code for building outside ports suggested by Richard Clayton
+.ifdef X11BASE
+X11=${X11BASE}
+.elifdef LOCALBASE
+X11=$(LOCALBASE)
+.else
+X11=/usr/local
+.endif
+# nb: FreeBSD is entirely elf; objformat was removed prior to FreeBSD 7
+# http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/objformat/Attic/objformat.c
+# deleted Jan 2007.
+#
+# So if this fails, you're on an ancient unsupported FreeBSD release *and*
+# running GUI software, which seems both unusual and unwise.
+#
+# http://www.freebsd.org/doc/handbook/binary-formats.html suggests that the
+# switch to default to ELF came with FreeBSD 3. elf(5) claims ELF support
+# introduced in FreeBSD 2.2.6.
+#
XINCLUDE=-I$(X11)/include
-XLFLAGS=-L$(X11)/lib
-.if ${PORTOBJFORMAT} == "elf"
-XLFLAGS+=-Wl,-rpath,${X11BASE}/lib
-.endif
+XLFLAGS=-L$(X11)/lib -Wl,-rpath,${X11}/lib
X11_LD_LIB=$(X11)/lib
EXIWHAT_PS_ARG=-ax