wangzhengquan
2020-05-25 ff31a5b78ebe4b4348ed7fd572941b23a87414c2
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
#
# Makefile for common library.
#
ROOT=..
PLATFORM=$(shell $(ROOT)/systype.sh)
INCLUDE+=-I./include
include $(ROOT)/Make.defines.$(PLATFORM)
 
LIBCOMMON = libusgcommon.a
DLIBCOMMON = libusgcommon.so
 
OBJS   = usg_common.o
 
all: $(LIBCOMMON)
 
test: test.c 
 
#static lib
$(LIBCOMMON):    $(OBJS)
    $(AR) rv $@ $?
    $(RANLIB) $@
 
#dynamic lib
$(DLIBCOMMON):    $(OBJS)
    $(CC) -fPIC -shared -o $@ $^
 
#PREFIX is environment variable, but if it is not set, then set default value
ifeq ($(PREFIX),)
    PREFIX := /usr/local
endif
 
# 使用方式: g++ test1.c  -lcommon
install: $(DLIBCOMMON) $(LIBCOMMON)
    sudo install -d $(PREFIX)/lib/
    sudo install -m 644 $^ $(PREFIX)/lib/
    sudo install -d $(PREFIX)/include/
    sudo install -m 644 include/* $(PREFIX)/include/
 
clean:
    rm -f *.o a.out core temp.* *.a *.so
 
# include $(ROOT)/Make.libapue.inc