Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonicalize build targets and allow custom config #21

Merged
merged 1 commit into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
SRC ?= ./src
OUT ?= ./build
DISABLE_GPU ?= 1
DISABLE_JNI ?= 1

CFLAGS = -Os -fPIC -g
LDFLAGS = -lpthread

-include $(OUT)/local.mk

# FIXME: avoid hardcoded architecture flags. We might support advanced SIMD
# instructions for Intel and Arm later.
CFLAGS += -msse2

ifneq ("$(DISABLE_GPU)","1")
ifeq ("$(BUILD_GPU)","1")
include mk/opencl.mk
endif

ifneq ("$(DISABLE_JNI)","1")
ifeq ("$(BUILD_JNI)","1")
include mk/java.mk
endif

Expand All @@ -24,7 +24,7 @@ TESTS = \
pow_sse \
multi_pow_cpu

ifneq ("$(DISABLE_GPU)","1")
ifeq ("$(BUILD_GPU)","1")
TESTS += \
pow_cl \
multi_pow_gpu
Expand All @@ -35,7 +35,7 @@ TESTS := $(addprefix $(OUT)/test-, $(TESTS))
LIBS = libdcurl.so
LIBS := $(addprefix $(OUT)/, $(LIBS))

all: $(TESTS) $(LIBS)
all: config $(TESTS) $(LIBS)
.DEFAULT_GOAL := all

OBJS = \
Expand All @@ -45,13 +45,13 @@ OBJS = \
dcurl.o \
pow_sse.o

ifneq ("$(DISABLE_GPU)","1")
ifeq ("$(BUILD_GPU)","1")
OBJS += \
pow_cl.o \
clcontext.o
endif

ifneq ("$(DISABLE_JNI)","1")
ifeq ("$(BUILD_JNI)","1")
OBJS += \
jni/iri-pearldiver-exlib.o
endif
Expand Down Expand Up @@ -93,6 +93,8 @@ check: $(addsuffix .done, $(TESTS))

clean:
$(RM) -r $(OUT)
distclean: clean
$(RM) local.mk

include mk/common.mk
-include $(deps)
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ Reference Implementation (IRI).
* Build a shared library for IRI, generating object files in directory `build`
* Generate JNI header file from downloading from [latest JAVA source](https://github.com/chenwei-tw/iri/tree/feat/new_pow_interface)
```shell
$ make DISABLE_JNI=0
$ make BUILD_JNI=1
```
You can modify `build/local.mk` for custom build options.
Alternatively, you can specify conditional build as following:
```shell
$ make DISABLE_GPU=1 DISABLE_JNI=1
$ make BUILD_GPU=0 BUILD_JNI=1
```

# Test
* Make a test with GPU

```$ make check DISABLE_GPU=0```
* Test with GPU
```shell
$ make BUILD_GPU=1 check
```

* Expected Results

Expand Down
7 changes: 7 additions & 0 deletions mk/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ ifeq ($(UNAME_S),Darwin)
else
PRINTF = env printf
endif

config: $(OUT)/config-timestamp

$(OUT)/config-timestamp: $(OUT)/local.mk
$(Q)touch $@
$(OUT)/local.mk:
$(Q)cp -f mk/defs.mk $@
5 changes: 5 additions & 0 deletions mk/defs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Build OpenCL backend or not
BUILD_GPU ?= 0

# Build JNI glue as the bridge between dcurl and IRI
BUILD_JNI ?= 0