forked from evil218/tstools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.mak
75 lines (59 loc) · 1.64 KB
/
common.mak
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
SRCS := $(obj-y:%.o=%.c)
DEPS := $(obj-y:%.o=%.d)
ifeq ($(TYPE),lib)
ifeq ($(LIB),shared)
aim = $(LIB_SHARED)
ifeq ($(SYS),LINUX)
LIB_SHARED = lib$(NAME).so.$(VMAJOR).$(VMINOR).$(VPATCH)
SONAME = lib$(NAME).so.$(VMAJOR)
else # CYGWIN or WINDOWS
LIB_SHARED = lib$(NAME)-$(VMAJOR).$(VMINOR).$(VPATCH).dll
IMPLIBNAME = lib$(NAME).dll.a
endif
else
aim = $(LIB_STATIC)
LIB_STATIC = lib$(NAME).a
endif
else # exe
aim = $(NAME)$(EXE)
endif
all: $(aim)
$(LIB_STATIC): $(obj-y)
$(AR)$@ $(obj-y); $(if $(RANLIB),$(RANLIB) $@)
$(LIB_SHARED): $(obj-y)
$(LD)$@ $(obj-y) $(LDFLAGS) $(SOFLAGS)
ifneq ($(SONAME),) # for other program to link
ln -fs $(LIB_SHARED) lib$(NAME).so
endif
$(NAME)$(EXE): $(obj-y)
$(LD)$@ $(obj-y) $(LDFLAGS)
doc: doc/$(NAME).html
test_$(NAME)$(EXE): test/test_$(NAME).c $(LIB_SHARED)
$(CC) -o $@ $< -I. -L. -l$(NAME)
# use '@' for "gcc -c" to avoid output
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
# depend
%.d: %.c
@$(CC) -MM $(CFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
sinclude $(DEPS)
# lib or exe
ifeq ($(TYPE),lib)
include ../common_lib.mak
else
include ../common_exe.mak
endif
# splint
lint: $(SRCS)
@echo -----------------------------------------------------------
-splint $(LINTFLAGS) $(INCDIRS) $(SRCS)
lintw: $(SRCS)
@echo -----------------------------------------------------------
-splint -weak $(LINTFLAGS) $(INCDIRS) $(SRCS)
lintc: $(SRCS)
@echo -----------------------------------------------------------
-splint -checks $(LINTFLAGS) $(INCDIRS) $(SRCS)
lints: $(SRCS)
@echo -----------------------------------------------------------
-splint -strict $(LINTFLAGS) $(INCDIRS) $(SRCS)
.PHONY: all clean install uninstall