-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (30 loc) · 717 Bytes
/
Copy pathMakefile
File metadata and controls
39 lines (30 loc) · 717 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
38
39
CC=gcc
AR=ar
CFLAGS= -Wall -O3 -fPIC -I./src
LDFLAGS=
OBJECTS=dstr.o
LIBRARY=libdstr
LIBRARY_A=$(LIBRARY).a
LIBRARY_SO=$(LIBRARY).so
vpath %.c ./src ./test
%.o: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
$(LIBRARY_A): $(OBJECTS)
$(AR) rcs $@ $(OBJECTS)
$(LIBRARY_SO): $(OBJECTS)
$(CC) -shared -Wl,-soname,$@.1 -o $@ $(OBJECTS)
static: $(LIBRARY_A)
shared: $(LIBRARY_SO)
install: $(LIBRARY_SO)
sudo install libdstr.so /usr/lib/libdstr.so.1
#Test target depends on libcunit (libcunit1-dev on debian/ubuntu)
test: $(LIBRARY_SO)
$(CC) $(CFLAGS) ./test/dstr_test.c -o dstr_test -L./ -ldstr -lcunit
run_tests: test
./dstr_test
all: static shared
clean:
rm -rf *.so
rm -rf *.a
rm -rf *.o
rm -rf dstr_test