-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
41 lines (32 loc) · 924 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
40
41
CFLAGS += -O2 -Iinclude -std=c11 -Wall -Wextra -pedantic
CFLAGS += -Wunused -Wno-implicit-fallthrough -fpic
LDFLAGS += -Wl,--as-needed,-O2,-z,relro,-z,now -shared
LDLIBS += -lm
MAJOR := 0
MINOR := 1
NAME := oak
VERSION := $(MAJOR).$(MINOR)
TARGET := lib$(NAME).so.$(VERSION)
SRC := $(wildcard src/*.c)
OBJ := $(SRC:.c=.o)
DEP := $(OBJ:.o=.d)
all: $(TARGET)
cp $(TARGET) lib$(NAME).so
$(CC) main.c -I include -L$(shell pwd) -Wl,-rpath $(shell pwd) -l$(NAME) -lm -o $(NAME) -g
debug: all
debug: CFLAGS += -g -O0
debug: LDFLAGS += -g -O0
$(TARGET): $(OBJ)
$(CC) ${LDFLAGS} -o $@ $^
$(SRCS:.c=.d):%.d:%.c
$(CC) ${LDFLAGS} -o $@ $^
install:
cp $(TARGET) /usr/local/lib/$(TARGET)
ln -sf /usr/local/lib/$(TARGET) /usr/local/lib/lib$(NAME).so
rsync -av include/* /usr/local/include/oak/
ldconfig
cp $(NAME) /usr/local/bin/$(NAME)
clean:
${RM} ${TARGET} ${OBJ} $(SRC:.c=.d)
-include $(DEP)
.PHONY: all debug clean