Skip to content

Commit

Permalink
Fix Compilation Issues On BSD-based OS (Thanks To @macie)
Browse files Browse the repository at this point in the history
  • Loading branch information
pegvin committed Jun 25, 2023
1 parent bedb8b4 commit 2e84c40
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
Expand All @@ -28,8 +28,8 @@
#include <termios.h>
#include <sys/ioctl.h>

#ifdef __FreeBSD__
#include <time.h>
#ifdef TARGET_BSD
#include <time.h>
#else
#include <sys/time.h>
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <execinfo.h>
#include <fcntl.h>

#define __BSD_VISIBLE 1
#include <signal.h>

#include <termios.h>
Expand Down

0 comments on commit 2e84c40

Please sign in to comment.