1VERSION=1.0.2
2LIB=./lib/libadaid.so
3DEBUG=./lib/libadaid.a
4TEST=./bin/test
5DIST_NAME=adaid-$(VERSION)
6DIST=$(DIST_NAME).tgz
7GNAT=gnat
8RM=rm
9CHMOD=chmod
10MKDIR=mkdir -p
11CP=cp
12
13
14.PHONY: debug test install installclean clean cleanall all support remove dist docs
15
16#library
17$(LIB): src/*.adb src/*.ads include/*.ads adaid.gpr
18	$(GNAT) make -Padaid.gpr
19
20adaid.gpr: adaid.gpr.in
21	@cat $< | sed 's/%VERSION%/$(VERSION)/' > $@
22
23#installation
24INSTALL = $(shell which $(GNAT) 2> /dev/null | sed -e 's/\/bin\/gnat.*//')
25INCLUDE= $(INSTALL)/share/ada/adainclude/adaid
26LIBRARY=$(INSTALL)/lib
27ALI=$(INSTALL)/lib/ada/adalib/adaid
28GPR   = $(INSTALL)/share/ada/adainclude
29
30support/adaid.gpr: support/adaid.gpr.in
31	@cat $< | sed  -e 's!%LIB_DIR%!$(LIBRARY)!' \
32									-e 's!%SRC_DIR%!$(INCLUDE)!' \
33									-e 's!%ALI_DIR%!$(ALI)!' > $@
34
35
36
37installclean:
38ifeq ($(INSTALL),)
39	@echo 'Error when installing: $$INSTALL is empty...'
40	@echo "Please set an installation path before installing"
41else
42	-$(CHMOD) -f -R 777 $(ALI)
43	$(RM) -fr $(ALI)
44	-$(CHMOD) -f -R 777 $(INCLUDE)
45	$(RM) -fr $(INCLUDE)
46	$(RM) -f $(GPR)/adaid.gpr
47	$(RM) -f $(GPR)/adaid_debug.gpr
48endif
49
50install: installclean support/adaid.gpr
51ifneq ($(INSTALL),)
52	$(MKDIR) $(GPR)
53	$(MKDIR) $(LIBRARY)
54	$(MKDIR) $(INCLUDE)
55	$(MKDIR) $(ALI)
56	$(CP) -r ali/* $(ALI)
57	$(CP) support/*.gpr $(GPR)
58	$(CP) -r lib/* $(LIBRARY)
59	$(CP) -r include/* $(INCLUDE)
60	@echo '--  AdaID has been installed.'
61endif
62
63remove: installclean
64
65
66#debug library
67debug: support/adaid_debug.gpr $(DEBUG)
68
69support/adaid_debug.gpr: support/adaid_debug.gpr.in
70	@cat $< n | sed  -e 's!%LIB_DIR%!$(LIBRARY)!' \
71									-e 's!%SRC_DIR%!$(INCLUDE)!' \
72									-e 's!%ALI_DIR%!$(ALI)!' > $@
73
74$(DEBUG): src/*.adb src/*.ads include/*.ads
75	$(GNAT) make -Padaid_debug.gpr
76
77#test executable
78$(TEST): $(LIB) include/*.ads test/*.adb test/*.ads
79	$(GNAT) make -Ptest.gpr
80
81#run tests
82test: $(TEST)
83	$(TEST)
84
85#make a tarball of the source
86dist: $(DIST)
87
88THIS=$(shell basename `pwd`)
89$(DIST): cleanall
90	cd ..;\
91	tar caf $@ \
92				--exclude-vcs --exclude=*~ --exclude=.gitignore --exclude=*.tgz\
93				--xform 's!$(THIS)!$(DIST_NAME)!'\
94				$(THIS)
95
96#documentation
97docs: include/*.ads
98	ls include/*.ads | adabrowse -i -o ./ -f-
99	@mv *.html doc
100
101#misc
102all: $(LIB) $(TEST)
103
104clean:
105	$(RM) -f obj/*.* obj/test/*.* obj/debug/*.* ali/*.* ali/debug/*.* 2> /dev/null
106
107cleanall: clean
108	$(RM) -f support/*.gpr bin/* lib/* adaid.gpr doc/*.html  2> /dev/null
109
110