-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (60 loc) · 1.53 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
68
69
70
71
72
73
74
75
76
77
OS = $(shell uname -s)
CC = gcc
ifeq ($(OS), Darwin)
JARSUFFIX=mac
endif
ifeq ($(OS), Linux)
JARSUFFIX=linux
endif
ifneq (,$(findstring WIN,$(OS)))
JARSUFFIX=win32
endif
# APIVERSION is used in soname
APIVERSION = 1
CFLAGS = -Os -g
CFLAGS += -fPIC
CFLAGS += -Wall
CFLAGS += -Wextra
LIBOBJS = test.o
STATICLIB = test.a
ifeq ($(OS), Darwin)
SHAREDLIB = test.dylib
SONAME = $(basename $(SHAREDLIB)).$(APIVERSION).dylib
CFLAGS := -DMACOSX -D_DARWIN_C_SOURCE $(CFLAGS)
else
ifeq ($(JARSUFFIX), win32)
SHAREDLIB = test.dll
else
SHAREDLIB = libtest.so
SONAME = $(SHAREDLIB).$(APIVERSION)
endif
endif
HEADERS = test.h
JAVA = java
# see http://code.google.com/p/jnaerator/
JNAERATOR = jnaerator-0.10-shaded.jar
JNAERATORBASEURL = http://jnaerator.googlecode.com/files/
.PHONY: all clean depend
all: $(STATICLIB) $(SHAREDLIB)
clean:
$(RM) $(LIBOBJS) $(STATICLIB) $(SHAREDLIB)
$(RM) -r build/ dist/
$(RM) _jnaerator.* java/test_$(OS).jar
depend:
makedepend -f$(MAKEFILE_LIST) -Y $(OBJS:.o=.c) 2>/dev/null
jnaerator-0.10-shaded.jar:
wget $(JNAERATORBASEURL)/$@ || curl -o $@ $(JNAERATORBASEURL)/$@
jar: $(SHAREDLIB) $(JNAERATOR)
$(JAVA) -jar $(JNAERATOR) -runtime JNAerator -mode StandaloneJar \
-library test $(SHAREDLIB) test.h \
-package org.getlantern.test -o . \
-libFile $(SHAREDLIB) -jar java/test_$(JARSUFFIX).jar
$(STATICLIB): $(LIBOBJS)
$(AR) crs $@ $?
$(SHAREDLIB): $(LIBOBJS)
ifeq ($(OS), Darwin)
$(CC) -dynamiclib -Wl,-install_name,$(SONAME) -o $@ $^
else
$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
endif
test.o: test.h