-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (54 loc) · 2.97 KB
/
Makefile
File metadata and controls
74 lines (54 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
include Makefile.project
-include .config
LC_PROJECT = $(shell echo -n "${PROJECT}" | tr '[:upper:].' '[:lower:]-')
PROJECT_ROOT_SOURCE = src/$(LC_PROJECT).ads
HG_STATE_SOURCE = src/$(LC_PROJECT)-mercurial.ads
HG_MODIFIER = `test $$(hg status | wc -c || echo 0) -gt 0 && echo "plus changes" || echo "as committed"`
HG_REVISION = `hg tip --template '{node}' 2>/dev/null || echo N/A_____________________________________`
GENERATED_SOURCES += $(HG_STATE_SOURCE)
EXECUTABLES=$(GENERATED_EXECUTABLES) $(SCRIPTS)
PREFIX ?= $(HOME)
REPOSITORY_STATE = .hg/dirstate
REPOSITORY_CONFIG = .hg/hgrc
all: build
build: build-depends fix-whitespace $(GENERATED_SOURCES)
gnatmake -j0 -p -P $(LC_PROJECT)
test: build $(EXECUTABLES)
@mkdir -p tests/results
@./tests/build
@./tests/run
install: build test
@if [ ! -z "$(GENERATED_EXECUTABLES)" ]; then strip $(GENERATED_EXECUTABLES) ; fi
@if [ ! -z "$(EXECUTABLES)" ]; then install -D -t $(DESTDIR)$(PREFIX)/bin/ $(EXECUTABLES) ; fi
clean:
find . \( -name "*~" -o -name "*.bak" -o -name "*.o" -o -name "*.ali" -o -name "*.adt" \) -type f -print0 | xargs -0 /bin/rm || true
if [ ! -z "$(GENERATED_SOURCES)" ]; then rm -f $(GENERATED_SOURCES) 2>/dev/null || true; fi
if [ ! -z "$(TEST_OUTPUT)" ]; then rm -f $(TEST_OUTPUT) 2>/dev/null || true; fi
rmdir bin || true
rmdir obj || true
distclean: clean
if [ ! -z "$(GENERATED_SOURCES)" ]; then rm -rf $(GENERATED_SOURCES); fi
if [ ! -z "$(TEST_OUTPUT)" ]; then rm -rf $(TEST_OUTPUT); fi
gnatclean -P $(LC_PROJECT) || true
rm -f $(GENERATED_EXECUTABLES)
rmdir bin || true
rmdir obj || true
build-depends:
@for command in $$(cat .build-depends.commands) ; do if [ ! -x "$$(which $${command})" ]; then echo "'$${command}' not found."; exit 1; fi; done
@for project in $$(cat .build-depends.projects) ; do project_file="$$(gnatls -v | egrep '^ [^ ]' | sort -u | while read directory ; do ls "$${directory}/$${project}.gpr" 2>/dev/null; done)" ; if [ -z "$${project_file}" -o ! -s "$${project_file}" ]; then echo "'$${project}.gpr' not found."; exit 1; fi; done
fix-whitespace:
@find src tests -name '*.ad?' | xargs egrep -l ' | $$' | grep -v '^b[~]' | xargs perl -i -lpe 's| | |g; s| +$$||g' 2>/dev/null || true
$(REPOSITORY_CONFIG):
@mkdir -p $(shell dirname $(REPOSITORY_CONFIG))
@touch $(REPOSITORY_CONFIG)
$(REPOSITORY_STATE):
@mkdir -p $(shell dirname $(REPOSITORY_STATE))
@touch $(REPOSITORY_STATE)
$(HG_STATE_SOURCE): Makefile $(REPOSITORY_CONFIG) $(REPOSITORY_STATE) $(PROJECT_ROOT_SOURCE)
@mkdir -p src
@echo 'package '$(PROJECT)'.Mercurial is' > $(HG_STATE_SOURCE)
@echo ' Revision : constant String (1 .. 53) :=' >> $(HG_STATE_SOURCE)
@echo ' "'$(HG_REVISION)' '$(HG_MODIFIER)'";' >> $(HG_STATE_SOURCE)
@echo 'end '$(PROJECT)'.Mercurial;' >> $(HG_STATE_SOURCE)
-include Makefile.project_rules
.PHONY: all build test install clean distclean build-depends fix-whitespace