-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
178 lines (145 loc) · 4.63 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# vtclock - a text-mode giant digital clock
# Copyright (C) 2024 Darren Embry.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307$
SRCS = vtclock.c msg.c figlet.c
# HDRS = font0.h font1.h font2.h font3.h msg.h vtclock.h figlet.h
program = vtclock
OBJS = $(SRCS:.c=.o)
PKGCONFIG_PKGS = ncurses
manpage =
VERSION = $(shell sed -n '/^\#define[ ][ ]*VTCLOCK_VERSION[ ][ ]*"/{s/^[^"]*"//;s/".*$$//;p;}' vtclock.h)
DEBPKGS = pkg-config libncurses5-dev gcc
TAR = $(shell if which gtar >/dev/null 2>/dev/null ; then echo gtar ; else echo tar ; fi)
###############################################################################
SHELL = /bin/sh
.SUFFIXES:
.SUFFIXES: .c .o .d
ifdef manpage
.SUFFIXES: .1 .1.txt .1.ps .1.html .ps .pdf
endif
EXTRA_CFLAGS =
EXTRA_LIBS =
PKGCONFIG_CFLAGS = `pkg-config --cflags $(PKGCONFIG_PKGS)`
PKGCONFIG_LIBS = `pkg-config --libs $(PKGCONFIG_PKGS)`
ifeq (0,$(shell pkg-config --cflags ncurses >/dev/null 2>/dev/null))
else
PKGCONFIG_CFLAGS =
PKGCONFIG_LIBS =
EXTRA_CFLAGS =
EXTRA_LIBS = -lncurses
endif
# Common prefix for installation directories.
# NOTE: This directory must exist when you start the install.
prefix = /usr/local
datarootdir = $(prefix)/share
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
mandir = $(datarootdir)/man
DESTDIR =
INSTALL = /usr/bin/install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 0644
INSTALL_MKDIR = $(INSTALL) -d
.PHONY: all
all: $(program)
$(program): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(PKGCONFIG_LIBS) $(EXTRA_LIBS) $(CFLAGS)
%.o: %.c
$(CC) -c $(CPPFLAGS) $(PKGCONFIG_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS) $<
%.d: %.c
@ >&2 echo Fixing dependencies for $< . . .
$(CC) -MM $(CPPFLAGS) $(PKGCONFIG_CFLAGS) $(CFLAGS) $< | \
sed 's/^$*\.o/& $@/g' > $@ || true
-include $(SRCS:.c=.d)
.PHONY: install
install: $(program)
$(INSTALL_MKDIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $(program) $(DESTDIR)$(bindir)
ifdef manpage
$(INSTALL_MKDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) $(manpage) $(DESTDIR)$(mandir)/man1
endif
.PHONY: uninstall
uninstall:
rm $(DESTDIR)$(bindir)/$(program)
ifdef manpage
rm $(DESTDIR)$(mandir)/man1/$(manpage)
endif
DIST = $(program)-$(VERSION).tar.gz
.PHONY: dist
dist:
$(TAR) cvvzf $(DIST) \
--transform='s:^:$(program)-$(VERSION)/:' \
--show-transformed-names \
--exclude=perl-version \
--exclude=MyMakefile \
--exclude=CVS \
--exclude=.svn \
--exclude=.git \
--exclude=test \
--exclude='*.rej' \
--exclude='#*#' \
--exclude='.#*' \
--exclude='.cvsignore' \
--exclude='.svnignore' \
--exclude='.gitignore' \
--exclude='*~' \
--exclude='.*~' \
--exclude='.deps' \
--exclude='*.1.*' \
--exclude=$(program) \
--exclude=TAGS \
--exclude='*.o' \
--exclude='*.d' \
--exclude='*.tar.gz' \
--exclude='*.tmp.*' \
--exclude='*.tmp' \
--exclude='*.log' \
*
.PHONY: clean
clean:
2>/dev/null rm $(program) *.d *.o '#'*'#' .'#'* *~ .*~ *.bak core || true
.PHONY: version
version:
@echo $(VERSION)
###############################################################################
# Dependencies
%.d: %.c
@ >&2 echo Fixing dependencies for $< . . .
@ $(CC) -MM $(CPPFLAGS) $< | sed 's/^$*\.o/& $@/g' > $@ || true
-include $(SRCS:.c=.d)
###############################################################################
# Documentation
%.1.txt: %.1 Makefile
nroff -man $< | col -bx > [email protected]
mv [email protected] $@
%.1.ps: %.1 Makefile
groff -Tps -man $< >[email protected]
mv [email protected] $@
%.1.html: %.1 Makefile
groff -Thtml -man $< >[email protected]
mv [email protected] $@
%.pdf: %.ps Makefile
ps2pdf $< [email protected]
mv [email protected] $@
###############################################################################
# Debian
.PHONY: install-debian-prerequisites
install-debian-prerequisites:
sudo apt-get install $(DEBPKGS)
###############################################################################
# My makefile customizations about which you need not be concerned :-)
-include MyMakefile