forked from igraph/rigraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile-cigraph
181 lines (132 loc) · 5.12 KB
/
Makefile-cigraph
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
########################################################
# Configuration variables
PYTHON ?= python3
PYVENV ?= .venv
STIMULUS ?= $(PYVENV)/bin/stimulus
all: pre_build
########################################################
# Main package
top_srcdir=src/vendor/cigraph
vendored_srcdir=$(top_srcdir)
VERSION=$(shell tools/getversion.sh)
# We put the version number in a file, so that we can detect
# if it changes
version_number: force
@echo '$(VERSION)' | cmp -s - $@ || echo '$(VERSION)' > $@
# Files generated by flex/bison
PARSER := $(shell cd $(top_srcdir) ; git ls-files --full-name src | \
grep -E '\.(l|y)$$')
PARSER1 := $(patsubst src/%.l, src/%.c, $(PARSER))
PARSER2 := $(patsubst src/%.y, src/%.c, $(PARSER1))
YACC=bison -b yy -d
LEX=flex
%.c: %.y
$(YACC) $<
mv -f yy.tab.c src/vendor/io/$(notdir $@)
mv -f yy.tab.h src/vendor/io/parsers/$(basename $(notdir $@)).h
%.c: %.l
$(LEX) -o src/vendor/io/$(notdir $@) --header-file=src/vendor/io/parsers/$(basename $(notdir $@)).h $<
# Create Python virtualenv for Stimulus
venv: $(PYVENV)/stamp
$(PYVENV)/stamp: tools/build-requirements.txt
$(PYTHON) -m venv $(PYVENV)
$(PYVENV)/bin/pip install -r $<
touch $(PYVENV)/stamp
# Apply possible patches
patches: $(CORESRC) $(VENDORSRC) $(CINC) $(PARSER2)
-rm -f src/*.orig
tools/fix-lexers.sh
# C files generated by C configure
CGEN = src/vendor/igraph_export.h src/vendor/igraph_threading.h src/vendor/igraph_version.h src/sources.mk
src/vendor/igraph_export.h: tools/stimulus/igraph_export.h
cp $< $@
src/vendor/igraph_threading.h: $(top_srcdir)/include/igraph_threading.h.in
mkdir -p src
sed 's/#cmakedefine01 IGRAPH_THREAD_SAFE/#define IGRAPH_THREAD_SAFE 0/g' $< >$@
src/vendor/igraph_version.h: $(top_srcdir)/include/igraph_version.h.in
cp $< $@
# Create sources.mk
src/sources.mk:
$(PYTHON) rconfigure.py
# R source and doc files
RSRC := $(shell git ls-files R doc inst demo NEWS cleanup.win configure.win)
# ARPACK Fortran sources
ARPACK := $(shell git ls-files vendor/arpack)
ARPACK2 := $(patsubst vendor/arpack/%, src/vendor/arpack/%, $(ARPACK))
$(ARPACK2): src/vendor/arpack/%: vendor/arpack/%
mkdir -p $(@D) && cp $< $@
# libuuid
UUID := $(shell git ls-files vendor/uuid)
UUID2 := $(patsubst vendor/uuid/%, src/vendor/uuid/%, $(UUID))
$(UUID2): src/vendor/uuid/%: vendor/uuid/%
mkdir -p $(@D) && cp $< $@
# Simpleraytracer
RAY := $(shell git ls-files vendor/simpleraytracer)
RAY2 := $(patsubst vendor/simpleraytracer/%, src/vendor/simpleraytracer/%, $(RAY))
$(RAY2): src/vendor/%: vendor/%
mkdir -p $(@D) && cp $< $@
# R files that are generated/copied
RGEN = R/aaa-auto.R src/rinterface.c \
configure src/config.h.in src/Makevars.in src/Makevars.win src/Makevars.ucrt
# Files generated by stimulus
src/rinterface.c: \
venv \
$(vendored_srcdir)/interfaces/functions.yaml \
$(vendored_srcdir)/interfaces/types.yaml \
tools/stimulus/rinterface.c.in \
tools/stimulus/functions-R.yaml \
tools/stimulus/types-RC.yaml
$(STIMULUS) \
-f $(vendored_srcdir)/interfaces/functions.yaml \
-f tools/stimulus/functions-R.yaml \
-i tools/stimulus/rinterface.c.in \
-o src/rinterface.c \
-t $(vendored_srcdir)/interfaces/types.yaml \
-t tools/stimulus/types-RC.yaml \
-l RC
R/aaa-auto.R: \
venv \
$(vendored_srcdir)/interfaces/functions.yaml \
$(vendored_srcdir)/interfaces/types.yaml \
tools/stimulus/aaa-auto.R.in \
tools/stimulus/functions-R.yaml \
tools/stimulus/types-RR.yaml
$(STIMULUS) \
-f $(vendored_srcdir)/interfaces/functions.yaml \
-f tools/stimulus/functions-R.yaml \
-i tools/stimulus/aaa-auto.R.in \
-o R/aaa-auto.R \
-t $(vendored_srcdir)/interfaces/types.yaml \
-t tools/stimulus/types-RR.yaml \
-l RR
# configure files
configure src/config.h.in: configure.ac
autoheader; autoconf
# CMake needs HAVE_ISFINITE but configure.ac generates HAVE_DECL_ISFINITE
echo "#define HAVE_ISFINITE HAVE_DECL_ISFINITE" >>src/config.h.in
# This is the list of all object files in the R package,
# we write it to a file to be able to depend on it.
# Makevars.in, Makevars.win and Makevars.ucrt are only regenerated if
# the list of object files changes.
OBJECTS := $(shell echo $(CORESRC) $(VENDORSRC) $(ARPACK) $(RAY) $(UUID) | \
tr ' ' '\n' | \
grep -E '\.(c|cpp|cc|f|l|y)$$' | \
sed 's/\.[^\.][^\.]*$$/.o/' | \
sed 's,^src/,,' \
) rinterface.o rinterface_extra.o rrandom.o lazyeval.o init.o cpp11.o cpprinterface.o
object_files: force
@echo '$(OBJECTS)' | cmp -s - $@ || echo '$(OBJECTS)' > $@
src/Makevars.win src/Makevars.ucrt src/Makevars.in: src/%: tools/stimulus/% \
object_files
cp $< $@
printf "%s" "OBJECTS=" >> $@
# Can't insert newlines, not all make variants accept them
cat object_files >> $@
pre_build: venv patches $(RSRC) \
$(CGEN) $(RAY2) $(ARPACK2) $(UUID2) \
$(PARSER2)
clean:
rm -rf src/core src/vendor src/include src/Makevars.in src/Makevars.ucrt src/Makevars.win src/config.h.in src/rinterface.c R/aaa-auto.R
git -C $(top_srcdir) reset --hard
.PHONY: all igraph force clean check check-cran check-rhub check-links install test
.NOTPARALLEL: