diff --git a/GNUmakefile b/GNUmakefile index 04ce43f..a108ccf 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -9,7 +9,7 @@ UNAME:= $(shell sh -c 'uname 2> /dev/null || echo undefined') CFLAGS+= -Iinclude -DFKEYS -DREGEX -DXKEYS -LDADD+= -lcurses -lcrypto -lrt +LDADD+= -lcurses SRCS= autoexec.c basic.c bell.c buffer.c cinfo.c cmode.c cscope.c \ dir.c dired.c display.c echo.c extend.c file.c fileio.c \ @@ -20,10 +20,13 @@ SRCS= autoexec.c basic.c bell.c buffer.c cinfo.c cmode.c cscope.c \ ifeq ($(UNAME), Linux) CFLAGS+= -D_GNU_SOURCE +LDADD+= -lcrypto -lrt SRCS+= compat/arc4random.c compat/arc4random_uniform.c \ compat/explicit_bzero.c compat/fgetln.c compat/fparseln.c \ compat/getentropy_linux.c compat/strlcat.c compat/strlcpy.c \ compat/strtonum.c +else ifeq ($(UNAME), Darwin) +SRCS+= compat/fparseln.c compat/strtonum.c endif OBJS= $(SRCS:.c=.o) diff --git a/include/limits.h b/include/limits.h new file mode 100644 index 0000000..8257c53 --- /dev/null +++ b/include/limits.h @@ -0,0 +1,10 @@ +#include_next + +#ifndef MG_COMPAT_LIMITS_H +#define MG_COMPAT_LIMITS_H + +#if defined(__APPLE__) +#define LOGIN_NAME_MAX MAXLOGNAME +#endif + +#endif diff --git a/include/stdlib.h b/include/stdlib.h index 2043239..d957577 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -10,6 +10,8 @@ uint32_t arc4random(void); void arc4random_buf(void *, size_t); uint32_t arc4random_uniform(uint32_t); long long strtonum(const char *, long long, long long, const char **); +#elif defined(__APPLE__) +long long strtonum(const char *, long long, long long, const char **); #endif #endif diff --git a/include/sys/socket.h b/include/sys/socket.h new file mode 100644 index 0000000..ad95532 --- /dev/null +++ b/include/sys/socket.h @@ -0,0 +1,10 @@ +#include_next + +#ifndef MG_COMPAT_SYS_SOCKET_H +#define MG_COMPAT_SYS_SOCKET_H + +#if defined(__APPLE__) +#define MSG_NOSIGNAL SO_NOSIGPIPE +#endif + +#endif diff --git a/include/util.h b/include/util.h index cc30c8e..8d20acc 100644 --- a/include/util.h +++ b/include/util.h @@ -1,7 +1,7 @@ #ifndef MG_COMPAT_UTIL_H #define MG_COMPAT_UTIL_H -#if defined(__linux__) +#if defined(__linux__) || defined(__APPLE__) #define FPARSELN_UNESCESC 0x01 #define FPARSELN_UNESCCONT 0x02 #define FPARSELN_UNESCCOMM 0x04