Ignore:
Timestamp:
Aug 20, 2002, 6:05:40 AM (23 years ago)
Author:
bird
Message:

Implemented structured make passes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/make/process.mak

    r9028 r9031  
    1 # $Id: process.mak,v 1.16 2002-08-19 15:00:25 bird Exp $
     1# $Id: process.mak,v 1.17 2002-08-20 04:05:40 bird Exp $
    22
    33#
     
    511511
    512512# -----------------------------------------------------------------------------
    513 # The build rule - Build the target.
    514 #   Must take into account any subdirectories and makefiles which is is to be
    515 #   made before and after the target. That makes it kind of messy, sorry.
    516 # -----------------------------------------------------------------------------
     513# The build rule - This runs all passes:
     514#   1. Make Dependencies
     515#   2. Make Libraries (all kinds)
     516#   3. Make Executables
     517#   4. Make Miscellaneous Targets
     518#   5. Make Install
     519# Note: In order to load dependencies we'll do a forwarding after making them.
     520# -----------------------------------------------------------------------------
     521build: _build
     522!if "$(MAKEFLAGS:I=_)" == "$(MAKEFLAGS)" # this is of course broken in nmake v5.0 for OS/2.
     523    @$(ECHO)$(CLRMAK)[Successfully Built Everything!] $(CLRRST)
     524!else
     525    @$(ECHO)$(CLRMAK)[Built Everything! (Ignore option specified)] $(CLRRST)
     526!endif
     527
     528# internal rule shared by rebuild and build.
     529_build:  _build_banner_dep dep
     530!ifndef BUILD_QUIET
     531    @$(ECHO) Restarting $(CLRFIL)$(MAKEFILE)$(CLRTXT) with new dependencies. $(CLRRST)
     532!endif
     533    \
     534!ifndef BUILD_VERBOSE
     535    @ \
     536!endif
     537    $(TOOL_MAKE) -f $(MAKEFILE) _build_new_dependencies_
     538
     539# internal rule used to reload dependencies.
     540_build_new_dependencies_: \
     541        _build_banner_lib           lib \
     542        _build_banner_executable    executable \
     543        _build_banner_miscellaneous miscellaneous \
     544        _build_banner_install       install
     545
     546# Banners for rebuild and build.
     547_build_banner_clean:
     548    @$(ECHO)$(CLRMAK)[Start Pass 0 - Make Clean] $(CLRRST)
     549    @SET _BUILD_PASS=0
     550_build_banner_dep:
     551    @$(ECHO)$(CLRMAK)[Start Pass 1 - Make Dependencies] $(CLRRST)
     552    @SET _BUILD_PASS=1
     553_build_banner_lib:
     554    @$(ECHO)$(CLRMAK)[Start Pass 2 - Make Libraries] $(CLRRST)
     555    @SET _BUILD_PASS=2
     556_build_banner_executable:
     557    @$(ECHO)$(CLRMAK)[Start Pass 3 - Make Executables] $(CLRRST)
     558    @SET _BUILD_PASS=3
     559_build_banner_miscellaneous:
     560    @$(ECHO)$(CLRMAK)[Start Pass 4 - Make Miscellaneous Targets] $(CLRRST)
     561    @SET _BUILD_PASS=4
     562_build_banner_install:
     563    @$(ECHO)$(CLRMAK)[Start Pass 5 - Make Install] $(CLRRST)
     564    @SET _BUILD_PASS=5
     565
     566
     567
     568# -----------------------------------------------------------------------------
     569# The rebuild rule - Same as build but does a clean first (as Pass 0).
     570# -----------------------------------------------------------------------------
     571rebuild: \
     572        _build_banner_clean clean \
     573        _build
     574!if "$(MAKEFLAGS:i=_)" == "$(MAKEFLAGS)"
     575    @$(ECHO)$(CLRMAK)[Successfully Rebuilt Everything!] $(CLRRST)
     576!else
     577    @$(ECHO)$(CLRMAK)[Rebuilt Everything! (Ignore option specified)] $(CLRRST)
     578!endif
     579
     580
     581
     582# -----------------------------------------------------------------------------
     583# Pass 0 - The clean rule - Clean up output files.
     584#   The current setup doesn't clean the installed ones.
     585# -----------------------------------------------------------------------------
     586!if "$(TARGET_MODE)" != "TESTCASE"
     587clean:
     588    @$(ECHO) Cleaning... $(CLRRST)
     589!if "$(PATH_TARGET)" != ""              # paranoia
     590    \
     591! ifndef BUILD_VERBOSE
     592    @ \
     593! endif
     594    $(TOOL_RM) \
     595        $(PATH_TARGET)\*.$(EXT_OBJ) \
     596        $(PATH_TARGET)\*.$(EXT_ILIB) \
     597        $(PATH_TARGET)\*.$(EXT_EXE) \
     598        $(PATH_TARGET)\*.$(EXT_DLL) \
     599        $(PATH_TARGET)\*.$(EXT_RES)
     600    \
     601! ifndef BUILD_VERBOSE
     602    @ \
     603! endif
     604    $(TOOL_RM) \
     605        $(PATH_TARGET)\*.$(EXT_SYS) \
     606        $(PATH_TARGET)\*.$(EXT_LIB) \
     607        $(PATH_TARGET)\*.$(EXT_IFS) \
     608        $(PATH_TARGET)\*.$(EXT_MAP) \
     609        $(PATH_TARGET)\*.$(EXT_SYM)
     610    \
     611! ifndef BUILD_VERBOSE
     612    @ \
     613! endif
     614    $(TOOL_RM) \
     615        $(PATH_TARGET)\*.s \
     616        $(PATH_TARGET)\*.lst \
     617        $(PATH_TARGET)\*.lnk \
     618        $(PATH_TARGET)\*.ii \
     619        $(PATH_TARGET)\.depend
     620    \
     621! ifndef BUILD_VERBOSE
     622    @ \
     623! endif
     624    $(TOOL_RM) \
     625        .\*.ii \
     626        .\*.err \
     627        .\.depend
     628!endif
    517629!ifdef SUBDIRS
    518 SUBDIRS_BUILD = subbuild
    519 $(SUBDIRS_BUILD):
    520     @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) build
    521 !endif
    522 
     630    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) NODEP=1 $@
     631!endif
    523632!ifdef PREMAKEFILES
    524 PREMAKEFILES_BUILD = premakefiles_build
    525 $(PREMAKEFILES_BUILD):
    526     @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) build
    527 !endif
    528 
    529 build: $(SUBDIRS_BUILD) $(PREMAKEFILES_BUILD) $(TARGET) $(TARGET_ILIB) $(TARGET_PUBNAME)
    530     @$(ECHO) Successfully Built $(CLRFIL)$(TARGET) $(TARGET_ILIB)$(CLRRST)
     633    @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
     634!endif
     635!ifdef POSTMAKEFILES
     636    @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
     637!endif
     638!endif #!TESTCASE
     639
     640
     641
     642# -----------------------------------------------------------------------------
     643# Pass 1 - The dep rule - Make dependencies.
     644# -----------------------------------------------------------------------------
     645dep:
     646    @$(ECHO) Making dependencies... $(CLRRST)
     647    \
     648!ifndef BUILD_VERBOSE
     649    @ \
     650!endif
     651!if "$(TARGET_MODE)" != "EMPTY" && "$(TARGET_MODE)" != "TESTCASE"
     652    $(TOOL_DEP) $(TOOL_DEP_FLAGS) -o$$(PATH_TARGET) -d$(TARGET_DEPEND)\
     653! ifdef TARGET_NO_DEP
     654        -x$(TARGET_NO_DEP: =;)\
     655! endif
     656        $(TOOL_DEP_FILES)
     657!endif
     658!ifdef SUBDIRS
     659    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) NODEP=1 $@
     660!endif
     661!ifdef PREMAKEFILES
     662    @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
     663!endif
     664!ifdef POSTMAKEFILES
     665    @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
     666!endif
     667
     668
     669
     670# -----------------------------------------------------------------------------
     671# Pass 2 - The lib rule - Make libraries.
     672# -----------------------------------------------------------------------------
     673!ifdef SUBDIRS
     674SUBDIRS_LIB = _subdir_lib
     675$(SUBDIRS_LIB):
     676    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) lib
     677!endif
     678
     679!ifdef PREMAKEFILES
     680PREMAKEFILES_LIB = _premakefiles_lib
     681$(PREMAKEFILES_LIB):
     682    @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) lib
     683!endif
     684
     685lib:    $(SUBDIRS_LIB) $(PREMAKEFILES_LIB) \
     686!if "$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB"
     687        $(TARGET) $(TARGET_PUBNAME) \
     688!endif
     689        $(TARGET_ILIB)
    531690!ifdef POSTMAKEFILES
    532691    @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
     
    536695
    537696# -----------------------------------------------------------------------------
    538 # The lib rule - Make Public libraries.
    539 #   Must take into account any subdirectories and makefiles which is is to be
    540 #   made before and after the target. That makes it kind of messy, sorry.
     697# Pass 3 - The executable rule - Build the executables.
    541698# -----------------------------------------------------------------------------
    542699!ifdef SUBDIRS
    543 SUBDIRS_LIB = subdir_lib
    544 $(SUBDIRS_LIB):
    545     @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) lib
     700SUBDIRS_EXECUTABLE = _subdir_executable
     701$(SUBDIRS_EXECUTABLE):
     702    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) executable
    546703!endif
    547704
    548705!ifdef PREMAKEFILES
    549 PREMAKEFILES_LIB = premakefiles_lib
    550 $(PREMAKEFILES_LIB):
    551     @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) lib
    552 !endif
    553 
    554 !if "$(TARGET_PUBLIC_PART)" != "" && ("$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB")
    555 lib: $(SUBDIRS_LIB) $(TARGET_ILIB) $(TARGET) $(TARGET_PUBNAME)
     706PREMAKEFILES_EXECUTABLE = _premakefiles_executable
     707$(PREMAKEFILES_EXECUTABLE):
     708    @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) executable
     709!endif
     710
     711executable: \
     712!if "$(TARGET_MODE)" != "LIB" && "$(TARGET_MODE)" != "SYSLIB" && "$(TARGET_MODE)" != "IFSLIB"
     713        $(SUBDIRS_EXECUTABLE) $(PREMAKEFILES_EXECUTABLE) $(TARGET) $(TARGET_PUBNAME)
     714    @$(ECHO) Successfully Built $(CLRFIL)$(TARGET)$(CLRRST)
    556715!else
    557 lib: $(SUBDIRS_LIB) $(TARGET_ILIB)
     716        $(SUBDIRS_EXECUTABLE) $(PREMAKEFILES_EXECUTABLE)
    558717!endif
    559718!ifdef POSTMAKEFILES
     
    564723
    565724# -----------------------------------------------------------------------------
    566 # The install rule - Copies target to main binary directory.
     725# Pass 4 - The miscellaneous rule - Makes other miscellaneous stuff like
     726#   documentations etc. This is experimental for the moment.
     727# -----------------------------------------------------------------------------
     728!ifdef SUBDIRS
     729SUBDIRS_MISC = _subdir_misc
     730$(SUBDIRS_MISC):
     731    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) miscellaneous
     732!endif
     733
     734!ifdef PREMAKEFILES
     735PREMAKEFILES_MISC = _premakefiles_misc
     736$(PREMAKEFILES_MISC):
     737    @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) miscellaneous
     738!endif
     739
     740miscellaneous:  $(SUBDIRS_MISC) $(PREMAKEFILES_MISC) \
     741                $(TARGET_DOCS) $(TARGET_MISC)
     742!if "$(TARGET_DOCS)$(TARGET_MISC)" != ""
     743    @$(ECHO) Successfully Built $(CLRFIL)$(TARGET_DOCS) $(TARGET_MISC)$(CLRRST)
     744!else
     745!endif
     746!ifdef POSTMAKEFILES
     747    @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
     748!endif
     749
     750
     751
     752# -----------------------------------------------------------------------------
     753# Pass 5 - The install rule - Copies target to main binary directory.
    567754#   Installation order is not concidered vital, so subdirectories and
    568755#   pre-makefiles are processed after this directory. This might be changed.
     
    616803
    617804
     805# -----------------------------------------------------------------------------
     806# Pass x - The testcase rule - Execute testcases when present.
     807#   Testcases are either a testcase.mak file or a testcase subdirectory.
     808# -----------------------------------------------------------------------------
    618809!if "$(TARGET_MODE)" != "TESTCASE"
    619810!ifndef BUILD_OWN_TESTCASE_RULE
     
    625816_TESTCASE_TST2 = exists(testcase.mak) != 0
    626817!endif
    627 # -----------------------------------------------------------------------------
    628 # The testcase rule - Execute testcases when present.
    629 #   Testcases are either a testcase.mak file or a testcase subdirectory.
    630 # -----------------------------------------------------------------------------
     818
    631819testcase:
     820    @$(ECHO) Executing testcases $(CLRRST)
    632821!if $(_TESTCASE_TST1)
    633822    @$(TOOL_DODIRS) "testcase" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) $@
     
    651840
    652841# -----------------------------------------------------------------------------
     842# The target rule - Build the target.
     843#   Note: This also builds libraries in subdirectories and submakefiles.
     844# -----------------------------------------------------------------------------
     845!ifdef SUBDIRS
     846SUBDIRS_TARGET = _subdir_target
     847$(SUBDIRS_TARGET):
     848    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) target
     849!endif
     850
     851!ifdef PREMAKEFILES
     852PREMAKEFILES_TARGET = _premakefiles_target
     853$(PREMAKEFILES_TARGET):
     854    @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) target
     855!endif
     856
     857target: $(SUBDIRS_TARGET) $(PREMAKEFILES_TARGET) $(TARGET) $(TARGET_ILIB) $(TARGET_PUBNAME)
     858    @$(ECHO) Successfully Built $(CLRFIL)$(TARGET) $(TARGET_ILIB)$(CLRRST)
     859!ifdef POSTMAKEFILES
     860    @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
     861!endif
     862
     863
     864
     865# -----------------------------------------------------------------------------
    653866# The shell rule - Setup the correcte shell environment and start a shell.
    654867# -----------------------------------------------------------------------------
    655868shell:
     869    @$(ECHO) Creating work shell $(CLRRST)
    656870    \
    657871!ifndef BUILD_VERBOSE
     
    664878
    665879# -----------------------------------------------------------------------------
    666 # The dep rule - Make dependencies.
    667 # -----------------------------------------------------------------------------
    668 dep:
    669     @$(ECHO) Building dependencies $(CLRRST)
    670     \
    671 !ifndef BUILD_VERBOSE
    672     @ \
    673 !endif
    674 !if "$(TARGET_MODE)" != "EMPTY" && "$(TARGET_MODE)" != "TESTCASE"
    675     $(TOOL_DEP) $(TOOL_DEP_FLAGS) -o$$(PATH_TARGET) -d$(TARGET_DEPEND)\
    676 ! ifdef TARGET_NO_DEP
    677         -x$(TARGET_NO_DEP: =;)\
    678 ! endif
    679         $(TOOL_DEP_FILES)
    680 !endif
    681 !ifdef SUBDIRS
    682     @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) NODEP=1 $@
    683 !endif
    684 !ifdef PREMAKEFILES
    685     @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
    686 !endif
    687 !ifdef POSTMAKEFILES
    688     @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
    689 !endif
    690 
    691 
    692 
    693 # -----------------------------------------------------------------------------
    694 # The clean rule - Clean up output files.
    695 #   The current setup doesn't clean the installed ones.
    696 # -----------------------------------------------------------------------------
    697 !if "$(TARGET_MODE)" != "TESTCASE"
    698 clean:
    699 !if "$(PATH_TARGET)" != ""              # paranoia
    700     $(TOOL_RM) \
    701         $(PATH_TARGET)\*.$(EXT_OBJ) \
    702         $(PATH_TARGET)\*.$(EXT_ILIB) \
    703         $(PATH_TARGET)\*.$(EXT_EXE) \
    704         $(PATH_TARGET)\*.$(EXT_DLL) \
    705         $(PATH_TARGET)\*.$(EXT_RES)
    706     $(TOOL_RM) \
    707         $(PATH_TARGET)\*.$(EXT_SYS) \
    708         $(PATH_TARGET)\*.$(EXT_LIB) \
    709         $(PATH_TARGET)\*.$(EXT_IFS) \
    710         $(PATH_TARGET)\*.$(EXT_MAP) \
    711         $(PATH_TARGET)\*.$(EXT_SYM)
    712     $(TOOL_RM) \
    713         $(PATH_TARGET)\*.s \
    714         $(PATH_TARGET)\*.lst \
    715         $(PATH_TARGET)\*.lnk \
    716         $(PATH_TARGET)\*.ii \
    717         $(PATH_TARGET)\.depend
    718     $(TOOL_RM) \
    719         .\*.ii \
    720         .\*.err \
    721         .\.depend
    722 !endif
    723 !ifdef SUBDIRS
    724     @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) NODEP=1 $@
    725 !endif
    726 !ifdef PREMAKEFILES
    727     @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
    728 !endif
    729 !ifdef POSTMAKEFILES
    730     @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
    731 !endif
    732 !endif #!TESTCASE
    733 
    734 
    735 
    736 # -----------------------------------------------------------------------------
    737880# The nothing rule - Rule for testing the makefile structure.
    738881# -----------------------------------------------------------------------------
    739882nothing:
     883    @$(ECHO) Doing nothing in $(MAKEFILE).
    740884!ifdef SUBDIRS
    741885    @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) $@
     
    9091053
    9101054
    911 #
     1055# -----------------------------------------------------------------------------
    9121056# Copy rule for public targets.
    913 #
     1057#   Normally used for public libraries, but may be used for other purposes...
     1058# -----------------------------------------------------------------------------
    9141059!if "$(TARGET_PUBNAME)" != ""
    9151060$(TARGET_PUBNAME): $(TARGET)
     
    9311076
    9321077# -----------------------------------------------------------------------------
    933 # The $(TARGET) rule - For EMPTY targets.
    934 # -----------------------------------------------------------------------------
    935 # this doesn't work as we don't have a target name. Hence not needed.
    936 #!if "$(TARGET_MODE)" == "EMPTY"
    937 #$(TARGET):
    938 #    @$(ECHO) .
    939 #!endif
     1078# The $(TARGET) rule - For DEPEND targets.
     1079# -----------------------------------------------------------------------------
    9401080!if "$(TARGET_MODE)" == "DEPEND"
    9411081$(TARGET):
Note: See TracChangeset for help on using the changeset viewer.