-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (35 loc) · 1.01 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
ARCHIVE_NAME = cspice.tar.Z
ARCHIVE_URL = https://naif.jpl.nasa.gov/pub/naif/toolkit//C/PC_Linux_GCC_64bit/packages/$(ARCHIVE_NAME)
# directories
TARGET_DIR := ./priv
SRC_DIR := ./c_src
SPICE_SRC_DIR = $(SRC_DIR)/cspice
# compilation
CC = gcc
# Erlang headers
CFLAGS += -I$(ERTS_INCLUDE_DIR)
# General C flags
CFLAGS += -fPIC -finline-functions -Wall -Wmissing-prototypes
# C SPICE libraries
CFLAGS += -I$(SPICE_SRC_DIR)/include
LDFLAGS += -L$(SPICE_SRC_DIR)/lib -l:cspice.a -l:csupport.a
# ERFA libraries
LDFLAGS += -lerfa -lgmp
.PHONY: all
all: $(TARGET_DIR)/time.so $(TARGET_DIR)/ephemeris.so $(TARGET_DIR)/support.so
# NIFs compilation
$(TARGET_DIR)/%.so: $(SRC_DIR)/%.c $(SRC_DIR)/utils.h $(SPICE_SRC_DIR)/lib/cspice.a
mkdir -p $(@D)
$(CC) $(CFLAGS) -shared -o $@ $^ $(LDFLAGS)
$(SPICE_SRC_DIR)/lib/cspice.a:
rm -rf $(SPICE_SRC_DIR)
wget $(ARCHIVE_URL)
gzip -d $(ARCHIVE_NAME)
tar xfv cspice.tar
mv cspice $(SRC_DIR)
rm cspice.tar
# cleaning
.PHONY: clean
clean:
rm -rf $(TARGET_DIR)
rm -rf $(SPICE_SRC_DIR)