-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
205 lines (166 loc) · 6.65 KB
/
Makefile.in
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/usr/bin/make -f
############################################################
### get all the ./configure arguments into this Makefile ###
############################################################
# install architecture-independent files in PREFIX [/usr/local]
prefix:=@prefix@
# install architecture-dependent files in EPREFIX [PREFIX]
exec_prefix:=@exec_prefix@
# user executables [EPREFIX/bin]
bindir:=@bindir@
# system admin executables [EPREFIX/sbin]
sbindir:=@sbindir@
# program executables [EPREFIX/libexec]
libexecdir:=@libexecdir@
# read-only single-machine data [PREFIX/etc]
sysconfdir:=@sysconfdir@
# modifiable architecture-independent data [PREFIX/com]
sharedstatedir:=@sharedstatedir@
# modifiable single-machine data [PREFIX/var]
localstatedir:=@localstatedir@
# modifiable per-process data [LOCALSTATEDIR/run]
runstatedir:=@runstatedir@
# object code libraries [EPREFIX/lib]
libdir:=@libdir@
# C header files [PREFIX/include]
includedir:=@includedir@
# C header files for non-gcc [/usr/include]
oldincludedir:=@oldincludedir@
# read-only arch.-independent data root [PREFIX/share]
datarootdir:=@datarootdir@
# read-only architecture-independent data [DATAROOTDIR]
datadir:=@datadir@
# info documentation [DATAROOTDIR/info]
infodir:=@infodir@
# locale-dependent data [DATAROOTDIR/locale]
localedir:=@localedir@
# man documentation [DATAROOTDIR/man]
mandir:=@mandir@
# documentation root [DATAROOTDIR/doc/simbuto]
docdir:=@docdir@
# html documentation [DOCDIR]
htmldir:=@htmldir@
# dvi documentation [DOCDIR]
dvidir:=@dvidir@
# pdf documentation [DOCDIR]
pdfdir:=@pdfdir@
# ps documentation [DOCDIR]
psdir:=@psdir@
PACKAGE_VERSION := @PACKAGE_VERSION@
PACKAGE_NAME := @PACKAGE_NAME@
PACKAGE_STRING := @PACKAGE_STRING@
configure_dirs = bindir sbindir libexecdir sysconfdir sharedstatedir \
localstatedir runstatedir libdir includedir oldincludedir datarootdir \
datadir infodir localedir mandir docdir htmldir dvidir pdfdir psdir
configure_vars = $(configure_dirs) PACKAGE_VERSION PACKAGE_STRING PACKAGE_NAME \
PACKAGE_URL
$(foreach configure_dir,$(configure_dirs),\
$(eval $(configure_dir) := $(abspath $(DESTDIR)/$($(configure_dir)))))
# $(foreach configure_dir,$(configure_dirs),\
# $(info $(configure_dir) := $($(configure_dir))))
#############################
### The local directories ###
#############################
local_sysconfdir = etc
local_mandir = man
local_bindir = bin
local_localedir = locale
local_datarootdir = share
local_libdir = lib
local_dirs = $(local_sysconfdir) $(local_mandir) $(local_bindir) \
$(local_localedir) $(local_datarootdir) $(local_libdir)
installed_files_file = installed_files.tmp
# all pofiles
POFILES = $(shell find $(local_localedir) -type f -iname '*.po')
# the corresponding mofiles
MOFILES = $(POFILES:.po=.mo)
# temporary pot-file template
POTFILE = $(local_localedir)/simbuto.pot
# all markdown manpages
MDMANPAGES = $(shell find $(local_mandir) -type f -iname '*.1.md')
# corresponding groff manpages
GFMANPAGES = $(MDMANPAGES:.1.md=.1)
# source files that contain translatable text - the _(...) function
# that is, all python files
PYTHONFILES = $(shell find $(local_bindir) $(local_libdir) -type f -exec file {} \; | perl -ne 'print if s/^([^:]+):.*python.*$$/$$1/ig')
# pandoc options for manpage creation
PANDOCOPTS = -f markdown -t man --standalone
IN_FILES = $(shell find $(local_dirs) -type f -iname '*.in')
IN_FILES_INSTANTIATED = $(IN_FILES:.in=)
SIMBUTOVERSION := @PACKAGE_VERSION@
SIMBUTODATE := $(shell date +%F)
CONFIGURE_AC = configure.ac
# get information from changelog
DEBIAN_CHANGELOG = debian/changelog
DEBIAN_CHANGELOG_VERSION = $(shell perl -ne 'if(s/^simbuto\s*\((.*?)\).*$$/$$1/g){print;exit}' $(DEBIAN_CHANGELOG))
# default target
.PHONY: all
all: $(MOFILES) $(GFMANPAGES) $(SIMBUTOPYTHONINIT) $(IN_FILES_INSTANTIATED) $(CONFIGURE_AC)
# create rule to install a FILE into the TARGET_DIRECTORY
# FILE can be a relative path from here
# $(call install_rule,FILE,TARGET_DIRECTORY)
define install_rule
$$(eval _target = $$(abspath $$(addprefix $(2)/,$$(shell echo $(1) | perl -pe 's|^[^/]*/+||g'))))
$$(_target): $(1) | $$(dir $$(_target))
cp -L --preserve=all $$< $$@
@echo $$@ >> $(installed_files_file)
$$(eval install_target_dirs = $$(install_target_dirs) $$(dir $$(_target)))
$$(eval install_targets = $$(install_targets) $$(_target))
endef
find_opts = -not -type d -not -iname '*.in'
# define the local content that is to install
local_datarootdir_toinstall = $(shell find $(local_datarootdir) $(find_opts))
local_mandir_toinstall = $(GFMANPAGES)
local_localedir_toinstall = $(MOFILES)
local_sysconfdir_toinstall = $(shell find $(local_sysconfdir) $(find_opts))
local_bindir_toinstall = $(shell find $(local_bindir) $(find_opts))
local_libdir_toinstall = $(shell find $(local_libdir) $(find_opts))
# set up install rules for all configure directories
$(foreach configure_dir,$(configure_dirs),\
$(foreach file,$(local_$(configure_dir)_toinstall),\
$(eval $(call install_rule,$(file),$($(configure_dir))))))
# build the manpages
# manpages:
%.1: %.1.md $(DEBIAN_CHANGELOG)
pandoc $(PANDOCOPTS) -Vfooter='Version $(SIMBUTOVERSION)' -Vdate='$(SIMBUTODATE)' -o $@ $<
# create the pot-file with all translatable strings from the srcfiles
$(POTFILE): $(PYTHONFILES)
xgettext -L Python -o $(POTFILE) $(PYTHONFILES)
# update the translated catalog
%.po: $(POTFILE)
VERSION_CONTROL=off msgmerge -U --backup=off $@ $<
touch $@ # make sure timestamp was updated
# compile the translations
%.mo: %.po
msgfmt -o $@ $<
$(sort $(install_target_dirs)): % :
mkdir -p $@
@echo $@ >> $(installed_files_file)
$(CONFIGURE_AC): $(DEBIAN_CHANGELOG)
perl -pi -e 's#^(\s*AC_INIT\([^,]*,\s*\[)([.0-9_a-zA-Z-]+)(\]\s*,.*\))#$${1}$(DEBIAN_CHANGELOG_VERSION)$${3}#g' $@
# substitute variables in a file
$(IN_FILES_INSTANTIATED): % : %.in Makefile
perl -pe '$(foreach var,$(configure_vars),s#[@]$(var)[@]#$($(var))#g;)' < $< > $@
.PHONY: bin_executable
bin_executable: $(local_bindir_toinstall)
chmod +x $^
.PHONY: install
install: bin_executable $(sort $(install_targets))
-@sort -u $(installed_files_file) -o $(installed_files_file)
# remove a file/folder without asking
# $(call remove,PATH)
# This is only to display a newline after the command
define remove
rm -rf $(1)
endef
.PHONY: uninstall
uninstall:
$(foreach file,$(sort $(install_targets) $(shell cat $(installed_files_file))),$(call remove,$(file)))
rm -f $(installed_files_file)
@echo WARNING: There might still be some empty folders left. This should not be a problem.
.PHONY: clean
clean:
rm -f $(MOFILES) $(POTFILE) $(GFMANPAGES)
rm -rf $(addprefix $(DEBIAN)/,files *.substvars *.debhelper simbuto debhelper-build-stamp *.debhelper.log)
rm -f $(IN_FILES_INSTANTIATED)
rm -f $(installed_files_file)