forked from maRc2/snownews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (73 loc) · 1.95 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
-include Config.mk
################ Source files ##########################################
exe := $O${name}
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 run
all: ${exe}
run: ${exe}
@${exe}
${exe}: ${objs}
@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 $<
include man/Module.mk
include po/Module.mk
################ Installation ##########################################
ifdef bindir
.PHONY: install installdirs uninstall uninstall-bin
exed := ${DESTDIR}${bindir}
exei := ${exed}/$(notdir ${exe})
${exed}:
@echo "Creating $@ ..."
@${INSTALL} -d $@
${exei}: ${exe} | ${exed}
@echo "Installing $@ ..."
@${INSTALL_PROGRAM} $< $@
installdirs: ${exed}
install: ${exei}
uninstall: uninstall-bin
uninstall-bin:
@if [ -f ${exei} ]; then\
echo "Removing ${exei} ...";\
rm -f ${exei};\
fi
endif
################ Maintenance ###########################################
.PHONY: clean distclean maintainer-clean
clean:
@if [ -d ${builddir} ]; then\
rm -f ${exe} ${objs} ${deps} $O.d;\
rmdir ${builddir};\
fi
distclean: clean
@rm -f ${oname} ${confs} config.status
maintainer-clean: distclean
$O.d: ${builddir}/.d
@[ -h ${oname} ] || ln -sf ${builddir} ${oname}
$O%/.d: $O.d
@[ -d $(dir $@) ] || mkdir $(dir $@)
@touch $@
${builddir}/.d: Makefile
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
@touch $@
Config.mk: Config.mk.in
config.h: config.h.in | Config.mk
${objs}: Makefile ${confs} | $O.d
${confs}: configure
@if [ -x config.status ]; then echo "Reconfiguring ...";\
./config.status;\
else echo "Running configure ...";\
./configure;\
fi
-include ${deps}