diff --git a/Makefile b/Makefile index 67981b7..05a24b7 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,18 @@ endif # BSD (ELF, dlopen lives in libc) ifeq ($(OS_KIND),bsd) EXPORT_LDFLAGS := -Wl,-E - # raylib's own BSD list lacks the X11 set its examples link. - PLAT_LIBS := -lm -lGL -lpthread -lX11 -lXrandr -lXinerama -lXi -lXcursor + # ld searches /usr/lib only. pkg(8) installs into /usr/local (FreeBSD, + # DragonFly), pkgsrc into /usr/pkg (NetBSD), and base X11 lives in + # /usr/X11R6 (OpenBSD) or /usr/X11R7 (NetBSD), so every -l below needs an + # explicit -L. raylib's own BSD link list omits the X11 set and these paths, + # which is why its examples only link on a system with the libs on the + # default search path. + BSD_LIBDIRS := -L/usr/local/lib + ifneq (,$(filter OpenBSD NetBSD,$(PLATFORM))) + BSD_LIBDIRS += -L/usr/pkg/lib -L/usr/X11R6/lib -L/usr/X11R7/lib + endif + PLAT_LIBS := $(BSD_LIBDIRS) -lm -lGL -lpthread \ + -lX11 -lXrandr -lXinerama -lXi -lXcursor ifneq (,$(filter $(PLATFORM),OpenBSD NetBSD)) PLAT_LIBS += -lossaudio endif @@ -332,6 +342,7 @@ print-config: @echo "CPPFLAGS = $(CPPFLAGS)" @echo "EXPORT_LDFLAGS = $(EXPORT_LDFLAGS)" @echo "PLAT_LIBS = $(PLAT_LIBS)" + @echo "BSD_LIBDIRS = $(BSD_LIBDIRS)" @echo "LINK_TARGET = $(LINK_TARGET)" @echo "OBJ = $(OBJ)" @echo "HOST_CC = $(HOST_CC)"