-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (57 loc) · 1.49 KB
/
Makefile
File metadata and controls
66 lines (57 loc) · 1.49 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
# Created by Fernando Oleo Blanco <irvise.xyz>
# Files
PROJ_FILE= scheme.gpr
SCHEME_FILES= chicken_ada.scm
ADA_FILES= scheme_test
LIB_NAME= scheme_hello
EXECUTABLE= scheme_ada
# Builder settings
LIBDIR= lib
OBJDIR= obj
# Compiler settings
# ADAC will be filled with the compiler toolchain detected in tooling:
ADAC=
ADAFLAGS+= -fPIC -ggdb -O1 -gnata
LINKFLAGS+= -shared
# Chicken flags. We are using Chicken Scheme here
CHICKENFLAGS= -L./lib -L -l${LIB_NAME} -Wl,-R./lib -v
# Build command, detect available toolchain
# As taken from https://stackoverflow.com/a/34756868
BUILDER:= $(shell command -v gprbuild 2> /dev/null)
.PHONY: all
all: scheme
# Buifld Scheme program
.PHONY: scheme
scheme: library
csc ${SCHEME_FILES} ${CHICKENFLAGS} -o ${EXECUTABLE}
# Build library
.PHONY: library
library: tooling
ifdef BUILDER
${ADAC} -P${PROJ_FILE}
else
${ADAC} -c -b $(addprefix src/, ${ADA_FILES}) ${ADAFLAGS} \
-D ${OBJDIR} -bargs -n -a
gcc ${LINKFLAGS} $(addprefix ${OBJDIR}/, $(addsufix .o, ${ADA_FILES})) \
-o $(addprefix $(LIBDIR)/lib, $(addsuffix .so, ${LIBNAME}))
endif
# Check what toolchain we have available.
# Use gprbuild if available, gnattools otherwise.
.PHONY: tooling
tooling:
ifndef BUILDER
@echo GPRBUILD is not available in the system. Defaulting to GNATTOOLS.
$(eval ADAC=gnatmake)
else
$(eval ADAC=gprbuild)
endif
# Clean project files
.PHONY: clean
clean: tooling
ifdef BUILDER
gprclean
else
gnatclean $(addprefix src/, ${ADA_FILES}) -D ${OBJDIR}
endif
@rm -f ${EXECUTABLE}
@rm -f *.o