Commit 7f87bae1 authored by 興怡's avatar 興怡
Browse files

static linked st

parent 6a6d8121
Pipeline #214020762 failed with stage
in 0 seconds
ARG ARCH=
FROM ${ARCH}alpine:3.12
##COPY . /opt/st
WORKDIR /opt
RUN wget -O - https://dl.suckless.org/st/st-0.8.4.tar.gz | tar -xz
RUN wget -O st-0.8.4/st-w3m.diff https://st.suckless.org/patches/w3m/st-w3m-0.8.3.diff
##RUN wget -O st-0.8.4/st-w3m.diff https://st.suckless.org/patches/w3m/st-w3m-0.8.3.diff
# add build deps
RUN apk update && apk --no-cache add git \
make g++ libx11-dev libxft-dev libxinerama-dev ncurses patch
binutils cmake make libgcc musl-dev gcc g++ \
libx11-static patch \
fontconfig-static freetype-static \
libxft-dev libxext-dev libxrender-dev libxcb-static libxau-dev \
libxdmcp-dev \
zlib-static bzip2-static libpng-static \
libuuid expat-static brotli-static \
ncurses
# patch color theme for gruvbox
RUN wget -O st-0.8.4/gruvbox.diff https://st.suckless.org/patches/gruvbox/st-gruvbox-dark-0.8.2.diff
# static linking patches
COPY Makefile /opt/st-0.8.4/Makefile
COPY config.mk /opt/st-0.8.4/config.mk
# compile
##RUN cd st-0.8.4 ; patch -p1 < st-w3m.diff ;
RUN cd st-0.8.4 ; patch -p1 < gruvbox.diff ;\
make clean install PREFIX=
make clean ;\
make ;\
make install
# clean build deps
#RUN apk del git \
......@@ -28,4 +36,4 @@ RUN cd st-0.8.4 ; patch -p1 < gruvbox.diff ;\
#RUN apk add libx11 libxft libxinerama dbus-x11 ;\
# rm -rf /opt/st* /apk /tmp/* /var/cache/apk/*
CMD ["/bin/st"]
##CMD ["/usr/local/bin/st"]
# st - simple terminal
# See LICENSE file for copyright and license details.
.POSIX:
include config.mk
SRC = st.c x.c
OBJ = $(SRC:.c=.o)
all: options st
options:
@echo st build options:
@echo "CFLAGS = $(STCFLAGS)"
@echo "LDFLAGS = $(STLDFLAGS)"
@echo "CC = $(CC)"
config.h:
cp config.def.h config.h
.c.o:
$(CC) $(STCFLAGS) -c $<
st.o: config.h st.h win.h
x.o: arg.h config.h st.h win.h
$(OBJ): config.h config.mk
st: $(OBJ)
$(CC) -o $@ $(OBJ) $(STLDFLAGS) -static
clean:
rm -f st $(OBJ) st-$(VERSION).tar.gz
dist: clean
mkdir -p st-$(VERSION)
cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
config.def.h st.info st.1 arg.h st.h win.h $(SRC)\
st-$(VERSION)
tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
rm -rf st-$(VERSION)
install: st
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f st $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
tic -sx st.info
@echo Please see the README file regarding the terminfo entry of st.
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/st
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
.PHONY: all options clean dist install uninstall
# st
Make a static linked binary of the st: simple terminal from
[Suckless](https://suckless.org)
The build is done with the Alpine Linux base image.
With the Makefile and config.mk modified to link the static libraries.
## Quickstart
1. Clone the repo
2. Compile inside the container
3. Copy the binary to your prefered path
```
$ git clone git@gitlab.com:rtmi5/containerizations.git
$ docker build -t stbuilder containerizations/st
$ docker run -ti --rm -v $PWD:/build -w /build stbuilder cp /opt/st-0.8.4/st ./st-gruvbox
$ sudo chown $USER ./st-gruvbox && mv ./st-gruvbox $HOME/.local/bin/
$ st-gruvbox -v
```
## Credits
[Suckless Tools](https://suckless.org)([LICENSE](https://git.suckless.org/st/file/LICENSE.html))
[Cautionary about static linking](https://medium.com/@neunhoef/static-binaries-for-a-c-application-f7c76f8041cf)
[Xft dependencies](https://github.com/freedesktop/libXft)
[Linking static Brotli](https://github.com/google/brotli/issues/795)
# st version
VERSION = 0.8.4
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
PKG_CONFIG = pkg-config
# includes and libs
INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2`
LIBS = -L$(X11LIB) -lm -lrt -lXft -lX11 -lutil \
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2` \
-lXrender -lxcb -lXau -lXdmcp \
-lexpat -luuid -lpng -lz -lbz2 \
-lbrotlidec-static -lbrotlicommon-static
# flags
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS)
# OpenBSD:
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
# `$(PKG_CONFIG) --libs fontconfig` \
# `$(PKG_CONFIG) --libs freetype2`
# compiler and linker
# CC = c99
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment