Debian Codegraph @

Makefile

raw ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 # This makefile contains all recipes to build and manage the FreeDict
2 # tools, including the API. It also provides targets to build a release archive
3 # with the latest tools included.
4
5 FREEDICT_TOOLS ?= .
6 include $(FREEDICT_TOOLS)/mk/config.mk
7
8 VERSION = 0.4
9 PREFIX ?= usr
10 DESTDIR ?=
11 INSTALLDIR ?= $(abspath $(DESTDIR)/$(PREFIX)/share/freedict)
12
13 dirs = JMdict lib mk xquery xsl/inc
14 TARGET_INSTALL_DIRS = $(addprefix $(INSTALLDIR)/tools/, $(dirs))
15
16
17 mount: #! mount or synchronize FreeDict releases / generated dictionaries
18 $(call exc_pyscript,fd_file_mgr,-m)
19
20 umount: #! runs umount / clean up actions for unmounting remote volumes (if SSH is used)
21 @$(call exc_pyscript,fd_file_mgr,-u)
22
23 $(BUILD_DIR)/freedict-tools-$(VERSION).tar.bz2: Makefile* *.pl
24 ifeq ($(wildcard $(BUILD_DIR)),)
25 mkdir -p $(BUILD_DIR)
26 endif
27 tar --totals --exclude="*/.svn/*" --exclude="*/.*" \
28 --exclude="*/charlint*" --exclude="*/UnicodeData.txt" \
29 --exclude="*/ergane/jet4/*" \
30 --exclude="*/ergane/unzip/*" \
31 --exclude="*/ergane/zip/*" \
32 --exclude="*/__pycache__/*" \
33 -cvjf $@ ../tools
34
35 install-deps: #! probe current operating system to install build prerequisites for dictionary development
36 echo -n "Do you want to use unison or sshfs? Enter one of them or nothing: "; \
37 read ACCESS_METHOD; \
38 if command -v apt-get; then \
39 sudo apt-get install unzip tar xsltproc libxml-libxml-perl python3 $$ACCESS_METHOD; \
40 elif command -v pacman; then \
41 if [ `uname -o` = 'GNU/Linux' ]; then \
42 sudo pacman -S unzip tar libxslt libxml-perl python $$ACCESS_METHOD; \
43 else \
44 echo "Sorry, but it seems you're not running pacman on GNU/Linux. There's currently no installation rule for this platform."; \
45 fi; \
46 else \
47 echo "Unknown platform. Feel free to report the corresponding packages to us."; \
48 fi
49
50
51 # This helps to express \n as a special variable to Make; it **needs** two
52 # newlines within the define
53 define newline
54
55
56 endef
57
58 # This may not contain apostrophes
59 define VENV_HELP
60 A virtual environment is a local copy of all Python utilities, scripts and
61 libraries for Python development. With a virtual environment, you do not need to
62 install all the FreeDict scripts globally in your system, but you are of course
63 free to do so. The mk_venv command will make sure that the virtual environment
64 is created at the correct place; use "P=/some/path" to specify the path.
65 Example:
66 make mk_venv P=../fd-venv
67 NOTE: If you have not pkg-config on your system, you need to manually set the
68 environment variable ICU_VERSION to the version of libicu on your system.
69 This is due to some internal restructuring of the libicu library that we
70 depend on.
71 After installation, you will be asked whether the virtual environment should be
72 added to the FreeDict configuration. This is generally a good idea, because this
73 means that the FreeDict build system will take care of all the required steps.
74 endef
75
76 mk_venv-help:
77 echo -e '$(subst $(newline),\n,${VENV_HELP})'
78
79 mk_venv: #! initialise a new (Python) virtual environment; use mk_venv-help for detailled help
80 @if [ "${P}" = '' ]; then \
81 echo Need to give a path with P=, e.g. "make mk_venv P=/some/dir"; \
82 exit 222; fi
83 @if ! command -v virtualenv &> /dev/null; then \
84 echo '`virtualenv` not found, please install it and try again.'; exit 10; \
85 fi
86 @virtualenv -q -p $(PYTHON) ${P}
87 @if [ -z "$(ICU_VERSION)" ]; then \
88 if ! command -v pkg-config; then \
89 echo "Environment variable ICU_VERSION unset and 'pkg-config' not found."; \
90 echo "Please set ICU_VERSION to the version of libicu installed on your system."; \
91 exit 127; \
92 fi; \
93 export ICU_VERSION=`pkg-config --modversion icu-i18n`; \
94 fi; \
95 source ${P}/bin/activate; pip install -r requirements.txt
96 @if [ "$(FREEDICTRC)" = "" ]; then \
97 echo "You don't have a FreeDict configuration yet. Please create one, "; \
98 echo 'as described in the chapter "Build System" of the FreeDict HOWTO';\
99 echo "from the Wiki";fi
100 if ! [ -f $(FREEDICTRC) ]; then \
101 NO_CONF=1; \
102 elif ! grep virtual_env < $(FREEDICTRC) &> /dev/null; then \
103 NO_CONF=1; \
104 else NO_CONF=0; \
105 fi; \
106 if [ $$NO_CONF -eq 1 ]; then \
107 echo -n "Do you want to add the virtual_env to the FreeDict configuration? [y|n] "; \
108 read CHOICE;\
109 if [ "$$CHOICE" = "y" ]; then \
110 mkdir -p $(dir $(FREEDICTRC));\
111 touch $(FREEDICTRC);\
112 PATH=$(abspath ${P}); \
113 if ! grep -r '[DEFAULT]' $(FREEDICTRC) &> /dev/null; then \
114 echo >> $(FREEDICTRC);\
115 echo '[DEFAULT]' >> $(FREEDICTRC); \
116 echo "virtual_env = $$PATH" >> $(FREEDICTRC) ;\
117 else \
118 sed -i 's|\[DEFAULT\]|[DEFAULT]\nvirtual_env = '$$PATH'|' $(FREEDICTRC); \
119 fi; \
120 echo done; \
121 fi; \
122 fi
123
124 # NOTE: the directories below HAVE to be on one line
125 INSTALL_DIRS := mk xquery xsl/inc
126 INSTALL_PATHS := $(wildcard freedict-database.rng \
127 mk/*.mk xsl/inc/* \
128 xquery/* xsl/tei2c5.xsl)
129 install: #! install the tools to $$DESTDIR/$PREFIX/share/freedict (default /usr/local/share/freedict)
130 install:
131 @echo Creating directories in $(INSTALLDIR)…
132 @set -e; for d in $(INSTALL_DIRS); do \
133 install -d $(INSTALLDIR)/$$d; \
134 done
135 @echo Copying files to $(INSTALLDIR)…
136 @set -e; for f in $(INSTALL_PATHS); do \
137 if [ -f $$f ]; then \
138 install -m 644 $$f $(INSTALLDIR)/$$f; \
139 fi \
140 done
141
142
143
144
145 release: #! build a release tarball in $$BUILD_DIR, ../build by default
146 release: $(BUILD_DIR)/freedict-tools-$(VERSION).tar.bz2
147
148 release-path: #! print the output directory to which releases are deployed (read from configuration); trailing newline is removed
149 @$(call exc_pyscript,fd_file_mgr,-r) | tr -d '\n'
150
151 .PHONY: release install all mount umount