From 2e84c403ca6bbb5694f29a555dc4545bfb650e43 Mon Sep 17 00:00:00 2001 From: pegvin <75035219+pegvin@users.noreply.github.com> Date: Sun, 25 Jun 2023 15:48:13 +0530 Subject: [PATCH] Fix Compilation Issues On BSD-based OS (Thanks To @macie) --- Makefile | 10 +++++++++- src/main.h | 14 +++++++------- src/signals.c | 2 -- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 64b74f2..96f9442 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,17 @@ CFLAGS:=-std=c99 -Wall -O0 -g LFLAGS:= UNAME_S:=$(shell uname -s) -ifeq ($(UNAME_S),FreeBSD) + +ifeq ($(findstring BSD,$(UNAME_S)),BSD) + CFLAGS+=-DTARGET_BSD=1 LFLAGS+=-lexecinfo endif +ifeq ($(UNAME_S),Linux) + CFLAGS+=-DTARGET_LINUX=1 +endif +ifeq ($(UNAME_S),Darwin) + CFLAGS+=-DTARGET_OSX=1 +endif bin:=termrec obj:=obj diff --git a/src/main.h b/src/main.h index cd582a1..df005fd 100644 --- a/src/main.h +++ b/src/main.h @@ -4,13 +4,13 @@ #define _XOPEN_SOURCE 600 #define _POSIX_C_SOURCE 1 -#ifdef __APPLE__ -#define _DARWIN_C_SOURCE 1 +#ifdef TARGET_OSX + #define _DARWIN_C_SOURCE 1 #endif -#ifdef __FreeBSD__ -#define _BSD_SOURCE 1 -#define __BSD_VISIBLE 1 +#ifdef TARGET_BSD + #define _BSD_SOURCE 1 + #define __BSD_VISIBLE 1 #endif #include @@ -28,8 +28,8 @@ #include #include -#ifdef __FreeBSD__ -#include +#ifdef TARGET_BSD + #include #else #include #endif diff --git a/src/signals.c b/src/signals.c index 3647f49..020068a 100644 --- a/src/signals.c +++ b/src/signals.c @@ -13,8 +13,6 @@ #include #include - -#define __BSD_VISIBLE 1 #include #include