Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. OPENLIBM_HOME=$(abspath .)
  2. include ./Make.inc
  3. SUBDIRS = src $(ARCH) bsdsrc
  4. ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1)
  5. # Add ld80 directory on x86 and x64
  6. ifneq ($(filter $(ARCH),i387 amd64),)
  7. SUBDIRS += ld80
  8. else
  9. ifneq ($(filter $(ARCH),aarch64),)
  10. SUBDIRS += ld128
  11. else
  12. endif
  13. endif
  14. endif
  15. define INC_template
  16. TEST=test
  17. override CUR_SRCS = $(1)_SRCS
  18. include $(1)/Make.files
  19. SRCS += $$(addprefix $(1)/,$$($(1)_SRCS))
  20. endef
  21. DIR=test
  22. $(foreach dir,$(SUBDIRS),$(eval $(call INC_template,$(dir))))
  23. DUPLICATE_NAMES = $(filter $(patsubst %.S,%,$($(ARCH)_SRCS)),$(patsubst %.c,%,$(src_SRCS)))
  24. DUPLICATE_SRCS = $(addsuffix .c,$(DUPLICATE_NAMES))
  25. OBJS = $(patsubst %.f,%.f.o,\
  26. $(patsubst %.S,%.S.o,\
  27. $(patsubst %.c,%.c.o,$(filter-out $(addprefix src/,$(DUPLICATE_SRCS)),$(SRCS)))))
  28. # If we're on windows, don't do versioned shared libraries. Also, generate an import library
  29. # for the DLL. If we're on OSX, put the version number before the .dylib. Otherwise,
  30. # put it after.
  31. ifeq ($(OS), WINNT)
  32. OLM_MAJOR_MINOR_SHLIB_EXT := $(SHLIB_EXT)
  33. LDFLAGS_add += -Wl,--out-implib,libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT).a
  34. else
  35. ifeq ($(OS), Darwin)
  36. OLM_MAJOR_MINOR_SHLIB_EXT := $(SOMAJOR).$(SOMINOR).$(SHLIB_EXT)
  37. OLM_MAJOR_SHLIB_EXT := $(SOMAJOR).$(SHLIB_EXT)
  38. else
  39. OLM_MAJOR_MINOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR).$(SOMINOR)
  40. OLM_MAJOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR)
  41. endif
  42. LDFLAGS_add += -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
  43. endif
  44. .PHONY: all check test clean distclean \
  45. install install-static install-shared install-pkgconfig install-headers
  46. OLM_LIBS := libopenlibm.a
  47. ifneq ($(ARCH), wasm32)
  48. OLM_LIBS += libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  49. endif
  50. all : $(OLM_LIBS)
  51. check test: test/test-double test/test-float
  52. test/test-double
  53. test/test-float
  54. libopenlibm.a: $(OBJS)
  55. $(AR) -rcs libopenlibm.a $(OBJS)
  56. libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT): $(OBJS)
  57. $(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -o $@
  58. ifneq ($(OS),WINNT)
  59. ln -sf $@ libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
  60. ln -sf $@ libopenlibm.$(SHLIB_EXT)
  61. endif
  62. test/test-double: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  63. $(MAKE) -C test test-double
  64. test/test-float: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  65. $(MAKE) -C test test-float
  66. clean:
  67. rm -f aarch64/*.o amd64/*.o arm/*.o bsdsrc/*.o i387/*.o ld80/*.o ld128/*.o src/*.o powerpc/*.o mips/*.o s390/*.o
  68. rm -f libopenlibm.a libopenlibm.*$(SHLIB_EXT)*
  69. $(MAKE) -C test clean
  70. openlibm.pc: openlibm.pc.in Make.inc Makefile
  71. echo "prefix=${prefix}" > openlibm.pc
  72. echo "version=${VERSION}" >> openlibm.pc
  73. cat openlibm.pc.in >> openlibm.pc
  74. install-static: libopenlibm.a
  75. mkdir -p $(DESTDIR)$(libdir)
  76. cp -RpP -f libopenlibm.a $(DESTDIR)$(libdir)/
  77. install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  78. mkdir -p $(DESTDIR)$(shlibdir)
  79. cp -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
  80. install-pkgconfig: openlibm.pc
  81. mkdir -p $(DESTDIR)$(pkgconfigdir)
  82. cp -RpP -f openlibm.pc $(DESTDIR)$(pkgconfigdir)/
  83. install-headers:
  84. mkdir -p $(DESTDIR)$(includedir)/openlibm
  85. cp -RpP -f include/*.h $(DESTDIR)$(includedir)/openlibm
  86. cp -RpP -f src/*.h $(DESTDIR)$(includedir)/openlibm
  87. install: install-static install-shared install-pkgconfig install-headers