os161.hostlib.mk 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #
  2. # OS/161 build environment: build a library for the compile host
  3. #
  4. # Usage:
  5. # TOP=../..
  6. # .include "$(TOP)/mk/os161.config.mk"
  7. # [defs go here]
  8. # .include "$(TOP)/mk/os161.hostlib.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. # HOST_CFLAGS Compile flags.
  17. #
  18. # Note that individual program makefiles should only *append* to
  19. # HOST_CFLAGS, not assign it. Otherwise stuff set by os161.config.mk
  20. # will get lost and bad things will happen.
  21. #
  22. # Because we only build static libs, we can't use and don't need
  23. # LDFLAGS or LIBS. (Shared libs would want these.)
  24. #
  25. # Note that there's no HOSTLIBDIR; host libs are always put in
  26. # $(TOOLDIR)/hostlib and do not end up in $(OSTREE).
  27. #
  28. _LIB_=lib$(LIB).a
  29. # We may want these directories created. (Used by os161.baserules.mk.)
  30. MKDIRS+=$(MYBUILDDIR)
  31. MKDIRS+=$(TOOLDIR)/hostlib
  32. # Default rule: create the program.
  33. # (In make the first rule found is the default.)
  34. all: $(MYBUILDDIR) .WAIT $(MYBUILDDIR)/$(_LIB_)
  35. # Now get rules to compile the SRCS.
  36. .include "$(TOP)/mk/os161.hostcompile.mk"
  37. # Further rules for libraries.
  38. #
  39. # Install: we can install into either $(INSTALLTOP) or $(OSTREE).
  40. # When building the whole system, we always install into the staging
  41. # area. We provide the same direct install that os161.prog.mk
  42. # provides; however, because it this doesn't relink anything using the
  43. # library it generally isn't a very useful thing to do. Hence the
  44. # warning.
  45. #
  46. # Note that we make a hard link instead of a copy by default to reduce
  47. # overhead.
  48. #
  49. install-staging: $(TOOLDIR)/hostlib .WAIT $(TOOLDIR)/hostlib/$(_LIB_)
  50. $(TOOLDIR)/hostlib/$(_LIB_): $(MYBUILDDIR)/$(_LIB_)
  51. rm -f $(.TARGET)
  52. ln $(MYBUILDDIR)/$(_LIB_) $(.TARGET) || \
  53. cp $(MYBUILDDIR)/$(_LIB_) $(.TARGET)
  54. install:
  55. @echo "Nothing to manually install"
  56. # Build the library.
  57. $(MYBUILDDIR)/$(_LIB_): $(HOST_OBJS)
  58. rm -f $(.TARGET)
  59. $(HOST_AR) -cq $(.TARGET) $(HOST_OBJS)
  60. $(HOST_RANLIB) $(.TARGET)
  61. # Mark targets that don't represent files PHONY, to prevent various
  62. # lossage if files by those names appear.
  63. .PHONY: all install-staging install
  64. # Finally, get the shared definitions for the most basic rules.
  65. .include "$(TOP)/mk/os161.baserules.mk"
  66. # End.