-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (36 loc) · 1.23 KB
/
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
42
43
CC = gcc
CFLAGS = -Wall -Wextra -g
OFLAGS = -O3
SRC = src
LIB = target/build/libvec.o
TEST = test/test.c
libvec.so: $(SRC)/vec.c $(SRC)/vec.h
@printf "\e[32m Compiling\e[0m libvec v0.1.0\n"
@$(CC) $(CFLAGS) $(OFLAGS) -fPIC -shared -o $@ src/vec.c -lc
@printf " \e[32mFinished\e[0m release (optimized + debugflags)\n"
install: libvec.so
@printf "\e[32m Installing\e[0m libvec v0.1.0\n"
@cp libvec.so /usr/lib/
uninstall:
@printf "\e[32mUninstalling\e[0m libvec v0.1.0\n"
@rm -f /usr/lib/libvec.so
$(LIB): $(SRC)/vec.c $(SRC)/vec.h
@mkdir -p target/build
@printf "\e[32m Compiling\e[0m vec v0.1.0\n"
@$(CC) $(CFLAGS) -c $(SRC)/vec.c -o $@
test: $(LIB)
@mkdir -p target/test
@printf "\e[32m Compiling\e[0m test\n"
@$(CC) $(CFLAGS) $^ $(TEST) -o target/test/main
@printf " \e[32mFinished\e[0m debug (unoptimized + debugflags)\n"
@printf " \e[32mRunning\e[0m target/test/main\n"
@target/test/main
test_release: libvec.so $(TEST)
@mkdir -p target/test
@printf "\e[32m Compiling\e[0m test\n"
@$(CC) $(CFLAGS) -L. $^ -o target/test/main -lvec
@printf " \e[32mFinished\e[0m release (optimized + debugflags)\n"
@printf " \e[32mRunning\e[0m target/test/main\n"
@LD_LIBRARY_PATH=. target/test/main
clean:
@rm -Rf target/ *.so