Makefile 1.53 KB
Newer Older
1
CFLAGS += -std=gnu11
Kunshan Wang's avatar
Kunshan Wang committed
2

3 4 5 6
ifndef JAVA_HOME
    $(error JAVA_HOME is required. Invoke with 'make JAVA_HOME=/path/to/java/home')
endif

Kunshan Wang's avatar
Kunshan Wang committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
CFLAGS += -I $(JAVA_HOME)/include

ifndef OS
    uname := $(shell uname)
    ifeq ($(uname),Darwin)
	OS = OSX
    else
    ifeq ($(uname),Linux)
	OS = LINUX
    else
	$(error Unrecognized operating system $(uname). I currently only worked on OSX and Linux.)
    endif
    endif
endif

ifeq ($(OS),OSX)
    CFLAGS += -I $(JAVA_HOME)/include/darwin
Kunshan Wang's avatar
Kunshan Wang committed
24
    LDFLAGS += -L $(JAVA_HOME)/jre/lib/server -l jvm -rpath $(JAVA_HOME)/jre/lib/server -install_name '@rpath/libmurefimpl2start.so'
Kunshan Wang's avatar
Kunshan Wang committed
25 26 27 28
endif

ifeq ($(OS),LINUX)
    CFLAGS += -I $(JAVA_HOME)/include/linux
29
    LDFLAGS += -Wl,--no-as-needed -L $(JAVA_HOME)/jre/lib/amd64/server -l jvm -Wl,-rpath,$(JAVA_HOME)/jre/lib/amd64/server
Kunshan Wang's avatar
Kunshan Wang committed
30 31 32
endif


33
.PHONY: all
Kunshan Wang's avatar
Kunshan Wang committed
34
all: libs tests
35

Kunshan Wang's avatar
Kunshan Wang committed
36 37 38 39
.PHONY: libs
libs: libmurefimpl2start.so

libmurefimpl2start.so: refimpl2-start.c classpath.h
40 41
	$(CC) -fPIC -shared $(CFLAGS) -o $@ $< $(LDFLAGS)

Kunshan Wang's avatar
Kunshan Wang committed
42
../classpath.txt: ../build.sbt
Kunshan Wang's avatar
Kunshan Wang committed
43 44
	cd .. ; sbt makeClasspathFile

Kunshan Wang's avatar
Kunshan Wang committed
45 46 47
classpath.h: ../classpath.txt
	cp ../classpath.txt ./
	xxd -i classpath.txt ./classpath.h
48

Kunshan Wang's avatar
Kunshan Wang committed
49
.PHONY: tests
Kunshan Wang's avatar
Kunshan Wang committed
50
tests: test_client test_client2
Kunshan Wang's avatar
Kunshan Wang committed
51 52

test_client: test_client.c libmurefimpl2start.so
Kunshan Wang's avatar
Kunshan Wang committed
53
	$(CC) `./refimpl2-config --istart --cflags --libs` -o $@ $<
Kunshan Wang's avatar
Kunshan Wang committed
54

Kunshan Wang's avatar
Kunshan Wang committed
55 56 57
test_client2: test_client2.c libmurefimpl2start.so
	$(CC) `./refimpl2-config --istart --cflags --libs` -o $@ $<

Kunshan Wang's avatar
Kunshan Wang committed
58
.PHONY: clean veryclean
59 60

clean:
Kunshan Wang's avatar
Kunshan Wang committed
61
	rm *.so test_client test_client2
Kunshan Wang's avatar
Kunshan Wang committed
62 63

veryclean:
Kunshan Wang's avatar
Kunshan Wang committed
64
	rm *.so test_client test_client2 classpath.txt classpath.h
65
	rm ../classpath.txt