1# FOSSology Makefile - install/
2# Copyright (C) 2008-2011 Hewlett-Packard Development Company, L.P.
3
4# Create and install:
5#  fo-postinstall
6#  SYSCONFDIR/db.conf
7
8TOP = ..
9VARS = $(TOP)/Makefile.conf
10include $(VARS)
11
12CONFPATH = $(SYSCONFDIR)
13# default version is the scm revision number
14-DVERSION=$(SCM_REV)
15
16all: fo-postinstall defconf/Db.conf defconf/fossology.conf fossdash/fossdash-publish.py db/dbcreate db/db.cron.in
17
18# include the preprocessing stuff
19include $(TOP)/Makefile.process
20
21# generate the postinstall script
22fo-postinstall:	fo-postinstall-process
23	chmod +x fo-postinstall
24
25# generate the default Db.conf file
26defconf/Db.conf: defconf/Db.conf-process
27
28# generate the fossdash-publish.py file
29fossdash/fossdash-publish.py: fossdash/fossdash-publish.py-process
30
31# generate fossology.conf
32defconf/fossology.conf:	defconf/fossology.conf-process
33
34# create dbcreate
35	$(MAKE) -s -C db
36
37install_offline: install
38
39install: all
40	$(INSTALL_PROGRAM) fo-postinstall $(DESTDIR)$(LIBEXECDIR)/fo-postinstall
41	$(INSTALL_PROGRAM) ./fossdash/fossdash-publish.py $(DESTDIR)$(LIBEXECDIR)/fossdash-publish.py
42	$(INSTALL_PROGRAM) fo_dbcheck.php $(DESTDIR)$(LIBEXECDIR)/fo_dbcheck.php
43	$(INSTALL_PROGRAM) fossinit.php $(DESTDIR)$(LIBEXECDIR)/fossinit.php
44	$(INSTALL_PROGRAM) fossinit-common.php $(DESTDIR)$(LIBEXECDIR)/fossinit-common.php
45	$(MAKE) -s -C db install
46
47	@echo "Making configuration directories"; \
48	if [ ! -e $(DESTDIR)$(CONFPATH) ]; then \
49		mkdir -p $(DESTDIR)$(CONFPATH); \
50	fi
51	@if [ ! -e $(DESTDIR)$(CONFPATH)/mods-enabled ]; then \
52		mkdir -p $(DESTDIR)$(CONFPATH)/mods-enabled; \
53		/bin/chmod 775 $(DESTDIR)$(CONFPATH)/mods-enabled; \
54	fi
55
56	@if [ ! -e $(DESTDIR)$(CONFPATH)/conf ]; then \
57		mkdir -p $(DESTDIR)$(CONFPATH)/conf; \
58	fi
59
60	@echo "Installing configuration files..."
61
62	@if [ ! -f $(DESTDIR)$(CONFPATH)/Db.conf -o "$(OVERWRITE)" ]; then \
63		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/Db.conf"; \
64	 	$(INSTALL) -m 640 defconf/Db.conf $(DESTDIR)$(CONFPATH)/Db.conf; \
65	else \
66		echo "WARNING: $(DESTDIR)$(CONFPATH)/Db.conf already exists."; \
67		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
68	fi
69
70	@if [ ! -f $(DESTDIR)$(CONFPATH)/fossology.conf -o "$(OVERWRITE)" ]; then \
71		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/fossology.conf"; \
72	 	$(INSTALL) -m 666 defconf/fossology.conf $(DESTDIR)$(CONFPATH)/fossology.conf; \
73	else \
74		echo "WARNING: $(DESTDIR)$(CONFPATH)/fossology.conf already exists."; \
75		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
76	fi
77
78	@if [ ! -f $(DESTDIR)$(CONFPATH)/fossdash_metrics.yml -o "$(OVERWRITE)" ]; then \
79		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/fossdash_metrics.yml"; \
80	 	$(INSTALL) -m 666 fossdash/fossdash_metrics.yml $(DESTDIR)$(CONFPATH)/fossdash_metrics.yml; \
81	else \
82		echo "WARNING: $(DESTDIR)$(CONFPATH)/fossdash_metrics.yml already exists."; \
83		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
84	fi
85
86	@if [ ! -f $(DESTDIR)$(CONFPATH)/sampleheader.txt -o "$(OVERWRITE)" ]; then \
87		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/sampleheader.txt"; \
88	 	$(INSTALL) -m 666 defconf/sampleheader.txt $(DESTDIR)$(CONFPATH)/sampleheader.txt; \
89	else \
90		echo "WARNING: $(DESTDIR)$(CONFPATH)/sampleheader.txt already exists."; \
91		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
92	fi
93
94	@if [ ! -f $(DESTDIR)$(CONFPATH)/samplefooter.txt -o "$(OVERWRITE)" ]; then \
95		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/samplefooter.txt"; \
96	 	$(INSTALL) -m 666 defconf/samplefooter.txt $(DESTDIR)$(CONFPATH)/samplefooter.txt; \
97	else \
98		echo "WARNING: $(DESTDIR)$(CONFPATH)/samplefooter.txt already exists."; \
99		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
100	fi
101
102	@if [ ! -f $(DESTDIR)$(CONFPATH)/conf/fo-apache.conf -o "$(OVERWRITE)" ]; then \
103		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/conf/fo-apache.conf"; \
104	 	$(INSTALL) -m 666 fo-apache.conf $(DESTDIR)$(CONFPATH)/conf/fo-apache.conf; \
105	else \
106		echo "WARNING: $(DESTDIR)$(CONFPATH)/conf/fo-apache.conf already exists."; \
107		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
108	fi
109
110	@if [ ! -f $(DESTDIR)$(CONFPATH)/conf/src-install-apache-example.conf -o "$(OVERWRITE)" ]; then \
111		echo "NOTE: using default version for $(DESTDIR)$(CONFPATH)/conf/src-install-apache-example.conf"; \
112	 	$(INSTALL) -m 666 src-install-apache-example.conf $(DESTDIR)$(CONFPATH)/conf/src-install-apache-example.conf; \
113	else \
114		echo "WARNING: $(DESTDIR)$(CONFPATH)/conf/src-install-apache-example.conf already exists."; \
115		echo "  Not overwriting, consider checking it by hand or use the OVERWRITE option."; \
116	fi
117
118uninstall:
119	rm -f $(DESTDIR)$(LIBEXECDIR)/fo-postinstall
120	rm -f $(DESTDIR)$(CONFPATH)/sampleheader.txt
121	rm -f $(DESTDIR)$(CONFPATH)/samplefooter.txt
122	rm -f $(DESTDIR)$(LIBEXECDIR)/fossinit.php
123	rm -f $(DESTDIR)$(LIBEXECDIR)/fo_dbcheck.php
124
125	@if [ -d $(DESTDIR)$(LIBEXECDIR) ]; then \
126		if [ "`ls -A $(DESTDIR)$(LIBEXECDIR)`" ]; then \
127			echo "WARNING: $(DESTDIR)$(LIBEXECDIR) not empty, not removing"; \
128		else \
129			rmdir $(DESTDIR)$(LIBEXECDIR); \
130		fi; \
131	fi
132
133	@echo "Configuration files will not be removed:"
134	@echo "      $(DESTDIR)$(CONFPATH)/fossology.conf"
135	@echo "      $(DESTDIR)$(CONFPATH)/Db.conf"
136	@echo "  Remove by hand if you desire."
137	$(MAKE) -s -C db uninstall
138
139clean:
140	rm -f fo-postinstall defconf/Db.conf defconf/fossology.conf fossdash/fossdash-publish.py
141	$(MAKE) -s -C db clean
142
143test: all
144	@echo "nothing to do"
145
146coverage: all
147	@echo "nothing to do"
148
149.PHONY: all install uninstall clean test coverage
150