bitcoin/Makefile

92 lines
3 KiB
Makefile
Raw Normal View History

2013-04-01 02:52:58 -03:00
FLAGS_COMMON:=-Wall -Wno-unused -fPIC -std=c99
2013-03-30 23:17:44 -03:00
FLAGS_PROD:=-DNDEBUG -O2 -march=native
FLAGS_DEBUG:=-DVERIFY -ggdb3 -O1
FLAGS_TEST:=-DVERIFY -ggdb3 -O2 -march=native
2013-03-16 11:51:55 -03:00
2013-04-01 07:49:54 -03:00
SECP256K1_FILES := src/num.h src/field.h src/field_5x52.h src/group.h src/ecmult.h src/ecdsa.h \
2013-04-01 02:52:58 -03:00
src/num.c src/field.c src/field_5x52.c src/group.c src/ecmult.c src/ecdsa.c
2013-03-31 00:03:27 -03:00
JAVA_FILES := src/java/org_bitcoin_NativeSecp256k1.h src/java/org_bitcoin_NativeSecp256k1.c
2013-03-16 11:51:55 -03:00
ifndef CONF
CONF := gmp
endif
2013-04-01 07:49:54 -03:00
OBJS :=
2013-03-31 00:03:27 -03:00
2013-03-25 21:39:53 -03:00
default: all
ifeq ($(CONF), gmpgmp)
FLAGS_COMMON := $(FLAGS_COMMON) -DUSE_NUM_GMP -DUSE_FIELD_GMP
LIBS := -lgmp
SECP256K1_FILES := $(SECP256K1_FILES) src/num_gmp.h src/num_gmp.c src/field_gmp.c src/field_gmp.h
else
2013-04-01 19:10:14 -03:00
ifeq ($(CONF), gmp32)
FLAGS_COMMON := $(FLAGS_COMMON) -DUSE_NUM_GMP -DUSE_FIELD_10X26
LIBS := -lgmp
SECP256K1_FILES := $(SECP256K1_FILES) src/num_gmp.h src/num_gmp.c src/field_10x26.c src/field_10x26.h
else
2013-03-16 11:51:55 -03:00
ifeq ($(CONF), openssl)
2013-04-01 07:49:54 -03:00
FLAGS_COMMON := $(FLAGS_COMMON) -DUSE_NUM_OPENSSL -DUSE_FIELD_INV_BUILTIN
LIBS := -lcrypto
2013-04-01 02:52:58 -03:00
SECP256K1_FILES := $(SECP256K1_FILES) src/num_openssl.h src/num_openssl.c src/field_5x52_int128.c
2013-03-16 11:51:55 -03:00
else
ifeq ($(CONF), gmp)
2013-04-01 07:49:54 -03:00
FLAGS_COMMON := $(FLAGS_COMMON) -DUSE_NUM_GMP
LIBS := -lgmp
2013-04-01 02:52:58 -03:00
SECP256K1_FILES := $(SECP256K1_FILES) src/num_gmp.h src/num_gmp.c src/field_5x52_int128.c
2013-03-25 21:39:53 -03:00
else
ifeq ($(CONF), gmpasm)
2013-04-01 07:49:54 -03:00
FLAGS_COMMON := $(FLAGS_COMMON) -DUSE_NUM_GMP -DUSE_FIELD_5X52_ASM
LIBS := -lgmp
OBJS := $(OBJS) obj/field_5x52_asm.o
2013-04-01 02:52:58 -03:00
SECP256K1_FILES := $(SECP256K1_FILES) src/num_gmp.h src/num_gmp.c src/field_5x52_asm.c
2013-03-25 21:39:53 -03:00
2013-03-31 00:03:27 -03:00
obj/field_5x52_asm.o: src/field_5x52_asm.asm
yasm -f elf64 -o obj/field_5x52_asm.o src/field_5x52_asm.asm
2013-03-30 23:37:15 -03:00
else
2013-04-01 02:52:58 -03:00
SECP256K1_FILES := $(SECP256K1_FILES) src/field_5x52_int128.c
2013-03-25 21:39:53 -03:00
endif
2013-03-16 11:51:55 -03:00
endif
endif
2013-04-01 19:10:14 -03:00
endif
endif
2013-03-31 00:03:27 -03:00
2013-04-01 02:52:58 -03:00
all: src/*.c src/*.asm src/*.h include/*.h
2013-03-16 11:51:55 -03:00
+make CONF=openssl all-openssl
+make CONF=gmp all-gmp
+make CONF=gmpgmp all-gmpgmp
2013-04-01 19:10:14 -03:00
+make CONF=gmp32 all-gmp32
2013-03-25 21:39:53 -03:00
+make CONF=gmpasm all-gmpasm
2013-03-16 11:51:55 -03:00
clean:
+make CONF=openssl clean-openssl
+make CONF=gmp clean-gmp
2013-04-01 19:10:14 -03:00
+make CONF=gmp32 clean-gmp32
2013-03-25 21:39:53 -03:00
+make CONF=gmpasm clean-gmpasm
2013-03-16 11:51:55 -03:00
bench-any: bench-$(CONF)
tests-any: tests-$(CONF)
2013-03-31 00:03:27 -03:00
all-$(CONF): bench-$(CONF) tests-$(CONF) libsecp256k1-$(CONF).a
2013-03-16 11:51:55 -03:00
clean-$(CONF):
rm -f bench-$(CONF) tests-$(CONF) libsecp256k1-$(CONF).a libjavasecp256k1-$(CONF).so obj/*
2013-03-31 00:03:27 -03:00
2013-04-01 02:52:58 -03:00
obj/secp256k1-$(CONF).o: $(SECP256K1_FILES) src/secp256k1.c include/secp256k1.h
2013-04-01 07:49:54 -03:00
$(CC) $(FLAGS_COMMON) $(FLAGS_PROD) src/secp256k1.c -c -o obj/secp256k1-$(CONF).o
2013-03-16 11:51:55 -03:00
2013-04-01 19:10:14 -03:00
bench-$(CONF): $(OBJS) $(SECP256K1_FILES) src/bench.c
2013-04-01 07:49:54 -03:00
$(CC) $(FLAGS_COMMON) $(FLAGS_PROD) src/bench.c $(LIBS) $(OBJS) -o bench-$(CONF)
2013-03-16 11:51:55 -03:00
2013-04-01 19:10:14 -03:00
tests-$(CONF): $(OBJS) $(SECP256K1_FILES) src/tests.c
2013-04-01 07:49:54 -03:00
$(CC) $(FLAGS_COMMON) $(FLAGS_TEST) src/tests.c $(LIBS) $(OBJS) -o tests-$(CONF)
2013-04-01 07:49:54 -03:00
libsecp256k1-$(CONF).a: $(OBJS) obj/secp256k1-$(CONF).o
$(AR) -rs $@ $(OBJS) obj/secp256k1-$(CONF).o
2013-04-01 07:49:54 -03:00
libjavasecp256k1-$(CONF).so: $(OBJS) obj/secp256k1-$(CONF).o $(JAVA_FILES)
$(CC) $(FLAGS_COMMON) $(FLAGS_PROD) -I. src/java/org_bitcoin_NativeSecp256k1.c $(LIBS) $(OBJS) obj/secp256k1-$(CONF).o -shared -o libjavasecp256k1-$(CONF).so
java: libjavasecp256k1-$(CONF).so