Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. all: libopenlibm.a libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  44. check test: test/test-double test/test-float
  45. test/test-double
  46. test/test-float
  47. libopenlibm.a: $(OBJS)
  48. $(AR) -rcs libopenlibm.a $(OBJS)
  49. libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT): $(OBJS)
  50. $(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT) -o $@
  51. ifneq ($(OS),WINNT)
  52. ln -sf $@ libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
  53. ln -sf $@ libopenlibm.$(SHLIB_EXT)
  54. endif
  55. test/test-double: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  56. $(MAKE) -C test test-double
  57. test/test-float: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  58. $(MAKE) -C test test-float
  59. clean:
  60. rm -f aarch64/*.o amd64/*.o arm/*.o bsdsrc/*.o i387/*.o ld80/*.o ld128/*.o src/*.o powerpc/*.o mips/*.o s390/*.o
  61. rm -f libopenlibm.a libopenlibm.*$(SHLIB_EXT)*
  62. $(MAKE) -C test clean
  63. openlibm.pc: openlibm.pc.in Make.inc Makefile
  64. echo "prefix=${prefix}" > openlibm.pc
  65. echo "version=${VERSION}" >> openlibm.pc
  66. cat openlibm.pc.in >> openlibm.pc
  67. install-static: libopenlibm.a
  68. mkdir -p $(DESTDIR)$(libdir)
  69. cp -RpP -f libopenlibm.a $(DESTDIR)$(libdir)/
  70. install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  71. mkdir -p $(DESTDIR)$(shlibdir)
  72. cp -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
  73. install-pkgconfig: openlibm.pc
  74. mkdir -p $(DESTDIR)$(pkgconfigdir)
  75. cp -RpP -f openlibm.pc $(DESTDIR)$(pkgconfigdir)/
  76. install-headers:
  77. mkdir -p $(DESTDIR)$(includedir)/openlibm
  78. cp -RpP -f include/*.h $(DESTDIR)$(includedir)/openlibm
  79. cp -RpP -f src/*.h $(DESTDIR)$(includedir)/openlibm
  80. install: install-static install-shared install-pkgconfig install-headers