2019-01-15 17:10:24 +00:00
|
|
|
objify = $(patsubst %.c,$(BUILD_DIR)/%.$2,$(patsubst %.s,$(BUILD_DIR)/%.$2,$1))
|
|
|
|
|
2019-01-30 16:17:20 +00:00
|
|
|
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)/
|
|
|
|
|
2019-01-15 17:10:24 +00:00
|
|
|
CFLAGS=-Wall -Wextra -Wpedantic -O3 -funroll-loops
|
|
|
|
LDFLAGS=
|
|
|
|
AR=ar rcs
|
|
|
|
RANLIB=ranlib
|
2019-01-30 16:17:20 +00:00
|
|
|
GOPATH=$(BUILD_DIR)
|
|
|
|
GO=go
|
|
|
|
IMPORT_PATH:=github.com/henrydcase/sidh_torture/csidh
|
2019-01-15 17:10:24 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2019-01-30 16:17:20 +00:00
|
|
|
all: libcsidh torturer
|
2019-01-15 17:10:24 +00:00
|
|
|
|
2019-01-30 16:17:20 +00:00
|
|
|
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
|
2019-01-16 17:20:24 +00:00
|
|
|
|
2019-01-15 17:10:24 +00:00
|
|
|
clean:
|
|
|
|
rm -rf build
|
2019-01-30 16:17:20 +00:00
|
|
|
rm -rf bin
|
|
|
|
|
|
|
|
torturer: $(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 $@
|