007.txt - gopherhole - My gopherhole source code.
(HTM) git clone git://jay.scot/gopherhole
(DIR) Log
(DIR) Files
(DIR) Refs
---
007.txt (2895B)
---
1 [jay.scot]
2 [007]
3
4
5 --[ Build, patch and maintain suckless tools
6
7
8 I am a long time supporter of the Unix philosophy and have been using
9 tools such as dwm as my daily driver since 2011, as such I mainly use
10 the terminal for everything. Lots of these tools are best built via the
11 latest source code release or development copy instead of a package
12 build, so you can apply your custom configuration. The most common
13 methods I have come across on managing to do this is a mixture of using
14 separate git branches for each patch or even just manually applying the
15 patches and then fixing anything that didn't succeed.
16
17 I am a big fan of Makefiles, I even use Makefiles to manage my dotfiles
18 instead of a tool like GNU Stow. So it will be no surprise I use these
19 to build, patch and install all my suckless based tools such as dwm, st,
20 dmenu and herbe. My Makefile makes patching easy and means I don't need
21 to worry about maintaining multiple branches, it's super easy to get the
22 latest versions etc. It also helps that I don't have any extra patches
23 apart from dmenu and st, any additions I have for dwm and herbe are
24 added to config.h as functions.
25
26 Below is the generic Makefile I use, this one is for dmenu as it's
27 a good example to use since I use a few minimal external patches. The
28 options at the top of the Makefile should be pretty obvious, the
29 defaults should be fine for most people.
30
31
32 REPOSITORY = http://git.suckless.org/dmenu
33 SRC_DIR = dmenu-src
34 PINNED_REVISION = HEAD
35 PATCH_DIR = patches
36
37 all: $(SRC_DIR)
38
39 clean: reset
40 @if test -d $(SRC_DIR); then \
41 $(MAKE) -C "${SRC_DIR}" -s clean; \
42 git -C "${SRC_DIR}" clean -f; \
43 fi
44
45 $(SRC_DIR): clone reset patch
46 @cp config.h $@
47 $(MAKE) -C "${SRC_DIR}" -s
48
49 patch: $(PATCH_DIR)/*
50 @for file in $^ ; do \
51 patch -d "${SRC_DIR}" < $${file}; \
52 done
53 reset:
54 @if [ -n "$(strip $(PINNED_REVISION))" ]; then \
55 git -C "${SRC_DIR}" reset --hard $(PINNED_REVISION); \
56 fi
57
58 clone:
59 @if ! test -d $(SRC_DIR); then \
60 git clone $(REPOSITORY) $(SRC_DIR); \
61 fi
62
63 update: clean
64 @git -C "${SRC_DIR}" pull
65
66 install:
67 $(MAKE) -C "${SRC_DIR}" -s install
68
69
70 .PHONY: all clean update install reset clone patch
71
72
73 And this is the file structure I have:
74
75 |- dwm
76 |-- dwm-src # git clone of dwm, handled by Makefile
77 |-- config.h # my custom config for dmenu
78 |-- Makefile # the Makefile from above
79 |-- patches # directory containing patches
80 |---- 01-dmenu-centre.patch
81 |---- 02-dmenu-border.patch
82
83 If you have no patches to apply, then remove the 'patch' from line 14
84 then run 'make', this will git clone or reset if already cloned, apply
85 patches, copy your custom config.h and the build, A 'make install' after
86 that will install as normal.
87
88 To see a working copy of these you can clone my dotfiles and have
89 a look in the dwm, dmenu, st or herbe folders.
90
91 git clone git://jay.scot/dotfiles
92
93 .EOF