sidh-torture/csidh/Makefile

60 рядки
1.4 KiB
Makefile

objify = $(patsubst %.c,$(BUILD_DIR)/%.$2,$(patsubst %.s,$(BUILD_DIR)/%.$2,$1))
BUILD_DIR=build
BIN_DIR=bin
MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
PRJ_DIR = $(abspath $(dir $(MK_FILE_PATH)))
GOPATH_LOCAL = $(PRJ_DIR)/$(BUILD_DIR)/
CFLAGS=-Wall -Wextra -Wpedantic -O3 -funroll-loops
LDFLAGS=
AR=ar rcs
RANLIB=ranlib
GOPATH=$(BUILD_DIR)
GO=go
IMPORT_PATH:=github.com/henrydcase/sidh_torture/csidh
CODE_SRC_C = \
ref/csidh/rng.c \
ref/csidh/mont.c \
ref/csidh/csidh.c
CODE_SRC_S = \
ref/csidh/u512.s \
ref/csidh/fp.s
CODE_OBJ = \
$(call objify,$(CODE_SRC_C),o) \
$(call objify,$(CODE_SRC_S),o)
$(BUILD_DIR)/%.o: %.c
case $@ in */*) f=$@; mkdir -p $${f%/*} ;; esac
$(CC) -c -o $@ $< $(CFLAGS)
$(BUILD_DIR)/%.o: %.s
case $@ in */*) f=$@; mkdir -p $${f%/*} ;; esac
$(CC) -c -o $@ $< $(CFLAGS)
all: libcsidh torturer vector-creator
libcsidh: $(CODE_OBJ)
mkdir -p $(PRJ_DIR)/$(BIN_DIR)
$(AR) $(BIN_DIR)/libcsidh.a $^
$(RANLIB) $(BIN_DIR)/libcsidh.a
$(CC) -o $(BIN_DIR)/test_ref ref/test/main.c -L$(BIN_DIR) -lcsidh
clean:
rm -rf build
rm -rf bin
torturer: $(BUILD_DIR)/.ok
GOPATH=$(GOPATH_LOCAL) $(GO) install $(IMPORT_PATH)/cmd/$@
vector-creator: $(BUILD_DIR)/.ok
GOPATH=$(GOPATH_LOCAL) $(GO) install $(IMPORT_PATH)/cmd/$@
$(BUILD_DIR)/.ok:
mkdir -p "$(dir $(BUILD_DIR)/src/$(IMPORT_PATH))"
ln -s `pwd` "$(BUILD_DIR)/src/$(IMPORT_PATH)"
mkdir -p bin
ln -s `pwd`/bin $(BUILD_DIR)/bin
touch $@