Skip to content
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
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ BUILD_DIR ?= ${CURDIR}/dist
PREFIX ?= /usr/local/bin

# Binary variables
URUNIT_BIN_DYNAMIC:= $(BUILD_DIR)/urunit_dynamic
URUNIT_BIN_STATIC := $(BUILD_DIR)/urunit_static
URUNIT_BIN_DYNAMIC := $(BUILD_DIR)/urunit_dynamic
URUNIT_BIN_DYNAMIC_DEBUG := $(BUILD_DIR)/urunit_dynamic_debug
URUNIT_BIN_STATIC := $(BUILD_DIR)/urunit_static
URUNIT_BIN_STATIC_DEBUG := $(BUILD_DIR)/urunit_static_debug

# Compiler variables
#? CC the compiler to use (default: gcc)
Expand Down Expand Up @@ -69,19 +71,33 @@ prepare: $(BUILD_DIR)
.PHONY: static
static: $(URUNIT_BIN_STATIC)

## static_debug Build urunit statically-linked for host arch enabling debug logs.
.PHONY: static_debug
static_debug: $(URUNIT_BIN_STATIC_DEBUG)

## dynamic Build urunit dynamically-linked for host arch.
.PHONY: dynamic
dynamic: $(URUNIT_BIN_DYNAMIC)

## dynamic_debug Build urunit dynamically-linked for host arch enabling debug logs.
.PHONY: dynamic_debug
dynamic_debug: $(URUNIT_BIN_DYNAMIC_DEBUG)

$(BUILD_DIR):
mkdir -p $@

$(URUNIT_BIN_DYNAMIC): $(URUNIT_SRC) | prepare
$(CC) $(CFLAGS) $(URUNIT_SRC) $(LDFLAGS) -o $@

$(URUNIT_BIN_DYNAMIC_DEBUG): $(URUNIT_SRC) | prepare
$(CC) $(CFLAGS) -DDEBUG $(URUNIT_SRC) $(LDFLAGS) -o $@

$(URUNIT_BIN_STATIC): $(URUNIT_SRC) | prepare
$(CC) $(CFLAGS) $(URUNIT_SRC) $(LDFLAGS) $(STATIC_LDFLAGS) -o $@

$(URUNIT_BIN_STATIC_DEBUG): $(URUNIT_SRC) | prepare
$(CC) $(CFLAGS) -DDEBUG $(URUNIT_SRC) $(LDFLAGS) $(STATIC_LDFLAGS) -o $@

## install Install urunit in PREFIX
.PHONY: install
install: $(INSTALL_DEPS)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ Building `urunit` is as simple as running `make`, but make sure that `make` and
a C compiler is installed. In particular:

- `make static`: builds `urunit` as a statically-linked binary
- `make static_debug`: builds `urunit` as a statically-linked binary enabling debug messages
- `make dynamic`: builds `urunit` as a dynamically-linked binary
- `make dynamic_debug`: builds `urunit` as a dynamically-linked binary enabling debug messages


> **NOTE**: The default build target is `make static`, hence running `make`
> will build `urunit` statically.
Expand Down
Loading
Loading