Makefile 3.1 KB

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