Changeset 219 for trunk/kBuild


Ignore:
Timestamp:
Feb 8, 2005, 2:50:34 PM (20 years ago)
Author:
bird
Message:

Fixing parallel issues. Working on NEEDED.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r207 r219  
    5151
    5252# all of a type
    53 _OBJS   :=
    54 _LIBS   :=
    55 _DLLS   :=
    56 _EXES  :=
    57 _SYSMODS:=
    58 _DIRS   :=
     53_OBJS     :=
     54_LIBS     :=
     55_DLLS     :=
     56_PROGRAMS :=
     57_SYSMODS  :=
     58_DIRS     :=
    5959_IMPORT_LIBS :=
    6060
     
    632632
    633633$$(basename $$(notdir $$(obj))).o::
    634         $$(MAKE) -B -f $$(MAKEFILE) $(obj)
     634        + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
    635635$$(basename $$(notdir $$(obj))).obj::
    636         $$(MAKE) -B -f $$(MAKEFILE) $(obj)
     636        + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
    637637
    638638$(eval _OBJS_$(target) += $(obj))
     
    657657        ,$(eval $(def_target_source_c_cpp_asm)) ))
    658658endef
     659
     660
     661#
     662# NEEDED
     663#
     664
     665## Needed (one).
     666# @param    $(target)   Normalized target (program) name.
     667define def_needed
     668# basics
     669$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
     670$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
     671$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
     672$(eval exesuff     := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(HOSTSUFF_EXE)))
     673$(eval exe         := $(outbase)$(exesuff))
     674$(eval TARGET_$(target) := $(exe))
     675
     676# source -> object
     677$(eval $(def_target_sources))
     678
     679# more library stuff.
     680$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
     681$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
     682$(eval objs         = $(_OBJS_$(target)))
     683$(eval flags       :=\
     684        $(TOOL_$(tool)_LDFLAGS)\
     685        $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
     686        $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
     687        $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
     688        $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
     689        $(LDFLAGS)\
     690        $(LDFLAGS.$(BUILD_TYPE))\
     691        $(LDFLAGS.$(BUILD_TARGET))\
     692        $(LDFLAGS.$(BUILD_TARGET_ARCH))\
     693        $(LDFLAGS.$(BUILD_TARGET_CPU))\
     694        $($(target)_LDFLAGS)\
     695        $($(target)_LDFLAGS.$(BUILD_TYPE))\
     696        $($(target)_LDFLAGS.$(BUILD_TARGET))\
     697        $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
     698        $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
     699)
     700$(eval libs        :=\
     701        $($(target)_LIBS.$(BUILD_TARGET_CPU))\
     702        $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
     703        $($(target)_LIBS.$(BUILD_TARGET))\
     704        $($(target)_LIBS.$(BUILD_TYPE))\
     705        $($(target)_LIBS)\
     706        $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
     707                                   $($(target)_SDKS.$(BUILD_TYPE)) \
     708                                   $($(target)_SDKS),\
     709        $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
     710        $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
     711        $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
     712        $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
     713        $(SDK_$(sdk)_LIBS))\
     714        $(LIBS.$(BUILD_TARGET_CPU))\
     715        $(LIBS.$(BUILD_TARGET_ARCH))\
     716        $(LIBS.$(BUILD_TARGET))\
     717        $(LIBS.$(BUILD_TYPE))\
     718        $(LIBS)\
     719        $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
     720                                   $(SDKS.$(BUILD_TYPE)) \
     721                                   $(SDKS),\
     722        $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
     723        $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
     724        $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
     725        $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
     726        $(SDK_$(sdk)_LIBS))\
     727        $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
     728        $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
     729        $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
     730        $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
     731        $(TOOL_$(tool)_LIBS)\
     732)
     733$(eval libpath    :=\
     734        $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
     735        $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
     736        $($(target)_LIBPATH.$(BUILD_TARGET))\
     737        $($(target)_LIBPATH.$(BUILD_TYPE))\
     738        $($(target)_LIBPATH)\
     739        $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
     740                                   $($(target)_SDKS.$(BUILD_TYPE)) \
     741                                   $($(target)_SDKS),\
     742        $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
     743        $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
     744        $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
     745        $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
     746        $(SDK_$(sdk)_LIBPATH))\
     747        $(LIBPATH.$(BUILD_TARGET_CPU))\
     748        $(LIBPATH.$(BUILD_TARGET_ARCH))\
     749        $(LIBPATH.$(BUILD_TARGET))\
     750        $(LIBPATH.$(BUILD_TYPE))\
     751        $(LIBPATH)\
     752        $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
     753                                   $(SDKS.$(BUILD_TYPE)) \
     754                                   $(SDKS),\
     755        $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
     756        $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
     757        $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
     758        $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
     759        $(SDK_$(sdk)_LIBPATH))\
     760        $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
     761        $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
     762        $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
     763        $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
     764        $(TOOL_$(tool)_LIBPATH)\
     765)
     766$(eval dirdep      := $(dir $(exe)).dir_created)
     767## @todo fix dependencies
     768$(eval deps        := $($(target)_DEPS))
     769#
     770$(eval custom_pre    := $(strip $(firstword
     771        $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
     772        $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
     773        $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
     774        $($(target)_CUSTOM_PRE)\
     775        $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
     776        $(CUSTOM_PRE.$(BUILD_TARGET))\
     777        $(CUSTOM_PRE.$(BUILD_TYPE))\
     778        $(CUSTOM_PRE)\
     779)))
     780$(eval custom_post    := $(strip $(firstword
     781        $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
     782        $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
     783        $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
     784        $($(target)_CUSTOM_POST)\
     785        $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
     786        $(CUSTOM_POST.$(BUILD_TARGET))\
     787        $(CUSTOM_POST.$(BUILD_TYPE))\
     788        $(CUSTOM_POST)\
     789)))
     790$(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
     791
     792$(eval $(TOOL_$(tool)_LINK_PROGRAM))
     793# publish rule (still need work)
     794ifndef $(target)_INST
     795$(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
     796$(pubexe) : $(exe) $(dir $(pubexe)).dir_created
     797        $(CP) $(exe) $(pubexe)
     798
     799_NEEDED    += $(pubexe)
     800_OUT_FILES += $(exe) $(pubexe)
     801else
     802_NEEDED    += $(exe)
     803_OUT_FILES += $(exe)
     804endif
     805_OBJS += $(_OBJS_$(target))
     806endef
     807
     808# Process needed.
     809$(foreach target, $(NEEDED) $(NEEDED.$(BUILD_TARGET)), $(eval $(def_needed)))
     810
    659811
    660812
     
    8971049# Process import libraries.
    8981050#
    899 #       - On OS/2 and windows these are libraries.
     1051#   - On OS/2 and windows these are libraries.
    9001052#   - On other platforms they are fake DLLs.
    9011053ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
     
    9061058$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval _IMPORT_LIBS += $(firstword $(TARGET_PUB_$(target)) $(TARGET_$(target)))))
    9071059
     1060   
    9081061
    9091062#
     
    10451198        $(CP) $(exe) $(pubexe)
    10461199
    1047 _DLLS += $(pubexe)
     1200_PROGRAMS += $(pubexe)
    10481201_OUT_FILES += $(exe) $(pubexe)
    10491202else
    1050 _DLLS += $(exe)
     1203_PROGRAMS += $(exe)
    10511204_OUT_FILES += $(exe)
    10521205endif
     
    12441397define def_createdir
    12451398$(dirfile):
    1246         $(call MSG_Ltarget,Creating directory $$(@D))
     1399        $(call MSG_L1,Creating directory $$(@D))
    12471400        $(MKDIR) -p $$(@D)
    12481401        @echo dir_created > $$@
     
    12761429# @param        $(tag)          tag to attach to the rule name.
    12771430define def_pass_subdir
    1278 pass_$(pass)$(tag)::
    1279         $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
     1431pass_$(pass)$(tag):: $(dep)
     1432        + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
    12801433endef
    12811434
     
    12861439# @param        $(tag)          tag to attach to the rule name.
    12871440define def_pass_makefile
    1288 pass_$(pass)$(tag)::
    1289         $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
     1441pass_$(pass)$(tag):: $(dep)
     1442        + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
    12901443endef
    12911444
     
    13011454
    13021455$(eval tag:=_before)
     1456$(eval dep:=)
    13031457$(foreach subdir,$(SUBDIRS_$(PASS))            $(SUBDIRS_$(PASS).$(BUILD_TARGET))         ,$(eval $(def_pass_subdir)))
    13041458$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
    13051459
    13061460$(eval tag:=_after)
     1461$(eval dep:=pass_$(pass)_doit)
    13071462$(foreach subdir,$(SUBDIRS_AFTER_$(PASS))      $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET))   ,$(eval $(def_pass_subdir)))
    13081463$(foreach makefile,$(MAKEFILES_AFTER_$(PASS))  $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
     
    13101465.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
    13111466.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
    1312 pass_$(pass): \
    1313         pass_$(pass)_before \
    1314         pass_$(pass)_doit \
    1315         pass_$(pass)_after
     1467pass_$(pass)_doit:      pass_$(pass)_before
     1468pass_$(pass)_after::    pass_$(pass)_doit
     1469pass_$(pass):           pass_$(pass)_after
    13161470
    13171471endef
     
    13411495## PASS: binaries
    13421496# This pass builds binary targets, i.e. programs, system modules and stuff.
    1343 pass_binaries_doit: $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
     1497pass_binaries_doit: $(_PROGRAMS) $(_SYSMODS) $(_OTHER_BINARIES)
    13441498pass := binaries
    13451499PASS := BINARIES
     
    13861540# This pass just walks the tree.
    13871541pass_nothing_doit:
    1388         $(call MSG_Ltarget,Did nothing in $(CURDIR))
     1542        $(call MSG_L1,Did nothing in $(CURDIR))
    13891543pass := nothing
    13901544PASS := NOTHING
     
    13931547
    13941548
    1395 
     1549## Pass order
     1550# @param        $(pass)         Current pass name.
     1551# @param        $(prev_pass)    The previous pass name.
     1552define def_pass_order
     1553pass_$(pass)_order: $(pass_prev)
     1554        $(call MSG_L1,Pass $(pass))
     1555        + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
     1556.NOTPARALLEL: pass_$(pass)_order
     1557$(eval pass_prev := pass_$(pass)_order)
     1558endef
     1559
     1560## PASS: order
     1561# Use dependencies to ensure correct pass order.
     1562pass_prev :=
     1563$(foreach pass,$(PASSES),$(eval $(def_pass_order)))
     1564
     1565     
    13961566#
    13971567# THE MAIN RULES
    13981568#
    1399 all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
     1569all_recursive: $(pass_prev)
    14001570
    14011571rebuild: clean
    1402         $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
     1572        + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
    14031573
    14041574
     
    14081578libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
    14091579dlls:      $(_DLLS)
    1410 programs:  $(_EXES)
     1580programs:  $(_PROGRAMS)
    14111581sysmods:   $(_SYSMODS)
    14121582
Note: See TracChangeset for help on using the changeset viewer.