-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (46 loc) · 1.07 KB
/
Copy pathMakefile
File metadata and controls
60 lines (46 loc) · 1.07 KB
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
##
SHELL :=
SHELL := /bin/sh
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
LIB := libokapibss
TEST := testokapi
VERSION := 1.0.0
## CC
CC := gcc
OPTIMISE := -O2
DEBUG := -g
NOW := -Wall
CFLAGS := $(OPTIMISE) $(DEBUG) $(NOW)
RM := rm -f
## Make gcc happy when linking so file on X86_64
ifeq ($(uname_M),x86_64)
CFLAGS += -fPIC
endif
## Dependent files
BSS_LIB := -L${OKAPI_ROOT}/lib
I0_DEFS := ${OKAPI_ROOT}/bss_defs
MATH_LIBS := -lm
INCL_DIR = -I. -I$(I0_DEFS)
LIB_DIR = $(BSS_LIB)
LIB_OBJS = okapi-bss.o
TEST_OBJS = test-libokapi.o
ALL_HEAD = defs.h
ALL_LIBS := -li0+ $(MATH_LIBS)
## Targets
all: $(LIB) $(TEST)
$(LIB):$(LIB_OBJS)
$(CC) -shared $(CFLAGS) $(INCL_DIR) $(LIB_DIR) \
-Wl,-soname,$(LIB).so.1 -o $(LIB).so.$(VERSION) \
$(LIB_OBJS) $(ALL_LIBS)
$(TEST):$(TEST_OBJS) $(LIB)
$(CC) $(CFLAGS) $(INCL_DIR) $(LIB_DIR) -o $(TEST) \
${TEST_OBJS} $(LIB).so.$(VERSION) ${ALL_LIBS}
%.o:%.c
$(CC) $(CFLAGS) -c $<
install: $(LIB).so.$(VERSION)
cp $< /usr/lib;
ldconfig;
ln -sf /usr/lib/$(LIB).so.1 /usr/lib/$(LIB).so
.PHONEY: clean
clean:
$(RM) *.o *~*