nageyqma·git
HTTPS https://git.nageyqma.icu/nageyqma/st.git SSH git@git.nageyqma.icu:nageyqma/st.git

HTTPS 链接可直接 git clone;推送代码请使用 SSH。

3.8 KB · 127 行raw
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
# st - simple terminal
# See LICENSE file for copyright and license details.
.POSIX:

include config.mk

PROTOHDR = xdg-shell-client-protocol.h \
           fractional-scale-client-protocol.h \
           viewporter-client-protocol.h \
           cursor-shape-client-protocol.h \
           system-bell-client-protocol.h \
           primary-selection-client-protocol.h \
           text-input-client-protocol.h \
           tablet-v2-client-protocol.h
PROTOC = xdg-shell-protocol.c \
         fractional-scale-protocol.c \
         viewporter-protocol.c \
         cursor-shape-protocol.c \
         system-bell-protocol.c \
         primary-selection-protocol.c \
         text-input-protocol.c \
         tablet-v2-protocol.c
SRC = st.c wl.c boxdraw.c hb.c $(PROTOC)
OBJ = $(SRC:.c=.o)

all: options st

# wayland-protocols is only needed to (re)generate the protocol bindings, so
# clean and dist keep working without it; anything else fails with a hint
# instead of make looking for /stable/xdg-shell/xdg-shell.xml.
ifeq ($(WLPROTO),)
ifeq ($(filter clean dist uninstall,$(MAKECMDGOALS)),)
$(error wayland-protocols not found: install it or run make WLPROTO=/path/to/wayland-protocols)
endif
endif

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
wl.o: arg.h config.h st.h win.h render.h hb.h $(PROTOHDR)
hb.o: st.h render.h hb.h
boxdraw.o: config.h st.h render.h boxdraw_data.h
$(PROTOC:.c=.o): $(PROTOHDR)

$(OBJ): config.h config.mk

st: $(OBJ)
	$(CC) -o $@ $(OBJ) $(STLDFLAGS)

# Wayland protocol bindings (generated, not committed)
xdg-shell-client-protocol.h: $(XDG_SHELL_XML)
	$(WAYLAND_SCANNER) client-header $< $@
xdg-shell-protocol.c: $(XDG_SHELL_XML)
	$(WAYLAND_SCANNER) private-code $< $@

fractional-scale-client-protocol.h: $(FRACTIONAL_XML)
	$(WAYLAND_SCANNER) client-header $< $@
fractional-scale-protocol.c: $(FRACTIONAL_XML)
	$(WAYLAND_SCANNER) private-code $< $@

viewporter-client-protocol.h: $(VIEWPORTER_XML)
	$(WAYLAND_SCANNER) client-header $< $@
viewporter-protocol.c: $(VIEWPORTER_XML)
	$(WAYLAND_SCANNER) private-code $< $@

cursor-shape-client-protocol.h: $(CURSOR_SHAPE_XML)
	$(WAYLAND_SCANNER) client-header $< $@
cursor-shape-protocol.c: $(CURSOR_SHAPE_XML)
	$(WAYLAND_SCANNER) private-code $< $@

system-bell-client-protocol.h: $(SYSTEM_BELL_XML)
	$(WAYLAND_SCANNER) client-header $< $@
system-bell-protocol.c: $(SYSTEM_BELL_XML)
	$(WAYLAND_SCANNER) private-code $< $@

primary-selection-client-protocol.h: $(PRIMARY_XML)
	$(WAYLAND_SCANNER) client-header $< $@
primary-selection-protocol.c: $(PRIMARY_XML)
	$(WAYLAND_SCANNER) private-code $< $@

text-input-client-protocol.h: $(TEXT_INPUT_XML)
	$(WAYLAND_SCANNER) client-header $< $@
text-input-protocol.c: $(TEXT_INPUT_XML)
	$(WAYLAND_SCANNER) private-code $< $@

tablet-v2-client-protocol.h: $(TABLET_XML)
	$(WAYLAND_SCANNER) client-header $< $@
tablet-v2-protocol.c: $(TABLET_XML)
	$(WAYLAND_SCANNER) private-code $< $@

clean:
	rm -f st $(OBJ) $(PROTOC) $(PROTOHDR) st-$(VERSION).tar.gz

dist: clean
	mkdir -p st-$(VERSION)
	cp -R AGENT.md LEGACY LICENSE Makefile README config.mk config.h\
		st.info st.1 arg.h st.h wl.c hb.h hb.c boxdraw.c boxdraw_data.h\
		render.h st.c 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