Skip to content

Commit

Permalink
Add support for osx.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Parker committed Feb 4, 2015
1 parent 9150af2 commit 29454fd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions include/limits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include_next <limits.h>

#ifndef MG_COMPAT_LIMITS_H
#define MG_COMPAT_LIMITS_H

#if defined(__APPLE__)
#define LOGIN_NAME_MAX MAXLOGNAME
#endif

#endif
2 changes: 2 additions & 0 deletions include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions include/sys/socket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include_next <sys/socket.h>

#ifndef MG_COMPAT_SYS_SOCKET_H
#define MG_COMPAT_SYS_SOCKET_H

#if defined(__APPLE__)
#define MSG_NOSIGNAL SO_NOSIGPIPE
#endif

#endif
2 changes: 1 addition & 1 deletion include/util.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 29454fd

Please sign in to comment.