-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile
67 lines (57 loc) · 1.6 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
56
57
58
59
60
61
62
63
64
65
66
67
major_version=2
version=$(major_version).0.1
LOCAL_DIR=/usr/local
LIB_DIR=$(LOCAL_DIR)/lib
INCLUDE_DIR=$(LOCAL_DIR)/include/statsd
CCFLAGS=
CFLAGS+=-Wall -g
LIBNAME=libstatsdclient.so
LIBFLAGS=
ifeq ($(OS),Windows_NT)
CCFLAGS += -soname=$(LIBNAME) -D WIN32
LIBFLAGS += -shared
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
CCFLAGS += -D AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
CCFLAGS += -D IA32
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CCFLAGS += -D LINUX
endif
ifeq ($(UNAME_S),Darwin)
CCFLAGS += -install_name $(LIBNAME) -D OSX
LIBFLAGS += -dynamiclib
else
LIBFLAGS += -shared
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
CCFLAGS += -D AMD64
endif
ifneq ($(filter %86,$(UNAME_P)),)
CCFLAGS += -D IA32
endif
ifneq ($(filter arm%,$(UNAME_P)),)
CCFLAGS += -D ARM
endif
endif
lib: libstatsdclient.so
all: test-client uptimed
uptimed: uptimed.o libstatsdclient.so
$(CC) -o uptimed uptimed.o -L . -lstatsdclient
test-client: libstatsdclient.so test-client.o
$(CC) -o test-client test-client.o -L . -lstatsdclient
libstatsdclient.so: statsd-client.c
$(CC) -fPIC -o $@.$(version) $(LIBFLAGS) $(CCFLAGS) $<
ln -sf $@.$(version) $@
install: lib
cp libstatsdclient.so.$(version) $(LIB_DIR)
ln -sf $(LIB_DIR)/libstatsdclient.so.$(version) $(LIB_DIR)/$(LIBNAME)
ln -sf $(LIB_DIR)/libstatsdclient.so.$(version) $(LIB_DIR)/$(LIBNAME).$(major_version)
mkdir -p $(INCLUDE_DIR)
cp statsd-client.h $(INCLUDE_DIR)
clean:
rm -f *.o *.so* test-client uptimed