-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
39 lines (27 loc) · 985 Bytes
/
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
SRC_DIR := ./src
SHORT_TEST_DIR := ./test/SHORTEXA
CC ?= clang
CFLAGS ?= -O3 -fstack-protector-all -D_FORTIFY_SOURCE=2
CFLAGS += -std=c11 -g -Wall -I${SRC_DIR} -L./
LDFLAGS += -lm
TARGET = libspacelib.so
SOURCES = $(wildcard $(SRC_DIR)/*.c)
HEADERS = $(wildcard $(SRC_DIR)/*.H)
LIB_OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(SRC_DIR)/%.o)
SHORT_TEST_SRC := $(wildcard $(SHORT_TEST_DIR)/*.c)
SHORT_TEST = $(SHORT_TEST_SRC:$(SHORT_TEST_DIR)/%.c=$(SHORT_TEST_DIR)/%)
.PHONY: all clean distclean test
all: $(TARGET)
$(LIB_OBJECTS) : %.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -fPIC -c -o $@ $<
$(TARGET) : $(LIB_OBJECTS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIB_OBJECTS) -fPIC -shared -Wl,-soname,${TARGET} -o $(TARGET)
$(SHORT_TEST) : %: %.c $(TARGET)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -fPIE -lspacelib -o $@ $<
test: $(SHORT_TEST)
clean:
@- $(RM) $(TARGET)
@- $(RM) $(LIB_OBJECTS)
@- $(RM) $(SHORT_TEST)
@- $(RM) rm -f $(SHORT_TEST_DIR)/*.tmp
distclean: clean