diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | config.mk | 13 | ||||
-rw-r--r-- | st.c | 27 |
3 files changed, 24 insertions, 21 deletions
@@ -10,6 +10,7 @@ all: options st | |||
10 | 10 | ||
11 | options: | 11 | options: |
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: | |||
31 | dist: clean | 32 | dist: 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 | ||
46 | uninstall: | 47 | uninstall: |
47 | @echo removing executable file from ${DESTDIR}${PREFIX}/bin | 48 | @echo removing executable file from ${DESTDIR}${PREFIX}/bin |
@@ -12,16 +12,17 @@ X11LIB = /usr/X11R6/lib | |||
12 | 12 | ||
13 | # includes and libs | 13 | # includes and libs |
14 | INCS = -I. -I/usr/include -I${X11INC} | 14 | INCS = -I. -I/usr/include -I${X11INC} |
15 | LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | 15 | LIBS = -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 |
18 | CPPFLAGS = -DVERSION=\"${VERSION}\" | 23 | CPPFLAGS = -DVERSION=\"${VERSION}\" ${SYSTEM} |
19 | CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} | 24 | CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} |
20 | LDFLAGS = -s ${LIBS} | 25 | LDFLAGS = -s ${LIBS} |
21 | 26 | ||
22 | # Solaris | ||
23 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | ||
24 | #LDFLAGS = ${LIBS} | ||
25 | |||
26 | # compiler and linker | 27 | # compiler and linker |
27 | CC = cc | 28 | CC = cc |
@@ -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) { | |||
242 | void | 250 | void |
243 | ttynew(void) { | 251 | ttynew(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"); |