a portable and fast pairing-based cryptography library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mcl/common.mk

120 lines
2.4 KiB

10 years ago
GCC_VER=$(shell $(PRE)$(CC) -dumpversion)
UNAME_S=$(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS=Linux
endif
ifneq ($(UNAME_S),Darwin)
LDFLAGS += -lrt
endif
CP = cp -f
AR = ar r
MKDIR=mkdir -p
RM=rm -fr
CFLAGS_OPT+=-fomit-frame-pointer -DNDEBUG
ifeq ($(CXX),clang++)
CFLAGS_OPT+=-O3
else
ifeq ($(shell expr $(GCC_VER) \> 4.6.0),1)
CFLAGS_OPT+=-Ofast
else
CFLAGS_OPT+=-O3
endif
endif
CFLAGS_WARN=-Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith
CFLAGS+= -g
10 years ago
CFLAGS+=$(CFLAGS_WARN)
BIT?=64
ifeq ($(BIT),32)
CPU?=x86
else
ifeq ($(BIT),64)
CPU?=x64
endif
endif
ifeq ($(BIT),0)
BIT_OPT=
else
BIT_OPT=-m$(BIT)
endif
ifeq ($(MARCH),)
ifeq ($(shell expr $(GCC_VER) \> 4.2.1),1)
CFLAGS+=-march=native
endif
else
CFLAGS+=$(MARCH)
endif
DEBUG=1
ifeq ($(RELEASE),1)
DEBUG=0
endif
ifeq ($(DEBUG),0)
CFLAGS+=$(CFLAGS_OPT)
OBJDIR=release
OBJSUF=
else
ifeq ($(OS),Linux)
# LDFLAGS+=-rdynamic
10 years ago
endif
OBJDIR=debug
OBJSUF=d
endif
####################################################
LIB=$(TOPDIR)lib/libmcl$(OBJSUF).a
LDFLAGS += -lpthread -m$(BIT) -lgmp -lgmpxx -lcrypto
10 years ago
ifeq ($(MARCH),)
ifeq ($(BIT),64)
CFLAGS += -DMCL_USE_XBYAK
endif
10 years ago
endif
CFLAGS += -DMCL_USE_LLVM
10 years ago
10 years ago
####################################################
TOPDIR:=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))/
PARENTDIR:=$(realpath $(TOPDIR)../)/
EXTDIR:=$(PARENTDIR)cybozulib_ext/
CFLAGS+= -I$(TOPDIR)include -I$(PARENTDIR)cybozulib/include/ -I$(PARENTDIR)xbyak/ $(BIT_OPT) $(INC_DIR)
#LDFLAGS+= -L$(TOPDIR)lib $(BIT_OPT) -Wl,-rpath,'$$ORIGIN/../lib' $(LD_DIR)
LDFLAGS+= $(BIT_OPT)
10 years ago
MKDEP = sh -ec '$(PRE)$(CC) -MM $(CFLAGS) $< | sed "s@\($*\)\.o[ :]*@$(OBJDIR)/\1.o $@ : @g" > $@; [ -s $@ ] || rm -f $@; touch $@'
CLEAN=$(RM) $(TARGET) $(OBJDIR)
define UNIT_TEST
sh -ec 'for i in $(TARGET); do $$i|grep "ctest:name"; done' > result.txt
grep -v "ng=0, exception=0" result.txt || echo "all unit tests are ok"
endef
define SAMPLE_TEST
sh -ec 'for i in $(TARGET); do $$i; done'
endef
.SUFFIXES: .cpp .d .exe
$(OBJDIR)/%.o: %.cpp
$(PRE)$(CXX) -c $< -o $@ $(CFLAGS)
$(OBJDIR)/%.o: %.s
$(PRE)$(CXX) -c $< -o $@ $(CFLAGS)
10 years ago
$(OBJDIR)/%.d: %.cpp $(OBJDIR)
@$(MKDEP)
$(TOPDIR)bin/%$(OBJSUF).exe: $(OBJDIR)/%.o $(LIB)
10 years ago
$(PRE)$(CXX) $< -o $@ $(LIB) $(LDFLAGS)
10 years ago
OBJ=$(addprefix $(OBJDIR)/,$(SRC:.cpp=.o))
10 years ago
DEPEND_FILE=$(addprefix $(OBJDIR)/, $(SRC:.cpp=.d))
TEST_FILE=$(addprefix $(TOPDIR)bin/, $(SRC:.cpp=$(OBJSUF).exe))
.PHONY: test