Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. INC_PATH = inc
  2. SRC_PATH = src
  3. OBJ_PATH = obj
  4. BIN_PATH = bin
  5. CPP = g++
  6. CPPFLAGS = -g -Wall -DCHECK -I$(INC_PATH)
  7. CC = gcc
  8. CFLAGS = -std=c99 -O3 -fomit-frame-pointer -I$(INC_PATH)
  9. LDFLAGS = -lm
  10. all: $(BIN_PATH) $(OBJ_PATH) as check c
  11. $(BIN_PATH):
  12. mkdir -p $@
  13. $(OBJ_PATH):
  14. mkdir -p $@
  15. C_BIN += $(BIN_PATH)/bilintest-c
  16. C_BIN += $(BIN_PATH)/speedtest-c
  17. c: $(C_BIN)
  18. AS_BIN += $(BIN_PATH)/bilintest-as
  19. AS_BIN += $(BIN_PATH)/speedtest-as
  20. AS_BIN += $(BIN_PATH)/test_curvepoint_multiscalar-as
  21. AS_BIN += $(BIN_PATH)/test_twistpoint_multiscalar-as
  22. as: $(AS_BIN)
  23. CHECK_BIN += $(BIN_PATH)/bilintest-check
  24. CHECK_BIN += $(BIN_PATH)/speedtest-check
  25. CHECK_BIN += $(BIN_PATH)/test_curvepoint_multiscalar-check
  26. CHECK_BIN += $(BIN_PATH)/test_twistpoint_multiscalar-check
  27. check: $(CHECK_BIN)
  28. COMMON_OBJ += $(OBJ_PATH)/linefunction_c.o
  29. COMMON_OBJ += $(OBJ_PATH)/optate_c.o
  30. COMMON_OBJ += $(OBJ_PATH)/fpe_c.o
  31. COMMON_OBJ += $(OBJ_PATH)/fp2e_c.o
  32. COMMON_OBJ += $(OBJ_PATH)/fp6e_c.o
  33. COMMON_OBJ += $(OBJ_PATH)/fp12e_c.o
  34. COMMON_OBJ += $(OBJ_PATH)/curvepoint_fp_c.o
  35. COMMON_OBJ += $(OBJ_PATH)/twistpoint_fp2_c.o
  36. COMMON_OBJ += $(OBJ_PATH)/final_expo_c.o
  37. COMMON_OBJ += $(OBJ_PATH)/scalar_c.o
  38. COMMON_OBJ += $(OBJ_PATH)/parameters_c.o
  39. COMMON_OBJ += $(OBJ_PATH)/mul_c.o
  40. COMMON_OBJ += $(OBJ_PATH)/mydouble_c.o
  41. COMMON_AS_OBJ += $(patsubst %_c.o, %_c_with_as.o, $(COMMON_OBJ))
  42. CHECK_SRC += $(patsubst $(OBJ_PATH)/%_c.o, $(SRC_PATH)/%.c, $(COMMON_OBJ))
  43. $(BIN_PATH)/bilintest-check: $(SRC_PATH)/bilintest.c $(CHECK_SRC)
  44. $(CPP) $(CPPFLAGS) -DNTESTS=20 -o $@ $^
  45. $(BIN_PATH)/bilintest-c: $(SRC_PATH)/bilintest.c $(COMMON_OBJ)
  46. $(CC) $(CFLAGS) -DNTESTS=1000 -o $@ $^ $(LDFLAGS)
  47. $(BIN_PATH)/bilintest-as: $(SRC_PATH)/bilintest.c $(COMMON_AS_OBJ) $(OBJ_PATH)/asfunctions.a
  48. $(CC) $(CFLAGS) -no-pie -DQHASM -DNTESTS=1000000 -o $@ $^ $(LDFLAGS)
  49. $(BIN_PATH)/speedtest-check: $(SRC_PATH)/speedtest.c $(CHECK_SRC)
  50. $(CPP) $(CPPFLAGS) -o $@ $^
  51. $(BIN_PATH)/speedtest-c: $(SRC_PATH)/speedtest.c $(COMMON_OBJ)
  52. $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
  53. $(BIN_PATH)/speedtest-as: $(SRC_PATH)/speedtest.c $(COMMON_AS_OBJ) $(OBJ_PATH)/asfunctions.a
  54. $(CC) $(CFLAGS) -no-pie -DQHASM -o $@ $^ $(LDFLAGS)
  55. TEST_SRC += $(SRC_PATH)/fpe.c
  56. TEST_SRC += $(SRC_PATH)/scalar.c
  57. TEST_SRC += $(SRC_PATH)/parameters.c
  58. TEST_SRC += $(SRC_PATH)/mul.c
  59. TEST_SRC += $(SRC_PATH)/mydouble.c
  60. TEST_SRC += $(SRC_PATH)/heap_rootreplaced.s
  61. TEST_SRC += $(SRC_PATH)/index_heap.c
  62. TEST_SRC += $(SRC_PATH)/scalar_sub_nored.s
  63. CURVE_TEST_SRC += $(TEST_SRC)
  64. CURVE_TEST_SRC += $(SRC_PATH)/curvepoint_fp.c
  65. CURVE_TEST_SRC += $(SRC_PATH)/curvepoint_fp_multiscalar.c
  66. CURVE_TEST_AS_OBJ += $(patsubst $(SRC_PATH)/%.s, $(OBJ_PATH)/%_as.o, $(patsubst $(SRC_PATH)/%.c, $(OBJ_PATH)/%_c_with_as.o, $(CURVE_TEST_SRC)))
  67. TWIST_TEST_SRC += $(TEST_SRC)
  68. TWIST_TEST_SRC += $(SRC_PATH)/fp2e.c
  69. TWIST_TEST_SRC += $(SRC_PATH)/twistpoint_fp2.c
  70. TWIST_TEST_SRC += $(SRC_PATH)/twistpoint_fp2_multiscalar.c
  71. TWIST_TEST_AS_OBJ += $(patsubst $(SRC_PATH)/%.s, $(OBJ_PATH)/%_as.o, $(patsubst $(SRC_PATH)/%.c, $(OBJ_PATH)/%_c_with_as.o, $(TWIST_TEST_SRC)))
  72. $(BIN_PATH)/test_curvepoint_multiscalar-check: $(SRC_PATH)/test_curvepoint_multiscalar.c $(CURVE_TEST_SRC) $(OBJ_PATH)/asfunctions.a
  73. $(CPP) $(CPPFLAGS) -o $@ $^
  74. $(BIN_PATH)/test_curvepoint_multiscalar-as: $(SRC_PATH)/test_curvepoint_multiscalar.c $(CURVE_TEST_AS_OBJ) $(OBJ_PATH)/asfunctions.a
  75. $(CC) $(CFLAGS) -no-pie -DQHASM -o $@ $^ $(LDFLAGS)
  76. $(BIN_PATH)/test_twistpoint_multiscalar-check: $(SRC_PATH)/test_twistpoint_multiscalar.c $(TWIST_TEST_SRC) $(OBJ_PATH)/asfunctions.a
  77. $(CPP) $(CPPFLAGS) -o $@ $^
  78. $(BIN_PATH)/test_twistpoint_multiscalar-as: $(SRC_PATH)/test_twistpoint_multiscalar.c $(TWIST_TEST_AS_OBJ) $(OBJ_PATH)/asfunctions.a
  79. $(CC) $(CFLAGS) -no-pie -DQHASM -o $@ $^ $(LDFLAGS)
  80. AS_OBJ += $(OBJ_PATH)/fp2e_add2_as.o
  81. AS_OBJ += $(OBJ_PATH)/fp2e_sub2_as.o
  82. AS_OBJ += $(OBJ_PATH)/fp2e_double2_as.o
  83. AS_OBJ += $(OBJ_PATH)/fp2e_triple2_as.o
  84. AS_OBJ += $(OBJ_PATH)/fp2e_neg2_as.o
  85. AS_OBJ += $(OBJ_PATH)/fp2e_mul_as.o
  86. AS_OBJ += $(OBJ_PATH)/fp2e_mul_fpe_as.o
  87. AS_OBJ += $(OBJ_PATH)/fp2e_short_coeffred_as.o
  88. AS_OBJ += $(OBJ_PATH)/fp2e_add_as.o
  89. AS_OBJ += $(OBJ_PATH)/fp2e_sub_as.o
  90. AS_OBJ += $(OBJ_PATH)/fp2e_parallel_coeffmul_as.o
  91. AS_OBJ += $(OBJ_PATH)/fp2e_mulxi_as.o
  92. AS_OBJ += $(OBJ_PATH)/fp2e_double_as.o
  93. AS_OBJ += $(OBJ_PATH)/fp2e_triple_as.o
  94. AS_OBJ += $(OBJ_PATH)/fp2e_neg_as.o
  95. AS_OBJ += $(OBJ_PATH)/fp2e_conjugate_as.o
  96. AS_OBJ += $(OBJ_PATH)/fpe_mul_as.o
  97. AS_OBJ += $(OBJ_PATH)/fp2e_square_as.o
  98. AS_OBJ += $(OBJ_PATH)/consts_as.o
  99. $(OBJ_PATH)/asfunctions.a: $(AS_OBJ)
  100. rm -f $@
  101. ar cr $@ $^
  102. $(OBJ_PATH)/%_c.o: $(SRC_PATH)/%.c
  103. $(CC) $(CFLAGS) -c -o $@ $^
  104. $(OBJ_PATH)/%_c_with_as.o: $(SRC_PATH)/%.c
  105. $(CC) $(CFLAGS) -DQHASM -c -o $@ $^
  106. $(OBJ_PATH)/%_as.o: $(SRC_PATH)/%.s
  107. $(CC) $(CFLAGS) -fPIC -c -o $@ $^
  108. .PHONY: clean
  109. clean:
  110. -rm $(BIN_PATH)/*
  111. -rm $(OBJ_PATH)/*