Fix build procedure.
[morzhol.git] / Makefile
blob22b91f28f1af8954e146aced32b5b2e7945d16f6
1 ##############################################################################
2 ## Morzhol ##
3 ## ##
4 ## Copyright (C) 2007-2008 ##
5 ## Pascal Obry - 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 all::
24 # Root dir
25 MODE = Release
26 JOBS = 1
27 BUILD_DIR = .build/$(shell echo $(MODE) | tr [[:upper:]] [[:lower:]])
28 GNATMAKE_OPTIONS = -XPRJ_BUILD=$(MODE)
29 VALGRIND =
30 TAR_DIR = tar czf
32 # Install prefix
33 GNAT_ROOT = $(dir $(shell which gnatls))..
34 ARGWIAD_ROOT =
35 prefix =
37 ifeq (,$(prefix))
38 prefix = $(shell cat $(BUILD_DIR)/gnat.root 2>/dev/null)
39 endif
41 ifeq (,$(ARGWIAD_ROOT))
42 ARGWIAD_ROOT = $(shell echo $$ARGWIAD_ROOT)
43 endif
45 GNAT = gnat
46 GNATMAKE = $(GNAT) make -p -j$(JOBS) $(GNATMAKE_OPTIONS)
47 GNATCLEAN = $(GNAT) clean $(GNATMAKE_OPTIONS)
48 GNATCHECK = $(GNAT) check $(GNATMAKE_OPTIONS) -rules -from=morzhol.check
49 RM = rm -f
50 LN = ln
51 CP = cp -p
52 MKDIR = mkdir -p
54 LIBRARIES =
55 LIBRARIES += morzhol
57 GPR =
58 GPR += morzhol
59 GPR += test/test
61 BLD_GPR := $(addprefix bld-, $(GPR))
62 CLN_GPR := $(addprefix cln-, $(GPR))
63 CHK_GPR := $(addprefix chk-, $(GPR))
65 ifeq (${OS},Windows_NT)
66 LIBEXT = .dll
67 EXEEXT = .exe
68 export PATH:=$(shell pwd)/lib:$(PATH) # Required to find the shared library
69 else
70 LIBEXT = .so
71 endif
73 VERSION_ALL = $(shell git describe 2>/dev/null)
75 $(BLD_GPR): bld-% :
76 $(GNATMAKE) -P$*
78 $(CLN_GPR): cln-% :
79 $(GNATCLEAN) -P$*
81 $(CHK_GPR): chk-% :
82 $(GNATCHECK) -P$*
84 morzhol build: prepare_install bld-morzhol
86 all:: prepare_install $(LIBRARIES)
88 clean: $(CLN_GPR)
90 clean_all:
91 $(RM) -rf $(BUILD_DIR)
93 regtests:: bld-test/test
94 ./test/test
95 ./test/test_compose
97 gnatcheck: $(CHK_GPR)
99 install::
100 $(MKDIR) $(prefix)/include/morzhol
101 $(MKDIR) $(prefix)/lib/morzhol
102 $(MKDIR) $(prefix)/lib/gnat
103 $(CP) src/*.ad[sb] $(prefix)/include/morzhol
104 $(CP) $(BUILD_DIR)/lib/*$(LIBEXT) $(prefix)/lib/morzhol
105 $(CP) $(BUILD_DIR)/lib/*.ali $(prefix)/lib/morzhol
106 $(CP) install.gpr $(prefix)/lib/gnat/morzhol.gpr
107 ifeq ($(OS), Windows_NT)
108 $(CP) $(BUILD_DIR)/lib/*$(LIBEXT) $(prefix)/bin
109 endif
111 prepare_install::
112 $(MKDIR) $(BUILD_DIR)
113 echo $(GNAT_ROOT) > $(BUILD_DIR)/gnat.root
115 install-clean::
116 $(RM) -rf $(prefix)/include/morzhol
117 $(RM) -rf $(prefix)/lib/morzhol
119 dist:
120 git archive --prefix="$(shell basename $(PWD))/" --format=tar HEAD \
121 | gzip > "$(shell basename $(PWD))-$(VERSION_ALL)-src.tgz"
124 .PHONY: all