extconf.rb 968 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. if RUBY_PLATFORM == "java"
  2. # Don't do anything when run in JRuby; this allows gem installation to pass.
  3. # We need to write a dummy Makefile so that RubyGems doesn't think compilation
  4. # failed.
  5. File.open('Makefile', 'w') do |f|
  6. f.puts "all:"
  7. f.puts "\t@true"
  8. f.puts "install:"
  9. f.puts "\t@true"
  10. end
  11. exit 0
  12. elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
  13. # Maglev doesn't support C extensions, fall back to compiling an FFI usable
  14. # library
  15. File.open('Makefile', 'w') do |f|
  16. f.puts <<-MAKEFILE
  17. CFLAGS = -fPIC
  18. OBJS = bcrypt.o blowfish.o
  19. DLIB = bcrypt_ext.so
  20. OS ?= $(strip $(shell uname -s | tr '[:upper:]' '[:lower:]'))
  21. ifeq ($(OS),darwin)
  22. DLIB = bcrypt_ext.dylib
  23. CFLAGS += -dynamiclib
  24. endif
  25. all: $(OBJS)
  26. cc -shared -o $(DLIB) $(OBJS)
  27. install:
  28. install $(DLIB) "../../lib/"
  29. clean:
  30. $(RM) $(OBJS) bcrypt_ext.so
  31. MAKEFILE
  32. end
  33. exit 0
  34. else
  35. require "mkmf"
  36. dir_config("bcrypt_ext")
  37. create_makefile("bcrypt_ext")
  38. end