Makefile 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. If we're on OSX,
  23. # put the version number before the .dylib. Otherwise, put it after.
  24. ifeq ($(OS), WINNT)
  25. OLM_MAJOR_MINOR_SHLIB_EXT := $(SHLIB_EXT)
  26. else
  27. ifeq ($(OS), Darwin)
  28. OLM_MAJOR_MINOR_SHLIB_EXT := $(SOMAJOR).$(SOMINOR).$(SHLIB_EXT)
  29. OLM_MAJOR_SHLIB_EXT := $(SOMAJOR).$(SHLIB_EXT)
  30. else
  31. OLM_MAJOR_MINOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR).$(SOMINOR)
  32. OLM_MAJOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR)
  33. endif
  34. endif
  35. .PHONY: all check test clean distclean \
  36. install install-static install-shared install-pkgconfig install-headers
  37. all: libopenlibm.a libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  38. check test: test/test-double test/test-float
  39. test/test-double
  40. test/test-float
  41. libopenlibm.a: $(OBJS)
  42. $(AR) -rcs libopenlibm.a $(OBJS)
  43. libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT): $(OBJS)
  44. $(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT) -o $@
  45. ifneq ($(OS),WINNT)
  46. ln -sf $@ libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
  47. ln -sf $@ libopenlibm.$(SHLIB_EXT)
  48. endif
  49. test/test-double: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  50. $(MAKE) -C test test-double
  51. test/test-float: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  52. $(MAKE) -C test test-float
  53. clean:
  54. rm -f amd64/*.o arm/*.o bsdsrc/*.o i387/*.o ld128/*.o ld80/*.o src/*.o
  55. rm -f libopenlibm.a libopenlibm.*$(SHLIB_EXT)*
  56. $(MAKE) -C test clean
  57. openlibm.pc: openlibm.pc.in Make.inc Makefile
  58. echo "prefix=${prefix}" > openlibm.pc
  59. echo "version=${VERSION}" >> openlibm.pc
  60. cat openlibm.pc.in >> openlibm.pc
  61. install-static: libopenlibm.a
  62. mkdir -p $(DESTDIR)$(libdir)
  63. cp -f -a libopenlibm.a $(DESTDIR)$(libdir)/
  64. install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
  65. mkdir -p $(DESTDIR)$(shlibdir)
  66. cp -f -a libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
  67. install-pkgconfig: openlibm.pc
  68. mkdir -p $(DESTDIR)$(pkgconfigdir)
  69. cp -f -a openlibm.pc $(DESTDIR)$(pkgconfigdir)/
  70. install-headers:
  71. mkdir -p $(DESTDIR)$(includedir)/openlibm
  72. cp -f -a include/*.h $(DESTDIR)$(includedir)/openlibm
  73. cp -f -a src/*.h $(DESTDIR)$(includedir)/openlibm
  74. install: install-static install-shared install-pkgconfig install-headers