Makefile 2.9 KB

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