aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 1e221d359aebf6e18a1557f54249f54d92735de3 (plain) (blame)
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
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.


# The package path prefix, if you want to install to another root, set DESTDIR to that root
PREFIX ?= /usr
# The library path excluding prefix
LIB ?= /lib
# The resource path excluding prefix
DATA ?= /share
# The library path including prefix
LIBDIR ?= $(PREFIX)$(LIB)
# The resource path including prefix
DATADIR ?= $(PREFIX)$(DATA)
# The generic documentation path including prefix
DOCDIR ?= $(DATADIR)/doc
# The info manual documentation path including prefix
INFODIR ?= $(DATADIR)/info
# The license base path including prefix
LICENSEDIR ?= $(DATADIR)/licenses

# The name of the package as it should be installed
PKGNAME = libgammamm



# The version of the library.
LIB_MAJOR = 1
LIB_MINOR = 0
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)

# The so in libgammamm.so as the library file is named on Linux
ifeq ($(PLATFORM),w32)
SO = dll
else
ifeq ($(PLATFORM),osx)
SO = dylib
else
SO = so
endif
endif

# Platform dependent flags
ifeq ($(PLATFORM),w32)
SHARED = -mdll
LDSO = -Wl,-soname,libgammamm.$(SO).$(LIB_MAJOR)
PIC =
else
ifeq ($(PLATFORM),osx)
SHARED = -dynamiclib
LDSO =
PIC = -fPIC
else
SHARED = -shared
LDSO = -Wl,-soname,libgammamm.$(SO).$(LIB_MAJOR)
PIC = -fPIC
endif
endif

# The C standard for C code compilation
STD = c++11
# Optimisation settings for C code compilation
OPTIMISE ?= -Og -g
# Definitions for CPP, remove __GCC__ if you are not using g++
DEFS = __GCC__

# Warning flags, set to empty if you are not using GCC
WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self       \
       -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow             \
       -Wmissing-declarations -Wredundant-decls -Winline -Wno-variadic-macros  \
       -Weffc++ -Wc++11-compat -Wzero-as-null-pointer-constant -Wuseless-cast  \
       -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow  \
       -Wundef -Wcast-qual -Wwrite-strings -Wlogical-op                        \
       -Wpacked -Wvector-operation-performance -Wsuggest-attribute=const       \
       -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure                   \
       -Wsuggest-attribute=format -Wnormalized=nfkc -Wconversion               \
       -fstrict-aliasing -fstrict-overflow -fipa-pure-const -ftree-vrp         \
       -fstack-usage -funsafe-loop-optimizations
# ignored: -Waggregate-return



# Flags to use when compiling
CXX_FLAGS = $(foreach D,$(DEFS),-D$(D)) -std=$(STD) \
            $(OPTIMISE) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(WARN)

# Flags to use when linking
LD_FLAGS = -lgamma -std=$(STD) $(OPTIMISE) $(LDFLAGS) $(WARN)



.PHONY: all
all: bin/libgammamm.so bin/test

bin/libgammamm.so: obj/libgamma-error.o obj/libgamma-facade.o obj/libgamma-method.o
	@mkdir -p bin
	$(CXX) $(LD_FLAGS) $(SHARED) $(LDSO) -o $@ $^

bin/test: obj/test.o obj/libgamma-error.o obj/libgamma-facade.o obj/libgamma-method.o
	$(CXX) $(LD_FLAGS) -o $@ $^

obj/%.o: src/%.cc src/*.hh
	@mkdir -p obj
	$(CXX) $(CXX_FLAGS) -c -o $@ $<



.PHONY: clean
clean:
	-rm -r obj bin