-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
121 lines (97 loc) · 2.7 KB
/
Makefile
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# berry - a healthy, bite-sized window manager
# See LICENSE file for copyright and license details.
-include Config.mk
################ Source files ##########################################
berry := $O${name}
berryc := ${berry}c
srcs := $(wildcard *.c)
objs := $(addprefix $O,$(srcs:.c=.o))
deps := ${objs:.o=.d}
confs := Config.mk config.h
oname := $(notdir $(abspath $O))
################ Compilation ###########################################
.SUFFIXES:
.PHONY: all clean distclean maintainer-clean
all: ${berry} ${berryc}
${berry}: $Outils.o $Owm.o
@echo "Linking $@ ..."
@${CC} ${ldflags} -o $@ $^ ${libs}
${berryc}: $Oclient.o
@echo "Linking $@ ..."
@${CC} ${ldflags} -o $@ $^ ${libs}
$O%.o: %.c
@echo " Compiling $< ..."
@${CC} ${cflags} -MMD -MT "$(<:.c=.s) $@" -o $@ -c $<
%.s: %.c
@echo " Compiling $< to assembly ..."
@${CC} ${cflags} -S -o $@ -c $<
################ Installation ##########################################
.PHONY: install installdirs
.PHONY: uninstall uninstall-man
ifdef bindir
exed := ${DESTDIR}${bindir}
berryi := ${exed}/$(notdir ${berry})
berryci := ${exed}/$(notdir ${berryc})
${exed}:
@echo "Creating $@ ..."
@${INSTALL} -d $@
${berryi}: ${berry} | ${exed}
@echo "Installing $@ ..."
@${INSTALL_PROGRAM} $< $@
${berryci}: ${berryc} | ${exed}
@echo "Installing $@ ..."
@${INSTALL_PROGRAM} $< $@
installdirs: ${exed}
install: ${berryi} ${berryci}
uninstall:
@if [ -f ${exei} ]; then\
echo "Removing ${berryi} and ${berryci} ...";\
rm -f ${berryi} ${berryci};\
fi
endif
ifdef man1dir
mand := ${DESTDIR}${man1dir}
mani := ${mand}/${name}.1
manci := ${mand}/${name}c.1
${mand}:
@echo "Creating $@ ..."
@${INSTALL} -d $@
${mani}: ${name}.1 | ${mand}
@echo "Installing $@ ..."
@${INSTALL_DATA} $< $@
${manci}: ${name}c.1 | ${mand}
@echo "Installing $@ ..."
@${INSTALL_DATA} $< $@
installdirs: ${mand}
install: ${mani} ${manci}
uninstall: uninstall-man
uninstall-man:
@if [ -f ${mani} ]; then\
echo "Removing ${mani} and ${manci} ...";\
rm -f ${mani} ${manci};\
fi
endif
################ Maintenance ###########################################
clean:
@if [ -d ${builddir} ]; then\
rm -f ${berry} ${berryc} ${objs} ${deps} $O.d;\
rmdir ${builddir};\
fi
distclean: clean
@rm -f ${oname} ${confs} config.status
maintainer-clean: distclean
${builddir}/.d:
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
@touch $@
$O.d: | ${builddir}/.d
@[ -h ${oname} ] || ln -sf ${builddir} ${oname}
${objs}: Makefile ${confs} | $O.d
config.h: config.h.in | Config.mk
Config.mk: Config.mk.in
${confs}: configure
@if [ -x config.status ]; then echo "Reconfiguring ...";\
./config.status;\
else echo "Running configure ...";\
./configure;\
fi
-include ${deps}