Bladeren bron

Merge pull request #1 from jspricke/linux

Adopt to Linux
Jan Klemkow 6 jaren geleden
bovenliggende
commit
be490d2fd4
2 gewijzigde bestanden met toevoegingen van 10 en 7 verwijderingen
  1. 3 2
      Makefile
  2. 7 5
      scroll.c

+ 3 - 2
Makefile

@@ -1,5 +1,6 @@
-CFLAGS = -std=c99 -pedantic -Wall -Wextra
-LDFLAGS += -lutil
+CFLAGS += -std=c99 -pedantic -Wall -Wextra
+LDLIBS += -lutil
+CPPFLAGS += -D_DEFAULT_SOURCE
 
 .PHONY: all clean
 

+ 7 - 5
scroll.c

@@ -1,5 +1,3 @@
-//#define _DEFAULT_SOURCE
-
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/select.h>
@@ -16,9 +14,13 @@
 #include <termios.h>
 #include <unistd.h>
 
-// TODO: OpenBSD/Linux ifdef
-#include <util.h>
-//#include <pty.h>
+#if   defined(__linux)
+ #include <pty.h>
+#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+ #include <util.h>
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+ #include <libutil.h>
+#endif
 
 typedef struct Line Line;
 struct Line {