makefile 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #CXX=g++-8
  2. #CC=gcc-8
  3. AR=gcc-ar
  4. PLATFORM=$(shell uname -m)
  5. CXXFLAGS=-std=c++11
  6. CCFLAGS=-std=c99
  7. ARFLAGS=rcs
  8. BINDIR=bin
  9. SRCDIR=src
  10. TESTDIR=src/tests
  11. OBJDIR=obj
  12. LDFLAGS=-lpthread
  13. RXA=$(BINDIR)/randomx.a
  14. BINARIES=$(RXA) $(BINDIR)/benchmark $(BINDIR)/code-generator
  15. RXOBJS=$(addprefix $(OBJDIR)/,aes_hash.o argon2_ref.o dataset.o jit_compiler_x86.o soft_aes.o virtual_memory.o vm_interpreted.o allocator.o assembly_generator_x86.o instruction.o randomx.o superscalar.o vm_compiled.o vm_interpreted_light.o argon2_core.o blake2_generator.o instructions_portable.o reciprocal.o virtual_machine.o vm_compiled_light.o blake2b.o)
  16. ifeq ($(PLATFORM),amd64)
  17. RXOBJS += $(OBJDIR)/jit_compiler_x86_static.o
  18. CXXFLAGS += -maes
  19. endif
  20. ifeq ($(PLATFORM),x86_64)
  21. RXOBJS += $(OBJDIR)/jit_compiler_x86_static.o
  22. CXXFLAGS += -maes
  23. endif
  24. release: CXXFLAGS += -O3 -flto
  25. release: CCFLAGS += -O3 -flto
  26. release: LDFLAGS += -flto
  27. release: $(BINARIES)
  28. native: CXXFLAGS += -march=native -O3 -flto
  29. native: CCFLAGS += -march=native -O3 -flto
  30. native: $(BINARIES)
  31. nolto: CXXFLAGS += -O3
  32. nolto: CCFLAGS += -O3
  33. nolto: $(BINARIES)
  34. debug: CXXFLAGS += -g
  35. debug: CCFLAGS += -g
  36. debug: LDFLAGS += -g
  37. debug: $(BINARIES)
  38. profile: CXXFLAGS += -pg
  39. profile: CCFLAGS += -pg
  40. profile: LDFLAGS += -pg
  41. profile: $(BINDIR)/benchmark
  42. test: CXXFLAGS += -O0
  43. $(RXA): $(RXOBJS) | $(BINDIR)
  44. $(AR) $(ARFLAGS) $@ $(RXOBJS)
  45. $(OBJDIR):
  46. mkdir $(OBJDIR)
  47. $(BINDIR):
  48. mkdir $(BINDIR)
  49. $(OBJDIR)/benchmark.o: $(TESTDIR)/benchmark.cpp $(TESTDIR)/stopwatch.hpp \
  50. $(TESTDIR)/utility.hpp $(SRCDIR)/randomx.h $(SRCDIR)/blake2/endian.h
  51. $(CXX) $(CXXFLAGS) -pthread -c $< -o $@
  52. $(BINDIR)/benchmark: $(OBJDIR)/benchmark.o $(RXA)
  53. $(CXX) $(LDFLAGS) -pthread $< $(RXA) -o $@
  54. $(OBJDIR)/code-generator.o: $(TESTDIR)/code-generator.cpp $(TESTDIR)/utility.hpp \
  55. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  56. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  57. $(SRCDIR)/assembly_generator_x86.hpp $(SRCDIR)/superscalar.hpp \
  58. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/instruction.hpp \
  59. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/aes_hash.hpp \
  60. $(SRCDIR)/blake2/blake2.h $(SRCDIR)/program.hpp
  61. $(CXX) $(CXXFLAGS) -c $< -o $@
  62. $(BINDIR)/code-generator: $(OBJDIR)/code-generator.o $(RXA)
  63. $(CXX) $(LDFLAGS) $< $(RXA) -o $@
  64. $(OBJDIR)/aes_hash.o: $(SRCDIR)/aes_hash.cpp $(SRCDIR)/soft_aes.h $(SRCDIR)/intrin_portable.h | $(OBJDIR)
  65. $(OBJDIR)/argon2_ref.o: $(SRCDIR)/argon2_ref.c $(SRCDIR)/argon2.h $(SRCDIR)/argon2_core.h \
  66. $(SRCDIR)/blake2/blamka-round-ref.h $(SRCDIR)/blake2/blake2.h \
  67. $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h $(SRCDIR)/blake2/blake2-impl.h \
  68. $(SRCDIR)/blake2/blake2.h
  69. $(OBJDIR)/blake2b.o: $(SRCDIR)/blake2/blake2b.c $(SRCDIR)/blake2/blake2.h \
  70. $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h
  71. $(CC) $(CCFLAGS) -c $< -o $@
  72. $(OBJDIR)/dataset.o: $(SRCDIR)/dataset.cpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  73. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/dataset.hpp \
  74. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp \
  75. $(SRCDIR)/allocator.hpp $(SRCDIR)/virtual_memory.hpp $(SRCDIR)/superscalar.hpp \
  76. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/reciprocal.h $(SRCDIR)/argon2.h $(SRCDIR)/argon2_core.h \
  77. $(SRCDIR)/intrin_portable.h
  78. $(OBJDIR)/jit_compiler_x86.o: $(SRCDIR)/jit_compiler_x86.cpp $(SRCDIR)/jit_compiler_x86.hpp \
  79. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  80. $(SRCDIR)/jit_compiler_x86_static.hpp $(SRCDIR)/superscalar.hpp \
  81. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/blake2_generator.hpp \
  82. $(SRCDIR)/program.hpp $(SRCDIR)/reciprocal.h $(SRCDIR)/virtual_memory.hpp \
  83. $(SRCDIR)/instruction_weights.hpp
  84. $(OBJDIR)/jit_compiler_x86_static.o: $(SRCDIR)/jit_compiler_x86_static.S $(SRCDIR)/configuration.h \
  85. $(SRCDIR)/asm/program_prologue_linux.inc $(SRCDIR)/asm/program_xmm_constants.inc \
  86. $(SRCDIR)/asm/program_loop_load.inc $(SRCDIR)/asm/program_read_dataset.inc \
  87. $(SRCDIR)/asm/program_read_dataset_sshash_init.inc \
  88. $(SRCDIR)/asm/program_read_dataset_sshash_fin.inc \
  89. $(SRCDIR)/asm/program_loop_store.inc $(SRCDIR)/asm/program_epilogue_linux.inc \
  90. $(SRCDIR)/asm/program_epilogue_store.inc $(SRCDIR)/asm/program_sshash_load.inc \
  91. $(SRCDIR)/asm/program_sshash_prefetch.inc $(SRCDIR)/asm/program_sshash_constants.inc \
  92. $(SRCDIR)/asm/randomx_reciprocal.inc
  93. $(OBJDIR)/soft_aes.o: $(SRCDIR)/soft_aes.cpp $(SRCDIR)/soft_aes.h $(SRCDIR)/intrin_portable.h
  94. $(OBJDIR)/virtual_memory.o: $(SRCDIR)/virtual_memory.cpp $(SRCDIR)/virtual_memory.hpp
  95. $(OBJDIR)/vm_interpreted.o: $(SRCDIR)/vm_interpreted.cpp $(SRCDIR)/vm_interpreted.hpp \
  96. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  97. $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
  98. $(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
  99. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/reciprocal.h \
  100. $(SRCDIR)/instruction_weights.hpp
  101. $(OBJDIR)/allocator.o: $(SRCDIR)/allocator.cpp $(SRCDIR)/allocator.hpp $(SRCDIR)/intrin_portable.h \
  102. $(SRCDIR)/virtual_memory.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  103. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h
  104. $(OBJDIR)/assembly_generator_x86.o: $(SRCDIR)/assembly_generator_x86.cpp \
  105. $(SRCDIR)/assembly_generator_x86.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  106. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/reciprocal.h $(SRCDIR)/program.hpp \
  107. $(SRCDIR)/instruction.hpp $(SRCDIR)/superscalar.hpp $(SRCDIR)/superscalar_program.hpp \
  108. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/instruction_weights.hpp
  109. $(OBJDIR)/instruction.o: $(SRCDIR)/instruction.cpp $(SRCDIR)/instruction.hpp \
  110. $(SRCDIR)/blake2/endian.h $(SRCDIR)/common.hpp $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  111. $(SRCDIR)/instruction_weights.hpp
  112. $(OBJDIR)/randomx.o: $(SRCDIR)/randomx.cpp $(SRCDIR)/randomx.h $(SRCDIR)/dataset.hpp $(SRCDIR)/common.hpp \
  113. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/superscalar_program.hpp \
  114. $(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp \
  115. $(SRCDIR)/vm_interpreted.hpp $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp \
  116. $(SRCDIR)/intrin_portable.h $(SRCDIR)/vm_interpreted_light.hpp $(SRCDIR)/vm_compiled.hpp \
  117. $(SRCDIR)/vm_compiled_light.hpp $(SRCDIR)/blake2/blake2.h
  118. $(OBJDIR)/superscalar.o: $(SRCDIR)/superscalar.cpp $(SRCDIR)/configuration.h $(SRCDIR)/program.hpp \
  119. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/randomx.h $(SRCDIR)/instruction.hpp \
  120. $(SRCDIR)/superscalar.hpp $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/blake2_generator.hpp \
  121. $(SRCDIR)/intrin_portable.h $(SRCDIR)/reciprocal.h
  122. $(OBJDIR)/vm_compiled.o: $(SRCDIR)/vm_compiled.cpp $(SRCDIR)/vm_compiled.hpp \
  123. $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  124. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
  125. $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
  126. $(SRCDIR)/superscalar_program.hpp
  127. $(OBJDIR)/vm_interpreted_light.o: $(SRCDIR)/vm_interpreted_light.cpp \
  128. $(SRCDIR)/vm_interpreted_light.hpp $(SRCDIR)/vm_interpreted.hpp $(SRCDIR)/common.hpp \
  129. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  130. $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
  131. $(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
  132. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp
  133. $(OBJDIR)/argon2_core.o: $(SRCDIR)/argon2_core.c $(SRCDIR)/argon2_core.h $(SRCDIR)/argon2.h \
  134. $(SRCDIR)/blake2/blake2.h $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h
  135. $(OBJDIR)/blake2_generator.o: $(SRCDIR)/blake2_generator.cpp $(SRCDIR)/blake2/blake2.h \
  136. $(SRCDIR)/blake2/endian.h $(SRCDIR)/blake2_generator.hpp
  137. $(OBJDIR)/instructions_portable.o: $(SRCDIR)/instructions_portable.cpp $(SRCDIR)/common.hpp \
  138. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  139. $(SRCDIR)/intrin_portable.h
  140. $(OBJDIR)/reciprocal.o: $(SRCDIR)/reciprocal.c $(SRCDIR)/reciprocal.h
  141. $(OBJDIR)/virtual_machine.o: $(SRCDIR)/virtual_machine.cpp $(SRCDIR)/virtual_machine.hpp \
  142. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  143. $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/aes_hash.hpp $(SRCDIR)/blake2/blake2.h \
  144. $(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp
  145. $(OBJDIR)/vm_compiled_light.o: $(SRCDIR)/vm_compiled_light.cpp $(SRCDIR)/vm_compiled_light.hpp \
  146. $(SRCDIR)/vm_compiled.hpp $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/common.hpp \
  147. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/program.hpp \
  148. $(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp \
  149. $(SRCDIR)/dataset.hpp $(SRCDIR)/superscalar_program.hpp
  150. $(OBJDIR)/%.o: $(SRCDIR)/%.c
  151. $(CC) $(CCFLAGS) -c $< -o $@
  152. $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
  153. $(CXX) $(CXXFLAGS) -c $< -o $@
  154. $(OBJDIR)/%.o: $(SRCDIR)/%.S
  155. $(CXX) -x assembler-with-cpp -c $< -o $@
  156. clean:
  157. rm -f $(BINARIES) $(OBJDIR)/*.o