aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--config.mk13
-rw-r--r--st.c27
3 files changed, 24 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 9ec8d21..ef3bf09 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ all: options st
10 10
11options: 11options:
12 @echo st build options: 12 @echo st build options:
13 @echo "SYSTEM = ${SYSTEM}"
13 @echo "CFLAGS = ${CFLAGS}" 14 @echo "CFLAGS = ${CFLAGS}"
14 @echo "LDFLAGS = ${LDFLAGS}" 15 @echo "LDFLAGS = ${LDFLAGS}"
15 @echo "CC = ${CC}" 16 @echo "CC = ${CC}"
@@ -31,7 +32,7 @@ clean:
31dist: clean 32dist: clean
32 @echo creating dist tarball 33 @echo creating dist tarball
33 @mkdir -p st-${VERSION} 34 @mkdir -p st-${VERSION}
34 @cp -R LICENSE Makefile README config.mk st.h ${SRC} st-${VERSION} 35 @cp -R LICENSE Makefile README config.mk config.h st.info ${SRC} st-${VERSION}
35 @tar -cf st-${VERSION}.tar st-${VERSION} 36 @tar -cf st-${VERSION}.tar st-${VERSION}
36 @gzip st-${VERSION}.tar 37 @gzip st-${VERSION}.tar
37 @rm -rf st-${VERSION} 38 @rm -rf st-${VERSION}
@@ -41,7 +42,7 @@ install: all
41 @mkdir -p ${DESTDIR}${PREFIX}/bin 42 @mkdir -p ${DESTDIR}${PREFIX}/bin
42 @cp -f st ${DESTDIR}${PREFIX}/bin 43 @cp -f st ${DESTDIR}${PREFIX}/bin
43 @chmod 755 ${DESTDIR}${PREFIX}/bin/st 44 @chmod 755 ${DESTDIR}${PREFIX}/bin/st
44 @tic st.info 45 @tic -s st.info
45 46
46uninstall: 47uninstall:
47 @echo removing executable file from ${DESTDIR}${PREFIX}/bin 48 @echo removing executable file from ${DESTDIR}${PREFIX}/bin
diff --git a/config.mk b/config.mk
index 2827e98..216e7df 100644
--- a/config.mk
+++ b/config.mk
@@ -12,16 +12,17 @@ X11LIB = /usr/X11R6/lib
12 12
13# includes and libs 13# includes and libs
14INCS = -I. -I/usr/include -I${X11INC} 14INCS = -I. -I/usr/include -I${X11INC}
15LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 15LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil
16
17# uncomment your system #
18#SYSTEM = -DLINUX
19#SYSTEM = -DOPENBSD
20#SYSTEM = -DFREEBSD
16 21
17# flags 22# flags
18CPPFLAGS = -DVERSION=\"${VERSION}\" 23CPPFLAGS = -DVERSION=\"${VERSION}\" ${SYSTEM}
19CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} 24CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
20LDFLAGS = -s ${LIBS} 25LDFLAGS = -s ${LIBS}
21 26
22# Solaris
23#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
24#LDFLAGS = ${LIBS}
25
26# compiler and linker 27# compiler and linker
27CC = cc 28CC = cc
diff --git a/st.c b/st.c
index 623ca29..9ca032f 100644
--- a/st.c
+++ b/st.c
@@ -20,6 +20,14 @@
20#include <X11/keysym.h> 20#include <X11/keysym.h>
21#include <X11/Xutil.h> 21#include <X11/Xutil.h>
22 22
23#if defined(LINUX)
24 #include <pty.h>
25#elif defined(OPENBSD)
26 #include <util.h>
27#elif defined(FREEBSD)
28 #include <libutil.h>
29#endif
30
23/* Arbitrary sizes */ 31/* Arbitrary sizes */
24#define ESC_TITLE_SIZ 256 32#define ESC_TITLE_SIZ 256
25#define ESC_BUF_SIZ 256 33#define ESC_BUF_SIZ 256
@@ -242,19 +250,12 @@ sigchld(int a) {
242void 250void
243ttynew(void) { 251ttynew(void) {
244 int m, s; 252 int m, s;
245 char *pts; 253
246 254 /* seems to work fine on linux, openbsd and freebsd */
247 if((m = posix_openpt(O_RDWR | O_NOCTTY)) < 0) 255 struct winsize w = {term.row, term.col, 0, 0};
248 die("openpt failed: %s\n", SERRNO); 256 if(openpty(&m, &s, NULL, NULL, &w) < 0)
249 if(grantpt(m) < 0) 257 die("openpty failed: %s\n", SERRNO);
250 die("grantpt failed: %s\n", SERRNO); 258
251 if(unlockpt(m) < 0)
252 die("unlockpt failed: %s\n", SERRNO);
253 if(!(pts = ptsname(m)))
254 die("ptsname failed: %s\n", SERRNO);
255 if((s = open(pts, O_RDWR | O_NOCTTY)) < 0)
256 die("Couldn't open slave: %s\n", SERRNO);
257 fcntl(s, F_SETFL, O_NDELAY);
258 switch(pid = fork()) { 259 switch(pid = fork()) {
259 case -1: 260 case -1:
260 die("fork failed\n"); 261 die("fork failed\n");