-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (26 loc) · 708 Bytes
/
Makefile
File metadata and controls
37 lines (26 loc) · 708 Bytes
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
PROJECT := clib
CC := gcc
CFLAGS := -MMD -MP -Wall -Wextra -Wpedantic -fPIC
# For out of source build
BUILD_DIR := build
MKDIR_P := mkdir -p
RM := rm -rfv
SRCS_C := clib.c
OBJS := $(SRCS_C:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
all: $(BUILD_DIR)/lib$(PROJECT).so
@echo "===================="
@echo "Running with Python2"
python clib.py
@echo "===================="
@echo "Running with Python3"
python3 clib.py
$(BUILD_DIR)/lib$(PROJECT).so: $(BUILD_DIR)/clib.c.o
$(CC) -shared -o $@ $^
$(BUILD_DIR)/%.c.o: %.c
@if [ ! -d "$(dir $@)" ]; then $(MKDIR_P) $(dir $@); fi
$(CC) $(CFLAGS) -c -o $@ $<
.PHONY: clean
clean:
$(RM) $(BUILD_DIR)/lib$(PROJECT).so $(OBJS) $(DEPS)
-include $(DEPS)