-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
executable file
·55 lines (50 loc) · 1.43 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
44
45
46
47
48
49
50
51
52
53
54
55
CFLAGS = -g -O2 -Wall -Wextra -Isrc -rdynamic $(OPTFLAGS)
LDLIBS = $(OPTLIBS)
PREFIX ?= /usr/local
PROGRAMS_SRC = $(wildcard bin/**/*.c bin/*.c)
PROGRAMS = $(patsubst %.c,%,$(PROGRAMS_SRC))
SOURCES = $(wildcard src/**/*.c src/*.c)
OBJECTS =$(patsubst %.c,%.o,$(SOURCES))
TEST_SRC =$(wildcard test/**/*_tests.c test/*_tests.c)
TEST =$(patsubst %.c,%,$(TEST_SRC))
TARGET = build/libYOURLIBRARY.a
SO_TARGET =$(patsubst %.a,%.so,$(TARGET))
$(PROGRAMS): LDLIBS += $(TARGET)
#The TARGET build
all: $(TARGET) $(SO_TARGET) test program
dev:CFLAGS = -g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
dev:all
.PHONY: program
program: LDLIBS +=$(TARGET) -lm -lpthread
program: $(PROGRAMS)
$(TARGET):CFLAGS += -fPIC
$(TARGET): build $(OBJECTS)
ar rcs $@ $(OBJECTS)
ranlib $@
echo gay
$(SO_TARGET): $(TARGET) $(OBJECTS)
$(CC) -shared -o $@ $(OBJECTS)
build:
@mkdir -p build
@mkdir -p bin
#the UNIT TEST
.PHONY: test
test: LDLIBS +=$(TARGET) -lm
test: $(TEST)
sh ./test/test.sh
#the CLEANER
clean:
rm -rf build $(OBJECTS) $(TEST) $(PROGRAMS)
rm -f test/tests.log
#the Install
Install: all
Install -d $(DESTDIR)/$(PREFIX)/lib/
Install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/
#the checker:
check:
@echo Files with potentially dangerous functions
@egrep '[^_.a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)' $(SOURCES) || true
report: LDLIBS += $(TARGET) -lm
report: CFLAGS += -fPIC
report:
$(CC) $(CFLAGS) proc.c $(LDLIBS) -o proc