commit 4e7e043
shrub
·
2026-02-03 17:30:03 +0000 UTC
parent 6c07136
openbsd compatibility
3 files changed,
+22,
-3
M
Makefile
+11,
-3
1@@ -2,7 +2,7 @@
2
3 include config.mk
4
5-PREFIX ?= /usr/local
6+PREFIX ?= /usr
7 LIBDIR ?= $(PREFIX)/lib
8 INCLUDEDIR ?= $(PREFIX)/include
9 PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
10@@ -87,8 +87,13 @@ WLD_PACKAGES = $(WLD_REQUIRES) $(WLD_REQUIRES_PRIVATE)
11 WLD_PACKAGE_CFLAGS ?= $(call pkgconfig,$(WLD_PACKAGES),cflags,CFLAGS)
12 WLD_PACKAGE_LIBS ?= $(call pkgconfig,$(WLD_PACKAGES),libs,LIBS)
13
14+ifeq ($(shell uname),OpenBSD)
15+ WLD_PACKAGE_LIBS += -lc
16+endif
17+
18+
19 FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c99 -Wvla
20-FINAL_CPPFLAGS = $(CPPFLAGS) -D_XOPEN_SOURCE=700
21+FINAL_CPPFLAGS = $(CPPFLAGS)
22
23 # Warning/error flags
24 FINAL_CFLAGS += -Werror=implicit-function-declaration -Werror=implicit-int \
25@@ -100,6 +105,10 @@ ifeq ($(shell uname),NetBSD)
26 FINAL_CPPFLAGS += -D_NETBSD_SOURCE
27 endif
28
29+ifeq ($(shell uname),Linux)
30+ FINAL_CPPFLAGS += -D_POSIX_C_SOURCE=200809L
31+endif
32+
33 ifeq ($(ENABLE_DEBUG),1)
34 FINAL_CPPFLAGS += -DENABLE_DEBUG=1
35 FINAL_CFLAGS += -g
36@@ -188,4 +197,3 @@ clean:
37 rm -rf $(CLEAN_FILES)
38
39 -include .deps/*.d
40-
M
drm.c
+4,
-0
1@@ -26,9 +26,13 @@
2
3 #include <sys/types.h>
4 #ifndef major
5+
6+#ifdef __linux__
7 #include <sys/sysmacros.h>
8 #endif
9
10+#endif
11+
12 const static struct drm_driver *drivers[] = {
13 #if WITH_DRM_INTEL
14 &intel_drm_driver,
+7,
-0
1@@ -177,8 +177,15 @@ context_create_buffer(struct wld_context *base,
2
3 unlink(name);
4
5+#if defined(__linux__)
6+ /* try to preallocate */
7 if (posix_fallocate(fd, 0, size) != 0 && ftruncate(fd, size) != 0)
8 goto error2;
9+#else
10+ /* ftruncate() is enough otherwise */
11+ if (ftruncate(fd, size) != 0)
12+ goto error2;
13+#endif
14
15 if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
16 goto error2;