Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. OPENLIBM_HOME=$(abspath .)
  2. include ./Make.inc
  3. SUBDIRS = src ld80 $(ARCH) bsdsrc
  4. define INC_template
  5. TEST=test
  6. override CUR_SRCS = $(1)_SRCS
  7. include $(1)/Make.files
  8. SRCS += $$(addprefix $(1)/,$$($(1)_SRCS))
  9. endef
  10. DIR=test
  11. $(foreach dir,$(SUBDIRS),$(eval $(call INC_template,$(dir))))
  12. DUPLICATE_NAMES = $(filter $(patsubst %.S,%,$($(ARCH)_SRCS)),$(patsubst %.c,%,$(src_SRCS)))
  13. DUPLICATE_SRCS = $(addsuffix .c,$(DUPLICATE_NAMES))
  14. OBJS = $(patsubst %.f,%.f.o,\
  15. $(patsubst %.S,%.S.o,\
  16. $(patsubst %.c,%.c.o,$(filter-out $(addprefix src/,$(DUPLICATE_SRCS)),$(SRCS)))))
  17. all: libopenlibm.a libopenlibm.$(SHLIB_EXT)
  18. $(MAKE) -C test
  19. libopenlibm.a: $(OBJS)
  20. $(AR) -rcs libopenlibm.a $(OBJS)
  21. libopenlibm.$(SHLIB_EXT): $(OBJS)
  22. $(CC) -shared $(OBJS) $(LDFLAGS) -Wl,$(SONAME_FLAG),libopenlibm.$(SHLIB_EXT).$(VERSION) -o libopenlibm.$(SHLIB_EXT).$(VERSION)
  23. @-ln -sf libopenlibm.$(SHLIB_EXT).$(VERSION) libopenlibm.$(SHLIB_EXT).$(word 1,$(VERSION_SPLIT)).$(word 2,$(VERSION_SPLIT))
  24. @-ln -sf libopenlibm.$(SHLIB_EXT).$(VERSION) libopenlibm.$(SHLIB_EXT).$(word 1,$(VERSION_SPLIT))
  25. @-ln -sf libopenlibm.$(SHLIB_EXT).$(VERSION) libopenlibm.$(SHLIB_EXT)
  26. clean:
  27. @for dir in $(SUBDIRS) .; do \
  28. rm -fr $$dir/*.o $$dir/*.a $$dir/*.$(SHLIB_EXT)*; \
  29. done
  30. distclean:
  31. -rm -f $(OBJS) *.a *.$(SHLIB_EXT) libopenlibm.*
  32. -$(MAKE) -C test clean
  33. install: all
  34. mkdir -p $(DESTDIR)$(libdir)
  35. mkdir -p $(DESTDIR)$(includedir)/openlibm
  36. cp -a libopenlibm.$(SHLIB_EXT)* libopenlibm.a $(DESTDIR)$(libdir)/
  37. cp -a src/openlibm.h $(DESTDIR)$(includedir)/
  38. cp -a include/*.h $(DESTDIR)$(includedir)/openlibm/
  39. ifneq ($(wildcard $(ARCH)/bsd_asm.h),)
  40. cp -a $(ARCH)/bsd_asm.h $(DESTDIR)$(includedir)/openlibm/
  41. endif
  42. ifneq ($(wildcard $(ARCH)/bsd_cdefs.h),)
  43. cp -a $(ARCH)/bsd_cdefs.h $(DESTDIR)$(includedir)/openlibm/
  44. endif