Skip to content

Commit

Permalink
Makefile: support LIBC and DESTDIR options.
Browse files Browse the repository at this point in the history
Fixes:#39

Signed-off-by: Jiale Zhang <[email protected]>
  • Loading branch information
jialez0 committed Dec 1, 2021
1 parent 64c12fb commit c4d34e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PROJDIR := $(shell readlink -f ..)
TOP_DIR := .
CUR_DIR := $(shell pwd)
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin

REDHATOS := $(shell cat /etc/redhat-release 2> /dev/null)
DEBIANOS := $(shell cat /etc/debian_version 2> /dev/null)
Expand All @@ -11,19 +10,20 @@ TARGET_DIR := ./target
BIN_NAME := attestation-agent

DEBUG ?=
MUSL ?=
LIBC ?=
KBC ?=
DESTDIR ?= $(PREFIX)/bin

ifdef KBC
feature := --no-default-features --features
endif

ifdef MUSL
ifeq ($(LIBC), musl)
MUSL_ADD := $(shell rustup target add x86_64-unknown-linux-musl)
ifneq ($(DEBIANOS),)
MUSL_INSTALL := $(shell sudo apt-get install -y musl-tools)
endif
MUSL_FLAG := --target x86_64-unknown-linux-musl
LIBC_FLAG := --target x86_64-unknown-linux-musl
TARGET_DIR := $(TARGET_DIR)/x86_64-unknown-linux-musl
endif

Expand All @@ -45,21 +45,20 @@ ifeq ($(KBC), eaa_kbc)
endif

build:
$(RUST_FLAGS) cargo build $(release) $(feature) $(KBC) $(MUSL_FLAG)
$(RUST_FLAGS) cargo build $(release) $(feature) $(KBC) $(LIBC_FLAG)

TARGET := $(TARGET_DIR)/$(BIN_NAME)

install:
install -D -m0755 $(TARGET) $(BINDIR)
install -D -m0755 $(TARGET) $(DESTDIR)

uninstall:
rm -f $(BINDIR)/$(BIN_NAME)
rm -f $(DESTDIR)/$(BIN_NAME)

clean:
cargo clean && rm -f Cargo.lock

help:
@echo "build: make [DEBUG=1] [MUSL=1] [KBC=xxx_kbc]"
@echo "KBC supported:"
@echo " sample_kbc"
@echo " offline_fs_kbc"
@echo "==========================Help============================="
@echo "build: make [DEBUG=1] [LIBC=(musl)] [KBC=xxx_kbc]"
@echo "install: make install [DESTDIR=/path/to/target] [LIBC=(musl)]"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ make KBC=sample_kbc

To build and install with musl, just run:
```shell
make MUSL=1 && make install
make LIBC=musl && make install
```

### Run
Expand Down

0 comments on commit c4d34e7

Please sign in to comment.