Makefile 1.47 KB
Newer Older
1 2 3 4
ifndef JAVA_HOME
    $(error JAVA_HOME is required. Invoke with 'make JAVA_HOME=/path/to/java/home')
endif

5
CFLAGS += -std=gnu11 -g -I $(JAVA_HOME)/include
Kunshan Wang's avatar
Kunshan Wang committed
6 7

ifndef OS
8 9 10 11 12
	uname := $(shell uname)
	ifeq ($(uname),Darwin)
		OS = OSX
    else ifeq ($(uname),Linux)
		OS = LINUX
Kunshan Wang's avatar
Kunshan Wang committed
13
    else
14
		$(error Unrecognized operating system $(uname). I currently only worked on OSX and Linux.)
Kunshan Wang's avatar
Kunshan Wang committed
15 16 17 18
    endif
endif

ifeq ($(OS),OSX)
19 20 21 22 23
	CFLAGS += -I $(JAVA_HOME)/include/darwin
	LDFLAGS += -L $(JAVA_HOME)/jre/lib/server -l jvm -rpath $(JAVA_HOME)/jre/lib/server -install_name '@rpath/libmurefimpl2start.so'
else ifeq ($(OS),LINUX)
	CFLAGS += -I $(JAVA_HOME)/include/linux
	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
24 25
endif

26
.PHONY: all
Kunshan Wang's avatar
Kunshan Wang committed
27
all: libs tests
28

Kunshan Wang's avatar
Kunshan Wang committed
29 30 31 32
.PHONY: libs
libs: libmurefimpl2start.so

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

35
../classpath.txt: ../build.sbt
Kunshan Wang's avatar
Kunshan Wang committed
36 37
	cd .. ; sbt makeClasspathFile

38 39 40
classpath.h: ../classpath.txt
	cp ../classpath.txt ./
	xxd -i classpath.txt ./classpath.h
41

Kunshan Wang's avatar
Kunshan Wang committed
42
.PHONY: tests
43
tests: test_client test_client2
Kunshan Wang's avatar
Kunshan Wang committed
44 45

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

48 49 50
test_client2: test_client2.c libmurefimpl2start.so
	$(CC) `./refimpl2-config --istart --cflags --libs` -o $@ $<

Kunshan Wang's avatar
Kunshan Wang committed
51
.PHONY: clean veryclean
52
clean:
53
	rm -f *.so test_client test_client2
Kunshan Wang's avatar
Kunshan Wang committed
54

55 56
veryclean: clean
	rm -f classpath.txt classpath.h ../classpath.txt