Skip to content

Instantly share code, notes, and snippets.

@cdosborn
Last active February 21, 2016 19:41
Show Gist options
  • Save cdosborn/a4b4dc8175c4634edbfb to your computer and use it in GitHub Desktop.
Save cdosborn/a4b4dc8175c4634edbfb to your computer and use it in GitHub Desktop.
Make suckless st compile on OSX..
diff --git a/config.mk b/config.mk
index 81e3e47..8f2352a 100644
--- a/config.mk
+++ b/config.mk
@@ -14,7 +14,7 @@ X11LIB = /usr/X11R6/lib
INCS = -I. -I/usr/include -I${X11INC} \
`pkg-config --cflags fontconfig` \
`pkg-config --cflags freetype2`
-LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft \
+LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lX11 -lutil -lXft \
`pkg-config --libs fontconfig` \
`pkg-config --libs freetype2`
diff --git a/st.c b/st.c
index 0536b6f..a63a85a 100644
--- a/st.c
+++ b/st.c
@@ -31,6 +31,7 @@
#include <fontconfig/fontconfig.h>
#include <wchar.h>
+
#include "arg.h"
char *argv0;
@@ -179,6 +180,20 @@ enum selection_snap {
SNAP_WORD = 1,
SNAP_LINE = 2
};
+#ifdef __MACH__
+#include <sys/time.h>
+//clock_gettime is not implemented on OSX
+#define CLOCK_MONOTONIC -1
+int clock_gettime(int clk_id /*clk_id*/, struct timespec* t) {
+ struct timeval now;
+ int rv = gettimeofday(&now, NULL);
+ if (rv) return rv;
+ t->tv_sec = now.tv_sec;
+ t->tv_nsec = now.tv_usec * 1000;
+ return 0;
+}
+#endif
+
typedef unsigned char uchar;
typedef unsigned int uint;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment