-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (33 loc) · 1.21 KB
/
Makefile
File metadata and controls
48 lines (33 loc) · 1.21 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
CC = gcc
AR = ar
CFLAGS = -std=gnu23 -O3 -Wall -Werror -Wextra -pedantic -march=native -mtune=native -fPIC
INCLUDES = -Iinclude/
SRC_FILES = $(shell find src/ -name "*.c")
TEST_FILES = $(shell find tests/ -name "*.c")
OBJ_FILES = $(SRC_FILES:src/%.c=build/obj/%.o)
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/obj
LIB_DIR = $(BUILD_DIR)
TEST_BUILD_DIR = $(BUILD_DIR)/tests
STATIC_LIB = $(LIB_DIR)/taskio.a
SHARED_LIB = $(LIB_DIR)/taskio.so
$(shell mkdir -p $(OBJ_DIR) $(TEST_BUILD_DIR))
all: $(STATIC_LIB) $(SHARED_LIB) $(TEST_FILES:tests/%.c=$(TEST_BUILD_DIR)/%.out)
all-debug: CFLAGS += -DTASKIO_TRACING_FEATURE
all-debug: all
$(OBJ_DIR)/%.o: src/%.c $(LIBUCONTEXT_TARGETS)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(STATIC_LIB): $(OBJ_FILES)
$(AR) rcs $@ $^
$(SHARED_LIB): $(OBJ_FILES)
$(CC) -shared -o $@ $^
$(TEST_BUILD_DIR)/%.out: tests/%.c $(STATIC_LIB) $(LIBUCONTEXT_TARGETS)
$(CC) $(CFLAGS) $(INCLUDES) $< $(STATIC_LIB) $(LIBUCONTEXT_TARGETS) -o $@
$(LIBUCONTEXT_TARGETS):
# split the target into directory and file path. This assumes that all
# targets directory/filename are built with $(MAKE) -C directory filename
$(MAKE) -C $(dir $@) $(notdir $@)
@true
clean:
rm -rf $(BUILD_DIR)