-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
60 lines (44 loc) · 1.31 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
CXXFLAGS+=-O3 -std=c++11 -fPIC -g
#CXX = clang++
CXX = g++
SSOPATH=$(shell pwd)/
CXXFLAGS+=-Iinc
# Project files
SOURCES = $(wildcard src/*.cpp)
OBJECTS = $(SOURCES:.cpp=.o)
#Dynamic Library
OS_NAME=$(shell uname -s)
ifeq ($(OS_NAME),Linux)
DYN_SUFFIX=.so
DYN_OPT=-shared -Wl,-soname,lib$(NAME).so
endif
ifeq ($(OS_NAME),Darwin)
DYN_SUFFIX=.dylib
DYN_OPT=-dynamiclib -install_name $(SSOPATH)lib/$(DYN_PRODUCT) -compatibility_version $(VERSION) -current_version $(VERSION)
endif
VERSION=1.0.0
NAME=Solar
STAT_PRODUCT=lib$(NAME).a
DYN_PRODUCT=lib$(NAME)$(DYN_SUFFIX)
LDFLAGS+=-Wl,-rpath -Wl,$(SSOPATH)/lib -L$(SSOPATH)/lib -lSolar
LDFLAGS+=-lSQuIDS -lgsl -lgslcblas
MAINS_SRC=$(wildcard mains/*.cpp)
MAINS=$(patsubst mains/%.cpp,bin/%.exe,$(MAINS_SRC))
.PHONY: all clean
# Compilation rules
all: $(STAT_PRODUCT) $(DYN_PRODUCT)
$(DYN_PRODUCT) : $(OBJECTS)
@echo Linking $(DYN_PRODUCT)
@$(CXX) $(DYN_OPT) $(LDFLAGS) -o $(DYN_PRODUCT) $(OBJECTS)
mv $(DYN_PRODUCT) $(SSOPATH)/lib/$(DYN_PRODUCT)
$(STAT_PRODUCT) : $(OBJECTS)
@echo Linking $(STAT_PRODUCT)
@$(AR) -rcs $(STAT_PRODUCT) $(OBJECTS)
mv $(STAT_PRODUCT) $(SSOPATH)/lib/$(STAT_PRODUCT)
bin/%.exe : mains/%.cpp
$(CXX) $(CXXFLAGS) $(CFLAGS) $< $(LDFLAGS) -o $@
mains : $(MAINS)
%.o : %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -fr src/*.o lib/* bin/* mains/*.o