about summary refs log tree commit diff stats
path: root/Makefile
blob: 9ef219a53c575f6adbbf5a8ae7f0e594ad0831fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# dwm - dynamic window manager
#   (C)opyright MMVI Anselm R. Garbe

include config.mk

SRC = client.c draw.c event.c main.c tag.c util.c
OBJ = ${SRC:.c=.o}

all: options dwm
	@echo finished

options:
	@echo dwm build options:
	@echo "CFLAGS   = ${CFLAGS}"
	@echo "LDFLAGS  = ${LDFLAGS}"
	@echo "CC       = ${CC}"

.c.o:
	@echo CC $<
	@${CC} -c ${CFLAGS} $<

${OBJ}: dwm.h config.h config.mk

config.h:
	@echo creating $@ from config.default.h
	@cp config.default.h $@

dwm: ${OBJ}
	@echo LD $@
	@${CC} -o $@ ${OBJ} ${LDFLAGS}
	@strip $@

clean:
	@echo cleaning
	@rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz

dist: clean
	@echo creating dist tarball
	@mkdir -p dwm-${VERSION}
	@cp -R LICENSE Makefile README config.*.h config.mk \
		dwm.1 dwm.h ${SRC} dwm-${VERSION}
	@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
	@gzip dwm-${VERSION}.tar
	@rm -rf dwm-${VERSION}

install: all
	@echo installing executable file to ${DESTDIR}${PREFIX}/bin
	@mkdir -p ${DESTDIR}${PREFIX}/bin
	@cp -f dwm ${DESTDIR}${PREFIX}/bin
	@chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
	@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
	@mkdir -p ${DESTDIR}${MANPREFIX}/man1
	@sed 's/VERSION/${VERSION}/g' < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
	@chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1

uninstall:
	@echo removing executable file from ${DESTDIR}${PREFIX}/bin
	@rm -f ${DESTDIR}${PREFIX}/bin/dwm
	@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
	@rm -f ${DESTDIR}${MANPREFIX}/man1/dwm.1

.PHONY: all options clean dist install uninstall
an class="o">+ rightsize # remove elemets from the right until it fits if sumsize > wid: while len(self.right) > 0: rightsize -= len(self.right.pop(0).string) if leftsize + rightsize <= wid: break sumsize = leftsize + rightsize if sumsize < wid: self.fill_gap(' ', (wid - sumsize), gapwidth=True) def shrink_from_the_left(self, wid): fixedsize = self.fixedsize() if wid < fixedsize: raise ValueError("Cannot shrink down to that size by cutting") leftsize = self.left.sumsize() rightsize = self.right.sumsize() oversize = leftsize + rightsize - wid - 1 if oversize <= 0: return self.fill_gap(' ', wid, gapwidth=False) nonfixed_items = self.left.nonfixed_items() # Shrink items to a minimum size of 1 until there is enough room. for item in self.left: if not item.fixed: itemlen = len(item) if oversize > itemlen - 1: item.cut_off_to(1) oversize -= (itemlen - 1) else: item.cut_off(oversize) break def fill_gap(self, char, wid, gapwidth=False): del self.gap[:] if not gapwidth: wid = wid - self.sumsize() if wid > 0: self.gap.add(char * wid, 'space') def combine(self): return self.left + self.gap + self.right class BarSide(list): def __init__(self, base_color_tag): self.base_color_tag = base_color_tag def add(self, string, *lst, **kw): cs = ColoredString(string, self.base_color_tag, *lst) cs.__dict__.update(kw) self.append(cs) def add_space(self, n=1): self.add(' ' * n, 'space') def sumsize(self): return sum(len(item) for item in self) def fixedsize(self): n = 0 for item in self: if item.fixed: n += len(item) else: n += 1 return n def nonfixed_items(self): return sum(1 for item in self if not item.fixed) class ColoredString(object): def __init__(self, string, *lst): self.string = string self.lst = lst self.fixed = False def cut_off(self, n): if n >= 1: self.string = self.string[:-n] def cut_off_to(self, n): self.string = self.string[:n] def __len__(self): return uwid(self.string) def __str__(self): return self.string