Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. .PHONY: all check test clean distclean install
  23. all: libopenlibm.a libopenlibm.$(SHLIB_EXT)
  24. check test: test/test-double test/test-float
  25. test/test-double
  26. test/test-float
  27. libopenlibm.a: $(OBJS)
  28. $(AR) -rcs libopenlibm.a $(OBJS)
  29. libopenlibm.$(SHLIB_EXT): $(OBJS)
  30. ifeq ($(OS),WINNT)
  31. $(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -Wl,$(SONAME_FLAG),libopenlibm.$(SHLIB_EXT) -o libopenlibm.$(SHLIB_EXT)
  32. else
  33. $(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -Wl,$(SONAME_FLAG),libopenlibm.$(SHLIB_EXT).$(SOMAJOR) -o libopenlibm.$(SHLIB_EXT).$(SOMAJOR).$(SOMINOR)
  34. ln -sf libopenlibm.$(SHLIB_EXT).$(SOMAJOR).$(SOMINOR) libopenlibm.$(SHLIB_EXT).$(SOMAJOR)
  35. ln -sf libopenlibm.$(SHLIB_EXT).$(SOMAJOR).$(SOMINOR) libopenlibm.$(SHLIB_EXT)
  36. endif
  37. test/test-double: libopenlibm.$(SHLIB_EXT)
  38. $(MAKE) -C test test-double
  39. test/test-float: libopenlibm.$(SHLIB_EXT)
  40. $(MAKE) -C test test-float
  41. clean:
  42. rm -f amd64/*.o arm/*.o bsdsrc/*.o i387/*.o ld128/*.o ld80/*.o src/*.o
  43. rm -f libopenlibm.a libopenlibm.$(SHLIB_EXT)*
  44. $(MAKE) -C test clean
  45. openlibm.pc: openlibm.pc.in Make.inc Makefile
  46. echo "prefix=${prefix}" > openlibm.pc
  47. echo "version=${VERSION}" >> openlibm.pc
  48. cat openlibm.pc.in >> openlibm.pc
  49. install: all openlibm.pc
  50. mkdir -p $(DESTDIR)$(shlibdir)
  51. mkdir -p $(DESTDIR)$(pkgconfigdir)
  52. mkdir -p $(DESTDIR)$(includedir)/openlibm
  53. cp -f -a libopenlibm.$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
  54. cp -f -a libopenlibm.a $(DESTDIR)$(libdir)/
  55. cp -f -a include/*.h $(DESTDIR)$(includedir)/openlibm
  56. cp -f -a src/*.h $(DESTDIR)$(includedir)/openlibm
  57. cp -f -a openlibm.pc $(DESTDIR)$(pkgconfigdir)/