Skip to content

Commit

Permalink
Clean up top-level build rules
Browse files Browse the repository at this point in the history
The ideal build system is modular and extensive. Directory mk/ is used
for placeholder of various build targets and helpers.
  • Loading branch information
jserv committed Mar 19, 2018
1 parent 029f58b commit 79b5419
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
18 changes: 4 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SRC ?= ./src
OUT ?= ./build
SRC := src

DISABLE_GPU ?= 1
DISABLE_JNI ?= 1

Expand Down Expand Up @@ -57,14 +58,11 @@ OBJS += \
endif

OBJS := $(addprefix $(OUT)/, $(OBJS))
deps := $(OBJS:%.o=%.o.d)

SHELL_HACK := $(shell mkdir -p $(OUT))
SHELL_HACK := $(shell mkdir -p $(addprefix $(OUT)/,jni))
#deps := $(OBJS:%.o=%.o.d)

$(OUT)/test-%.o: tests/test-%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -I src -c -MMD -MF $@.d $<
$(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) -c -MMD -MF $@.d $<

$(OUT)/%.o: $(SRC)/%.c
$(VECHO) " CC\t$@\n"
Expand All @@ -86,13 +84,5 @@ $(OUT)/test-multi_pow_%: tests/test-multi_pow_%.py $(OUT)/libdcurl.so
@cat $< >> $@
@chmod +x $@

$(OUT)/test-%.done: $(OUT)/test-%
$(Q)$(PRINTF) "*** Validating $< ***\n"
$(Q)./$< && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
check: $(addsuffix .done, $(TESTS))

clean:
$(RM) -r $(OUT)

include mk/common.mk
-include $(deps)
28 changes: 21 additions & 7 deletions mk/common.mk
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
# Always ensure directory build exist
SHELL_HACK := $(shell mkdir -p $(OUT))

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PRINTF = printf
else
PRINTF = env printf
endif

# Control the build verbosity
ifeq ("$(VERBOSE)","1")
Q :=
VECHO = @true
else
Q := @
VECHO = @printf
VECHO = @$(PRINTF)
endif

# dependency of source files
deps := $(OBJS:%.o=%.o.d)

# Test suite
PASS_COLOR = \e[32;01m
NO_COLOR = \e[0m
$(OUT)/test-%.done: $(OUT)/test-%
$(Q)$(PRINTF) "*** Validating $< ***\n"
$(Q)./$< && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
check: $(addsuffix .done, $(TESTS))

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PRINTF = printf
else
PRINTF = env printf
endif
clean:
$(RM) -r $(OUT)
1 change: 1 addition & 0 deletions mk/java.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ifndef CURL
$(error "curl is not available.")
endif

SHELL_HACK := $(shell mkdir -p $(addprefix $(OUT)/,jni))
SHELL_HACK := $(shell mkdir -p $(OUT)/com/iota/iri/hash)

GITHUB_REPO ?= chenwei-tw/iri/feat/new_pow_interface
Expand Down

0 comments on commit 79b5419

Please sign in to comment.