-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
95 lines (81 loc) · 3.54 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
################################################################################
# LICENSE #
################################################################################
# This file is part of rss_ringoccs. #
# #
# rss_ringoccs is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# rss_ringoccs is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with rss_ringoccs. If not, see <https://www.gnu.org/licenses/>. #
################################################################################
# Author: Ryan Maguire #
# Date: Sepemtber 15, 2022 #
################################################################################
TARGET_LIB_SHARED := librssringoccs.so
TARGET_LIB_STATIC := librssringoccs.a
ifdef BUILD_STATIC
TARGET_LIB := $(TARGET_LIB_STATIC)
AR ?= ar
else
TARGET_LIB := $(TARGET_LIB_SHARED)
endif
BUILD_DIR := ./build
SRC_DIRS := ./src
LIBTMPL := ./libtmpl/libtmpl.a
CWARN := -Wall -Wextra -Wpedantic
CFLAGS := $(EXTRA_FLAGS) -I../ -I./ -O3 -fPIC -flto -DNDEBUG -c
LFLAGS := $(EXTRA_LFLAGS) -L./libtmpl/ -O3 -flto -shared
LFLAGS += -lm -l:libtmpl.a -l:libcspice.a -l:libcsupport.a
ifdef OMP
CFLAGS += -fopenmp
LFLAGS += -fopenmp
endif
SRCS := $(shell find $(SRC_DIRS) -name "*.c")
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
.PHONY: clean install uninstall all libtmpl
all: $(BUILD_DIR) $(TARGET_LIB) $(LIBTMPL)
$(TARGET_LIB_SHARED): $(OBJS) $(LIBTMPL)
@echo "Building librssringoccs.so ..."
@-$(CC) $(OBJS) $(LFLAGS) -o $@
$(TARGET_LIB_STATIC): $(OBJS) $(LIBTMPL)
@echo "Building librssringoccs.a ..."
@-$(AR) rcs $@ $(OBJS)
$(BUILD_DIR)/%.c.o: %.c $(LIBTMPL)
$(CC) $(CWARN) $(CFLAGS) $< -o $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)/src/csv_tools/
mkdir -p $(BUILD_DIR)/src/fresnel_kernel/
mkdir -p $(BUILD_DIR)/src/fresnel_transform/
mkdir -p $(BUILD_DIR)/src/history/
mkdir -p $(BUILD_DIR)/src/occultation_geometry/
mkdir -p $(BUILD_DIR)/src/reconstruction/
mkdir -p $(BUILD_DIR)/src/tau/
$(LIBTMPL):
$(MAKE) -C libtmpl/ BUILD_STATIC=1
clean:
rm -rf $(BUILD_DIR)
rm -f $(TARGET_LIB)
$(MAKE) -C libtmpl/ clean BUILD_STATIC=1
install:
mkdir -p /usr/local/lib/
mkdir -p /usr/local/include/rss_ringoccs/
cp -r ./include /usr/local/include/rss_ringoccs/
cp $(TARGET_LIB) /usr/local/lib/$(TARGET_LIB)
mkdir -p /usr/local/lib/
mkdir -p /usr/local/include/libtmpl/
cp -r ./libtmpl/include /usr/local/include/libtmpl/
uninstall:
rm -rf $(BUILD_DIR)
rm -f $(TARGET_LIB)
rm -rf /usr/local/include/rss_ringoccs/
rm -rf /usr/local/include/libtmpl/
rm -f /usr/local/lib/$(TARGET_LIB)
$(MAKE) -C libtmpl/ uninstall