include changes to support OpenBSD and prepare NetBSD support

Some systems do not split -lrt and -ldl from the main libc.

Musl libc is one of them, but offers an empty -ldl and -lrt
precisely to avoid these kind of compilation errors.

OpenBSD tried to add a librt.a but it broke libtool-based packages
on multiple OSes[1] so it got reverted, nad -lrt needs to be removed.

Some other adjustments for FreeBSD also work for other BSD, like
packages in /usr/local/ instead of /usr/, TLC libraries...

[1]: https://marc.info/?l=openbsd-tech&m=139559970907629&w=2
This commit is contained in:
Josuah Demangeon 2022-07-08 13:39:18 +02:00
parent 793b9ade56
commit 6eba56fcf0
1 changed files with 7 additions and 5 deletions

View File

@ -126,8 +126,10 @@ endif
else else
LDFLAGS += -rdynamic LDFLAGS += -rdynamic
ifneq ($(OS), OpenBSD)
LDLIBS += -lrt LDLIBS += -lrt
endif endif
endif
YOSYS_VER := 0.19+18 YOSYS_VER := 0.19+18
@ -395,7 +397,7 @@ endif # ENABLE_PYOSYS
ifeq ($(ENABLE_READLINE),1) ifeq ($(ENABLE_READLINE),1)
CXXFLAGS += -DYOSYS_ENABLE_READLINE CXXFLAGS += -DYOSYS_ENABLE_READLINE
ifeq ($(OS), FreeBSD) ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD))
CXXFLAGS += -I/usr/local/include CXXFLAGS += -I/usr/local/include
endif endif
LDLIBS += -lreadline LDLIBS += -lreadline
@ -430,7 +432,7 @@ endif
ifeq ($(ENABLE_PLUGINS),1) ifeq ($(ENABLE_PLUGINS),1)
CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS
LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi)
ifneq ($(OS), FreeBSD) ifneq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD))
LDLIBS += -ldl LDLIBS += -ldl
endif endif
endif endif
@ -447,7 +449,7 @@ endif
ifeq ($(ENABLE_TCL),1) ifeq ($(ENABLE_TCL),1)
TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')") TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')")
ifeq ($(OS), FreeBSD) ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD))
TCL_INCLUDE ?= /usr/local/include/$(TCL_VERSION) TCL_INCLUDE ?= /usr/local/include/$(TCL_VERSION)
else else
TCL_INCLUDE ?= /usr/include/$(TCL_VERSION) TCL_INCLUDE ?= /usr/include/$(TCL_VERSION)
@ -458,8 +460,8 @@ CXXFLAGS += -DYOSYS_ENABLE_TCL
LDLIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32 -lz -luserenv LDLIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32 -lz -luserenv
else else
CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL
ifeq ($(OS), FreeBSD) ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD))
# FreeBSD uses tcl8.6, but lib is named "libtcl86" # BSDs usually use tcl8.6, but the lib is named "libtcl86"
LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION) | tr -d '.') LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION) | tr -d '.')
else else
LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION)) LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION))