Makefile 1.48 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 43 44 45 46
classpath.txt: ../build.sbt
	cd .. ; sbt makeClasspathFile

classpath.h: classpath.txt
	xxd -i classpath.txt > classpath.h
47

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

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

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

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

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

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