-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (25 loc) · 923 Bytes
/
Makefile
File metadata and controls
37 lines (25 loc) · 923 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
# Remember to tweak these values after moving this `Makefile`.
SOURCE_DIR ?= $(PWD)
BUILD_DIR ?= $(PWD)/_build
CFLAGS += -I$(PWD)/include
OBJS = test_math.o lib_math.o
LIBS = libmath.so libmath.a
EXES = test_math_o test_math_so test_math_a
.PHONY: all clean
all: $(OBJS) $(LIBS) $(EXES)
clean:
cd $(BUILD_DIR); rm -f $(OBJS) $(LIBS) $(EXES)
test_math_o: test_math.o lib_math.o
cd $(BUILD_DIR); $(CC) -o $@ $^
test_math_so: test_math.o libmath.so
cd $(BUILD_DIR); $(CC) -o $@ $< -Wl,-rpath,. -L. -lmath
test_math_a: test_math.o libmath.a
cd $(BUILD_DIR); $(CC) -o $@ -static $< -L. -lmath
test_math.o:
cd $(BUILD_DIR); $(CC) $(CFLAGS) -o $@ -c $(SOURCE_DIR)/test/math.c
lib_math.o:
cd $(BUILD_DIR); $(CC) $(CFLAGS) -o $@ -c $(SOURCE_DIR)/src/math.c
libmath.so: lib_math.o
cd $(BUILD_DIR); $(CC) -o $@ -shared -fpic $(SOURCE_DIR)/src/math.c
libmath.a: lib_math.o
cd $(BUILD_DIR); $(AR) $(ARFLAGS) $@ $^