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 1bdb2c8 commit 829475e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
19 changes: 3 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SRC ?= ./src
OUT ?= ./build
SRC := src

CFLAGS = -Os -fPIC -g
LDFLAGS = -lpthread
Expand Down Expand Up @@ -57,14 +57,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 @@ -83,16 +80,6 @@ $(OUT)/test-multi_pow_%: tests/test-multi_pow_%.py $(OUT)/libdcurl.so
$(call py_prepare_cmd)
$(Q)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)
distclean: clean
$(RM) local.mk

include mk/common.mk
include mk/python.mk
-include $(deps)
32 changes: 24 additions & 8 deletions mk/common.mk
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
# 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

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PRINTF = printf
else
PRINTF = env printf
endif
$(OUT)/test-%.done: $(OUT)/test-%
$(Q)$(PRINTF) "*** Validating $< ***\n"
$(Q)./$< && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
check: $(addsuffix .done, $(TESTS))

config: $(OUT)/config-timestamp

$(OUT)/config-timestamp: $(OUT)/local.mk
$(Q)touch $@
$(OUT)/local.mk:
$(Q)cp -f mk/defs.mk $@

clean:
$(RM) -r $(OUT)
distclean: clean
$(RM) local.mk
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 829475e

Please sign in to comment.