forked from brhamon/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (67 loc) · 2.05 KB
/
Makefile
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
DE ?= 440
ASTRO_PATH = ~/.astro
JPLEPH_LINK = $(ASTRO_PATH)/JPLEPH
export NOVAS_CDIST = novasc3.1
NOVAS_URL = https://ascl.net/assets/codes/NOVAS/$(NOVAS_CDIST).zip
NOVAS_ZIP := $(shell basename $(NOVAS_URL))
CURLOPTS = --connect-timeout 20 --no-keepalive
ifeq ($(DE),440)
DE_URL := ftp://ssd.jpl.nasa.gov/pub/eph/planets/Linux/de440/linux_p1550p2650.440
DE_CKSUM = 29915576d0a6555766b99485ac3056ee415e86df4fce282611c31afb329ad062
else
ifeq ($(DE),430)
DE_URL := ftp://ssd.jpl.nasa.gov/pub/eph/planets/Linux/de430/linux_p1550p2650.430
DE_CKSUM = 0deb23ca9269496fcbab9f84bec9f3f090e263bfb99c62428b212790721de126
else
ifeq ($(DE),431)
DE_URL := ftp://ssd.jpl.nasa.gov/pub/eph/planets/Linux/de431/lnxm13000p17000.431
DE_CKSUM = fe3d0323d26ada11f8d8228fda9ca590c7eb00cee8b22dff1839f74f5be71149
else
$(error Unsupported DE)
endif
endif
endif
DE_FILE := $(shell basename $(DE_URL))
.PHONY: astro_path clean veryclean
all: $(JPLEPH_LINK) .Cdist.is_patched
make -C ephutil && \
make -C planets && \
make -C tropical
clean:
-make -C ephutil clean
-make -C planets clean
-make -C tropical clean
veryclean: clean
-rm -f .Cdist.is_patched $(DE_FILE) $(JPLEPH_LINK) $(NOVAS_ZIP)
-rm -fr $(NOVAS_CDIST)
astro_path:
mkdir -p $(ASTRO_PATH)
$(DE_FILE):
@echo "Downloading $@"
curl $(CURLOPTS) -O $(DE_URL)
@if [ ! -f $@ ]; then \
echo "Problem downloading $@" && false; \
elif [ "$$(sha256sum $(DE_FILE) | cut -f1 -d' ')" != "$(DE_CKSUM)" ]; then \
echo "$@ is corrupted" && false; \
fi
$(JPLEPH_LINK): astro_path $(DE_FILE)
ln -sf $$(readlink --canonicalize $(DE_FILE)) $@
.Cdist.is_patched: $(NOVAS_ZIP)
unzip $(NOVAS_ZIP)
@if [ ! -d $(NOVAS_CDIST) ]; then \
echo "Problem untarring $(NOVAS_ZIP)" && false; \
else \
echo "Patching NOVAS-C"; \
cd $(NOVAS_CDIST) && \
sed -ie '/[\r]$$/s/[\r]$$//' * && \
patch -p1 < ../support/novasc3.1-linux64.patch && \
cp ../support/Makefile.Cdist Makefile && \
cd .. && \
touch $@; \
fi
$(NOVAS_ZIP):
@echo "Reading NOVAS-C"
curl $(CURLOPTS) -O $(NOVAS_URL)
@if [ ! -f $@ ]; then \
echo "Problem downloading $@" && false; \
fi