build.mk 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. D := util/ego
  2. define build-ego-backend-impl
  3. $(call reset)
  4. $(eval cflags += -DVERBOSE -DNOTCOMPACT)
  5. $(eval cflags += -I$D/share -I$(OBJDIR)/$D)
  6. $(foreach f, $2, $(call cfile, $f))
  7. $(call file, $(LIBDIR)/libegocore.a)
  8. $(call file, $(LIBEM_DATA))
  9. $(call cprogram, $(BINDIR)/ego/$(strip $1))
  10. $(call installto, $(PLATDEP)/ego/$(strip $1))
  11. $(eval EGO_MODULES += $q)
  12. endef
  13. define build-ego-impl
  14. # Generated files that egocore needs.
  15. $(call reset)
  16. $(call cfile, $D/share/makecldef.c)
  17. $(call cprogram, $(OBJDIR)/$D/makecldef)
  18. $(eval g := $(OBJDIR)/$D/classdefs.h)
  19. $(eval CLEANABLES += $g)
  20. $g: $(OBJDIR)/$D/makecldef $(INCDIR)/em_mnem.h $D/share/cldefs.src
  21. @echo MAKECLDEF $g
  22. @mkdir -p $(dir $g)
  23. $(hide) $$^ > $g
  24. $(eval g := $(OBJDIR)/$D/pop_push.h)
  25. $(eval CLEANABLES += $g)
  26. $g: $D/share/pop_push.awk h/em_table
  27. @echo POP_PUSH $g
  28. @mkdir -p $(dir $g)
  29. $(hide) awk -f $D/share/pop_push.awk < h/em_table > $g
  30. # Build the egocore library.
  31. $(call reset)
  32. $(eval cflags += -I$D/share -I$(OBJDIR)/$D)
  33. $(eval cflags += -DVERBOSE -DNOTCOMPACT)
  34. $(call cfile, $D/share/debug.c)
  35. $(call cfile, $D/share/global.c)
  36. $(call cfile, $D/share/files.c)
  37. $(call cfile, $D/share/go.c)
  38. $(call cfile, $D/share/map.c)
  39. $(call cfile, $D/share/aux.c)
  40. $(call cfile, $D/share/get.c)
  41. $(call cfile, $D/share/put.c)
  42. $(call cfile, $D/share/alloc.c)
  43. $(call cfile, $D/share/lset.c)
  44. $(call cfile, $D/share/cset.c)
  45. $(call cfile, $D/share/parser.c)
  46. $(call cfile, $D/share/stack_chg.c)
  47. $(call cfile, $D/share/locals.c)
  48. $(call cfile, $D/share/init_glob.c)
  49. $(eval $q: $(OBJDIR)/$D/classdefs.h $(OBJDIR)/$D/pop_push.h)
  50. $(call clibrary, $(LIBDIR)/libegocore.a)
  51. $(eval CLEANABLES += $q)
  52. # Now build each of the back ends.
  53. $(call build-ego-backend-impl, bo, \
  54. $D/bo/bo.c)
  55. $(call build-ego-backend-impl, ca, \
  56. $D/ca/ca.c \
  57. $D/ca/ca_put.c)
  58. $(call build-ego-backend-impl, cf, \
  59. $D/cf/cf.c \
  60. $D/cf/cf_idom.c \
  61. $D/cf/cf_loop.c \
  62. $D/cf/cf_succ.c)
  63. $(call build-ego-backend-impl, cj, \
  64. $D/cj/cj.c)
  65. $(call build-ego-backend-impl, cs, \
  66. $D/cs/cs.c \
  67. $D/cs/cs_alloc.c \
  68. $D/cs/cs_aux.c \
  69. $D/cs/cs_avail.c \
  70. $D/cs/cs_debug.c \
  71. $D/cs/cs_elim.c \
  72. $D/cs/cs_entity.c \
  73. $D/cs/cs_getent.c \
  74. $D/cs/cs_kill.c \
  75. $D/cs/cs_partit.c \
  76. $D/cs/cs_profit.c \
  77. $D/cs/cs_stack.c \
  78. $D/cs/cs_vnm.c)
  79. $(call build-ego-backend-impl, ic, \
  80. $D/ic/ic.c \
  81. $D/ic/ic_aux.c \
  82. $D/ic/ic_io.c \
  83. $D/ic/ic_lib.c \
  84. $D/ic/ic_lookup.c)
  85. $(call build-ego-backend-impl, il, \
  86. $D/il/il.c \
  87. $D/il/il1_anal.c \
  88. $D/il/il1_aux.c \
  89. $D/il/il1_cal.c \
  90. $D/il/il1_formal.c \
  91. $D/il/il2_aux.c \
  92. $D/il/il3_aux.c \
  93. $D/il/il3_change.c \
  94. $D/il/il3_subst.c \
  95. $D/il/il_aux.c)
  96. $(call build-ego-backend-impl, lv, \
  97. $D/lv/lv.c)
  98. $(call build-ego-backend-impl, ra, \
  99. $D/ra/ra.c \
  100. $D/ra/ra_allocl.c \
  101. $D/ra/ra_aux.c \
  102. $D/ra/ra_interv.c \
  103. $D/ra/ra_lifet.c \
  104. $D/ra/ra_pack.c \
  105. $D/ra/ra_profits.c \
  106. $D/ra/ra_xform.c \
  107. $D/ra/ra_items.c)
  108. $(eval g := $(OBJDIR)/$D/itemtab.h)
  109. $(eval CLEANABLES += $g)
  110. $D/ra/ra_items.c: $g
  111. $g: $(OBJDIR)/$D/makeitems $(INCDIR)/em_mnem.h $D/ra/itemtab.src
  112. @echo MAKEITEMS $g
  113. @mkdir -p $(dir $g)
  114. $(hide) $$^ > $g
  115. $(call reset)
  116. $(call cfile, $D/ra/makeitems.c)
  117. $(call cprogram, $(OBJDIR)/$D/makeitems)
  118. $(call build-ego-backend-impl, sp, \
  119. $D/sp/sp.c)
  120. $(call build-ego-backend-impl, sr, \
  121. $D/sr/sr.c \
  122. $D/sr/sr_aux.c \
  123. $D/sr/sr_cand.c \
  124. $D/sr/sr_expr.c \
  125. $D/sr/sr_iv.c \
  126. $D/sr/sr_reduce.c \
  127. $D/sr/sr_xform.c)
  128. $(call build-ego-backend-impl, ud, \
  129. $D/ud/ud.c \
  130. $D/ud/ud_aux.c \
  131. $D/ud/ud_const.c \
  132. $D/ud/ud_copy.c \
  133. $D/ud/ud_defs.c)
  134. # ...and now the front end, which depends on all the backends.
  135. $(call reset)
  136. $(call cfile, $D/em_ego/em_ego.c)
  137. $(eval $q: $(INCDIR)/print.h $(INCDIR)/system.h)
  138. $(eval $q: $(INCDIR)/em_path.h)
  139. $(call file, $(LIBPRINT))
  140. $(call file, $(LIBSTRING))
  141. $(call file, $(LIBSYSTEM))
  142. $(call cprogram, $(BINDIR)/em_ego)
  143. $(call installto, $(PLATDEP)/em_ego)
  144. $(eval EM_EGO := $q)
  145. $(eval $q: $(EGO_MODULES))
  146. $(eval ACK_CORE_TOOLS += $q)
  147. endef
  148. $(eval $(build-ego-impl))
  149. # Install the ego descr file for the current architecture, if one exists.
  150. # This is a bit annoying because it's called by each platform, so we need
  151. # to protect against the architecture being seen more than once. And some
  152. # architectures don't get descr files.
  153. define build-ego-descr-impl
  154. $(eval EGO_DESCR_$(ARCH) := 1)
  155. $(eval g := $(PLATIND)/ego/$(ARCH).descr)
  156. $(eval CLEANABLES += $g)
  157. $(eval $(EM_EGO): $g)
  158. $g: util/ego/descr/descr.sed util/ego/descr/$(ARCH).descr $(CPPANSI) \
  159. $(INCDIR)/em_mnem.h
  160. @echo EGODESCR $g
  161. @mkdir -p $(dir $g)
  162. $(hide) $(CPPANSI) -P -I$(INCDIR) util/ego/descr/$(ARCH).descr | sed -f util/ego/descr/descr.sed > $g
  163. endef
  164. build-ego-descr = $(if $(EGO_DESCR_$(ARCH)),, \
  165. $(if $(wildcard util/ego/descr/$(ARCH).descr), \
  166. $(eval $(call build-ego-descr-impl, $1))))