1 # FusionForge build system
3 # Copyright (C) 2014, 2015 Inria (Sylvain Beucler)
4 # Copyright 2017-2018, Franck Villaume - TrivialDev
6 # This file is part of FusionForge. FusionForge is free software;
7 # you can redistribute it and/or modify it under the terms of the
8 # GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the Licence, or (at your option)
12 # FusionForge is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 include GNUmakefile.defaults
22 VERSION:=$(shell cat VERSION)
25 ## Step 1: build files
29 ## Step 2: install files
30 install: all install-base install-plugins
32 # Directories required for stand-alone plugin install
34 $(INSTALL) -d -m 00755 $(DESTDIR)$(pkgdatadir)/
35 $(INSTALL) -d -m 00755 $(DESTDIR)$(pkgdatadir)/cronjobs/
36 $(INSTALL) -d -m 00755 $(DESTDIR)$(pkgdatadir)/plugins/
37 $(INSTALL) -d -m 00755 $(DESTDIR)$(pkgdatadir)/post-install.d/
38 $(INSTALL) -d -m 00755 $(DESTDIR)$(config_path)/config.ini.d/
39 $(INSTALL) -d -m 00755 $(DESTDIR)$(config_path)/httpd.conf.d/
40 $(INSTALL) -d -m 00755 $(DESTDIR)$(config_path)/plugins/
41 $(INSTALL) -d -m 00755 $(DESTDIR)$(sysconfdir)/cron.d/
42 $(INSTALL) -d -m 00755 $(DESTDIR)$(sysconfdir)/logrotate.d/
43 $(INSTALL) -d -m 00755 $(DESTDIR)$(data_path)/
45 install-config: install-base-dirs
46 # Install initial configuration (without overwriting)
47 # Required for post-install scripts
48 $(CP_R) --no-clobber etc/config.ini.d/* $(DESTDIR)$(config_path)/config.ini.d/
49 if [ ! -e $(DESTDIR)$(config_path)/config.ini ]; then \
51 -e 's,@source_path@,$(pkgdatadir),' \
52 -e 's,@gettext_path@,$(localedir),' \
53 -e 's,@data_path@,$(data_path),' \
54 -e 's,@config_path@,$(config_path),' \
55 -e 's,@log_path@,$(log_path),' \
56 -e 's,@apache_user@,$(apache_user),' \
57 -e 's,@apache_group@,$(apache_group),' \
58 -e 's,@apache_service@,$(apache_service),' \
59 -e 's,@ssh_service@,$(ssh_service),' \
60 > $(DESTDIR)$(config_path)/config.ini; \
63 install-common: install-config install-plugin-authbuiltin install-plugin-globalactivity
64 $(MAKE) -C locale DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install
65 $(CP_R) VERSION bin common templates $(DESTDIR)$(pkgdatadir)/
66 chmod 755 $(DESTDIR)$(pkgdatadir)/bin/ssh_akc.php
67 $(INSTALL) -d -m 00755 $(DESTDIR)$(config_path)/custom/
68 $(CP_R) post-install.d/common $(DESTDIR)$(pkgdatadir)/post-install.d/
69 $(CP_R) plugins/env.inc.php $(DESTDIR)$(pkgdatadir)/plugins/
70 $(INSTALL) -d -m 00755 $(DESTDIR)$(bindir)
71 ln -nfs $(pkgdatadir)/bin/forge_get_config $(DESTDIR)$(bindir)
72 ln -nfs $(pkgdatadir)/bin/forge_run_job $(DESTDIR)$(bindir)
73 ln -nfs $(pkgdatadir)/bin/forge_run_plugin_job $(DESTDIR)$(bindir)
74 ln -nfs $(pkgdatadir)/bin/forge_make_admin $(DESTDIR)$(bindir)
75 ln -nfs $(pkgdatadir)/bin/forge_set_password $(DESTDIR)$(bindir)
76 ln -nfs $(pkgdatadir)/bin/forge $(DESTDIR)$(bindir)
77 $(INSTALL) -d -m 00755 $(DESTDIR)$(sysconfdir)/init.d/
78 sed 's,@bindir@,$(bindir),' etc/init.d/fusionforge-systasksd \
79 > $(DESTDIR)$(sysconfdir)/init.d/fusionforge-systasksd
80 chmod 755 $(DESTDIR)$(sysconfdir)/init.d/fusionforge-systasksd
81 $(INSTALL) -d -m 00755 $(DESTDIR)$(log_path)/
82 if [ ! -e $(DESTDIR)$(sysconfdir)/logrotate.d/fusionforge-common ]; then \
83 sed 's,@log_path@,$(log_path),g' etc/logrotate.d/fusionforge-common \
84 > $(DESTDIR)$(sysconfdir)/logrotate.d/fusionforge-common; \
87 install-db-local: install-db
88 install-db: install-base-dirs
89 $(CP_R) db $(DESTDIR)$(pkgdatadir)/
90 $(CP_R) cronjobs/db $(DESTDIR)$(pkgdatadir)/cronjobs/
91 $(CP_R) post-install.d/db $(DESTDIR)$(pkgdatadir)/post-install.d/
92 if [ ! -e $(DESTDIR)$(sysconfdir)/cron.d/fusionforge-db ]; then \
93 sed 's,@bindir@,$(bindir),' etc/cron.d/fusionforge-db \
94 > $(DESTDIR)$(sysconfdir)/cron.d/fusionforge-db; \
97 install-web: install-base-dirs
98 $(CP_R) vendor www $(DESTDIR)$(pkgdatadir)/
99 $(CP_R) --no-clobber etc/httpd.conf* $(DESTDIR)$(config_path)
100 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/docman/
101 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/docman/review/
102 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/download/
103 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/forum/
104 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/forum/pending/
105 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/tracker/
106 $(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/rss/
107 $(CP_R) post-install.d/web $(DESTDIR)$(pkgdatadir)/post-install.d/
108 if [ ! -e $(DESTDIR)$(sysconfdir)/logrotate.d/fusionforge-web ]; then \
109 sed 's,@log_path@,$(log_path),g' etc/logrotate.d/fusionforge-web \
110 > $(DESTDIR)$(sysconfdir)/logrotate.d/fusionforge-web; \
112 if [ ! -e $(DESTDIR)$(sysconfdir)/cron.d/fusionforge-web ]; then \
113 sed 's,@bindir@,$(bindir),' etc/cron.d/fusionforge-web \
114 > $(DESTDIR)$(sysconfdir)/cron.d/fusionforge-web; \
116 # TODO: multiple servers support?
117 # (e.g. install scm, lists, vhosts and vhosts-extra separately)
119 install-web-vhosts: install-base-dirs
120 $(CP_R) cronjobs/web-vhosts $(DESTDIR)$(pkgdatadir)/cronjobs/
121 # TODO: only install 40-vhosts-extra.conf and httpd.vhosts with this module
123 install-scm: install-base-dirs
124 $(CP_R) cronjobs/scm $(DESTDIR)$(pkgdatadir)/cronjobs/
125 $(INSTALL) -d -m 00755 $(DESTDIR)$(sysconfdir)/xinetd.d/
126 $(CP_R) etc/xinetd.d/fusionforge-scm $(DESTDIR)$(sysconfdir)/xinetd.d/
127 if [ ! -e $(DESTDIR)$(sysconfdir)/cron.d/fusionforge-scm ]; then \
128 sed 's,@bindir@,$(bindir),' etc/cron.d/fusionforge-scm \
129 > $(DESTDIR)$(sysconfdir)/cron.d/fusionforge-scm; \
132 install-shell: install-base-dirs
133 $(INSTALL) -d -m 00755 $(DESTDIR)$(bindir)
134 ln -nfs $(pkgdatadir)/bin/limited_ssh.sh $(DESTDIR)$(bindir)
135 $(CP_R) cronjobs/shell $(DESTDIR)$(pkgdatadir)/cronjobs/
136 $(CP_R) post-install.d/shell $(DESTDIR)$(pkgdatadir)/post-install.d/
138 install-mta-postfix: install-base-dirs
139 $(CP_R) post-install.d/mta-postfix $(DESTDIR)$(pkgdatadir)/post-install.d/
141 install-mta-exim4: install-base-dirs
142 $(CP_R) post-install.d/mta-exim4 $(DESTDIR)$(pkgdatadir)/post-install.d/
144 install-lists: install-base-dirs
145 $(CP_R) cronjobs/lists $(DESTDIR)$(pkgdatadir)/cronjobs/
146 $(CP_R) post-install.d/lists $(DESTDIR)$(pkgdatadir)/post-install.d/
147 $(INSTALL) -d -m 00755 $(DESTDIR)$(pkgdatadir)/lists/
148 ln -fs /usr/lib/mailman/cgi-bin $(DESTDIR)$(pkgdatadir)/lists/
150 install-ftp: install-base-dirs
151 $(CP_R) cronjobs/ftp $(DESTDIR)$(pkgdatadir)/cronjobs/
152 $(CP_R) post-install.d/ftp $(DESTDIR)$(pkgdatadir)/post-install.d/
154 install-base: install-base-dirs install-common install-web install-db install-scm install-ftp
156 # Select only "valid" plugins for 'make install'
157 PLUGINS=$(shell grep -l '^plugin_status\s=\svalid' plugins/*/etc/*.ini | sed 's,plugins/\([^/]*\)/.*,\1,')
158 PLUGINS_INSTALL_TARGETS=$(addprefix install-plugin-,$(PLUGINS))
159 install-plugins: $(PLUGINS_INSTALL_TARGETS)
161 install-plugin-%: plugins/% install-base-dirs
163 $(INSTALL) -d -m 00755 $(DESTDIR)$(pkgdatadir)/plugins/$*/
164 cd plugins/$* && $(CP_R) $$(ls | grep -v '^(etc|packaging)$$') $(DESTDIR)$(pkgdatadir)/plugins/$*/
165 # Initial config files
166 $(CP_R) --no-clobber plugins/$*/etc/$*.ini $(DESTDIR)$(config_path)/config.ini.d/;
167 if [ -d plugins/$*/etc/plugins/$* ]; then \
168 $(CP_R) --no-clobber plugins/$*/etc/plugins/$* $(DESTDIR)$(config_path)/plugins/; \
170 if [ -d plugins/$*/etc/httpd.conf.d/ ]; then \
171 $(CP_R) --no-clobber plugins/$*/etc/httpd.conf.d/ \
172 $(DESTDIR)$(config_path); \
174 for i in $$(ls plugins/$*/etc/cron.d/* 2>/dev/null); do \
175 if [ ! -e $(DESTDIR)$(sysconfdir)/cron.d/$$(basename $$i) ]; then \
176 sed 's,@bindir@,$(bindir),' $$i \
177 > $(DESTDIR)$(sysconfdir)/cron.d/$$(basename $$i); \
181 if [ -e plugins/$*/GNUmakefile ]; then $(MAKE) -C plugins/$*/ install; fi
184 rm -rf $(DESTDIR)$(pkgdatadir)
185 $(MAKE) -C locale/ uninstall
186 # Not removing $(config_path) and $(data_path) on purpose
190 ## Step 3: configure & update system
191 # not relying on 'prefix' for post-install (for no-install/dev setups)
192 post_source_path:=$(shell forge_get_config source_path 2>/dev/null)
193 post_plugins_path:=$(shell forge_get_config plugins_path 2>/dev/null)
195 $(post_source_path)/bin/post-install.sh
197 post-install-base: post-install-common post-install-db post-install-web post-install-scm post-install-ftp
200 $(post_source_path)/post-install.d/common/common.sh configure
203 $(post_source_path)/post-install.d/db/db.sh configure
206 $(post_source_path)/post-install.d/web/web.sh configure
212 $(post_source_path)/post-install.d/shell/shell.sh configure
214 post-install-mta-postfix:
215 $(post_source_path)/post-install.d/mta-postfix/mta-postfix.sh configure
217 post-install-mta-exim4:
218 $(post_source_path)/post-install.d/mta-exim4/mta-exim4.sh configure
221 $(post_source_path)/post-install.d/lists/lists.sh configure
224 $(post_source_path)/post-install.d/ftp/ftp.sh configure
226 PLUGINS_INSTALLED:=$(shell [ -d "$(post_plugins_path)" ] && cd $(post_plugins_path) && find * -maxdepth 0 -type d)
227 PLUGINS_POST_INSTALL_TARGETS=$(addprefix post-install-plugin-,$(PLUGINS_INSTALLED))
228 # Not depending on PLUGINS_POST_INSTALL_TARGETS: too many dependencies and non-production plugins
229 post-install-plugins:
230 @echo "Please select which plugin you want to configure (if needed):"
231 @for i in $(PLUGINS_INSTALLED); do \
232 echo " make post-install-plugin-$$i"; \
234 post-install-plugin-%: $(post_plugins_path)/%/
235 $(post_source_path)/post-install.d/common/plugin.sh $* configure
237 uninstall-plugin-%: $(post_plugins_path)/%/
238 $(post_source_path)/post-install.d/common/plugin.sh $* remove
239 # $(post_source_path)/post-install.d/common/plugin.sh $* uninstall
244 # not removing pre-built .mo files in e.g. 'debclean'
246 $(MAKE) -C locale/ clean
252 # depends: gettext tar
253 TAR_PREFIX=fusionforge-$(VERSION)
255 rm -rf $(TAR_PREFIX)/
257 $(CP_R) $$(ls -A | grep -v '^\.git' | grep -v $(TAR_PREFIX)) $(TAR_PREFIX)/
258 find $(TAR_PREFIX)/ -name '*~' -print0 | xargs -r0 rm
259 find $(TAR_PREFIX)/ -type d -print0 | xargs -r0 chmod g-s # rpmlint non-standard-dir-perm
260 rm -f $(TAR_PREFIX)/debian/control $(TAR_PREFIX)/fusionforge.spec
261 echo $(VERSION) > $(TAR_PREFIX)/VERSION # if using e.g. make dist VERSION=5.3.50+20141027
262 tar cjf $(TAR_PREFIX).tar.bz2 $(TAR_PREFIX)/
263 rm -rf $(TAR_PREFIX)/
266 rm -rf $(TAR_PREFIX)/
267 mkdir -p $(TAR_PREFIX)/{src,autoinstall}
268 $(CP_R) $$(ls -A | grep -v '^\.git' | grep -v $(TAR_PREFIX)) $(TAR_PREFIX)/src/
269 $(CP_R) ../autoinstall/* $(TAR_PREFIX)/autoinstall/
270 find $(TAR_PREFIX)/ -name '*~' -print0 | xargs -r0 rm
271 find $(TAR_PREFIX)/ -type d -print0 | xargs -r0 chmod g-s # rpmlint non-standard-dir-perm
272 rm -f $(TAR_PREFIX)/src/debian/control $(TAR_PREFIX)/src/fusionforge.spec
273 echo $(VERSION) > $(TAR_PREFIX)/src/VERSION # if using e.g. make dist VERSION=5.3.50+20141027
274 tar cjf $(TAR_PREFIX).tar.bz2 $(TAR_PREFIX)/
275 rm -rf $(TAR_PREFIX)/