Fix typos, add more info in README
[gwiad.git] / makefile
blob5a895493e4a13384b630fe82a29b188eb755a83d
1 ##############################################################################
2 ## Gwiad ##
3 ## ##
4 ## Copyright (C) 2007-2008 ##
5 ## Olivier Ramonat ##
6 ## ##
7 ## This library is free software; you can redistribute it and/or modify ##
8 ## it under the terms of the GNU General Public License as published by ##
9 ## the Free Software Foundation; either version 2 of the License, or (at ##
10 ## your option) any later version. ##
11 ## ##
12 ## This library is distributed in the hope that it will be useful, but ##
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of ##
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
15 ## General Public License for more details. ##
16 ## ##
17 ## You should have received a copy of the GNU General Public License ##
18 ## along with this library; if not, write to the Free Software Foundation, ##
19 ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ##
20 ##############################################################################
22 include mk.config
24 ifeq ($(OS),Windows_NT)
25 SOEXT=.dll
26 EXEEXT=.exe
27 else
28 SOEXT=.so
29 EXEEXT=
30 endif
32 APP := $(ADA_PROJECT_PATH)
34 ifeq ($(OS),Windows_NT)
35 export ADA_PROJECT_PATH=$PWD/external-libs/morzhol\;${APP}
36 else
37 export ADA_PROJECT_PATH=$PWD/external-libs/morzhol:${APP}
38 endif
40 export LIBRARY_TYPE=relocatable
42 # Set BDIR to .build/#lowercase_mode#
43 BDIR = .build/$(shell echo $(MODE) | tr [[:upper:]] [[:lower:]])
45 GENERAL_OPTIONS = CP="$(CP)" MKDIR="$(MKDIR)" RM="$(RM)" \
46 GNATMAKE="$(GNATMAKE)" GNATCLEAN="$(GNATCLEAN)" \
47 GNATCHECK="$(GNATCHECK)" GNATCHOP="$(GNATCHOP)" \
48 EXEEXT="$(EXEEXT)" DIFF="$(DIFF)"
50 OPTIONS = MODE="$(MODE)" $(GENERAL_OPTIONS)
52 # Modules support
54 MODULES = external-libs gwiad dynamic_libraries plugins web admin \
55 example argwiad argwiadctl
57 all: build
59 include mk.modules
61 # Version
63 VERSION = $(shell git describe --abbrev=0 2>/dev/null)
64 VERSION_ALL = $(shell git describe 2>/dev/null)
66 # Targets
68 mkinstall: force
69 ifneq ($(INSTALL), "")
70 # Write INSTALL target into mk.install (see install target)
71 $(shell echo INSTALL = $(INSTALL) > mk.install)
72 endif
74 build: mkinstall build-default
76 clean: clean-default
77 make -C regtests clean $(OPTIONS)
79 clean-all:
80 $(RM) -f mk.install
81 $(RM) -r .build
83 setup: setup-version setup-default
85 setup-version:
86 # If git is not present then use the version.ads provided in distrib
87 ifneq ("$(VERSION)", "")
88 sed -e 's,\$$VERSION\$$,$(VERSION),g' \
89 -e 's,\$$VERSION_ALL\$$,$(VERSION_ALL),g' \
90 gwiad/src/gwiad-version.tads > gwiad/src/gwiad-version.ads
91 endif
93 distrib:
94 git archive --prefix=gwiad/ HEAD > gwiad.tar
95 tar -C ../ -r --file=gwiad.tar gwiad/gwiad/src/gwiad-version.ads
96 gzip -f gwiad.tar
98 regtests: force
99 make -C external-libs/morzhol regtests \
100 MODE="Profile" $(GENERAL_OPTIONS)
101 make -C regtests MODE="Profile" BDIR=".build/profile" $(GENERAL_OPTIONS)
102 rm -f regtests/obj/* # To avoid error in lcov_analyse ???
103 make lcov_analyse
105 lcov_analyse: force
106 sh analyse.sh
108 build_doc:
109 @echo ""
110 @echo "=== Build doc"
111 ${MAKE} -C doc build_doc $(GALL_OPTIONS)
112 @echo ""
113 @echo "=== Build argwiadctl manpage"
114 ${MAKE} -C argwiadctl build_doc
116 check : check_message check-default
117 @echo
118 @echo "#####################################"
119 @echo "### Check style with style_checker ##"
120 @echo "#####################################"
121 @echo
122 -find . -follow -not -name "b~*" \
123 -a \( -name "*.adb" -o -name "*.ads" \) \
124 -and -not -path "*tsrc*" \
125 | xargs style_checker -lang Ada -cp -cy -sp -gnat05
127 check_message:
128 @echo
129 @echo "############################################"
130 @echo "### Verifying Properties Using gnatcheck ###"
131 @echo "############################################"
132 @echo
134 force:
136 ifeq ($(OS),Windows_NT)
137 DISTRIB_OS = Windows
138 else
139 DISTRIB_OS = $(shell uname -s | tr [[:upper:]] [[:lower:]])-$(shell uname -m)
140 endif
142 DISTRIB = argwiad-$(DISTRIB_OS)-$(VERSION_ALL)
144 install_demo: install_server
145 $(CP) -r $(BDIR)/slib/services/*hello_world_service$(SOEXT) \
146 $(SERVER_INSTALL)/lib/services/
147 $(CP) -r $(BDIR)/slib/websites/*hello_world_website$(SOEXT) \
148 $(SERVER_INSTALL)/lib/websites/
149 $(CP) $(BDIR)/lib/*helloworld_interface*$(SOEXT) $(SERVER_INSTALL)/bin
151 install_admin_plugin:
152 $(CP) -r admin/templates/*.thtml \
153 $(SERVER_INSTALL)/templates/admin
154 $(CP) -r $(BDIR)/slib/websites/libgwiad_admin$(SOEXT) \
155 $(SERVER_INSTALL)/lib/websites/
157 install_server:
158 $(MKDIR) $(SERVER_INSTALL)/data
159 $(MKDIR) $(SERVER_INSTALL)/bin
160 $(RM) -r $(SERVER_INSTALL)/lib/
161 $(MKDIR) $(SERVER_INSTALL)/lib/websites
162 $(MKDIR) $(SERVER_INSTALL)/lib/services
163 $(MKDIR) $(SERVER_INSTALL)/templates
164 $(MKDIR) $(SERVER_INSTALL)/templates/admin
165 $(MKDIR) $(SERVER_INSTALL)/scripts
166 $(MKDIR) $(SERVER_INSTALL)/uploads
167 $(MKDIR) $(SERVER_INSTALL)/www
168 $(CP) templates/default.html $(SERVER_INSTALL)/www/index.html
169 $(CP) $(BDIR)/bin/argwiad$(EXEEXT) $(SERVER_INSTALL)/bin
171 # Set INSTALL directories
172 -include mk.install
174 I_INC = $(INSTALL)/include/gwiad
175 I_LIB = $(INSTALL)/lib/gwiad
176 I_GPR = $(INSTALL)/lib/gnat
177 I_INC_WEB = $(INSTALL)/include/gwiad/web
178 I_INC_DL = $(INSTALL)/include/gwiad/dl
179 I_INC_R = $(INSTALL)/include/gwiad/plugins
180 I_INC_RS = $(INSTALL)/include/gwiad/plugins/s
181 I_INC_RWS = $(INSTALL)/include/gwiad/plugins/ws
182 I_BIN = $(INSTALL)/bin
184 install_clean: force
185 ifeq ("$(INSTALL)", "")
186 $(error "Wrong install path : empty INSTALL var")
187 endif
188 echo $(RM) -fr $(I_INC)
189 $(RM) -fr $(I_LIB)
190 $(RM) -f $(I_GPR)/gwiad.gpr
192 install_dirs: install_clean
193 $(MKDIR) $(I_BIN)
194 $(MKDIR) $(I_INC)
195 $(MKDIR) $(I_INC_WEB)
196 $(MKDIR) $(I_INC_DL)
197 $(MKDIR) $(I_INC_R)
198 $(MKDIR) $(I_INC_RS)
199 $(MKDIR) $(I_INC_RWS)
200 $(MKDIR) $(I_LIB)
201 $(MKDIR) $(I_GPR)
203 install: install_dirs
204 make -C external-libs install $(OPTIONS)
205 $(CP) gwiad/src/*.ad[sb] $(I_INC)
206 $(CP) dynamic_libraries/src/*.ad[sb] $(I_INC_DL)
207 $(CP) plugins/src/*.ad[sb] $(I_INC_R)
208 $(CP) plugins/services/src/*.ad[sb] $(I_INC_RS)
209 $(CP) plugins/websites/src/*.ad[sb] $(I_INC_RWS)
210 $(CP) web/src/*.ad[sb] $(I_INC_WEB)
211 $(CP) $(BDIR)/obj/*.ali $(I_LIB)
212 $(CP) $(BDIR)/lib/* $(I_LIB)
213 $(CP) $(BDIR)/dl/obj/*.ali $(I_LIB)
214 $(CP) $(BDIR)/dl/lib/* $(I_LIB)
215 $(CP) $(BDIR)/gwiad/obj/*.ali $(I_LIB)
216 $(CP) $(BDIR)/gwiad/lib/* $(I_LIB)
217 $(CP) $(BDIR)/plugins/obj/*.ali $(I_LIB)
218 $(CP) $(BDIR)/plugins/lib/* $(I_LIB)
219 $(CP) $(BDIR)/ps/obj/*.ali $(I_LIB)
220 $(CP) $(BDIR)/ps/lib/* $(I_LIB)
221 $(CP) $(BDIR)/pw/obj/*.ali $(I_LIB)
222 $(CP) $(BDIR)/pw/lib/* $(I_LIB)
223 $(CP) $(BDIR)/web/obj/*.ali $(I_LIB)
224 $(CP) $(BDIR)/web/lib/* $(I_LIB)
225 $(CP) config/projects/gwiad.gpr $(I_GPR)
226 $(CP) config/projects/gwiad-shared.gpr $(I_GPR)
227 $(CP) config/projects/gwiad-web.gpr $(I_GPR)
228 $(CP) config/projects/gwiad-dynamic_libraries.gpr $(I_GPR)
229 $(CP) config/projects/gwiad-plugins.gpr $(I_GPR)
230 $(CP) config/projects/gwiad-plugins-services.gpr $(I_GPR)
231 $(CP) config/projects/gwiad-plugins-websites.gpr $(I_GPR)
232 $(CP) .build/static/bin/argwiadctl$(EXEEXT) $(I_BIN)
233 ifneq ("$(MANPAGE_DIR)", "")
234 -$(CP) argwiadctl/doc/argwiadctl.1 $(MANPAGE_DIR)/man1/
235 endif
236 ifeq ($(OS), Windows_NT)
237 $(CP) $(I_LIB)/*$(SOEXT) $(I_BIN)
238 endif
240 install-distrib:
241 $(RM) -r $(DISTRIB)
242 $(MKDIR) $(DISTRIB)/data
243 $(MKDIR) $(DISTRIB)/bin
244 $(MKDIR) $(DISTRIB)/lib/websites
245 $(MKDIR) $(DISTRIB)/lib/services
246 $(MKDIR) $(DISTRIB)/config
247 $(MKDIR) $(DISTRIB)/templates
248 $(MKDIR) $(DISTRIB)/templates/admin
249 $(MKDIR) $(DISTRIB)/scripts
250 $(MKDIR) $(DISTRIB)/uploads
251 $(MKDIR) $(DISTRIB)/www
252 $(CP) $(BDIR)/lib/*$(SOEXT) $(DISTRIB)/bin
253 $(CP) $(BDIR)/dl/lib/*$(SOEXT) $(DISTRIB)/bin
254 $(CP) $(BDIR)/gwiad/lib/*$(SOEXT) $(DISTRIB)/bin
255 $(CP) $(BDIR)/plugins/lib/*$(SOEXT) $(DISTRIB)/bin
256 $(CP) $(BDIR)/pw/lib/*$(SOEXT) $(DISTRIB)/bin
257 $(CP) $(BDIR)/ps/lib/*$(SOEXT) $(DISTRIB)/bin
258 $(CP) $(BDIR)/web/lib/*$(SOEXT) $(DISTRIB)/bin
259 $(CP) external-libs/morzhol/$(BDIR)/lib/*$(SOEXT) $(DISTRIB)/bin
260 $(CP) $(BDIR)/bin/argwiad$(EXEEXT) $(DISTRIB)/bin
261 $(CP) .build/static/bin/argwiadctl $(DISTRIB)/bin
262 $(CP) $(AWS_LIB_DIR)/*$(SOEXT) $(DISTRIB)/bin
263 $(CP) $(ADA_LIB_DIR)/*$(SOEXT) $(DISTRIB)/bin
264 $(CP) config/scripts/unregister $(DISTRIB)/scripts
265 $(CP) templates/default.html $(DISTRIB)/www/index.html
266 $(TAR_DIR) $(DISTRIB).tgz $(DISTRIB)
267 $(RM) -r $(DISTRIB)
269 install-distrib-show-name:
270 @echo $(DISTRIB)