os161.prog.mk 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #
  2. # OS/161 build environment: build a program
  3. #
  4. # Usage:
  5. # TOP=../..
  6. # .include "$(TOP)/mk/os161.config.mk"
  7. # [defs go here]
  8. # .include "$(TOP)/mk/os161.prog.mk"
  9. # [any extra rules go here]
  10. #
  11. # Variables controlling this file:
  12. #
  13. # PROG Name of program to generate.
  14. # SRCS .c and .S files to compile.
  15. #
  16. # CFLAGS Compile flags.
  17. # LDFLAGS Link flags.
  18. # LIBS Libraries to link with.
  19. # LIBDEPS Full paths of LIBS for depending on.
  20. #
  21. # BINDIR Directory under $(OSTREE) to install into,
  22. # e.g. /bin. Should have a leading slash.
  23. #
  24. # Note that individual program makefiles should only *append* to
  25. # CFLAGS, LDFLAGS, LIBS, and LIBDEPS, not assign them. Otherwise stuff
  26. # set by os161.config.mk will get lost and bad things will happen.
  27. #
  28. # UW Mod
  29. .include "$(TOP)/mk/os161.uw-prog.mk"
  30. BINDIR?=/bin
  31. # We may want these directories created. (Used by os161.baserules.mk.)
  32. MKDIRS+=$(MYBUILDDIR)
  33. MKDIRS+=$(INSTALLTOP)$(BINDIR)
  34. MKDIRS+=$(OSTREE)$(BINDIR)
  35. # Default rule: create the program.
  36. # (In make the first rule found is the default.)
  37. all: $(MYBUILDDIR) .WAIT $(MYBUILDDIR)/$(PROG)
  38. # Now get rules to compile the SRCS.
  39. .include "$(TOP)/mk/os161.compile.mk"
  40. # Further rules for programs.
  41. # Clean: delete extraneous files.
  42. clean: cleanprog
  43. cleanprog:
  44. rm -f $(MYBUILDDIR)/$(PROG)
  45. #
  46. # Install: we can install into either $(INSTALLTOP) or $(OSTREE).
  47. # When building the whole system, we always install into the staging
  48. # area. However, if you're working on a particular program it is
  49. # usually convenient to be able to install it directly to $(OSTREE)
  50. # instead of doing a complete top-level install.
  51. #
  52. # Note that we make a hard link instead of a copy by default to reduce
  53. # overhead.
  54. #
  55. install-staging: $(INSTALLTOP)$(BINDIR) .WAIT $(INSTALLTOP)$(BINDIR)/$(PROG)
  56. $(INSTALLTOP)$(BINDIR)/$(PROG): $(MYBUILDDIR)/$(PROG)
  57. rm -f $(.TARGET)
  58. ln $(MYBUILDDIR)/$(PROG) $(.TARGET) || \
  59. cp $(MYBUILDDIR)/$(PROG) $(.TARGET)
  60. install: install-prog
  61. install-prog: $(OSTREE)$(BINDIR) $(MYBUILDDIR)/$(PROG)
  62. rm -f $(OSTREE)$(BINDIR)/$(PROG)
  63. ln $(MYBUILDDIR)/$(PROG) $(OSTREE)$(BINDIR)/$(PROG) || \
  64. cp $(MYBUILDDIR)/$(PROG) $(OSTREE)$(BINDIR)/$(PROG)
  65. # Link the program.
  66. # $(MYBUILDDIR)/$(PROG): $(OBJS) $(LIBDEPS)
  67. # $(LDCC) $(LDFLAGS) $(OBJS) $(LIBS) $(MORELIBS) -o $(.TARGET)
  68. # UW - TBB June 28, 2013 Use our script to separate data from code/ro segments.
  69. $(MYBUILDDIR)/$(PROG): $(OBJS) $(LIBDEPS)
  70. $(LDCC) $(LDFLAGS) $(UWLDSCRIPT) $(OBJS) $(LIBS) $(MORELIBS) -o $(.TARGET)
  71. # Mark targets that don't represent files PHONY, to prevent various
  72. # lossage if files by those names appear.
  73. .PHONY: all clean cleanprog install-staging install install-prog
  74. # Finally, get the shared definitions for the most basic rules.
  75. .include "$(TOP)/mk/os161.baserules.mk"
  76. # End.