os161.lib.mk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #
  2. # OS/161 build environment: build a library
  3. #
  4. # Usage:
  5. # TOP=../..
  6. # .include "$(TOP)/mk/os161.config.mk"
  7. # [defs go here]
  8. # .include "$(TOP)/mk/os161.lib.mk"
  9. # [any extra rules go here]
  10. #
  11. # Variables controlling this file:
  12. #
  13. # LIB Name of library. We create lib$(LIB).a.
  14. # SRCS .c and .S files to compile.
  15. #
  16. # CFLAGS Compile flags.
  17. #
  18. # LIBDIR Directory under $(OSTREE) to install into,
  19. # e.g. /lib. Should have a leading slash.
  20. #
  21. # Note that individual program makefiles should only *append* to
  22. # CFLAGS, not assign it. Otherwise stuff set by os161.config.mk will
  23. # get lost and bad things will happen.
  24. #
  25. # Because we only build static libs, we can't use and don't need
  26. # LDFLAGS, LIBS, or LIBDEPS. (Shared libs would want these.)
  27. #
  28. LIBDIR?=/lib
  29. _LIB_=lib$(LIB).a
  30. # We may want these directories created. (Used by os161.baserules.mk.)
  31. MKDIRS+=$(MYBUILDDIR)
  32. MKDIRS+=$(INSTALLTOP)$(LIBDIR)
  33. MKDIRS+=$(OSTREE)$(LIBDIR)
  34. # Default rule: create the program.
  35. # (In make the first rule found is the default.)
  36. all: $(MYBUILDDIR) .WAIT $(MYBUILDDIR)/$(_LIB_)
  37. # Now get rules to compile the SRCS.
  38. .include "$(TOP)/mk/os161.compile.mk"
  39. # Further rules for libraries.
  40. #
  41. # Install: we can install into either $(INSTALLTOP) or $(OSTREE).
  42. # When building the whole system, we always install into the staging
  43. # area. We provide the same direct install that os161.prog.mk
  44. # provides; however, because it this doesn't relink anything using the
  45. # library it generally isn't a very useful thing to do. Hence the
  46. # warning.
  47. #
  48. # Note that we make a hard link instead of a copy by default to reduce
  49. # overhead.
  50. #
  51. install-staging: $(INSTALLTOP)$(LIBDIR) .WAIT $(INSTALLTOP)$(LIBDIR)/$(_LIB_)
  52. $(INSTALLTOP)$(LIBDIR)/$(_LIB_): $(MYBUILDDIR)/$(_LIB_)
  53. rm -f $(.TARGET)
  54. ln $(MYBUILDDIR)/$(_LIB_) $(.TARGET) || \
  55. cp $(MYBUILDDIR)/$(_LIB_) $(.TARGET)
  56. install: $(OSTREE)$(LIBDIR) $(MYBUILDDIR)/$(_LIB_)
  57. @echo "Warning: manually installing library without relinking anything"
  58. rm -f $(OSTREE)$(LIBDIR)/$(_LIB_)
  59. ln $(MYBUILDDIR)/$(_LIB_) $(OSTREE)$(LIBDIR)/$(_LIB_) || \
  60. cp $(MYBUILDDIR)/$(_LIB_) $(OSTREE)$(LIBDIR)/$(_LIB_)
  61. # Build the library.
  62. $(MYBUILDDIR)/$(_LIB_): $(OBJS)
  63. rm -f $(.TARGET)
  64. $(AR) -cq $(.TARGET) $(OBJS)
  65. $(RANLIB) $(.TARGET)
  66. # Mark targets that don't represent files PHONY, to prevent various
  67. # lossage if files by those names appear.
  68. .PHONY: all install-staging install
  69. # Finally, get the shared definitions for the most basic rules.
  70. .include "$(TOP)/mk/os161.baserules.mk"
  71. # End.