File: Makefile

package info (click to toggle)
topal 81-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 1,216 kB
  • sloc: ada: 11,204; ansic: 783; sh: 174; makefile: 153
file content (170 lines) | stat: -rw-r--r-- 4,927 bytes parent folder | download
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
# Topal: GPG/GnuPG and Alpine/Pine integration
# Copyright (C) 2001--2022  Phillip J. Brooke
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
# 
# 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, see <http://www.gnu.org/licenses/>.

RELEASECODE := $(shell grep '^<dt>' Changelog.html | tail -1 | sed 's/.* release //; sx</a>.*$$xx')
ifdef SOURCE_DATE_EPOCH
  BUILDDATE := $(shell date '+%Y-%m-%dT%H%M%S%Z' -d @$(SOURCE_DATE_EPOCH))
else
  # Force a rebuild each time this Makefile is run.
  .PHONY: version_id.adb versionid.tex
  BUILDDATE := $(shell date '+%Y-%m-%dT%H%M%S%Z')
endif

# If you intend to redistribute this package, you will obviously need
# to substitute your own key id here.
MYKEY := 0x47DC67A1

include Buildflags.mk

generated_ada_sources := version_id.adb help.ads help.adb
GENFILES := $(generated_ada_sources) b~topal.ads b~topal.adb
CFILES := $(wildcard *.c)
c_objects := $(CFILES:c=o)
ADAFILES := $(filter-out $(GENFILES),$(wildcard *.ad[bs]))
patches := $(wildcard pine-*.patch alpine-*.patch alpine-*.patch-*)
archive     := topal-package-$(RELEASECODE).tgz
archive_asc := topal-package-$(RELEASECODE).tgz.asc
archive_dir := topal-$(RELEASECODE)
archive_components_644 := \
  $(patches) \
  $(CFILES) \
  $(ADAFILES) \
  Buildflags.mk \
  COPYING \
  Changelog.html \
  Features.html \
  MIME-tool/GPL.txt \
  MIME-tool/Makefile \
  MIME-tool/README.Topal.txt \
  MIME-tool/README.txt \
  MIME-tool/mime-tool.man \
  MIME-tool/mime.c \
  Makefile \
  cygwin.patch \
  help.txt \
  topal.man \
  topal.pdf \
  topal.tex
archive_components_755 := \
  screens \
  mkdistrib \
  mkhelp \
  mkversionid \
  mkversionidtex

DESTDIR ?=
prefix ?= /usr
INSTALLPATH ?= $(DESTDIR)$(prefix)
INSTALLPATHBIN ?= $(INSTALLPATH)/bin
INSTALLPATHMAN ?= $(INSTALLPATH)/share/man
INSTALLPATHDOC ?= $(INSTALLPATH)/share/doc/topal
INSTALLPATHPATCHES ?= $(INSTALLPATH)/share/topal/patches

# Set this to "true" to keep debugging symbols.
strip ?= strip


.PHONY: all binary all2

# The default action.
all:	binary topal.pdf

binary: topal mime-tool

all2:	package distrib

$(c_objects): %.o: %.c
	$(CC) -c $(default_CFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@

mime-tool:	
	$(MAKE) -C MIME-tool

# Always run gnatmake, it knows better than Make in which order Ada
# units must be recompiled.
.PHONY: topal
topal: $(c_objects) $(generated_ada_sources)
	gnatmake -j4 $(gnatmake_options) topal.adb \
	  -cargs $(default_ADAFLAGS) $(ADAFLAGS) \
	  -largs $(default_LDFLAGS) $(LDFLAGS) \

version_id.adb:	mkversionid
	./mkversionid $(RELEASECODE) $(BUILDDATE)

versionid.tex:	mkversionidtex
	./mkversionidtex $(RELEASECODE) $(BUILDDATE)

# We want this to be run only once.
# Using the hint at https://www.cmcrossroads.com/article/rules-multiple-outputs-gnu-make
%.ads %.adb: %.txt mkhelp
	./mkhelp

.PHONY: doc
doc:	topal.pdf

topal.pdf:	topal.tex versionid.tex
	pdflatex $<
	pdflatex $<

.PHONY: install
install:	all
	install -d $(INSTALLPATHBIN) $(INSTALLPATHDOC) $(INSTALLPATHMAN)/man1 $(INSTALLPATHPATCHES)
	install -m 755 -s --strip-program=$(strip) topal $(INSTALLPATHBIN)
	install -m 644 Features.html Changelog.html topal.pdf COPYING $(INSTALLPATHDOC)
	install -m 644 topal.man $(INSTALLPATHMAN)/man1/topal.1
	install -m 644 $(patches) $(INSTALLPATHPATCHES)
	install -m 755 -s --strip-program=$(strip) MIME-tool/mime-tool $(INSTALLPATHBIN)
	install -m 644 MIME-tool/mime-tool.man $(INSTALLPATHMAN)/man1/mime-tool.1

.PHONY: clean
clean:
	$(RM) *.o *.ali $(GENFILES) versionid.tex
	# Clean LaTeX stuff.
	$(RM) $(addprefix topal.,toc out log aux)
	# Clean packaging directories.
	-$(RM) -r topal-[0-9]*
	$(MAKE) -C MIME-tool $@

.PHONY: distclean realclean
distclean realclean:	clean
	-$(RM) topal README.txt *~ $(archive) $(archive_asc) topal.pdf
	-$(RM) -r www www.bak
	$(MAKE) -C MIME-tool $@


.PHONY:	package tarball fixperms

package:	$(archive) $(archive_asc)

tarball:	$(archive)

# fixperms: for manual fix before a rebuild
fixperms:	
	-chmod 644 $(archive_components_644)
	-chmod 755 $(archive_components_755)

$(archive):	$(archive_components_644) $(archive_components_755)
	chmod 644 $(archive_components_644)
	chmod 755 $(archive_components_755)
	tar cvaf $@ --transform='s|^|$(archive_dir)/|' $^

$(archive_asc):	$(archive)
	-gpg --detach-sign --armor --local-user=$(MYKEY) -o $@ $<

.PHONY: distrib
distrib:	 $(archive) $(archive_asc) mkdistrib
	-$(RM) -r www
	mkdir www
	cp $(archive) $(archive_asc) topal.pdf Changelog.html COPYING www
	cd www && ../mkdistrib $(RELEASECODE)