Makefile 2.9 KB

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