-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (48 loc) · 1.65 KB
/
Makefile
File metadata and controls
61 lines (48 loc) · 1.65 KB
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
# Compiler
CC = gcc
# Warning flags
WARN_FLAGS = -Wall -Wpointer-arith \
-Werror=vla -Wendif-labels \
-Wmissing-format-attribute -Wimplicit-fallthrough=3 \
-Wcast-function-type -Wshadow=compatible-local \
-Wformat-security -Wno-format-truncation \
-Wno-stringop-truncation -Wdate-time -Wformat \
-Werror=format-security -Werror=implicit-function-declaration
# Optimization and debugging flags
OPT_FLAGS = -std=gnu99 -O3 -g -flto=auto -ffat-lto-objects
# Security and hardening flags
SEC_FLAGS = -fno-strict-aliasing -fwrapv -fexcess-precision=standard \
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
-fstack-protector-strong -fstack-clash-protection \
-fcf-protection -D_FORTIFY_SOURCE=3
# Position independent code flags
PIC_FLAGS = -fPIC -fvisibility=hidden
# PostgreSQL
PG_VERSION ?= 17
PG_INCLUDE ?= /usr/include/postgresql
PG_INCLUDE_SERVER ?= $(PG_INCLUDE)/$(PG_VERSION)/server
PG_INCLUDE_INTERNAL ?= $(PG_INCLUDE)/internal
# TA-Lib paths
TALIB_SOURCE_DIR ?= ./ta-lib
TALIB_INCLUDE ?= $(TALIB_SOURCE_DIR)/include
TALIB_COMMON ?= $(TALIB_SOURCE_DIR)/src/ta_common
TALIB_FUNC ?= $(TALIB_SOURCE_DIR)/src/ta_func
# Include paths
INCLUDES = -I. -I./ -I$(PG_INCLUDE_SERVER) -I$(PG_INCLUDE_INTERNAL) \
-I/usr/include/libxml2 -I$(TALIB_INCLUDE) -I$(TALIB_COMMON)
# Preprocessor flags
CPPFLAGS = -D_GNU_SOURCE
# All compiler flags
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(SEC_FLAGS) $(PIC_FLAGS) \
$(INCLUDES) $(CPPFLAGS)
# Source files
SOURCE_DIR = src
SOURCES = $(SOURCE_DIR)/ta_pg.c $(TALIB_FUNC)/*.c $(TALIB_COMMON)/*.c
# Output
TARGET = ta_pg.so
# Build rule
$(TARGET): $(SOURCES)
$(CC) $(CFLAGS) -shared -o $@ $^
.PHONY: clean
clean:
rm -f $(TARGET)