diff options
author | Felix Geyer <debfx-pkg@fobos.de> | 2011-08-21 11:16:23 +0200 |
---|---|---|
committer | Felix Geyer <debfx-pkg@fobos.de> | 2011-08-21 11:16:23 +0200 |
commit | bd9ff04c49dda0d5d1d99fb88960c1779f3229a3 (patch) | |
tree | ceb9f9f990c51a3bd1263e81091e460d66bbcb39 | |
parent | beb92cf0e95b1ffa9361993d7a248dbab63741c3 (diff) | |
download | kbuild-bd9ff04c49dda0d5d1d99fb88960c1779f3229a3.tar.gz |
Imported Upstream version 0.1.9998svn2543upstream/0.1.9998svn2543
270 files changed, 12052 insertions, 5121 deletions
@@ -1,10 +1,10 @@ -# $Id: Config.kmk 2266 2009-01-23 00:43:08Z bird $ +# $Id: Config.kmk 2538 2011-08-02 20:00:46Z bird $ ## @file # Build Configuration. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -32,8 +32,8 @@ KBUILD_DO_AUTO_INSTALL := 1 # KBUILD_VERSION_MAJOR = 0 KBUILD_VERSION_MINOR = 1 -KBUILD_VERSION_PATCH = 98 -KBUILD_VERSION = 0.1.98 +KBUILD_VERSION_PATCH = 9998 +KBUILD_VERSION = 0.1.9998 DEFS += \ KBUILD_VERSION_MAJOR=$(KBUILD_VERSION_MAJOR) \ KBUILD_VERSION_MINOR=$(KBUILD_VERSION_MINOR) \ @@ -97,6 +97,16 @@ PATH_GNUMAKE_SRC ?= $(PATH_ROOT)/src/kmk # +# Various platform specific hacks. +# +ifn1of ($(KBUILD_TARGET), openbsd) + GCC_Wextra = -Wextra +endif +if1of ($(KBUILD_TARGET), openbsd) + TOOL_FLEX_LEX = gflex +endif + +# # The OS and Architecture indicators. # DEFS.darwin += KBUILD_OS_DARWIN @@ -178,7 +188,7 @@ TEMPLATE_DOC_GID ?= $(firstword $(MY_INST_DOC_GID) $(MY_INST_GID)) # # Template for building commandline tools. # -TEMPLATE_BIN = Commandline binary +TEMPLATE_BIN = Command line binary TEMPLATE_BIN_INCS = $(PATH_ROOT)/src/lib TEMPLATE_BIN_DEFS.profile = NDEBUG @@ -203,19 +213,33 @@ endif ifeq ($(KBUILD_TARGET),darwin) ifndef KBUILD_MACOSX_VERSION - export KBUILD_MACOSX_VERSION := $(firstword $(subst ., ,$(shell uname -r))) + export KBUILD_MACOSX_VERSION := $(expr $(firstword $(subst ., ,$(shell uname -r))) - 4) + endif + ifndef KBUILD_MACOSX_TARGET_VERSION + if $(KBUILD_TARGET_ARCH) == amd64 + KBUILD_MACOSX_TARGET_VERSION = 6 + else + KBUILD_MACOSX_TARGET_VERSION = 4 + endif + endif + if $(KBUILD_MACOSX_TARGET_VERSION) == 4 + TOOL_GCC4MACHO_SUFFIX = -4.0 + TOOL_GXX4MACHO_SUFFIX = -4.0 + else if $(KBUILD_MACOSX_TARGET_VERSION) >= 5 + TOOL_GCC4MACHO_SUFFIX = -4.2 + TOOL_GXX4MACHO_SUFFIX = -4.2 endif - KBUILD_MACOSX_SDK ?= /Developer/SDKs/MacOSX10.4u.sdk + KBUILD_MACOSX_SDK ?= /Developer/SDKs/MacOSX10.$(KBUILD_MACOSX_TARGET_VERSION)$(if-expr $(KBUILD_MACOSX_TARGET_VERSION)==4,u,).sdk TEMPLATE_BIN_TOOL = GCC4MACHO - TEMPLATE_BIN_CFLAGS = -g -mmacosx-version-min=10.4 -isysroot $(KBUILD_MACOSX_SDK) + TEMPLATE_BIN_CFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) -isysroot $(KBUILD_MACOSX_SDK) ifeq ($(USER),bird) - TEMPLATE_BIN_CFLAGS += -Wall -Wextra -pedantic -Wno-unused-parameter + TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter -Wno-long-long TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS endif TEMPLATE_BIN_CFLAGS.profile = -O3 -pg TEMPLATE_BIN_CFLAGS.release = -O3 - TEMPLATE_BIN_LDFLAGS = -g -mmacosx-version-min=10.4 -Wl,-syslibroot,$(KBUILD_MACOSX_SDK) - ifneq ($(int-ge $(KBUILD_MACOSX_VERSION),9),) # >= 10.5 + TEMPLATE_BIN_LDFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) -Wl,-syslibroot,$(KBUILD_MACOSX_SDK) + if $(KBUILD_MACOSX_TARGET_VERSION) == 4 && $(KBUILD_MACOSX_VERSION) >= 5 TEMPLATE_BIN_LDFLAGS += -classic_ld endif TEMPLATE_BIN_LDFLAGS.profile = -pg @@ -270,7 +294,7 @@ ifndef TEMPLATE_BIN_TOOL endif TEMPLATE_BIN_CFLAGS = -g ifeq ($(USER),bird) - TEMPLATE_BIN_CFLAGS += -Wall -Wextra -pedantic -Wno-unused-parameter + TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS endif TEMPLATE_BIN_LDFLAGS = -g @@ -296,10 +320,25 @@ ifndef TEMPLATE_BIN_TOOL TEMPLATE_BIN_LDFLAGS.amd64 += -m64 TEMPLATE_BIN_LDFLAGS.sparc64 += -m64 ifeq ($(KBUILD_TARGET),solaris) - TEMPLATE_BIN_LIBS += rt + TEMPLATE_BIN_LIBS += rt dl TEMPLATE_BIN_LDFLAGS += -Wl,-i + TEMPLATE_BIN_DEFS.x86 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE + TEMPLATE_BIN_DEFS.sparc32 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE endif endif +if1of ($(KBUILD_TARGET), darwin win) + TEMPLATE_BIN_LD_DEBUG = split +endif + +# +# Template for building threaded binaries. +# +TEMPLATE_BIN-THREADED = Threaded command line binary +TEMPLATE_BIN-THREADED_EXTENDS = BIN +TEMPLATE_BIN-THREADED_EXTENDS_BY = appending +if1of ($(KBUILD_TARGET), dragonfly freebsd openbsd) + TEMPLATE_BIN-THREADED_LIBS = pthread +endif # # Template for building libraries for the tools. diff --git a/Maintenance.kmk b/Maintenance.kmk index f4957c5..9d10f55 100644 --- a/Maintenance.kmk +++ b/Maintenance.kmk @@ -1,10 +1,10 @@ -# $Id: Maintenance.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Maintenance.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Maintenance Makefile for kBuild. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/Makefile.kmk b/Makefile.kmk index b6e14fb..79c58e9 100644 --- a/Makefile.kmk +++ b/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2440 2011-07-06 12:17:51Z bird $ ## @file # Top-Level Sub-Makefile for kBuild. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -72,9 +72,6 @@ kBuild_bin_SOURCES.os2 = \ kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/libc063.dll=>libc063.dll if1of ($(KBUILD_TARGET), nt win) -kBuild_bin_SOURCES.$(KBUILD_TARGET) = \ - kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/kmk_ash.exe=>kmk_ash.exe \ - kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/cygwin1.dll=>cygwin1.dll kBuild_bin_SOURCES.$(KBUILD_TARGET).x86 = \ kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/msvcr71.dll=>msvcr71.dll kBuild_bin_SOURCES.$(KBUILD_TARGET).amd64 = \ diff --git a/VSlickMacros/kdev.e b/VSlickMacros/kdev.e index 176e495..a86dd1d 100644 --- a/VSlickMacros/kdev.e +++ b/VSlickMacros/kdev.e @@ -1,10 +1,10 @@ -/* $Id: kdev.e 2243 2009-01-10 02:24:02Z bird $ -*- tab-width: 4 c-indent-level: 4 -*- */ +/* $Id: kdev.e 2413 2010-09-11 17:43:04Z bird $ -*- tab-width: 4 c-indent-level: 4 -*- */ /** @file * Visual SlickEdit Documentation Macros. */ /* - * Copyright (c) 1999-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 1999-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -69,7 +69,7 @@ def 'C-S-M' = k_javadoc_moduleheader def 'C-S-O' = k_oneliner def 'C-S-P' = k_mark_modified_line def 'C-S-S' = k_box_structs -def 'C-S-T' = odin32_maketagfile +def 'C-S-T' = k_rebuild_tagfile def 'C-S-L' = k_style_load //optional stuff @@ -92,7 +92,7 @@ def 'C-S-L' = k_style_load /* Remeber to change these! */ static _str skUserInitials = "bird"; static _str skUserName = "knut st. osmundsen"; -static _str skUserEmail = "bird-kBuild-spamix@anduin.net"; +static _str skUserEmail = "bird-kBuild-spamx@anduin.net"; /******************************************************************************* @@ -184,10 +184,22 @@ static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sEx if (sLexer) { /* multiline */ +#if __VERSION__>=14.0 + _str aComments[]; + GetComments(aComments, "mlcomment", sLexer) + for (i = 0; i < aComments._length(); i++) + if (!pos("documentation", aComments[i]) > 0) + { + sLine = aComments[i]; + break; + } + if (sLine != '') +#else rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine); if (rc) rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine); if (!rc) +#endif { sLeft = strip(word(sLine, 1)); sRight = strip(word(sLine, 2)); @@ -196,10 +208,21 @@ static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sEx } /* failed, try single line. */ +#if __VERSION__>=14.0 + GetComments(aComments, "linecomment", sLexer) + for (i = 0; i < aComments._length(); i++) + if (!pos("documentation", aComments[i]) > 0) + { + sLine = aComments[i]; + break; + } + if (sLine != '') +#else rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine); if (rc) rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine); if (!rc) +#endif { sLeft = strip(word(sLine, 1)); sRight = ''; @@ -1171,6 +1194,7 @@ void k_javadoc_funcbox() _str sArgs = ""; int iCursorLine; int iPadd = k_alignup(11, p_SyntaxIndent); + /* look for parameters */ boolean fFoundFn = !k_func_goto_nearest_function(); if (fFoundFn) @@ -1195,11 +1219,13 @@ void k_javadoc_funcbox() for (i = 0; i < cArgs; i++) { _str sName, sType, sDefault; - if (!k_func_enumparams(sArgs, i, sType, sName, sDefault) + if ( !k_func_enumparams(sArgs, i, sType, sName, sDefault) && iPadd2 < length(sName)) iPadd2 = length(sName); } iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent); + if (iPadd2 < 28) + iPadd2 = k_alignup(28, p_SyntaxIndent); /* * Insert parameter. @@ -1209,7 +1235,7 @@ void k_javadoc_funcbox() _str sName, sType, sDefault; if (!k_func_enumparams(sArgs, i, sType, sName, sDefault)) { - _str sStr3 = ''; + _str sStr3 = '.'; if (sDefault != "") sStr3 = '(default='sDefault')'; k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3); @@ -1943,35 +1969,24 @@ static void klib_klog_file_int(boolean fAsk) } } - -/******************************************************************************* -* Odin32 backward compatibility * -*******************************************************************************/ -_command void odin32_maketagfile() +/** @todo move to kkeys.e */ +_command void k_rebuild_tagfile() { - /* We'll */ +#if 1 /*__VERSION__ < 14.0*/ if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "") - { - _project_update_files_retag(false,false,false,false); - /* - RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false, - doRemove,false,true,true);*/ - } + _project_update_files_retag(false, false, false, false); else - _project_update_files_retag(true,false,false,true); -} - -_command void odin32_setcurrentdir() -{ - //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir); - //cd(workingdir); - /* Go the the directory containing the project filename */ - cd(strip_filename(_project_name, 'NE')); + _project_update_files_retag(true, false, false, true); +#else + _str sArgs = "-refs=on"; + if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "") + sArgs = sArgs :+ " -retag"; + sArgs = sArgs :+ " " :+ _workspace_filename; + build_workspace_tagfiles(sArgs); +#endif } - - /******************************************************************************* * Styles * *******************************************************************************/ @@ -2728,6 +2743,7 @@ static int k_style_emacs_var(_str sVar, _str sVal) case 'nuke-trailing-whitespace-p': { +#if 0 _str sName = 'def-koptions-'p_buf_id; int idx = insert_name(sName, MISC_TYPE, "kstyledoc"); if (!idx) @@ -2740,6 +2756,7 @@ static int k_style_emacs_var(_str sVar, _str sVal) set_name_info(idx, "saveoptions: -S"); say 'sVal=' sVal; } +#endif break; } @@ -2872,12 +2889,17 @@ void k_style_load() void _buffer_add_kdev(int buf_id) { _str sName = 'def-koptions-'buf_id; - int idx = insert_name(sName, MISC_TYPE, "kstyledoc"); - if (!idx) - idx = find_index(sName, MISC_TYPE); + int idx = find_index(sName, MISC_TYPE); + if (idx) + delete_name(idx); + //message("_buffer_add_kdev: " idx " name=" sName); + + sName = 'def-kstyledoc-'buf_id; + idx = find_index(sName, MISC_TYPE); if (idx) - set_name_info(idx, ""); - //message("_buffer_add_kdev: " idx); + delete_name(idx); + + //k_style_load(); } @@ -3315,9 +3337,9 @@ btnCancel.lbutton_up() definit() { /* do cleanup. */ - for (i = 0; i < 200; i++) + for (i = 0; i < 999; i++) { - index = name_match("def-koptions-", 1, MISC_TYPE); + index = name_match("def-koptions-", 1 /*find_first*/, MISC_TYPE); if (!index) break; delete_name(index); diff --git a/VSlickMacros/kkeys.e b/VSlickMacros/kkeys.e index e2933b3..ce6af56 100644 --- a/VSlickMacros/kkeys.e +++ b/VSlickMacros/kkeys.e @@ -1,10 +1,10 @@ -/* $Id: kkeys.e 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kkeys.e 2437 2011-03-28 19:17:08Z bird $ */ /** @file * Bird's key additions to Visual Slickedit. */ /* - * Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -23,6 +23,15 @@ * */ +/******************************************************************************* +* Header Files * +*******************************************************************************/ +#include 'slick.sh' + + +/******************************************************************************* +* Global Variables * +*******************************************************************************/ defeventtab default_keys def 'A-UP' = find_prev def 'A-DOWN' = find_next @@ -41,19 +50,54 @@ def 'C-DOWN' = kkeys_scroll_up def 'C-PGUP' = prev_window def 'C-PGDN' = next_window def 'C-DEL' = kkeys_delete_right +#if __VERSION__ >= 15.0 +def 'S-C-=' = svn_diff_with_base +#endif +#if __VERSION__ >= 14.0 +def 'C-/' = kkeys_push_ref +def 'S-C-/' = push_ref +def 'S-A-]' = next_buff_tab +def 'S-A-[' = prev_buff_tab +def 'S-A-U' = kkeys_gen_uuid +#endif /* For the mac (A/M mix, all except A-z): */ +def 'M-1' = cursor_error def 'M-UP' = find_prev def 'M-DOWN' = find_next def 'M-PGUP' = prev_proc def 'M-PGDN' = next_proc def 'M-d' = delete_line +def 'M-f' = kkeys_open_file_menu +def 'M-e' = kkeys_open_edit_menu def 'M-o' = kkeys_duplicate_line def 'M-s' = kkeys_switch_lines +def 'M-t' = kkeys_open_tools_menu def 'M-u' = undo_cursor def 'M-g' = goto_line +#if __VERSION__ >= 14.0 +def 'S-M-]' = next_buff_tab +def 'S-M-[' = prev_buff_tab +def 'S-M-U' = kkeys_gen_uuid +#endif /* Fixing brainfucked slickedit silliness: */ def 'M-v' = paste + +/** Saves the cursor position. */ +static long kkeys_save_cur_pos() +{ + long offset = _QROffset(); + message(offset); + return offset; +} + +/** Restores a saved cursor position. */ +static void kkeys_restore_cur_pos(long lSavedCurPos) +{ + _GoToROffset(lSavedCurPos); +} + + _command kkeys_switch_lines() { /* Allocate a selection for copying the current line. */ @@ -91,18 +135,31 @@ _command kkeys_duplicate_line() _command kkeys_delete_right() { - col=p_col - search('[ \t]#|?|$|^','r+'); - if ( match_length()&& get_text(1,match_length('s'))=='' ) + col=p_col; + + /* virtual space hack*/ + keyin(" "); + left(); + _delete_char(); + + /* are we in a word, delete it? */ + ch = get_text(); + if (ch != ' ' && ch != "\t" && ch != "\r" && ch != "\n") + delete_word(); + + /* delete spaces and newlines until the next word. */ + ch = get_text(); + if (ch == ' ' || ch == "\t" || ch == "\r" || ch == "\n") { - _nrseek(match_length('s')); - _delete_text(match_length()); + if (search('[ \t\n\r]#','r+') == 0) + { + _nrseek(match_length('s')); + _delete_text(match_length()); + } } - else - delete_word(); + p_col=col //retrieve_command_results() - } _command kkeys_delete_left() @@ -140,11 +197,9 @@ _command kkeys_scroll_down() _command boxer_paste() { - int rc; - offset = _QROffset(); - message(offset); - rc = paste(); - _GoToROffset(offset); + long lSavedCurPos = kkeys_save_cur_pos() + paste(); + kkeys_restore_cur_pos(lSavedCurPos); } _command kkeys_fullscreen() @@ -238,9 +293,117 @@ _command boxer_select() } } +#if __VERSION__ >= 14.0 + +/** + * Search for references only in the current workspace. + */ +_command kkeys_push_ref() +{ + if (_isEditorCtl()) + { + sProjTagFile = project_tags_filename(); + sLangId = p_LangId; + if (sProjTagFile != '') + { + + /* HACK ALERT: Make sure gtag_filelist_last_ext has the right value. */ + _update_tag_filelist_ext(sLangId); + + /* save */ + boolean saved_gtag_filelist_cache_updated = gtag_filelist_cache_updated; + _str saved_gtag_filelist_ext[] = gtag_filelist_ext; + + /* HACK ALERT: Replace the tag file list for this language. */ + gtag_filelist_ext._makeempty(); + gtag_filelist_ext[0] = sProjTagFile; + saved_gtag_filelist_cache_updated = true; + + /* Do the reference searching. */ + push_ref('-e ' :+ sLangId); + + /* restore*/ + gtag_filelist_cache_updated = saved_gtag_filelist_cache_updated; + gtag_filelist_ext = saved_gtag_filelist_ext; + } + else + push_ref(); + } + else + push_ref(); +} + + +_command kkeys_gen_uuid() +{ + _str uuid = guid_create_string('G'); + uuid = lowcase(uuid); + + long lSavedCurPos = kkeys_save_cur_pos(); + _insert_text(uuid); + kkeys_restore_cur_pos(lSavedCurPos); +} + +#endif /* >= 14.0 */ + +/** @name Mac OS X Hacks: Alt+[fet] -> drop down menu + * + * This only works when the alt menu hotkeys are enabled in the + * settings. Al + * + * @{ + */ +_command void kkeys_open_file_menu() +{ + call_key(A_F) +} + +_command void kkeys_open_edit_menu() +{ + call_key(A_E) +} + +_command void kkeys_open_tools_menu() +{ + call_key(A_T) +} +/** @} */ void nop() { } + +#if __VERSION__ >= 14.0 + +/* + * Some diff keyboard hacks for Mac OS X. + */ +defeventtab _diff_form +def 'M-f' = kkeys_diffedit_find +def 'M-n' = kkeys_diffedit_next +def 'M-p' = kkeys_diffedit_prev + +_command kkeys_diffedit_find() +{ + _nocheck _control _ctlfind; + _ctlfind.call_event(_ctlfind, LBUTTON_UP); +} + +_command kkeys_diffedit_next() +{ + _nocheck _control _ctlfile1; + _nocheck _control _ctlfile2; + _DiffNextDifference(_ctlfile1, _ctlfile2); +} + +_command kkeys_diffedit_prev() +{ + _nocheck _control _ctlfile1; + _nocheck _control _ctlfile2; + _DiffNextDifference(_ctlfile1, _ctlfile2, '-'); +} + +#endif /* >= 14.0 */ + diff --git a/bootstrap.gmk b/bootstrap.gmk index 06498a7..8cbb233 100644 --- a/bootstrap.gmk +++ b/bootstrap.gmk @@ -1,10 +1,10 @@ -# $Id: bootstrap.gmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: bootstrap.gmk 2421 2010-10-17 21:27:53Z bird $ ## @file # GNU Make Compatible bootstrap Makefile. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -41,6 +41,9 @@ # Note to self on bootstrapping solaris.sparc64: # SED_MAKE_DEFS="SED=gsed" AUTOPOINT=true ACLOCAL=aclocal-1.10 AUTOMAKE=automake-1.10 nice ./kBuild/env.sh --full gmake -f bootstrap.gmk # +# Note to self on bootstrapping openbsd: +# AUTOCONF_VERSION=2.59 AUTOMAKE_VERSION=1.9 ./kBuild/env.sh --full gmake -f bootstrap.gmk +# # # OPTIONAL: @@ -215,11 +218,11 @@ $(OUTDIR)/ts-stage2-build: \ $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \ $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET) \ $(OUTDIR)/kmk/kmk - $(OUTDIR)/kmk/kmk -C $(SRCDIR) KBUILD_BOOTSTRAP=1 + KBUILD_BIN_PATH=$(OUTDIR)/kmk $(OUTDIR)/kmk/kmk -C $(SRCDIR) KBUILD_BOOTSTRAP=1 echo done > $@ $(OUTDIR)/ts-stage2-install: $(OUTDIR)/ts-stage2-build - $(OUTDIR)/kmk/kmk -C $(SRCDIR) KBUILD_BOOTSTRAP=1 PATH_INS=$(SRCDIR) install + KBUILD_BIN_PATH=$(OUTDIR)/kmk $(OUTDIR)/kmk/kmk -C $(SRCDIR) KBUILD_BOOTSTRAP=1 PATH_INS=$(SRCDIR) install echo done > $@ diff --git a/dist/debian/changelog b/dist/debian/changelog index 906fcbf..cd34516 100644 --- a/dist/debian/changelog +++ b/dist/debian/changelog @@ -3,7 +3,7 @@ kbuild (1:0.1.5-1) unstable; urgency=low * New upstream version. * Adopted for tarball use. - -- bird <bird-kBuild-spamix@anudin.net> Thu, 22 Jan 2009 01:05:00 +0100 + -- bird <bird-kBuild-spamx@anduin.net> Thu, 22 Jan 2009 01:05:00 +0100 kbuild (1:0.1.5svn2062-1) unstable; urgency=low diff --git a/dist/debian/copyright b/dist/debian/copyright index 1873184..2e9daa1 100644 --- a/dist/debian/copyright +++ b/dist/debian/copyright @@ -4,10 +4,10 @@ Sat May 5 14:23:24 CEST 2007. It was downloaded from http://svn.netlabs.org/kbuild Upstream Author: -2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> Copyright: -(C) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +(C) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> License: diff --git a/dist/macports/devel/kbuild-head/Portfile b/dist/macports/devel/kbuild-head/Portfile index 7f5c5ae..8ca831d 100644 --- a/dist/macports/devel/kbuild-head/Portfile +++ b/dist/macports/devel/kbuild-head/Portfile @@ -1,11 +1,11 @@ -# $Id: Portfile 2243 2009-01-10 02:24:02Z bird $ +# $Id: Portfile 2413 2010-09-11 17:43:04Z bird $ # Very crude atm, everything is exec'ed. PortSystem 1.0 name kbuild-head version 9999 categories devel -maintainers bird-kBuild-spamix@anduin.net +maintainers bird-kBuild-spamx@anduin.net description kBuild subversion trunk long_description \ See http://svn.netlabs.org/kbuild (I'm lazy). diff --git a/dist/macports/devel/kbuild/Portfile b/dist/macports/devel/kbuild/Portfile index fb4411f..d59e402 100644 --- a/dist/macports/devel/kbuild/Portfile +++ b/dist/macports/devel/kbuild/Portfile @@ -1,11 +1,11 @@ -# $Id: Portfile 2261 2009-01-22 01:00:16Z bird $ +# $Id: Portfile 2413 2010-09-11 17:43:04Z bird $ # Very crude atm, everything is exec'ed. PortSystem 1.0 name kbuild version 0.1.5 categories devel -maintainers bird-kBuild-spamix@anduin.net +maintainers bird-kBuild-spamx@anduin.net description kBuild long_description \ See http://svn.netlabs.org/kbuild (I'm lazy). diff --git a/kBuild/doc/Makefile.kmk b/kBuild/doc/Makefile.kmk index fc74100..17730b1 100644 --- a/kBuild/doc/Makefile.kmk +++ b/kBuild/doc/Makefile.kmk @@ -1,6 +1,63 @@ +DEPTH = ../.. +include ../header.kmk -QuickReference-kmk.html: QuickReference-kmk.txt - LC_ALL=C rst2html.py --no-generator $< $@ +TXTFILES = \ + QuickReference-kmk.txt \ + QuickReference-kBuild.txt + +define genrule +all: $(name).html +clean:: + kmk_rm -f $(name).html +$(name).html: $(name).txt + LC_ALL=C rst2html.py --no-generator $$< $$@ +$(name).o: $(name).html +.PHONY: $(name).o +endef + +$(foreach name, $(basename $(TXTFILES)), $(eval $(genrule))) + + +# +# For generating the basis for the target properties table. +# +my_tp.1 = BLDPROGS PROGRAMS +my_tp.2 = LIBRARIES +my_tp.3 = IMPORT_LIBS DLLS +my_tp.4 = DLLS +my_tp.5 = PROGRAMS +my_tp.6 = SYSMODS +my_tp.7 = MISCBINS +my_tp.8 = INSTALLS +my_tp.9 = FETCHES +my_tp.a = OTHERS +my_tp = 1 2 3 4 5 6 7 8 9 a +tpc := $(translate $(my_tp),$(SP)) + +define def_target_prop_rule +target-properties:: + @$$(PRINTF) '|%-2s| %-18s| %-6s|%$(expr 79-33)s|\n' "$(kind)" "``$(prop)``" "$(my_tmp_which)" "" + @$$(ECHO) '+--+-------------------+-------+----------------------------------------------+' +endef +define def_target_prop_doit +my_tmp_which := $(foreach x,$(my_tp),$(if $(intersects \ + $(prop),\ + $(foreach nm,$(my_tp.$(x)),$(foreach suff,SINGLE DEFERRED ACCUMULATE_R ACCUMULATE_L,$(PROPS_$(nm)_$(suff)))))\ + ,$(x),)) +my_tmp_which := $(translate $(my_tmp_which),$(SP)) +$(for local i = 1, $i < 10, local i := $(expr $i + 1),$(for local l = $(expr 10 - $i + 1), $l > 3, local l := $(expr $l - 1), \ + $(eval my_tmp_which:=$(subst $(substr $(tpc), $i, $l),$i-$(substr $(tpc),$(expr $i + $l - 1),1),$(my_tmp_which)))\ +) ) +$(eval $(def_target_prop_rule)) +endef +kind := S +$(foreach prop,$(sort $(PROPS_SINGLE)),$(evalcall def_target_prop_doit)) +kind := D +$(foreach prop,$(sort $(PROPS_DEFERRED)),$(evalcall def_target_prop_doit)) +kind := Ar +$(foreach prop,$(sort $(PROPS_ACCUMULATE_R)),$(evalcall def_target_prop_doit)) +kind := Al +$(foreach prop,$(sort $(PROPS_ACCUMULATE_L)),$(evalcall def_target_prop_doit)) +#kind := To +#$(foreach prop,$(sort $(PROPS_TOOLS_ONLY)),$(evalcall def_target_prop_doit)) -QuickReference-kmk.o: QuickReference-kmk.html -.PHONY: QuickReference-kmk.o diff --git a/kBuild/doc/QuickReference-kBuild.txt b/kBuild/doc/QuickReference-kBuild.txt new file mode 100644 index 0000000..70079c1 --- /dev/null +++ b/kBuild/doc/QuickReference-kBuild.txt @@ -0,0 +1,276 @@ + +kBuild Quick Reference +====================== + +This is an attempt at summarizing the magic of kBuild makefiles. + + +The anatomy of a kBuild Makefile +-------------------------------- + +A typical makefile:: + + # $Id: QuickReference-kBuild.txt 2345 2009-04-19 23:47:42Z bird $ + ## @file + # Makefile description. + # + + # + # Copyright (c) year name + # License, disclaimer and other legal text. + # + + SUB_DEPTH = ../.. + include $(KBUILD_PATH)/subheader.kmk + + # + # Include sub-makefiles. + # + include $(PATH_CURRENT)/subdir1/Makefile.kmk + include $(PATH_CURRENT)/subdir2/Makefile.kmk + + # + # Global variables. + # + MYPREFIX_SOMETHING = or another + + # + # Target lists. + # + DLLS += mydll + PROGRAMS += myprogs + + # + # mydll - description. + # + mydll_TEMPLATE = MYDLL + mydll_SOURCES = mydll.c + mydll_SOURCES.win = $(mydll_0_OUTDIR)/mydll.def + + # + # myprog - description. + # + myprog_TEMPLATE = MYPROG + myprog_SOURCES = myprog.c + + # + # Custom rules (optional of course). + # + $$(mydll_0_OUTDIR)/mydll.def: + $(APPEND) -t $@ LIBRARY mydll.dll + $(APPEND) $@ EXPORTS + $(APPEND) $@ ' myfunction' + + include $(FILE_KBUILD_SUB_FOOTER) + + +Target lists +------------ + ++-+-------------------+-------------------------------------------------------+ +|#| Name | Description | ++=+===================+=======================================================+ +|1| ``BLDPROGS`` | Build programs, targets the host platform. | ++-+-------------------+-------------------------------------------------------+ +|2| ``LIBRARIES`` | Libraries (not shared). | ++-+-------------------+-------------------------------------------------------+ +|3| ``IMPORT_LIBS`` | Import libraries or stub shared libraries. | ++-+-------------------+-------------------------------------------------------+ +|4| ``DLLS`` | DLLs, Shared Libraries, DYLIBs, etc. | ++-+-------------------+-------------------------------------------------------+ +|5| ``PROGRAMS`` | Executable programs. | ++-+-------------------+-------------------------------------------------------+ +|6| ``SYSMODS`` | System modules (kexts, kernel modules, drivers, etc). | ++-+-------------------+-------------------------------------------------------+ +|7| ``MISCBINS`` | Miscellanceous binaries like BIOS images and such. | ++-+-------------------+-------------------------------------------------------+ +|8| ``INSTALLS`` | Things to install. [1]_ | ++-+-------------------+-------------------------------------------------------+ +|9| ``FETCHES`` | Things to fetch. [1]_ | ++-+-------------------+-------------------------------------------------------+ +|a| ``OTHERS`` | List of targets made during the others pass. | ++-+-------------------+-------------------------------------------------------+ + + +Target properties +----------------- + +The first column indicates the kind of property, S=Single, D=Deferred, +Ar=Accumlate-Right and Al=Accumulate-Left. + +The third column should be cross referenced with the first column in the +target list table above. + ++--+-------------------+-------+----------------------------------------------+ +|K | Name | Which | Description | ++==+===================+=======+==============================================+ +|S | ``ARLIBSUFF`` | 2 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``ARTOOL`` | 2 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``ASOBJSUFF`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``ASTOOL`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``BINSUFF`` | 7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``BLD_TRG`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``BLD_TRG_ARCH`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``BLD_TRG_CPU`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``BLD_TYPE`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``COBJSUFF`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``CTOOL`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``CXXOBJSUFF`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``CXXTOOL`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``DLLSUFF`` | 34 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``EXESUFF`` | 15 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``FETCHDIR`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``FETCHTOOL`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``GID`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``INST`` | 1-9 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``LDTOOL`` | 13-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``LIBSUFF`` | 234 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``MODE`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``NOINST`` | 1-8 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``OBJCOBJSUFF`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``OBJCTOOL`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``OBJSUFF`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``PATCHTOOL`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``RCOBJSUFF`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``RCTOOL`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``SYSSUFF`` | 6 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``TEMPLATE`` | 1-9 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``TOOL`` | 1-9 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``UID`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|S | ``UNPACKTOOL`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|D | ``INSTALLER`` | 1-8 | | ++--+-------------------+-------+----------------------------------------------+ +|D | ``INSTFUN`` | 1-8 | | ++--+-------------------+-------+----------------------------------------------+ +|D | ``NAME`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|D | ``POST_CMDS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|D | ``PRE_CMDS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|D | ``SONAME`` | 13-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``ARFLAGS`` | 2 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``ASDEFS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``ASFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``CDEFS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``CFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``CXXDEFS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``CXXFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``DEFS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``DEPS`` | 1-8 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``FETCHFLAGS`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``IDFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``IFDLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``ISFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``LDFLAGS`` | 13-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``LNK_DEPS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``LNK_ORDERDEPS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``OBJCDEFS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``OBJCFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``ORDERDEPS`` | 1-8 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``PATCHFLAGS`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``RCDEFS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``RCFLAGS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Ar| ``UNPACKFLAGS`` | 9 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``ASINCS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``BLDDIRS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``CINCS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``CLEAN`` | 1-9 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``CXXINCS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``DIRS`` | 8 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``INCS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``INTERMEDIATES`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``LIBPATH`` | 13-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``LIBS`` | 13-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``OBJCINCS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``RCINCS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``SDKS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``SOURCES`` | 1-9 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``SRC_HANDLERS`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ +|Al| ``USES`` | 1-7 | | ++--+-------------------+-------+----------------------------------------------+ + + +----- + +.. [1] Normally not one of the default passes. + +----- + +:Status: $Id: QuickReference-kBuild.txt 2345 2009-04-19 23:47:42Z bird $ +:Copyright: Copyright (c) 2009 knut st. osmundsen + + diff --git a/kBuild/doc/QuickReference-kmk.html b/kBuild/doc/QuickReference-kmk.html index 0ffe3a0..3f56877 100644 --- a/kBuild/doc/QuickReference-kmk.html +++ b/kBuild/doc/QuickReference-kmk.html @@ -10,8 +10,8 @@ /* :Author: David Goodger :Contact: goodger@users.sourceforge.net -:Date: $Date: 2009-01-10 03:24:02 +0100 (Sa, 10. Jan 2009) $ -:Revision: $Revision: 2243 $ +:Date: $Date: 2009-04-18 14:05:47 +0200 (Sa, 18 Apr 2009) $ +:Revision: $Revision: 2340 $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. @@ -327,7 +327,7 @@ include file -include file sinclude file </pre> -<p>Include another dependency file <a class="footnote-reference" href="#id83" id="id1" name="id1">[1]</a>:</p> +<p>Include another dependency file <a class="footnote-reference" href="#id84" id="id1" name="id1">[1]</a>:</p> <pre class="literal-block"> includedep file </pre> @@ -357,7 +357,7 @@ export variable <= value [1] export variable ?= value unexport variable </pre> -<p>Define a variable in the local context instead of the global one <a class="footnote-reference" href="#id83" id="id2" name="id2">[1]</a>:</p> +<p>Define a variable in the local context instead of the global one <a class="footnote-reference" href="#id84" id="id2" name="id2">[1]</a>:</p> <pre class="literal-block"> local variable = value local variable := value @@ -508,36 +508,36 @@ processed, if any). Do not set this.</td> <tt class="docutils literal"><span class="pre">KBUILD_VERSION_PATCH</span></tt>, <tt class="docutils literal"><span class="pre">KBUILD_KMK_REVISION</span></tt></td> <td>The kBuild version string and the break down -into individual components. <a class="footnote-reference" href="#id83" id="id3" name="id3">[1]</a></td> +into individual components. <a class="footnote-reference" href="#id84" id="id3" name="id3">[1]</a></td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST</span></tt> <a class="footnote-reference" href="#id83" id="id4" name="id4">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST</span></tt> <a class="footnote-reference" href="#id84" id="id4" name="id4">[1]</a></td> <td>The host operating system.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_ARCH</span></tt> <a class="footnote-reference" href="#id83" id="id5" name="id5">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_ARCH</span></tt> <a class="footnote-reference" href="#id84" id="id5" name="id5">[1]</a></td> <td>The host architecture.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_CPU</span></tt> <a class="footnote-reference" href="#id83" id="id6" name="id6">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_CPU</span></tt> <a class="footnote-reference" href="#id84" id="id6" name="id6">[1]</a></td> <td>The host CPU <tt class="docutils literal"><span class="pre">kmk</span></tt> is built for, set to <tt class="docutils literal"><span class="pre">blend</span></tt> if not any particular CPU.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KBUILD_PATH</span></tt> <a class="footnote-reference" href="#id83" id="id7" name="id7">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KBUILD_PATH</span></tt> <a class="footnote-reference" href="#id84" id="id7" name="id7">[1]</a></td> <td>Where the kBuild scripts are.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KBUILD_BIN_PATH</span></tt> <a class="footnote-reference" href="#id83" id="id8" name="id8">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KBUILD_BIN_PATH</span></tt> <a class="footnote-reference" href="#id84" id="id8" name="id8">[1]</a></td> <td>Where the host specific kBuild binaries are.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KMK</span></tt> <a class="footnote-reference" href="#id83" id="id9" name="id9">[1]</a>, +<tr><td><tt class="docutils literal"><span class="pre">KMK</span></tt> <a class="footnote-reference" href="#id84" id="id9" name="id9">[1]</a>, <tt class="docutils literal"><span class="pre">MAKE</span></tt></td> <td>The name with which <tt class="docutils literal"><span class="pre">kmk</span></tt> was invoked. Using this variable in recipes has special meaning.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KMK_BUILTIN</span></tt> <a class="footnote-reference" href="#id83" id="id10" name="id10">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KMK_BUILTIN</span></tt> <a class="footnote-reference" href="#id84" id="id10" name="id10">[1]</a></td> <td>List of built-in commands.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KMK_FEATURES</span></tt> <a class="footnote-reference" href="#id83" id="id11" name="id11">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KMK_FEATURES</span></tt> <a class="footnote-reference" href="#id84" id="id11" name="id11">[1]</a></td> <td>List of <tt class="docutils literal"><span class="pre">kmk</span></tt> specific features.</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt> <a class="footnote-reference" href="#id83" id="id12" name="id12">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt> <a class="footnote-reference" href="#id84" id="id12" name="id12">[1]</a></td> <td><p class="first">The flags given to <tt class="docutils literal"><span class="pre">kmk</span></tt>. You can set this in the environment or a makefile to set flags.</p> <p class="last">It is never appropriate to use <tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt> @@ -547,10 +547,10 @@ allow recursive <tt class="docutils literal"><span class="pre">kmk</span></tt>'s through the environment from its parent.</p> </td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KMK_LEVEL</span></tt> <a class="footnote-reference" href="#id83" id="id13" name="id13">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KMK_LEVEL</span></tt> <a class="footnote-reference" href="#id84" id="id13" name="id13">[1]</a></td> <td>The number of levels of recursion (sub-makes).</td> </tr> -<tr><td><tt class="docutils literal"><span class="pre">KMK_VERSION</span></tt> <a class="footnote-reference" href="#id83" id="id14" name="id14">[1]</a></td> +<tr><td><tt class="docutils literal"><span class="pre">KMK_VERSION</span></tt> <a class="footnote-reference" href="#id84" id="id14" name="id14">[1]</a></td> <td>The GNU <tt class="docutils literal"><span class="pre">make</span></tt> version number.</td> </tr> <tr><td><tt class="docutils literal"><span class="pre">MAKECMDGOALS</span></tt></td> @@ -586,7 +586,7 @@ current directory.</td> </tr> </tbody> </table> -<p>The following variables reflects <tt class="docutils literal"><span class="pre">kmk</span></tt> options. Do not set these. <a class="footnote-reference" href="#id83" id="id15" name="id15">[1]</a></p> +<p>The following variables reflects <tt class="docutils literal"><span class="pre">kmk</span></tt> options. Do not set these. <a class="footnote-reference" href="#id84" id="id15" name="id15">[1]</a></p> <table border="1" class="docutils"> <colgroup> <col width="49%" /> @@ -668,7 +668,7 @@ created with low resolution time stamps.</td> <tr><td><tt class="docutils literal"><span class="pre">.NOTPARALLEL</span></tt></td> <td>If mentioned without any prerequisites, <tt class="docutils literal"><span class="pre">kmk</span></tt> will run serially as if -j1 was -given. If it has prerequisites <tt class="docutils literal"><span class="pre">kmk</span></tt> <a class="footnote-reference" href="#id83" id="id16" name="id16">[1]</a> +given. If it has prerequisites <tt class="docutils literal"><span class="pre">kmk</span></tt> <a class="footnote-reference" href="#id84" id="id16" name="id16">[1]</a> will only do this for the targets among them.</td> </tr> @@ -694,7 +694,7 @@ it will be expanded a second time after all makefiles have been read.</td> </tr> <tr><td><tt class="docutils literal"><span class="pre">.SECONDTARGETEXPANSION</span></tt> -<a class="footnote-reference" href="#id83" id="id17" name="id17">[1]</a></td> +<a class="footnote-reference" href="#id84" id="id17" name="id17">[1]</a></td> <td>If mentioned, all targets after it will be expanded a second time after all makefiles have been read.</td> @@ -715,7 +715,7 @@ will be cleared.</td> </div> <div class="section"> <h1><a id="commands" name="commands">Commands</a></h1> -<p>Builtin commands <a class="footnote-reference" href="#id83" id="id18" name="id18">[1]</a> all start with <tt class="docutils literal"><span class="pre">kmk_builtin_</span></tt>, so in order to save +<p>Builtin commands <a class="footnote-reference" href="#id84" id="id18" name="id18">[1]</a> all start with <tt class="docutils literal"><span class="pre">kmk_builtin_</span></tt>, so in order to save space this prefix has been omitted in the table below. All commands comes in an external edition that can be used by/in the shell, these are prefixed <tt class="docutils literal"><span class="pre">kmk_</span></tt>.</p> <table border="1" class="docutils"> @@ -826,7 +826,7 @@ variables and current directory before kicking of program.</td> </div> <div class="section"> <h1><a id="kmk-expression" name="kmk-expression">kmk-expression</a></h1> -<p><tt class="docutils literal"><span class="pre">kmk</span></tt>-expressions <a class="footnote-reference" href="#id83" id="id19" name="id19">[1]</a> are related to the C/C++ preprocessor in some ways as +<p><tt class="docutils literal"><span class="pre">kmk</span></tt>-expressions <a class="footnote-reference" href="#id84" id="id19" name="id19">[1]</a> are related to the C/C++ preprocessor in some ways as well as <tt class="docutils literal"><span class="pre">nmake</span></tt> and BSD <tt class="docutils literal"><span class="pre">make</span></tt>. There are however some peculiarities because of the way GNU <tt class="docutils literal"><span class="pre">make</span></tt> choose to represent booleans in its function library, so, strings can be turned into boolean by taking any non-empty string @@ -980,7 +980,7 @@ $(filter-out pattern...,text) $(sort list) </pre> <p>Sort the words in <tt class="docutils literal"><span class="pre">list</span></tt> lexicographically in reserve order, removing -duplicates <a class="footnote-reference" href="#id83" id="id20" name="id20">[1]</a>:</p> +duplicates <a class="footnote-reference" href="#id84" id="id20" name="id20">[1]</a>:</p> <pre class="literal-block"> $(rsort list) </pre> @@ -1008,44 +1008,44 @@ $(lastword names...) <pre class="literal-block"> $(join list1,list2) </pre> -<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to upper case <a class="footnote-reference" href="#id83" id="id21" name="id21">[1]</a>:</p> +<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to upper case <a class="footnote-reference" href="#id84" id="id21" name="id21">[1]</a>:</p> <pre class="literal-block"> $(toupper text) </pre> -<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to lower case <a class="footnote-reference" href="#id83" id="id22" name="id22">[1]</a>:</p> +<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to lower case <a class="footnote-reference" href="#id84" id="id22" name="id22">[1]</a>:</p> <pre class="literal-block"> $(tolower text) </pre> -<p>String formatting a la the unix <tt class="docutils literal"><span class="pre">printf</span></tt> command <a class="footnote-reference" href="#id83" id="id23" name="id23">[1]</a>:</p> +<p>String formatting a la the unix <tt class="docutils literal"><span class="pre">printf</span></tt> command <a class="footnote-reference" href="#id84" id="id23" name="id23">[1]</a>:</p> <pre class="literal-block"> $(printf fmt, arg...) </pre> -<p>Return the length of a string or a (unexpanded) variable <a class="footnote-reference" href="#id83" id="id24" name="id24">[1]</a>:</p> +<p>Return the length of a string or a (unexpanded) variable <a class="footnote-reference" href="#id84" id="id24" name="id24">[1]</a>:</p> <pre class="literal-block"> $(length string) $(length-var var) </pre> <p>Find the position of <tt class="docutils literal"><span class="pre">needle</span></tt> in <tt class="docutils literal"><span class="pre">haystack</span></tt>, returns 0 if not found. Negative <tt class="docutils literal"><span class="pre">start</span></tt> indices are relative to the end of <tt class="docutils literal"><span class="pre">haystack</span></tt>, while -positive ones are one based <a class="footnote-reference" href="#id83" id="id25" name="id25">[1]</a>:</p> +positive ones are one based <a class="footnote-reference" href="#id84" id="id25" name="id25">[1]</a>:</p> <pre class="literal-block"> $(pos needle, haystack[, start]) $(lastpos needle, haystack[, start]) </pre> <p>Returns the specified substring. The <tt class="docutils literal"><span class="pre">start</span></tt> works like with <tt class="docutils literal"><span class="pre">$(pos</span> <span class="pre">)</span></tt>. If the substring is partially outside the <tt class="docutils literal"><span class="pre">string</span></tt> the result will be -padded with <tt class="docutils literal"><span class="pre">pad</span></tt> if present <a class="footnote-reference" href="#id83" id="id26" name="id26">[1]</a>:</p> +padded with <tt class="docutils literal"><span class="pre">pad</span></tt> if present <a class="footnote-reference" href="#id84" id="id26" name="id26">[1]</a>:</p> <pre class="literal-block"> $(substr string, start[, length[, pad]]) </pre> <p>Insert <tt class="docutils literal"><span class="pre">in</span></tt> into <tt class="docutils literal"><span class="pre">str</span></tt> at the specified position. <tt class="docutils literal"><span class="pre">n</span></tt> works like with -<tt class="docutils literal"><span class="pre">$(pos</span> <span class="pre">)</span></tt>, except that <tt class="docutils literal"><span class="pre">0</span></tt> is the end of the string <a class="footnote-reference" href="#id83" id="id27" name="id27">[1]</a>:</p> +<tt class="docutils literal"><span class="pre">$(pos</span> <span class="pre">)</span></tt>, except that <tt class="docutils literal"><span class="pre">0</span></tt> is the end of the string <a class="footnote-reference" href="#id84" id="id27" name="id27">[1]</a>:</p> <pre class="literal-block"> $(insert in, str[, n[, length[, pad]]]) </pre> <p>Translate <tt class="docutils literal"><span class="pre">string</span></tt> exchanging characters in <tt class="docutils literal"><span class="pre">from-set</span></tt> with <tt class="docutils literal"><span class="pre">to-set</span></tt>, optionally completing <tt class="docutils literal"><span class="pre">to-set</span></tt> with <tt class="docutils literal"><span class="pre">pad-char</span></tt> if specified. If no -<tt class="docutils literal"><span class="pre">pad-char</span></tt> characters absent in <tt class="docutils literal"><span class="pre">to-set</span></tt> will be deleted <a class="footnote-reference" href="#id83" id="id28" name="id28">[1]</a>:</p> +<tt class="docutils literal"><span class="pre">pad-char</span></tt> characters absent in <tt class="docutils literal"><span class="pre">to-set</span></tt> will be deleted <a class="footnote-reference" href="#id84" id="id28" name="id28">[1]</a>:</p> <pre class="literal-block"> $(translate string, from-set[, to-set[, pad-char]]) </pre> @@ -1070,7 +1070,7 @@ $(suffix names...) $(basename names...) </pre> <p>Extract the root specification of each file name (a bit complicated on -Windows & OS/2) <a class="footnote-reference" href="#id83" id="id29" name="id29">[1]</a>:</p> +Windows & OS/2) <a class="footnote-reference" href="#id84" id="id29" name="id29">[1]</a>:</p> <pre class="literal-block"> $(root names...) </pre> @@ -1098,72 +1098,72 @@ contain any <tt class="docutils literal"><span class="pre">.</span></tt> or <tt $(abspath names...) </pre> <p>Same as <tt class="docutils literal"><span class="pre">$(abspath</span> <span class="pre">)</span></tt> except that the current directory can be -specified as <tt class="docutils literal"><span class="pre">curdir</span></tt> <a class="footnote-reference" href="#id83" id="id30" name="id30">[1]</a>:</p> +specified as <tt class="docutils literal"><span class="pre">curdir</span></tt> <a class="footnote-reference" href="#id84" id="id30" name="id30">[1]</a>:</p> <pre class="literal-block"> $(abspathex names...[, curdir]) </pre> </blockquote> <p>Arithmetic Functions:</p> <blockquote> -<p>Returns the sum of the arguments <a class="footnote-reference" href="#id83" id="id31" name="id31">[1]</a>:</p> +<p>Returns the sum of the arguments <a class="footnote-reference" href="#id84" id="id31" name="id31">[1]</a>:</p> <pre class="literal-block"> $(int-add addend1, addend2[, addendN]) </pre> <p>Returns the difference between the first argument and the sum of the -rest <a class="footnote-reference" href="#id83" id="id32" name="id32">[1]</a>:</p> +rest <a class="footnote-reference" href="#id84" id="id32" name="id32">[1]</a>:</p> <pre class="literal-block"> $(int-sub minuend, subtrahend[, subtrahendN]) </pre> -<p>Returns the product of the arguments <a class="footnote-reference" href="#id83" id="id33" name="id33">[1]</a>:</p> +<p>Returns the product of the arguments <a class="footnote-reference" href="#id84" id="id33" name="id33">[1]</a>:</p> <pre class="literal-block"> $(int-mul factor1, factor2[, factorN]) </pre> -<p>Returns the quotient of first argument and the rest <a class="footnote-reference" href="#id83" id="id34" name="id34">[1]</a>:</p> +<p>Returns the quotient of first argument and the rest <a class="footnote-reference" href="#id84" id="id34" name="id34">[1]</a>:</p> <pre class="literal-block"> $(int-div dividend, divisor[, divisorN]) </pre> -<p>Returns the modulus of the two arguments <a class="footnote-reference" href="#id83" id="id35" name="id35">[1]</a>:</p> +<p>Returns the modulus of the two arguments <a class="footnote-reference" href="#id84" id="id35" name="id35">[1]</a>:</p> <pre class="literal-block"> $(int-mod dividend, divisor) </pre> -<p>Returns the bitwise two-complement of argument <a class="footnote-reference" href="#id83" id="id36" name="id36">[1]</a>:</p> +<p>Returns the bitwise two-complement of argument <a class="footnote-reference" href="#id84" id="id36" name="id36">[1]</a>:</p> <pre class="literal-block"> $(int-not val) </pre> -<p>Returns the result of a bitwise AND of the arguments <a class="footnote-reference" href="#id83" id="id37" name="id37">[1]</a>:</p> +<p>Returns the result of a bitwise AND of the arguments <a class="footnote-reference" href="#id84" id="id37" name="id37">[1]</a>:</p> <pre class="literal-block"> $(int-and val1, val2[, valN]) </pre> -<p>Returns the result of a bitwise OR of the arguments <a class="footnote-reference" href="#id83" id="id38" name="id38">[1]</a>:</p> +<p>Returns the result of a bitwise OR of the arguments <a class="footnote-reference" href="#id84" id="id38" name="id38">[1]</a>:</p> <pre class="literal-block"> $(int-or val1, val2[, valN]) </pre> -<p>Returns the result of a bitwise XOR of the arguments <a class="footnote-reference" href="#id83" id="id39" name="id39">[1]</a>:</p> +<p>Returns the result of a bitwise XOR of the arguments <a class="footnote-reference" href="#id84" id="id39" name="id39">[1]</a>:</p> <pre class="literal-block"> $(int-xor val1, val2[, valN]) </pre> <p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean (true = non-empty, false = empty) result -of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">==</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id83" id="id40" name="id40">[1]</a>:</p> +of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">==</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id84" id="id40" name="id40">[1]</a>:</p> <pre class="literal-block"> $(int-eq val1, val2) </pre> -<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">!=</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id83" id="id41" name="id41">[1]</a>:</p> +<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">!=</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id84" id="id41" name="id41">[1]</a>:</p> <pre class="literal-block"> $(int-ne val1, val2) </pre> -<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">></span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id83" id="id42" name="id42">[1]</a>:</p> +<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">></span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id84" id="id42" name="id42">[1]</a>:</p> <pre class="literal-block"> $(int-gt val1, val2) </pre> -<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">>=</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id83" id="id43" name="id43">[1]</a>:</p> +<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">>=</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id84" id="id43" name="id43">[1]</a>:</p> <pre class="literal-block"> $(int-ge val1, val2) </pre> -<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre"><</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id83" id="id44" name="id44">[1]</a>:</p> +<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre"><</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id84" id="id44" name="id44">[1]</a>:</p> <pre class="literal-block"> $(int-lt val1, val2) </pre> -<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre"><=</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id83" id="id45" name="id45">[1]</a>:</p> +<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre"><=</span> <span class="pre">val2</span></tt> <a class="footnote-reference" href="#id84" id="id45" name="id45">[1]</a>:</p> <pre class="literal-block"> $(int-le val1, val2) </pre> @@ -1187,54 +1187,54 @@ last one:</p> $(and condition1[,condition2[,condition3[...]]]) </pre> <p>Test if the two strings are identical, returning <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean (true = -non-empty, false = empty) <a class="footnote-reference" href="#id84" id="id46" name="id46">[2]</a>:</p> +non-empty, false = empty) <a class="footnote-reference" href="#id85" id="id46" name="id46">[2]</a>:</p> <pre class="literal-block"> $(eq str1, str2) </pre> -<p>Invert a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value <a class="footnote-reference" href="#id84" id="id47" name="id47">[2]</a>:</p> +<p>Invert a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value <a class="footnote-reference" href="#id85" id="id47" name="id47">[2]</a>:</p> <pre class="literal-block"> $(not val) </pre> -<p>Test if <tt class="docutils literal"><span class="pre">variable</span></tt> is defined, returning a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value <a class="footnote-reference" href="#id83" id="id48" name="id48">[1]</a>:</p> +<p>Test if <tt class="docutils literal"><span class="pre">variable</span></tt> is defined, returning a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value <a class="footnote-reference" href="#id84" id="id48" name="id48">[1]</a>:</p> <pre class="literal-block"> $(defined variable) </pre> <p>Test if <tt class="docutils literal"><span class="pre">set-a</span></tt> and <tt class="docutils literal"><span class="pre">set-b</span></tt> intersects, returning a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean -value <a class="footnote-reference" href="#id83" id="id49" name="id49">[1]</a>:</p> +value <a class="footnote-reference" href="#id84" id="id49" name="id49">[1]</a>:</p> <pre class="literal-block"> $(intersects set-a, set-b) </pre> -<p>Same as <tt class="docutils literal"><span class="pre">$(if</span> <span class="pre">)</span></tt> execpt that the condition is a <tt class="docutils literal"><span class="pre">kmk</span></tt>-expression <a class="footnote-reference" href="#id83" id="id50" name="id50">[1]</a>:</p> +<p>Same as <tt class="docutils literal"><span class="pre">$(if</span> <span class="pre">)</span></tt> execpt that the condition is a <tt class="docutils literal"><span class="pre">kmk</span></tt>-expression <a class="footnote-reference" href="#id84" id="id50" name="id50">[1]</a>:</p> <pre class="literal-block"> $(if-expr kmk-expression,true-part[,false-part]) </pre> <p>Select the first true condition (<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) and expand the following body. Special condition strings <tt class="docutils literal"><span class="pre">default</span></tt> and -<tt class="docutils literal"><span class="pre">otherwise</span></tt> <a class="footnote-reference" href="#id83" id="id51" name="id51">[1]</a>:</p> +<tt class="docutils literal"><span class="pre">otherwise</span></tt> <a class="footnote-reference" href="#id84" id="id51" name="id51">[1]</a>:</p> <pre class="literal-block"> $(select when1-cond, when1-body[, whenN-cond, whenN-body]) </pre> <p>Evalutate the <tt class="docutils literal"><span class="pre">kmk-expression</span></tt> returning what it evalues as. This is -the preferred way of doing arithmentic now <a class="footnote-reference" href="#id83" id="id52" name="id52">[1]</a>:</p> +the preferred way of doing arithmentic now <a class="footnote-reference" href="#id84" id="id52" name="id52">[1]</a>:</p> <pre class="literal-block"> $(expr kmk-expression) </pre> </blockquote> <p>Stack Fuctions:</p> <blockquote> -<p>Push <tt class="docutils literal"><span class="pre">item</span></tt> onto the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string <a class="footnote-reference" href="#id83" id="id53" name="id53">[1]</a>:</p> +<p>Push <tt class="docutils literal"><span class="pre">item</span></tt> onto the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string <a class="footnote-reference" href="#id84" id="id53" name="id53">[1]</a>:</p> <pre class="literal-block"> $(stack-push stack-var, item) </pre> -<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt> <a class="footnote-reference" href="#id83" id="id54" name="id54">[1]</a>:</p> +<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt> <a class="footnote-reference" href="#id84" id="id54" name="id54">[1]</a>:</p> <pre class="literal-block"> $(stack-pop stack-var) </pre> -<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string <a class="footnote-reference" href="#id83" id="id55" name="id55">[1]</a>:</p> +<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string <a class="footnote-reference" href="#id84" id="id55" name="id55">[1]</a>:</p> <pre class="literal-block"> $(stack-popv stack-var) </pre> -<p>Get the top item of the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string <a class="footnote-reference" href="#id83" id="id56" name="id56">[1]</a>:</p> +<p>Get the top item of the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string <a class="footnote-reference" href="#id84" id="id56" name="id56">[1]</a>:</p> <pre class="literal-block"> $(stack-top stack-var) </pre> @@ -1254,13 +1254,13 @@ $(foreach var,words,body) <p>C-style for-loop. Start by evaluating <tt class="docutils literal"><span class="pre">init</span></tt>. Each iteration will first check whether the <tt class="docutils literal"><span class="pre">condition</span></tt> (<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) is true, then expand <tt class="docutils literal"><span class="pre">body</span></tt> concatenating the result to the previous iterations -(spaced), and finally evaluate <tt class="docutils literal"><span class="pre">next</span></tt> <a class="footnote-reference" href="#id83" id="id57" name="id57">[1]</a>:</p> +(spaced), and finally evaluate <tt class="docutils literal"><span class="pre">next</span></tt> <a class="footnote-reference" href="#id84" id="id57" name="id57">[1]</a>:</p> <pre class="literal-block"> $(for init,conditions,next,body) </pre> <p>C-style while-loop. Each iteration will check whether the <tt class="docutils literal"><span class="pre">condition</span></tt> (<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) is true, then expand <tt class="docutils literal"><span class="pre">body</span></tt> concatenating the -result to the previous iterations <a class="footnote-reference" href="#id83" id="id58" name="id58">[1]</a>:</p> +result to the previous iterations <a class="footnote-reference" href="#id84" id="id58" name="id58">[1]</a>:</p> <pre class="literal-block"> $(while conditions,body) </pre> @@ -1275,48 +1275,48 @@ to the empty string:</p> $(eval text) </pre> <p>Same as <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">text)</span></tt> except that the <tt class="docutils literal"><span class="pre">text</span></tt> is expanded in its -own variable context <a class="footnote-reference" href="#id83" id="id59" name="id59">[1]</a>:</p> +own variable context <a class="footnote-reference" href="#id84" id="id59" name="id59">[1]</a>:</p> <pre class="literal-block"> $(evalctx text) </pre> -<p>Same as <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt> <a class="footnote-reference" href="#id83" id="id60" name="id60">[1]</a>:</p> +<p>Same as <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt> <a class="footnote-reference" href="#id84" id="id60" name="id60">[1]</a>:</p> <pre class="literal-block"> $(evalval var) </pre> -<p>Same as <tt class="docutils literal"><span class="pre">$(evalctx</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt> <a class="footnote-reference" href="#id83" id="id61" name="id61">[1]</a>:</p> +<p>Same as <tt class="docutils literal"><span class="pre">$(evalctx</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt> <a class="footnote-reference" href="#id84" id="id61" name="id61">[1]</a>:</p> <pre class="literal-block"> $(evalvalctx var) </pre> -<p>A combination of <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">)</span></tt>, <tt class="docutils literal"><span class="pre">$(call</span> <span class="pre">)</span></tt> and <tt class="docutils literal"><span class="pre">$(value</span> <span class="pre">)</span></tt> <a class="footnote-reference" href="#id83" id="id62" name="id62">[1]</a>:</p> +<p>A combination of <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">)</span></tt>, <tt class="docutils literal"><span class="pre">$(call</span> <span class="pre">)</span></tt> and <tt class="docutils literal"><span class="pre">$(value</span> <span class="pre">)</span></tt> <a class="footnote-reference" href="#id84" id="id62" name="id62">[1]</a>:</p> <pre class="literal-block"> $(evalcall var) </pre> -<p>A combination of <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">)</span></tt> and <tt class="docutils literal"><span class="pre">$(call</span> <span class="pre">)</span></tt> <a class="footnote-reference" href="#id83" id="id63" name="id63">[1]</a>:</p> +<p>A combination of <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">)</span></tt> and <tt class="docutils literal"><span class="pre">$(call</span> <span class="pre">)</span></tt> <a class="footnote-reference" href="#id84" id="id63" name="id63">[1]</a>:</p> <pre class="literal-block"> $(evalcall var) </pre> <p>Remove comments and blank lines from the variable <tt class="docutils literal"><span class="pre">var</span></tt>. Expands to -the empty string <a class="footnote-reference" href="#id83" id="id64" name="id64">[1]</a>:</p> +the empty string <a class="footnote-reference" href="#id84" id="id64" name="id64">[1]</a>:</p> <pre class="literal-block"> $(eval-opt-var var) </pre> <p>Returns accessing <tt class="docutils literal"><span class="pre">$<</span></tt> of <tt class="docutils literal"><span class="pre">target</span></tt>, either retriving the whole thing -or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id83" id="id65" name="id65">[1]</a>:</p> +or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id84" id="id65" name="id65">[1]</a>:</p> <pre class="literal-block"> $(deps target[, pos]) </pre> <p>Returns accessing <tt class="docutils literal"><span class="pre">$+</span></tt> (order + duplicates) of <tt class="docutils literal"><span class="pre">target</span></tt>, either -retriving the whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id83" id="id66" name="id66">[1]</a>:</p> +retriving the whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id84" id="id66" name="id66">[1]</a>:</p> <pre class="literal-block"> $(deps-all target[, pos]) </pre> <p>Returns accessing <tt class="docutils literal"><span class="pre">$?</span></tt> of <tt class="docutils literal"><span class="pre">target</span></tt>, either retriving the whole -thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id83" id="id67" name="id67">[1]</a>:</p> +thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id84" id="id67" name="id67">[1]</a>:</p> <pre class="literal-block"> $(deps-newer target[, pos]) </pre> <p>Returns accessing <tt class="docutils literal"><span class="pre">$|</span></tt> (order only) of <tt class="docutils literal"><span class="pre">target</span></tt>, either retriving the -whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id83" id="id68" name="id68">[1]</a>:</p> +whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin) <a class="footnote-reference" href="#id84" id="id68" name="id68">[1]</a>:</p> <pre class="literal-block"> $(deps-oo target[, pos]) </pre> @@ -1324,14 +1324,14 @@ $(deps-oo target[, pos]) <p>Command Functions:</p> <blockquote> <p>Create one or more command lines avoiding the max argument -length restriction of the host OS <a class="footnote-reference" href="#id83" id="id69" name="id69">[1]</a>:</p> +length restriction of the host OS <a class="footnote-reference" href="#id84" id="id69" name="id69">[1]</a>:</p> <pre class="literal-block"> $(xargs ar cas mylib.a,$(objects)) $(xargs ar cas mylib.a,ar as mylib.a,$(objects)) </pre> <p>Returns the commands for the specified target separated by new-line, space, or a user defined string. Note that this might not produce the 100% correct -result if any of the prerequisite automatic variables are used <a class="footnote-reference" href="#id83" id="id70" name="id70">[1]</a>:</p> +result if any of the prerequisite automatic variables are used <a class="footnote-reference" href="#id84" id="id70" name="id70">[1]</a>:</p> <pre class="literal-block"> $(commands target) $(commands-sc target) @@ -1340,14 +1340,14 @@ $(commands-usr target,sep) <p>Compares two commands returning the empty string if equal and the 3rd argument if not. This differs from <tt class="docutils literal"><span class="pre">$(comp-vars</span> <span class="pre">v1,v2,ne)</span></tt> in that line by line is stripped of leading spaces, command prefixes and -trailing spaces before comparing <a class="footnote-reference" href="#id83" id="id71" name="id71">[1]</a>:</p> +trailing spaces before comparing <a class="footnote-reference" href="#id84" id="id71" name="id71">[1]</a>:</p> <pre class="literal-block"> $(comp-cmds cmds-var1, cmds-var2, ne) $(comp-cmds-ex cmds1, cmd2, ne) </pre> <p>Compares the values of the two variables returning the empty string if equal and the 3rd argument if not. Leading and trailing spaces is -ignored <a class="footnote-reference" href="#id83" id="id72" name="id72">[1]</a>:</p> +ignored <a class="footnote-reference" href="#id84" id="id72" name="id72">[1]</a>:</p> <pre class="literal-block"> $(comp-var var1, var2, ne) </pre> @@ -1383,41 +1383,41 @@ $(flavor variable) </pre> <p>Returns the current local time and date formatted in the <tt class="docutils literal"><span class="pre">strftime</span></tt> style specifier <tt class="docutils literal"><span class="pre">fmt</span></tt>. <tt class="docutils literal"><span class="pre">fmt</span></tt> defaults to <tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%S</span></tt> when -not specified <a class="footnote-reference" href="#id83" id="id73" name="id73">[1]</a>:</p> +not specified <a class="footnote-reference" href="#id84" id="id73" name="id73">[1]</a>:</p> <pre class="literal-block"> $(date fmt) </pre> <p>Returns the current UTC time and date formatted in the <tt class="docutils literal"><span class="pre">strftime</span></tt> style specifier <tt class="docutils literal"><span class="pre">fmt</span></tt>. <tt class="docutils literal"><span class="pre">fmt</span></tt> defaults to <tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%SZ</span></tt> when -not specified <a class="footnote-reference" href="#id83" id="id74" name="id74">[1]</a>:</p> +not specified <a class="footnote-reference" href="#id84" id="id74" name="id74">[1]</a>:</p> <pre class="literal-block"> $(date-utc fmt) </pre> <p>Reformats the <tt class="docutils literal"><span class="pre">in</span></tt> time and date using <tt class="docutils literal"><span class="pre">fmt</span></tt>. The <tt class="docutils literal"><span class="pre">in-fmt</span></tt> defaults to <tt class="docutils literal"><span class="pre">fmt</span></tt> if not specified. While <tt class="docutils literal"><span class="pre">fmt</span></tt> defaults to -<tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%SZ</span></tt> if not specified <a class="footnote-reference" href="#id83" id="id75" name="id75">[1]</a>:</p> +<tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%SZ</span></tt> if not specified <a class="footnote-reference" href="#id84" id="id75" name="id75">[1]</a>:</p> <pre class="literal-block"> $(date-utc fmt,time,in-fmt) </pre> -<p>Returns the current nanosecond timestamp (monotonic when possible) <a class="footnote-reference" href="#id83" id="id76" name="id76">[1]</a>:</p> +<p>Returns the current nanosecond timestamp (monotonic when possible) <a class="footnote-reference" href="#id84" id="id76" name="id76">[1]</a>:</p> <pre class="literal-block"> $(nanots ) </pre> <p>Returns the size of the specified file, or -1 if the size could not -be obtained. This can be used to check if a file exist or not <a class="footnote-reference" href="#id83" id="id77" name="id77">[1]</a>:</p> +be obtained. This can be used to check if a file exist or not <a class="footnote-reference" href="#id84" id="id77" name="id77">[1]</a>:</p> <pre class="literal-block"> $(file-size file) </pre> -<p>Searches the <tt class="docutils literal"><span class="pre">PATH</span></tt> <tt class="docutils literal"><span class="pre">kmk</span></tt> variable for the specified <tt class="docutils literal"><span class="pre">files</span></tt> <a class="footnote-reference" href="#id83" id="id78" name="id78">[1]</a>:</p> +<p>Searches the <tt class="docutils literal"><span class="pre">PATH</span></tt> <tt class="docutils literal"><span class="pre">kmk</span></tt> variable for the specified <tt class="docutils literal"><span class="pre">files</span></tt> <a class="footnote-reference" href="#id84" id="id78" name="id78">[1]</a>:</p> <pre class="literal-block"> $(which files...) </pre> -<p>OS/2: Returns the specified LIBPATH variable value <a class="footnote-reference" href="#id83" id="id79" name="id79">[1]</a>:</p> +<p>OS/2: Returns the specified LIBPATH variable value <a class="footnote-reference" href="#id84" id="id79" name="id79">[1]</a>:</p> <pre class="literal-block"> $(libpath var) </pre> <p>OS/2: Sets the specified LIBPATH variable value, returning the empty -string <a class="footnote-reference" href="#id83" id="id80" name="id80">[1]</a>:</p> +string <a class="footnote-reference" href="#id84" id="id80" name="id80">[1]</a>:</p> <pre class="literal-block"> $(libpath var,value) </pre> @@ -1425,27 +1425,69 @@ $(libpath var,value) <p>Debugging Functions:</p> <blockquote> <p>Returns various make statistics, if no item is specified a default -selection is returned <a class="footnote-reference" href="#id83" id="id81" name="id81">[1]</a>:</p> +selection is returned <a class="footnote-reference" href="#id84" id="id81" name="id81">[1]</a>:</p> <pre class="literal-block"> $(make-stats item[,itemN]) </pre> <p>Raise a debug breakpoint. Used for debugging <tt class="docutils literal"><span class="pre">kmk</span></tt> makefile -parsing <a class="footnote-reference" href="#id83" id="id82" name="id82">[1]</a>:</p> +parsing <a class="footnote-reference" href="#id84" id="id82" name="id82">[1]</a>:</p> <pre class="literal-block"> $(breakpoint ) </pre> </blockquote> +</div> +<div class="section"> +<h1><a id="recipes" name="recipes">Recipes</a></h1> +<blockquote> +<p>A typical recipe takes one of the two following forms:</p> +<pre class="literal-block"> +targets : normal-prerequisites | order-only-prerequisites + command + ... + +targets : normal-prerequisites | order-only-prerequisites ; command + command + ... +</pre> +<p>Specifying more than one file in the <tt class="docutils literal"><span class="pre">targets</span></tt> lists is the same as +repeating the recipe for each of the files.</p> +<p>Use <tt class="docutils literal"><span class="pre">+</span></tt> and <tt class="docutils literal"><span class="pre">+|</span></tt> in the list of <tt class="docutils literal"><span class="pre">targets</span></tt> to tell <tt class="docutils literal"><span class="pre">kmk</span></tt> that the +recipe has more than one output. <a class="footnote-reference" href="#id84" id="id83" name="id83">[1]</a> The files after a <tt class="docutils literal"><span class="pre">+</span></tt> will +always be remade, while the files after a <tt class="docutils literal"><span class="pre">+|</span></tt> don't have to be remade. +The latter is frequently employed to update files which prerequisites +change wihtout the output files necessarily changing. See also +<tt class="docutils literal"><span class="pre">kmk_cp</span> <span class="pre">--changed</span></tt>.</p> +</blockquote> +<p>Double colon recipes</p> +<blockquote> +Double colon recipes are written with <tt class="docutils literal"><span class="pre">::</span></tt> instead of <tt class="docutils literal"><span class="pre">:</span></tt> and are +handled differently from ordinary recipes if the target appears in more +than one recipe. First, all the recipes must be of the double colon type. +Second, the recipes are executed individually and may be omitted depending +on the state of their prerequisites. Double colon recipes without any +prerequisites will always be executed.</blockquote> +<p>Pattern rules</p> +<blockquote> +<p>A couple of examples:</p> +<pre class="literal-block"> +%.o : %.c + gcc -o $@ $< +%.tab.c %.tab.h : %.y + bison -d $< +</pre> +<p>The latter has two outputs.</p> +</blockquote> <hr class="docutils" /> -<table class="docutils footnote" frame="void" id="id83" rules="none"> +<table class="docutils footnote" frame="void" id="id84" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> -<tr><td class="label"><a name="id83">[1]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>, <a class="fn-backref" href="#id3">3</a>, <a class="fn-backref" href="#id4">4</a>, <a class="fn-backref" href="#id5">5</a>, <a class="fn-backref" href="#id6">6</a>, <a class="fn-backref" href="#id7">7</a>, <a class="fn-backref" href="#id8">8</a>, <a class="fn-backref" href="#id9">9</a>, <a class="fn-backref" href="#id10">10</a>, <a class="fn-backref" href="#id11">11</a>, <a class="fn-backref" href="#id12">12</a>, <a class="fn-backref" href="#id13">13</a>, <a class="fn-backref" href="#id14">14</a>, <a class="fn-backref" href="#id15">15</a>, <a class="fn-backref" href="#id16">16</a>, <a class="fn-backref" href="#id17">17</a>, <a class="fn-backref" href="#id18">18</a>, <a class="fn-backref" href="#id19">19</a>, <a class="fn-backref" href="#id20">20</a>, <a class="fn-backref" href="#id21">21</a>, <a class="fn-backref" href="#id22">22</a>, <a class="fn-backref" href="#id23">23</a>, <a class="fn-backref" href="#id24">24</a>, <a class="fn-backref" href="#id25">25</a>, <a class="fn-backref" href="#id26">26</a>, <a class="fn-backref" href="#id27">27</a>, <a class="fn-backref" href="#id28">28</a>, <a class="fn-backref" href="#id29">29</a>, <a class="fn-backref" href="#id30">30</a>, <a class="fn-backref" href="#id31">31</a>, <a class="fn-backref" href="#id32">32</a>, <a class="fn-backref" href="#id33">33</a>, <a class="fn-backref" href="#id34">34</a>, <a class="fn-backref" href="#id35">35</a>, <a class="fn-backref" href="#id36">36</a>, <a class="fn-backref" href="#id37">37</a>, <a class="fn-backref" href="#id38">38</a>, <a class="fn-backref" href="#id39">39</a>, <a class="fn-backref" href="#id40">40</a>, <a class="fn-backref" href="#id41">41</a>, <a class="fn-backref" href="#id42">42</a>, <a class="fn-backref" href="#id43">43</a>, <a class="fn-backref" href="#id44">44</a>, <a class="fn-backref" href="#id45">45</a>, <a class="fn-backref" href="#id48">46</a>, <a class="fn-backref" href="#id49">47</a>, <a class="fn-backref" href="#id50">48</a>, <a class="fn-backref" href="#id51">49</a>, <a class="fn-backref" href="#id52">50</a>, <a class="fn-backref" href="#id53">51</a>, <a class="fn-backref" href="#id54">52</a>, <a class="fn-backref" href="#id55">53</a>, <a class="fn-backref" href="#id56">54</a>, <a class="fn-backref" href="#id57">55</a>, <a class="fn-backref" href="#id58">56</a>, <a class="fn-backref" href="#id59">57</a>, <a class="fn-backref" href="#id60">58</a>, <a class="fn-backref" href="#id61">59</a>, <a class="fn-backref" href="#id62">60</a>, <a class="fn-backref" href="#id63">61</a>, <a class="fn-backref" href="#id64">62</a>, <a class="fn-backref" href="#id65">63</a>, <a class="fn-backref" href="#id66">64</a>, <a class="fn-backref" href="#id67">65</a>, <a class="fn-backref" href="#id68">66</a>, <a class="fn-backref" href="#id69">67</a>, <a class="fn-backref" href="#id70">68</a>, <a class="fn-backref" href="#id71">69</a>, <a class="fn-backref" href="#id72">70</a>, <a class="fn-backref" href="#id73">71</a>, <a class="fn-backref" href="#id74">72</a>, <a class="fn-backref" href="#id75">73</a>, <a class="fn-backref" href="#id76">74</a>, <a class="fn-backref" href="#id77">75</a>, <a class="fn-backref" href="#id78">76</a>, <a class="fn-backref" href="#id79">77</a>, <a class="fn-backref" href="#id80">78</a>, <a class="fn-backref" href="#id81">79</a>, <a class="fn-backref" href="#id82">80</a>)</em> <tt class="docutils literal"><span class="pre">kmk</span></tt> only feature.</td></tr> +<tr><td class="label"><a name="id84">[1]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>, <a class="fn-backref" href="#id3">3</a>, <a class="fn-backref" href="#id4">4</a>, <a class="fn-backref" href="#id5">5</a>, <a class="fn-backref" href="#id6">6</a>, <a class="fn-backref" href="#id7">7</a>, <a class="fn-backref" href="#id8">8</a>, <a class="fn-backref" href="#id9">9</a>, <a class="fn-backref" href="#id10">10</a>, <a class="fn-backref" href="#id11">11</a>, <a class="fn-backref" href="#id12">12</a>, <a class="fn-backref" href="#id13">13</a>, <a class="fn-backref" href="#id14">14</a>, <a class="fn-backref" href="#id15">15</a>, <a class="fn-backref" href="#id16">16</a>, <a class="fn-backref" href="#id17">17</a>, <a class="fn-backref" href="#id18">18</a>, <a class="fn-backref" href="#id19">19</a>, <a class="fn-backref" href="#id20">20</a>, <a class="fn-backref" href="#id21">21</a>, <a class="fn-backref" href="#id22">22</a>, <a class="fn-backref" href="#id23">23</a>, <a class="fn-backref" href="#id24">24</a>, <a class="fn-backref" href="#id25">25</a>, <a class="fn-backref" href="#id26">26</a>, <a class="fn-backref" href="#id27">27</a>, <a class="fn-backref" href="#id28">28</a>, <a class="fn-backref" href="#id29">29</a>, <a class="fn-backref" href="#id30">30</a>, <a class="fn-backref" href="#id31">31</a>, <a class="fn-backref" href="#id32">32</a>, <a class="fn-backref" href="#id33">33</a>, <a class="fn-backref" href="#id34">34</a>, <a class="fn-backref" href="#id35">35</a>, <a class="fn-backref" href="#id36">36</a>, <a class="fn-backref" href="#id37">37</a>, <a class="fn-backref" href="#id38">38</a>, <a class="fn-backref" href="#id39">39</a>, <a class="fn-backref" href="#id40">40</a>, <a class="fn-backref" href="#id41">41</a>, <a class="fn-backref" href="#id42">42</a>, <a class="fn-backref" href="#id43">43</a>, <a class="fn-backref" href="#id44">44</a>, <a class="fn-backref" href="#id45">45</a>, <a class="fn-backref" href="#id48">46</a>, <a class="fn-backref" href="#id49">47</a>, <a class="fn-backref" href="#id50">48</a>, <a class="fn-backref" href="#id51">49</a>, <a class="fn-backref" href="#id52">50</a>, <a class="fn-backref" href="#id53">51</a>, <a class="fn-backref" href="#id54">52</a>, <a class="fn-backref" href="#id55">53</a>, <a class="fn-backref" href="#id56">54</a>, <a class="fn-backref" href="#id57">55</a>, <a class="fn-backref" href="#id58">56</a>, <a class="fn-backref" href="#id59">57</a>, <a class="fn-backref" href="#id60">58</a>, <a class="fn-backref" href="#id61">59</a>, <a class="fn-backref" href="#id62">60</a>, <a class="fn-backref" href="#id63">61</a>, <a class="fn-backref" href="#id64">62</a>, <a class="fn-backref" href="#id65">63</a>, <a class="fn-backref" href="#id66">64</a>, <a class="fn-backref" href="#id67">65</a>, <a class="fn-backref" href="#id68">66</a>, <a class="fn-backref" href="#id69">67</a>, <a class="fn-backref" href="#id70">68</a>, <a class="fn-backref" href="#id71">69</a>, <a class="fn-backref" href="#id72">70</a>, <a class="fn-backref" href="#id73">71</a>, <a class="fn-backref" href="#id74">72</a>, <a class="fn-backref" href="#id75">73</a>, <a class="fn-backref" href="#id76">74</a>, <a class="fn-backref" href="#id77">75</a>, <a class="fn-backref" href="#id78">76</a>, <a class="fn-backref" href="#id79">77</a>, <a class="fn-backref" href="#id80">78</a>, <a class="fn-backref" href="#id81">79</a>, <a class="fn-backref" href="#id82">80</a>, <a class="fn-backref" href="#id83">81</a>)</em> <tt class="docutils literal"><span class="pre">kmk</span></tt> only feature.</td></tr> </tbody> </table> -<table class="docutils footnote" frame="void" id="id84" rules="none"> +<table class="docutils footnote" frame="void" id="id85" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> -<tr><td class="label"><a name="id84">[2]</a></td><td><em>(<a class="fn-backref" href="#id46">1</a>, <a class="fn-backref" href="#id47">2</a>)</em> Experimental GNU <tt class="docutils literal"><span class="pre">make</span></tt> feature that is not enabled by default.</td></tr> +<tr><td class="label"><a name="id85">[2]</a></td><td><em>(<a class="fn-backref" href="#id46">1</a>, <a class="fn-backref" href="#id47">2</a>)</em> Experimental GNU <tt class="docutils literal"><span class="pre">make</span></tt> feature that is not enabled by default.</td></tr> </tbody> </table> <hr class="docutils" /> @@ -1453,7 +1495,7 @@ $(breakpoint ) <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">Status:</th><td class="field-body"><p class="first">$Id: QuickReference-kmk.html 2243 2009-01-10 02:24:02Z bird $</p> +<tr class="field"><th class="field-name">Status:</th><td class="field-body"><p class="first">$Id: QuickReference-kmk.html 2340 2009-04-18 12:05:47Z bird $</p> </td> </tr> <tr class="field"><th class="field-name">Copyright:</th><td class="field-body"><p class="first">Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, diff --git a/kBuild/doc/QuickReference-kmk.txt b/kBuild/doc/QuickReference-kmk.txt index 88bec2a..cab3a58 100644 --- a/kBuild/doc/QuickReference-kmk.txt +++ b/kBuild/doc/QuickReference-kmk.txt @@ -543,6 +543,16 @@ String Manipulation Functions: $(join list1,list2) + Extract the first defined variable from ``variables``, returning its name + (default) or value:: + + $(firstdefined variables[, name|value]) + + Extract the last defined variable from ``variables``, returning its name + (default) or value:: + + $(lastdefined variables[, name|value]) + Fold ``text`` to upper case [1]_:: $(toupper text) @@ -609,6 +619,11 @@ Functions for file names: $(root names...) + Extract the non-root part of each file name (a bit complicated on + Windows & OS/2) [1]_:: + + $(notroot names...) + Append ``suffix`` to each word in ``names``:: $(addsuffix suffix,names...) @@ -829,7 +844,7 @@ Advanced Functions: A combination of ``$(eval )`` and ``$(call )`` [1]_:: - $(evalcall var) + $(evalcall2 var) Remove comments and blank lines from the variable ``var``. Expands to the empty string [1]_:: @@ -911,6 +926,11 @@ Utility functions: $(shell command) + Return a string with the location where the ``kmk`` variable ``variable`` + was defined:: + + $(where variable) + Return a string describing how the ``kmk`` variable ``variable`` was defined:: $(origin variable) @@ -973,6 +993,52 @@ Debugging Functions: $(breakpoint ) +Recipes +------- + + A typical recipe takes one of the two following forms:: + + targets : normal-prerequisites | order-only-prerequisites + command + ... + + targets : normal-prerequisites | order-only-prerequisites ; command + command + ... + + Specifying more than one file in the ``targets`` lists is the same as + repeating the recipe for each of the files. + + Use ``+`` and ``+|`` in the list of ``targets`` to tell ``kmk`` that the + recipe has more than one output. [1]_ The files after a ``+`` will + always be remade, while the files after a ``+|`` don't have to be remade. + The latter is frequently employed to update files which prerequisites + change wihtout the output files necessarily changing. See also + ``kmk_cp --changed``. + + +Double colon recipes + + Double colon recipes are written with ``::`` instead of ``:`` and are + handled differently from ordinary recipes if the target appears in more + than one recipe. First, all the recipes must be of the double colon type. + Second, the recipes are executed individually and may be omitted depending + on the state of their prerequisites. Double colon recipes without any + prerequisites will always be executed. + + +Pattern rules + + A couple of examples:: + + %.o : %.c + gcc -o $@ $< + %.tab.c %.tab.h : %.y + bison -d $< + + The latter has two outputs. + + ----- .. [1] ``kmk`` only feature. @@ -980,7 +1046,7 @@ Debugging Functions: ----- -:Status: $Id: QuickReference-kmk.txt 2243 2009-01-10 02:24:02Z bird $ +:Status: $Id: QuickReference-kmk.txt 2532 2011-08-02 13:05:37Z bird $ :Copyright: Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. diff --git a/kBuild/doc/example1/Config.kmk b/kBuild/doc/example1/Config.kmk new file mode 100644 index 0000000..31eeb84 --- /dev/null +++ b/kBuild/doc/example1/Config.kmk @@ -0,0 +1,25 @@ +# $Id: Config.kmk 2343 2009-04-19 21:44:50Z bird $ +## @file +# kBuild Example no. 1 - Config.kmk - The global configuration file. +# + +# +# The author disclaims copyright to this example script and places +# it in the public domain. +# +# include full-legal-disclaimer.kmk +# + +# +# Some templates. +# +TEMPLATE_ExampleNo1Exe = For creating a program or static library for linking into a program. +TEMPLATE_ExampleNo1Exe_TOOL = GCC +TEMPLATE_ExampleNo1Exe_DEFS = MY_DEFINE=42 MY_OTHER_DEFINE + +TEMPLATE_ExampleNo1Dll = For creating a DLL/SO/DYLIB or static library for linking into a DLL/SO/DYLIB +TEMPLATE_ExampleNo1Dll_EXTENDS = ExampleNo1Exe +TEMPLATE_ExampleNo1Dll_EXTENDS_BY = appending +TEMPLATE_ExampleNo1Dll_DEFS = MY_DLL_INDICATOR + + diff --git a/kBuild/doc/example1/Makefile.kmk b/kBuild/doc/example1/Makefile.kmk new file mode 100644 index 0000000..ecb9350 --- /dev/null +++ b/kBuild/doc/example1/Makefile.kmk @@ -0,0 +1,43 @@ +# $Id: Makefile.kmk 2343 2009-04-19 21:44:50Z bird $ +## @file +# kBuild Example no. 1 - Makefile.kmk - The top-level makefile. +# + +# +# The author disclaims copyright to this example script and places +# it in the public domain. +# +# include full-legal-disclaimer.kmk +# + +SUB_DEPTH = . +include $(KBUILD_PATH)/subheader.kmk + +# +# Include sub-makefiles. +# +include $(PATH_CURRENT)/libhello/Makefile.kmk + +# +# The targets. +# +PROGRAMS += \ + hello \ + hellolib + +# +# Hello world program. +# +hello_TEMPLATE = ExampleNo1Exe +hello_SOURCES = hello.c + +# +# A hello world variant that has some of the code in the libhello directory, +# i.e. linking with a library built by the sub-makefile included above. +# +hellolib_TEMPLATE = ExampleNo1Exe +hellolib_SOURCES = hellolib.c +hellolib_LIBS = $(libhello_1_TARGET) + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/kBuild/doc/example1/hello.c b/kBuild/doc/example1/hello.c new file mode 100644 index 0000000..71f37fe --- /dev/null +++ b/kBuild/doc/example1/hello.c @@ -0,0 +1,21 @@ +/* $Id: hello.c 2343 2009-04-19 21:44:50Z bird $ */ +/** @file + * Example no. 1 - hello.c - Hello world program. + */ + +/* + * The author disclaims copyright to this example code and places + * it in the public domain. + * + * #include <full-legal-disclaimer.h> + * + */ + +#include <stdio.h> + +int main() +{ + printf("Hello world!\n"); + return 0; +} + diff --git a/kBuild/doc/example1/hellolib.c b/kBuild/doc/example1/hellolib.c new file mode 100644 index 0000000..feff4c6 --- /dev/null +++ b/kBuild/doc/example1/hellolib.c @@ -0,0 +1,20 @@ +/* $Id: hellolib.c 2343 2009-04-19 21:44:50Z bird $ */ +/** @file + * Example no. 1 - hellolib.c - Hello world program w/ lib. + */ + +/* + * The author disclaims copyright to this example code and places + * it in the public domain. + * + * #include <full-legal-disclaimer.h> + * + */ + +extern int print_hello_world(void); + +int main() +{ + return print_hello_world(); +} + diff --git a/kBuild/doc/example1/libhello/Makefile.kmk b/kBuild/doc/example1/libhello/Makefile.kmk new file mode 100644 index 0000000..674c8b3 --- /dev/null +++ b/kBuild/doc/example1/libhello/Makefile.kmk @@ -0,0 +1,30 @@ +# $Id: Makefile.kmk 2343 2009-04-19 21:44:50Z bird $ +## @file +# kBuild Example no. 1 - libhello/Makefile.kmk - The libhello sub-makefile. +# + +# +# The author disclaims copyright to this example script and places +# it in the public domain. +# +# include full-legal-disclaimer.kmk +# + +SUB_DEPTH = .. +include $(KBUILD_PATH)/subheader.kmk + +# +# The targets. +# +LIBRARIES += libhello + +# +# The hello world library. +# +libhello_TEMPLATE = ExampleNo1Exe +libhello_SOURCES = libhello.c + +## @todo Create a DLL variant. + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/kBuild/doc/example1/libhello/libhello.c b/kBuild/doc/example1/libhello/libhello.c new file mode 100644 index 0000000..5a9024d --- /dev/null +++ b/kBuild/doc/example1/libhello/libhello.c @@ -0,0 +1,24 @@ +/* $Id: libhello.c 2343 2009-04-19 21:44:50Z bird $ */ +/** @file + * Example no. 1 - libhello.c - Hello world library. + */ + +/* + * The author disclaims copyright to this example code and places + * it in the public domain. + * + * #include <full-legal-disclaimer.h> + * + */ + +#include <stdio.h> + +extern int print_hello_world(void); + +int print_hello_world(void) +{ + printf("Hello library world!\n"); + return 0; +} + + diff --git a/kBuild/env.sh b/kBuild/env.sh index e7522cb..c0f2eb5 100755 --- a/kBuild/env.sh +++ b/kBuild/env.sh @@ -1,11 +1,11 @@ #!/bin/sh -# $Id: env.sh 2243 2009-01-10 02:24:02Z bird $ +# $Id: env.sh 2413 2010-09-11 17:43:04Z bird $ ## @file # Environment setup script. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -112,7 +112,7 @@ do ;; "--help") - echo "kBuild Environment Setup Script, v0.1.4" + echo "kBuild Environment Setup Script, v0.2.0-pre" echo "" echo "syntax: $0 [options] [command [args]]" echo " or: $0 [options] --var <varname>" @@ -123,7 +123,7 @@ do echo "an interactive shell." echo "The second form will print the specfified variable(s)." echo "The third form will print all exported variables suitable for bourne shell" - echo "evalutation." + echo "evaluation." echo "The forth form will only print the specified variable(s)." echo "" echo "Options:" @@ -142,7 +142,7 @@ do echo " --set, --export" echo " Whether --eval explicitly export the variables. --set is useful for" echo " getting a list of environment vars for a commandline, while --eval" - echo " is useful for eval `env.sh`. Default: --export" + echo ' is useful for eval `env.sh`. Default: --export' echo "" exit 1 ;; diff --git a/kBuild/envos2.cmd b/kBuild/envos2.cmd index 6a02d92..4ce849c 100644 --- a/kBuild/envos2.cmd +++ b/kBuild/envos2.cmd @@ -2,14 +2,14 @@ echo this is a rexx script!
cancel & quit & exit
*/
-/* $Id: envos2.cmd 2243 2009-01-10 02:24:02Z bird $ */
+/* $Id: envos2.cmd 2413 2010-09-11 17:43:04Z bird $ */
/** @file
* Environment setup script for OS/2.
*/
/*
*
- * Copyright (c) 1999-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
+ * Copyright (c) 1999-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
*
* This file is part of kBuild.
*
diff --git a/kBuild/envwin.cmd b/kBuild/envwin.cmd index 4460ddf..26c769c 100644 --- a/kBuild/envwin.cmd +++ b/kBuild/envwin.cmd @@ -1,11 +1,11 @@ @echo off
-REM $Id: $
+REM $Id: envwin.cmd 2413 2010-09-11 17:43:04Z bird $
REM REM @file
REM Environment setup script.
REM
REM
-REM Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
+REM Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
REM
REM This file is part of kBuild.
REM
@@ -393,7 +393,7 @@ goto try_by_pwd cd "%_KBUILD_SELF%\.."
for /f "tokens=*" %%d in ('cd') do set _KBUILD_PATH=%%d
cd "%_KBUILD_CURDIR%"
-if exist "%_KBUILD_PATH%\footer.kmk" goto found_kbuild
+if exist "%_KBUILD_PATH%\footer.kmk" goto found_kbuild
REM Try relative to the current directory.
:try_by_pwd
diff --git a/kBuild/footer-inherit-uses-tools.kmk b/kBuild/footer-inherit-uses-tools.kmk new file mode 100644 index 0000000..55b7056 --- /dev/null +++ b/kBuild/footer-inherit-uses-tools.kmk @@ -0,0 +1,1059 @@ +# $Id: footer-inherit-uses-tools.kmk 2521 2011-07-26 18:18:19Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Template & Target Inheritance, Uses and Tools. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +## Converts a variable from simple to recursive flavor. +# This is used by def_inherit_template_one_accumulate_l and def_inherit_template_one_accumulate_r. +# @param $1 The variable name. +define def_simple_2_recursive +$1_DEFERRED := $$($1) +$1 = $$($1_DEFERRED) +endef + + +## Inherit one keyword in a non-accumulative manner. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +define def_inherit_one_keyword +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key)) + endif +endif +endef + + +# EXPAND_BY = overriding + +## Inherit one keyword in a non-accumulative manner. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +define def_inherit_one_keyword_overriding_now_l +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) + endif +endif +endef + +## @copydoc def_inherit_one_overriding_now_l +define def_inherit_one_keyword_overriding_now_r +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) + endif +endif +endef + +## Inherit one keyword in a non-accumulative manner, deferred expansion. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +# @remark This define relies on double evaluation +define def_inherit_one_keyword_overriding_deferred +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) + endif +endif +endef + +## @copydoc def_inherit_one_overriding_deferred +define def_inherit_one_keyword_overriding_deferred_l +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) + endif +endif +endef + +## @copydoc def_inherit_one_overriding_deferred +define def_inherit_one_keyword_overriding_deferred_r +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) + endif +endif +endef + + +# EXPAND_BY = prepending + +## Inherit one keyword in a prepending manner. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +define def_inherit_one_keyword_prepending_now_l +ifdef $(trg)_$(prop).$(src_key) + $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key)) +endif +endef + +## @copydoc def_inherit_one_prepending_now_l +define def_inherit_one_keyword_prepending_now_r +ifdef $(trg)_$(prop).$(src_key) + $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key)) +endif +endef + +## Inherit one keyword in a non-accumulative manner, deferred expansion. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +# @remark This define relies on double evaluation +define def_inherit_one_keyword_prepending_deferred +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) + endif +endif +endef + +## Inherit one keyword in a prepending manner, deferred expansion. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +define def_inherit_one_keyword_prepending_deferred_l +ifdef $(trg)_$(prop).$(src_key) + ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) + endif + $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key)) +endif +endef + +## @copydoc def_inherit_one_prepending_deferred_l +define def_inherit_one_keyword_prepending_deferred_r +ifdef $(trg)_$(prop).$(src_key) + ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) + endif + $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key)) +endif +endef + + +# EXPAND_BY = appending + +## Inherit one keyword in an appending manner. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +define def_inherit_one_keyword_appending_now_l +ifdef $(trg)_$(prop).$(src_key) + $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key)) +endif +endef + +## @copydoc def_inherit_one_appending_now_l +define def_inherit_one_keyword_appending_now_r +ifdef $(trg)_$(prop).$(src_key) + $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key)) +endif +endef + +## Inherit one keyword in a non-accumulative manner, deferred expansion. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +# @remark This define relies on double evaluation +define def_inherit_one_keyword_appending_deferred +ifdef $(trg)_$(prop).$(src_key) + ifndef $(trg)_$(prop).$(trg_key) + $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) + endif +endif +endef + +## Inherit one keyword in an appending manner, deferred expansion. +# @param $(trg) Target object. +# @param $(prop) The property. +# @param $(src_key) Source keyword. +# @param $(trg_key) Target keyword. +define def_inherit_one_keyword_appending_deferred_l +ifdef $(trg)_$(prop).$(src_key) + ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) + endif + $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key)) +endif +endef + +## @copydoc def_inherit_one_appending_deferred_l +define def_inherit_one_keyword_appending_deferred_r +ifdef $(trg)_$(prop).$(src_key) + ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) + endif + $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key)) +endif +endef + + +## Worker for def_inherit that deals with one keyword that makes +# use of inheritance. +# @param prefix_keyword key_prefix:keyword. The cool join/split game as usual. +# @param trg Object to consider for inheriting. +# @param properties List of the properties with straight expansion. +# @param properties_now_l List of the properties with immediate expansion, accumulating on the left side. +# @param properties_now_r List of the properties with immediate expansion, accumulating on the right side. +# @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative . +# @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side. +# @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side. +define def_inherit_keyword +local prefix := $(word 1,$(subst :, ,$(prefix_keyword))) +local trg_key := $(word 2,$(subst :, ,$(prefix_keyword))) +local src_key := $($(prefix)_$(trg_key)_EXTENDS) +local by := $($(prefix)_$(trg_key)_EXTENDS_BY) + +# Inherit the properties. +$(foreach prop, $(properties), $(eval $(def_inherit_one_keyword))) +$(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l))) +$(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r))) +$(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred))) +$(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l))) +$(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r))) + +endef # def_inherit_keyword + + +## Inherit one template property in a non-accumulative manner. +# @param $(prop) Property name +# @param $(src) Source (parent) object. +# @param $(trg) Target (child) object. +define def_inherit_one +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) = $($(src)_$(prop)) + endif +endif +endef + + +# EXPAND_BY = overriding + +## Inherit one template property in a non-accumulative manner. +# @param $(prop) Property name +# @param $(src) Source (parent) object. +# @param $(trg) Target (child) object. +define def_inherit_one_overriding_now_l +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) := $($(src)_$(prop)) + endif +endif +endef + +## @copydoc def_inherit_one_overriding_now_l +define def_inherit_one_overriding_now_r +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) := $($(src)_$(prop)) + endif +endif +endef + +## Inherit one template property in a non-accumulative manner, deferred expansion. +# @param $(prop) Property name +# @param $(src) Source +# @param $(trg) Target +# @remark This define relies on double evaluation +define def_inherit_one_overriding_deferred +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) = $$($(src)_$(prop)) + endif +endif +endef + +## @copydoc def_inherit_one_overriding_deferred +define def_inherit_one_overriding_deferred_l +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) = $$($(src)_$(prop)) + endif +endif +endef + +## @copydoc def_inherit_one_overriding_deferred +define def_inherit_one_overriding_deferred_r +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) = $$($(src)_$(prop)) + endif +endif +endef + + +# EXPAND_BY = prepending + +## Inherit one template property in a prepending manner. +# @param $(prop) Property name +# @param $(src) Source (parent) object. +# @param $(trg) Target (child) object. +define def_inherit_one_prepending_now_l +ifdef $(src)_$(prop) + $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop)) +endif +endef + +## @copydoc def_inherit_one_prepending_now_l +define def_inherit_one_prepending_now_r +ifdef $(src)_$(prop) + $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop)) +endif +endef + +## Inherit one template property in a non-accumulative manner, deferred expansion. +# @param $(prop) Property name +# @param $(src) Source +# @param $(trg) Target +# @remark This define relies on double evaluation +define def_inherit_one_prepending_deferred +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) = $$($(src)_$(prop)) + endif +endif +endef + +## Inherit one template property in a prepending manner, deferred expansion. +# @param $(prop) Property name +# @param $(src) Source (parent) object. +# @param $(trg) Target (child) object. +define def_inherit_one_prepending_deferred_l +ifdef $(src)_$(prop) + ifeq ($$(flavor $(trg)_$(prop)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) + endif + $(trg)_$(prop) <= $$($(src)_$(prop)) +endif +endef + +## @copydoc def_inherit_one_prepending_deferred_l +define def_inherit_one_prepending_deferred_r +ifdef $(src)_$(prop) + ifeq ($$(flavor $(trg)_$(prop)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) + endif + $(trg)_$(prop) += $$($(src)_$(prop)) +endif +endef + + +# EXPAND_BY = appending + +## Inherit one template property in an appending manner. +# @param $(prop) Property name +# @param $(src) Source (parent) object. +# @param $(trg) Target (child) object. +define def_inherit_one_appending_now_l +ifdef $(src)_$(prop) + $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop)) +endif +endef + +## @copydoc def_inherit_one_appending_now_l +define def_inherit_one_appending_now_r +ifdef $(src)_$(prop) + $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop)) +endif +endef + +## Inherit one template property in a non-accumulative manner, deferred expansion. +# @param $(prop) Property name +# @param $(src) Source +# @param $(trg) Target +# @remark This define relies on double evaluation +define def_inherit_one_appending_deferred +ifdef $(src)_$(prop) + ifndef $(trg)_$(prop) + $(trg)_$(prop) = $$($(src)_$(prop)) + endif +endif +endef + +## Inherit one template property in an appending manner, deferred expansion. +# @param $(prop) Property name +# @param $(src) Source (parent) object. +# @param $(trg) Target (child) object. +define def_inherit_one_appending_deferred_l +ifdef $(src)_$(prop) + ifeq ($$(flavor $(trg)_$(prop)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) + endif + $(trg)_$(prop) += $$($(src)_$(prop)) +endif +endef + +## @copydoc def_inherit_one_appending_deferred_l +define def_inherit_one_appending_deferred_r +ifdef $(src)_$(prop) + ifeq ($$(flavor $(trg)_$(prop)),simple) + $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) + endif + $(trg)_$(prop) <= $$($(src)_$(prop)) +endif +endef + + +## combines the specified properties $(1) with the $(_KEYWORDS) list. +_INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1))) + + +## Generic inheritance for use with targets templates and tools. +# @param trg Object to consider for inheriting. +# @param src_prefix What to prefix the value found in EXTENDS with to get the object. +# @param load_function Load function for stuff that needs +# @param properties List of the properties with straight expansion. +# @param properties_now_l List of the properties with immediate expansion, accumulating on the left side. +# @param properties_now_r List of the properties with immediate expansion, accumulating on the right side. +# @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative . +# @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side. +# @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side. +define def_inherit + +# Load it - loading is a mess, fix. +ifneq ($(load_function),) + local loading := $(patsubst $(src_prefix)%,%,$(trg)) + $(evalvalctx $(load_function)) +endif + +local src := $(strip $($(trg)_EXTENDS)) +ifneq ($(src),) + ifndef $(trg)_EXTENDS_STATUS_ + $(trg)_EXTENDS_STATUS_ := 0 + + # Load the source. + ifneq ($(load_function),) + local loading := $(src) + $(evalvalctx $(load_function)) + endif + + # less typing. + local src := $(src_prefix)$(src) + + # Recursivly process the parent (src) if it's inherting from somebody too. + ifdef $(src)_EXTENDS + ifneq ($($(src)_EXTENDS_STATUS_),42) + # 'foreach' will create 'trg' in a new variable context hiding + # out current variable. 'src' OTOH will be overwritten. + $(foreach trg, $(src), $(evalval def_inherit)) + local src := $(src_prefix)$(strip $($(trg)_EXTENDS)) + endif + endif + + # Get & check EXTENDS_BY. + local by = $(strip $($(trg)_EXTENDS_BY)) + ifeq ($(by),) + local by = overriding + else ifn1of ($(by), overriding appending prepending) + $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!) + endif + + # Inherit the properties. + $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one))) + $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l))) + $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r))) + $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred))) + $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l))) + $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r))) + + # Mark the target as done. + $(trg)_EXTENDS_STATUS_ := 42 + else + # Check for inheritance loops. + ifneq ($($(trg)_EXTENDS_STATUS_),42) + $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_)) + endif + endif +endif + +# Keyword inheritance. +$(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword)) + +endef # def_inherit + + +# +# Load global units before doing any inheriting so they can add new properties. +# +# This only applies to the guys listed in the global USES since there is +# no reliable way to deal with things on a target level without first +# applying templates. So, to avoid having USES mess up all targets, +# we'll make the global and per-target USES property work differently: +# The global USES does not apply to targets, just globally. +# + +## Unit load function. +# @param loading The unit name +define def_unit_load_function +ifndef UNIT_$(loading) + UNIT_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) + ifeq ($(UNIT_$(loading)_KMK_FILE),) + $(error kBuild: Cannot find include file for the unit '$(loading)'! Searched: $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS)) + endif + include $(UNIT_$(loading)_KMK_FILE) + ifndef UNIT_$(loading) + $(warning kBuild: UNIT_$(loading) was not defined by $(UNIT_$(loading)_KMK_FILE)!) + endif +endif +endef # def_unit_load_function + +$(foreach loading, \ + $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(USES.$(KBUILD_TARGET_CPU)) \ + $(USES.$(KBUILD_TARGET_ARCH)) \ + $(USES.$(KBUILD_TARGET)) \ + $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ + $(USES.$(KBUILD_HOST_CPU)) \ + $(USES.$(KBUILD_HOST_ARCH)) \ + $(USES.$(KBUILD_TARGET)) \ + $(USES.$(KBUILD_TYPE)) \ + $(USES),$(evalval def_unit_load_function)) + + +# +# Determin all the templates that is being used and make +# sure they are present before we try collect keywords. +# +_TEMPLATES := $(TEMPLATE) +define def_templates +ifdef $(target)_TEMPLATE + ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))") + $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them) + endif + _TEMPLATES += $($(target)_TEMPLATE) +endif +endef # def_templates +$(foreach target, $(_ALL_TARGETS), $(eval $(def_templates))) +_TEMPLATES := $(sort $(_TEMPLATES)) + +## Template load function. +# @param loading The template name. This is prefixed. +define def_templates_load_function +ifndef TEMPLATE_$(loading) + TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) + ifeq ($(TEMPLATE_$(loading)_KMK_FILE),) + $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS)) + endif + include $(TEMPLATE_$(loading)_KMK_FILE) + ifndef TEMPLATE_$(loading) + $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!) + endif +endif +endef # def_templates_load_function +$(foreach loading, $(_TEMPLATES), $(evalval def_templates_load_function)) + + +# +# Determin the keywords required for correct inherting and setup keyword inheritance. +# +# This means walking all the lists of immediate template and targets and +# pick up all the BLD_T* keywords. Since templates that are referenced +# indirectly in the inheritance hierarchy, the result from this exercise +# might not be 100% accurate... :-/ +# +_BLD_TYPES := $(KBUILD_TYPE) +_BLD_TARGETS := $(KBUILD_TARGET) $(KBUILD_HOSTS) +_BLD_ARCHES := $(KBUILD_TARGET_ARCH) $(KBUILD_HOST_ARCH) +_BLD_CPUS := $(KBUILD_TARGET_CPU) $(KBUILD_HOST_CPU) + +define def_collect_bld_xyz +ifdef $(src)_BLD_TYPE + ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES)) + $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!) + endif + _BLD_TYPES += $($(src)_BLD_TYPE) +endif +ifdef $(src)_BLD_TRG + ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES)) + $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!) + endif + _BLD_TARGETS += $($(src)_BLD_TRG) +endif +ifdef $(src)_BLD_TRG_ARCH + ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES)) + $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!) + endif + _BLD_ARCHES += $($(src)_BLD_TRG_ARCH) +endif +ifdef $(src)_BLD_TRG_CPU + if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES)) + $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!) + endif + _BLD_CPUS += $($(src)_BLD_TRG_CPU) +endif +endef # def_collect_bld_xyz +$(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \ + ,$(evalval def_collect_bld_xyz)) + +# Drop duplicate values. +# WARNING! These list might not include keywords only involved in inheritance. +_BLD_TYPES := $(sort $(_BLD_TYPES)) +_BLD_TARGETS := $(sort $(_BLD_TARGETS)) +_BLD_ARCHES := $(sort $(_BLD_ARCHES)) +_BLD_CPUS := $(sort $(_BLD_CPUS)) + +## Look for keywords which extends others and order them. +# @param keyword +# @param prefix +# @param valid +define def_keyword_ordering +# Check for EXTENDS, fix and validate it if found. +local src := $(strip $($(prefix)_$(keyword)_EXTENDS)) +ifneq ($(src),) + ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_ + ifn1of ($(src), $(valid)) + $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid))) + endif + + # Recursivly process the parent (src). + ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42) + $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0 + # 'foreach' will create 'keyword' in a new variable context hiding + # out current variable. 'src' OTOH will be overwritten. + $(foreach keyword, $(src), $(evalval def_keyword_ordering)) + local src := $(strip $($(prefix)_$(keyword)_EXTENDS)) + endif + + # Check and strip EXTENDS_BY. + local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY)) + ifeq ($(by),) + local by = overriding + else ifn1of ($(by), overriding appending prepending) + $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!) + endif + + # Update the attributes with stripped + $(prefix)_$(keyword)_EXTENDS_BY := $(by) + $(prefix)_$(keyword)_EXTENDS := $(src) + + # Add it to the list and mark it as done. + _KEYWORDS_EXTENDS += $(keyword) + _KEYWORDS_PREFIX += $(prefix) + $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42 + else + # Check for inheritance loops. + ifneq ($($(trg)_EXTENDS_STATUS_),42) + $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_)) + endif + endif +else + # Add it to the ordered list and mark it as done. + _KEYWORDS_ORDERED += $(keyword) + $(prefix)_$(src)_EXTENDS_STATUS_ := 42 +endif +endef # def_keyword_ordering +$(eval-opt-var def_keyword_ordering) + +# Look for keywords which extends others and their parents, and from this +# construct two lists. +_KEYWORDS_ORDERED := +_KEYWORDS_EXTENDS := +_KEYWORDS_PREFIX := + +prefix := BLD_TYPE +valid := $(KBUILD_BLD_TYPES) +$(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering)) + +prefix := BLD_TRG +valid := $(KBUILD_OSES) +$(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering)) + +prefix := BLD_ARCH +valid := $(KBUILD_ARCHES) +$(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering)) + +prefix := BLD_CPU +valid := $(KBUILD_CPUS) +$(foreach keyword, $(_BLD_CPUS) , $(evalval def_keyword_ordering)) + +## @todo Inherit bld_trg.bld_arch for too? + +# Construct all the possible keywords. +_KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \ + $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES))) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done keywords) +endif + + +# +# Target inheritance. +# +# This has to be done on a per target list basis as to avoid adding +# incorrect properties that will wast memory, time, and may confuse +# later strictness checks. This also has to be done *before* templates +# are applied to the targets. Since we're doing that part rather +# early on, the target inheritance feature is a bit restricted at +# the moment. However, this will be addressed in a little(?) while. +# + +src_prefix := +load_function := +properties_deferred_l := +properties_deferred_r := + +# Fetches. +properties := $(PROPS_FETCHES_SINGLE) +properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L) +properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R) +properties_deferred := $(PROPS_FETCHES_DEFERRED) +$(foreach trg, $(_ALL_FETCHES),$(evalval def_inherit)) + +## Patches. - not implemented yet. +#properties := $(PROPS_PATCHES_SINGLE) +#properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L) +#properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R) +#properties_deferred := $(PROPS_PATCHES_DEFERRED) +#$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit)) + +# Programs and build programs. +properties := $(PROPS_PROGRAMS_SINGLE) +properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L) +properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R) +properties_deferred := $(PROPS_PROGRAMS_DEFERRED) +$(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit)) + +# Libraries and import libraries. +properties := $(PROPS_LIBRARIES_SINGLE) +properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L) +properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R) +properties_deferred := $(PROPS_LIBRARIES_DEFERRED) +if1of ($(KBUILD_TARGET), nt os2 win) + $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit)) +else + $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit)) +endif + +# DLLs. +properties := $(PROPS_DLLS_SINGLE) +properties_now_l := $(PROPS_DLLS_ACCUMULATE_L) +properties_now_r := $(PROPS_DLLS_ACCUMULATE_R) +properties_deferred := $(PROPS_DLLS_DEFERRED) +if1of ($(KBUILD_TARGET), nt os2 win) + $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit)) +else + $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit)) +endif + +# System modules. +properties := $(PROPS_SYSMODS_SINGLE) +properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L) +properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R) +properties_deferred := $(PROPS_SYSMODS_DEFERRED) +$(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit)) + +# Misc binaries. +properties := $(PROPS_MISCBINS_SINGLE) +properties_now_l := $(PROPS_MISCBINS_ACCUMULATE_L) +properties_now_r := $(PROPS_MISCBINS_ACCUMULATE_R) +properties_deferred := $(PROPS_MISCBINS_DEFERRED) +$(foreach trg, $(_ALL_MISCBINS),$(evalval def_inherit)) + +# Installs. +properties := $(PROPS_INSTALLS_SINGLE) +properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L) +properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R) +properties_deferred := $(PROPS_INSTALLS_DEFERRED) +$(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done target inheritance) +endif + + +# +# Template Inheritance. +# +# This is much the same as with target inheritance, except we cannot +# restrict the properties involved since we haven't got a clue which +# target platforms/archs are using them. But, we can drop the instance +# expansion we're doing for targets since there won't be any more +# changes to either the source nor the target templates beyond this +# exercise. +# + +src_prefix := TEMPLATE_ +load_function := def_templates_load_function +properties := +properties_now_l := +properties_now_r := +properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) +properties_deferred_l := $(PROPS_ACCUMULATE_L) +properties_deferred_r := $(PROPS_ACCUMULATE_R) +$(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit)) + +# done inheriting. +src_prefix := +load_function := +properties := +properties_now_l := +properties_now_r := +properties_deferred := +properties_deferred_l := +properties_deferred_r := + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done template inheritance) +endif + + + + +# +# Template/Target Expansion. +# +# Extend all targets with the values from the template. Doing this up front +# allows more generic code and less mess down in the pass 2 target handling. +# However it does eat a good deal of memory. +# + +define def_inherit_template_workaround_target +local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE)) +local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE)) +local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_TARGET)) +local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) +local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) +$(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type)) +endef # def_inherit_template_workaround_target +#$(kb-exp-tmpl 1,$(_ALL_TARGET_TARGETS),$(KBUILD_TARGET),$(KBUILD_TARGET_ARCH),$(KBUILD_TARGET_CPU),$(KBUILD_TYPE)) +$(foreach target,$(_ALL_TARGET_TARGETS),$(evalval def_inherit_template_workaround_target)) + +define def_inherit_template_workaround_host +local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE)) +local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE)) +local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_HOST)) +local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_HOST_ARCH)) +local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_HOST_CPU)) +$(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type)) +endef # def_inherit_template_workaround_target +#$(kb-exp-tmpl 1,$(_ALL_HOST_TARGETS),$(KBUILD_HOST),$(KBUILD_HOST_ARCH),$(KBUILD_HOST_CPU),$(KBUILD_TYPE)) +$(foreach target,$(_ALL_HOST_TARGETS),$(evalval def_inherit_template_workaround_host)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done template/target expansion) +endif + + +# +# Include tools, sdks and units. +# +# The first part of this exercise is to figure out which TOOLS and SDKS +# that should be included. +# +_TOOLS := $(TOOL.$(KBUILD_TARGET)) $(TOOL.$(KBUILD_TARGET_ARCH)) $(TOOL.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(TOOL.$(KBUILD_HOST)) $(TOOL.$(KBUILD_HOST_ARCH)) $(TOOL.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ + $(TOOL) +_SDKS := $(SDKS.$(KBUILD_TARGET)) $(SDKS.$(KBUILD_TARGET_ARCH)) $(SDKS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(SDKS.$(KBUILD_HOST)) $(SDKS.$(KBUILD_HOST_ARCH)) $(SDKS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ + $(SDKS.$(KBUILD_TYPE)) \ + $(SDKS) +_USES := $(USES.$(KBUILD_TARGET)) $(USES.$(KBUILD_TARGET_ARCH)) $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(USES.$(KBUILD_HOST)) $(USES.$(KBUILD_HOST_ARCH)) $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ + $(USES.$(KBUILD_TYPE)) \ + $(USES) +define def_tools_sdks_target_source +$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \ + $($(source)_$(prop).$(_bld_trg)) \ + $($(target)_$(source)_$(prop).$(_bld_trg)) \ + $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \ + $($(source)_$(prop).$(_bld_trg_arch)) \ + $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \ + $($(source)_$(prop)) \ + $($(target)_$(source)_$(prop)))) +$(eval _SDKS += \ + $($(source)_SDKS.$(_bld_trg)) \ + $($(target)_$(source)_SDKS.$(_bld_trg)) \ + $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \ + $($(source)_SDKS.$(_bld_trg_arch)) \ + $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \ + $($(source)_SDKS.$(KBUILD_TYPE)) \ + $($(target)_$(source)_SDKS.$(KBUILD_TYPE)) \ + $($(source)_SDKS) \ + $($(target)_$(source)_SDKS)) +$(eval _USES += \ + $($(source)_USES.$(_bld_trg)) \ + $($(target)_$(source)_USES.$(_bld_trg)) \ + $($(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_$(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \ + $($(source)_USES.$(_bld_trg_arch)) \ + $($(target)_$(source)_USES.$(_bld_trg_arch)) \ + $($(source)_USES.$(KBUILD_TYPE)) \ + $($(target)_$(source)_USES.$(KBUILD_TYPE)) \ + $($(source)_USES) \ + $($(target)_$(source)_USES)) +endef # def_tools_sdks_target_source +$(eval-opt-var def_tools_sdks_target_source) + +define def_tools_sdks_target +local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg)) +local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch)) +local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu)) + +$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \ + $($(target)_$(prop).$(_bld_trg)) \ + $($(target)_$(prop).$(_bld_trg_arch)) \ + $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_$(prop)))) +$(eval _SDKS += \ + $($(target)_SDKS.$(_bld_trg)) \ + $($(target)_SDKS.$(_bld_trg_arch)) \ + $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_SDKS)) +$(eval _USES += \ + $($(target)_USES.$(_bld_trg)) \ + $($(target)_USES.$(_bld_trg_arch)) \ + $($(target)_USES.$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_USES)) +$(foreach source, \ + $($(target)_SOURCES.$(_bld_trg)) \ + $($(target)_SOURCES.$(_bld_trg_arch)) \ + $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_SOURCES.$(_bld_trg_cpu)) \ + $($(target)_SOURCES.$(_bld_type)) \ + $($(target)_SOURCES) \ + , $(evalval def_tools_sdks_target_source)) +endef # def_tools_sdks_target +$(eval-opt-var def_tools_sdks_target) + +define def_tools_srcname_target +local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg)) +local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch)) +local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu)) + +$(foreach source, $(notdir\ + $($(target)_SOURCES.$(_bld_trg)) \ + $($(target)_SOURCES.$(_bld_trg_arch)) \ + $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \ + $($(target)_SOURCES.$(_bld_trg_cpu)) \ + $($(target)_SOURCES.$(_bld_type)) \ + $($(target)_SOURCES) \ + ), $(evalval def_tools_sdks_target_source)) +endef # def_tools_srcname_target +$(eval-opt-var def_tools_srcname_target) + +bld_trg := $(KBUILD_TARGET) +bld_trg_arch := $(KBUILD_TARGET_ARCH) +bld_trg_cpu := $(KBUILD_TARGET_CPU) +$(foreach target, $(_ALL_TARGET_TARGETS), $(evalval def_tools_sdks_target)) +$(foreach target, $(_ALL_SRCNAME_TARGETS), $(evalval def_tools_srcname_target)) + +bld_trg := $(KBUILD_HOST) +bld_trg_arch := $(KBUILD_HOST_ARCH) +bld_trg_cpu := $(KBUILD_HOST_CPU) +$(foreach target, $(_ALL_HOST_TARGETS), $(evalval def_tools_sdks_target)) + +_TOOLS := $(sort $(_TOOLS)) +_SDKS := $(sort $(_SDKS)) + +## Tool load function. +# @param loading The tool name +define def_tools_load_function +ifndef TOOL_$(loading) + TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) + ifeq ($(TOOL_$(loading)_KMK_FILE),) + $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS)) + endif + include $(TOOL_$(loading)_KMK_FILE) + ifndef TOOL_$(loading) + $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!) + endif +endif +endef # def_tools_include + +## SDK load function. +# @param loading The tool name +define def_sdk_load_function +ifndef SDK_$(loading) + SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) + ifeq ($(SDK_$(loading)_KMK_FILE),) + $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS)) + endif + include $(SDK_$(loading)_KMK_FILE) + ifndef SDK_$(loading) + $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!) + endif +endif +endef # def_sdk_load_function + + +properties := +properties_now_l := +properties_now_r := +properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) +properties_deferred_l := $(PROPS_ACCUMULATE_L) +properties_deferred_r := $(PROPS_ACCUMULATE_R) + +src_prefix := SDK_ +load_function := def_sdk_load_function +$(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit)) + +properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_TOOLS_ONLY) +src_prefix := TOOL_ +load_function := def_tools_load_function +$(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit)) + +# done inheriting. +src_prefix := +load_function := +properties := +properties_now_l := +properties_now_r := +properties_deferred := +properties_deferred_l := +properties_deferred_r := + +# No inheriting for the uses, they're just global 'code'. +$(foreach loading, $(_USES), $(evalval def_unit_load_function)) + + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done tools + sdks + units) +endif + diff --git a/kBuild/footer-misc.kmk b/kBuild/footer-misc.kmk new file mode 100644 index 0000000..8dda2a5 --- /dev/null +++ b/kBuild/footer-misc.kmk @@ -0,0 +1,131 @@ +# $Id: footer-misc.kmk 2523 2011-07-31 23:45:20Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Misc. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + + +# +# OTHERS +# +_OTHERS = $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) + + + +# +# TESTING +# +_TESTING += $(TESTING) \ + $(TESTING.$(KBUILD_TARGET)) \ + $(TESTING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(TESTING.$(KBUILD_TARGET_ARCH)) \ + $(TESTING.$(KBUILD_TARGET_CPU)) + + +# +# PACKING +# +_PACKING += $(PACKING) \ + $(PACKING.$(KBUILD_TARGET)) \ + $(PACKING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(PACKING.$(KBUILD_TARGET_ARCH)) \ + $(PACKING.$(KBUILD_TARGET_CPU)) + + +# +# DOCS +# + + +# +# DIRECTORIES +# +_DIR_ALL := $(sort \ + $(addsuffix /,$(patsubst %/,%,$(_DIRS) )) \ + $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES) $(_DEBUG_INSTALL_FILES) $(_STAGE_FILES) $(_DEBUG_STAGE_FILES) ) \ + $(foreach path, $(KBUILD_INST_PATHS), $(PATH_INS)/$(INST_$(path)) $(PATH_STAGE)/$(STAGE_$(path)) ) \ + $(dir $(patsubst %/,%, $(_INSTALLS_DIRS) $(_STAGE_DIRS) $(_DEBUG_INSTALL_DIRS) $(_DEBUG_STAGE_DIRS)) ) \ + ) +$(foreach directory, \ + $(_INSTALLS_DIRS) \ + $(_STAGE_DIRS) \ + $(_DEBUG_INSTALL_DIRS) \ + $(_DEBUG_STAGE_DIRS) \ + , $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))) ) + + +define def_mkdir_rule +$(directory): + %$$(call MSG_MKDIR,$$@) + $$(QUIET)$$(MKDIR) -p -- $$@ +endef + +$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule))) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done directories) +endif + + +# +# NOTHING +# +do-nothing: + %$(call MSG_NOTHING) +ifdef KBUILD_PROFILE_SELF + @$(ECHO) 'prof: $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_PREV)) - executing $@' + ifeq ($(KBUILD_PROFILE_SELF),2) + @$(ECHO) 'stat: $(make-stats )' + endif +endif + + +# +# CLEAN UP +# +do-clean: + %$(call MSG_CLEAN) + $(QUIET)$(RM) -f -- \ + $(_OUT_FILES) \ + $(_OBJS) \ + $(_DEPFILES) \ + $(_DEPFILES_INCLUDED) \ + $(_CLEAN_FILES) \ + $(OTHER_CLEAN) \ + $(_STAGE_FILES) + $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- \ + $(rsort $(dir $(_OUT_FILES) \ + $(_OBJS) \ + $(_DEPFILES) \ + $(_DEPFILES_INCLUDED) \ + $(_CLEAN_FILES) \ + $(OTHER_CLEAN))\ + $(_STAGE_DIRS) ) + diff --git a/kBuild/footer-pass1.kmk b/kBuild/footer-pass1.kmk new file mode 100644 index 0000000..6b31599 --- /dev/null +++ b/kBuild/footer-pass1.kmk @@ -0,0 +1,467 @@ +# $Id: footer-pass1.kmk 2523 2011-07-31 23:45:20Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 1. +# +# This pass is for defining variables that might be referenced in +# properties of other targets. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + + +# Don't do anything for fetch targets (yet). + +## +# Link prolog for Pass 1. +# +# @param $(target) Normalized target name. +# @param $(EXT) EXE,DLL,SYS,LIB. +# @param $(EXTPRE) HOST or nothing. +# @param $(definst) The default _INST value. +# @param $(tool_prefix) LD or AR. +# @param $(bld_trg_base_var) TARGET or PLATFORM. +define def_pass1_link_common + +local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var))) +local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH)) +local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU)) + +local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix)) +local name := $(firstword\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg).$(bld_type))\ + $($(target)_NAME.$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg))\ + $($(target)_NAME.$(bld_type))\ + $($(target)_NAME)\ + $(target)) +local outbase := $(call TARGET_BASE,$(name),$(target)) +$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase))) +$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR) + +## @todo fix the fun at the last line (AR != LIB => mess). +local suff := $(firstword \ + $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ + $($(target)_$(EXT)SUFF.$(bld_trg))\ + $($(target)_$(EXT)SUFF)\ + $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ + $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\ + $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\ + $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) ) +local out := $(outbase)$(suff) + +# Object directory target variable. +$(target)_1_TARGET := $(out) +$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET) + +# Staging and install directory target variables. +local insttype := $(firstword \ + $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_INSTTYPE.$(bld_trg).$(bld_type)) \ + $($(target)_INSTTYPE.$(bld_trg_arch)) \ + $($(target)_INSTTYPE.$(bld_trg_cpu)) \ + $($(target)_INSTTYPE.$(bld_trg)) \ + $($(target)_INSTTYPE.$(bld_type)) \ + $($(target)_INSTTYPE) \ + ) +ifeq ($(insttype),) + ifneq ($(firstword \ + $($(target)_NOINST) \ + $($(target)_NOINST.$(bld_trg)) \ + $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_NOINST.$(bld_trg_arch)) \ + $($(target)_NOINST.$(bld_trg_cpu)) \ + $($(target)_NOINST.$(bld_type)) ),) + local insttype := none + else + local insttype := both + endif +endif +ifn1of ($(insttype), none both stage) + $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.) +endif +$(target)_1_INSTTYPE := $(insttype) + +if1of ($(insttype), stage both) + local inst := $(strip $(firstdefined \ + $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_INST.$(bld_trg).$(bld_trg_arch) \ + $(target)_INST.$(bld_trg).$(bld_type) \ + $(target)_INST.$(bld_trg_arch) \ + $(target)_INST.$(bld_trg_cpu) \ + $(target)_INST.$(bld_trg) \ + $(target)_INST.$(bld_type) \ + $(target)_INST \ + definst \ + ,value)) + local stage := $(strip $(firstdefined \ + $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \ + $(target)_STAGE.$(bld_trg).$(bld_type) \ + $(target)_STAGE.$(bld_trg_arch) \ + $(target)_STAGE.$(bld_trg_cpu) \ + $(target)_STAGE.$(bld_trg) \ + $(target)_STAGE.$(bld_type) \ + $(target)_STAGE \ + inst \ + ,value)) + $(target)_1_STAGE := $(stage) + if "$(substr $(stage),-1,1)" == "/" # Multicast support requires addprefix/suffix. + $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(addsuffix $(notdir $(out)),$(stage))) + else if "$(stage)" == "" + $(target)_1_STAGE_TARGET := $(PATH_STAGE)/$(notdir $(out)) + else + $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(stage)) + endif +else + $(target)_1_STAGE := + $(target)_1_STAGE_TARGET := +endif +INSTARGET_$(target) := $($(target)_1_STAGE_TARGET) + +if1of ($(insttype), both) + $(target)_1_INST := $(inst) + if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix. + $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(addsuffix $(notdir $(out)),$(inst))) + else if "$(inst)" == "" + $(target)_1_INST_TARGET := $(PATH_INS)/$(notdir $(out)) + else + $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(inst)) + endif +else + $(target)_1_INST := + $(target)_1_INST_TARGET := +endif + +# Debug info related stuff. +local debug_insttype := $(firstword \ + $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_type)) \ + $($(target)_DEBUG_INSTTYPE.$(bld_trg_arch)) \ + $($(target)_DEBUG_INSTTYPE.$(bld_trg_cpu)) \ + $($(target)_DEBUG_INSTTYPE.$(bld_trg)) \ + $($(target)_DEBUG_INSTTYPE.$(bld_type)) \ + $($(target)_DEBUG_INSTTYPE) \ + $(insttype) ) +ifn1of ($(debug_insttype), none both stage) + $(error kBuild: Unknown value '$(debug_insttype)' for '$(target)_DEBUG_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.) +endif +$(target)_1_DEBUG_INSTTYPE := $(debug_insttype) + +if1of ($(debug_insttype), stage both) + ifn1of ($(insttype), stage both) + $(error kBuild: DEBUG_INSTTYPE=$(debug_insttype) and INSTTYPE=$(insttype) for target '$(target)' are not compatible) + endif + local debug_stage := $(firstdefined \ + $(target)_DEBUG_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_DEBUG_STAGE.$(bld_trg).$(bld_trg_arch) \ + $(target)_DEBUG_STAGE.$(bld_trg).$(bld_type) \ + $(target)_DEBUG_STAGE.$(bld_trg_arch) \ + $(target)_DEBUG_STAGE.$(bld_trg_cpu) \ + $(target)_DEBUG_STAGE.$(bld_trg) \ + $(target)_DEBUG_STAGE.$(bld_type) \ + $(target)_DEBUG_STAGE \ + $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch) \ + $(target)_DEBUG_INST.$(bld_trg).$(bld_type) \ + $(target)_DEBUG_INST.$(bld_trg_arch) \ + $(target)_DEBUG_INST.$(bld_trg_cpu) \ + $(target)_DEBUG_INST.$(bld_trg) \ + $(target)_DEBUG_INST.$(bld_type) \ + $(target)_DEBUG_INST) + ifneq ($(debug_stage),) + $(target)_1_DEBUG_STAGE := $($(debug_stage)) + else + $(target)_1_DEBUG_STAGE := $(addprefix $(STAGE_DEBUG),$(stage)) + endif + ifndef $(target)_1_DEBUG_STAGE + $(target)_1_DEBUG_STAGE := ./ + endif +else + $(target)_1_DEBUG_STAGE := +endif + +if1of ($(debug_insttype), both) + ifn1of ($(insttype), both) + $(error kBuild: DEBUG_INSTTYPE=$(debug_insttype) and INSTTYPE=$(insttype) for target '$(target)' are not compatible) + endif + local debug_inst := $(firstdefined \ + $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch) \ + $(target)_DEBUG_INST.$(bld_trg).$(bld_type) \ + $(target)_DEBUG_INST.$(bld_trg_arch) \ + $(target)_DEBUG_INST.$(bld_trg_cpu) \ + $(target)_DEBUG_INST.$(bld_trg) \ + $(target)_DEBUG_INST.$(bld_type) \ + $(target)_DEBUG_INST) + ifneq ($(debug_inst),) + $(target)_1_DEBUG_INST := $($(debug_inst)) + else + $(target)_1_DEBUG_INST := $(addprefix $(INST_DEBUG),$(inst)) + endif + ifndef $(target)_1_DEBUG_INST + $(target)_1_DEBUG_INST := ./ + endif +else + $(target)_1_DEBUG_INST := +endif +#$(warning $(NLTAB)$(target)_1_DEBUG_INST=$($(target)_1_DEBUG_INST)$(NLTAB)$(target)_1_DEBUG_STAGE=$($(target)_1_DEBUG_STAGE)$(NLTAB)insttype=$(insttype)$(NLTAB)debug_insttype=$(debug_insttype)) + +endef # def_pass1_link_common +$(eval-opt-var def_pass1_link_common) + + +# +# BLDPROGS (Pass 1) +# +define def_pass1_bldprog +# set NOINST if not forced installation before doing the usual stuff. +ifndef $(target)_INST +$(target)_INSTTYPE := none +endif +$(evalval def_pass1_link_common) +endef + +EXT := EXE +EXTPRE := HOST +definst := $(INST_BIN) +tool_prefix := LD +bld_trg_base_var := PLATFORM +$(foreach target, $(_ALL_BLDPROGS), \ + $(evalval def_pass1_bldprog)) + + +# +# LIBRARIES (Pass 1) +# +EXT := LIB +EXTPRE := +definst := $(INST_LIB) +tool_prefix := AR +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_LIBRARIES), \ + $(evalval def_pass1_link_common)) + + +# +# DLLS (Pass 1) +# +EXT := DLL +EXTPRE := +definst := $(INST_DLL) +tool_prefix := LD +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_DLLS), \ + $(evalval def_pass1_link_common)) + + +# +# IMPORT LIBRARIES (Pass 1) +# +# - On OS/2 and windows these are libraries. +# - On other platforms they are fake DLLs. +# +if1of ($(KBUILD_TARGET), nt os2 win win64 win32) + EXT := LIB + EXTPRE := + definst := $(INST_LIB) + tool_prefix := AR + bld_trg_base_var := TARGET + $(foreach target, $(_ALL_IMPORT_LIBS), \ + $(evalval def_pass1_link_common)) +else + EXT := DLL + EXTPRE := + definst := $(INST_DLL) + tool_prefix := LD + bld_trg_base_var := TARGET + $(foreach target, $(_ALL_IMPORT_LIBS), \ + $(evalval def_pass1_link_common)) +endif + + +# +# PROGRAMS (Pass 1) +# +EXT := EXE +EXTPRE := +definst := $(INST_BIN) +tool_prefix := LD +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_PROGRAMS), \ + $(evalval def_pass1_link_common)) + + +# +# SYSMODS (Pass 1) +# +EXT := SYS +EXTPRE := +definst := $(INST_SYS) +tool_prefix := LD +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_SYSMODS), \ + $(evalval def_pass1_link_common)) + + +# +# MISCBINS (Pass 1) +# +EXT := BIN +EXTPRE := +definst := $(INST_BIN) +tool_prefix := LD +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_MISCBINS), \ + $(evalval def_pass1_link_common)) + + +# +# INSTALLS (Pass 1) +# Note! INSTARGET_* for INSTALLS aren't available until later. +# +define def_pass1_install +local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET)) +local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) +local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) +# _1_TARGET +$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins +$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET) + +# Determine and set 1_INSTTYPE. +local insttype := $(firstword \ + $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_INSTTYPE.$(bld_trg).$(bld_type)) \ + $($(target)_INSTTYPE.$(bld_trg_arch)) \ + $($(target)_INSTTYPE.$(bld_trg_cpu)) \ + $($(target)_INSTTYPE.$(bld_trg)) \ + $($(target)_INSTTYPE.$(bld_type)) \ + $($(target)_INSTTYPE) \ + ) +ifeq ($(insttype),) + ifneq ($(firstword \ + $($(target)_NOINST) \ + $($(target)_NOINST.$(bld_trg)) \ + $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_NOINST.$(bld_trg_arch)) \ + $($(target)_NOINST.$(bld_trg_cpu)) \ + $($(target)_NOINST.$(bld_type)) ),) + local insttype := none + else + local insttype := both + endif +endif +ifn1of ($(insttype), none both stage) + $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.) +endif +$(target)_1_INSTTYPE := $(insttype) + +# Determine the actual INST and STAGE sub-dirs to use for this target. +if1of ($(insttype), stage both) + local stage := $(strip $(firstdefined \ + $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \ + $(target)_STAGE.$(bld_trg).$(bld_type) \ + $(target)_STAGE.$(bld_trg_arch) \ + $(target)_STAGE.$(bld_trg_cpu) \ + $(target)_STAGE.$(bld_trg) \ + $(target)_STAGE.$(bld_type) \ + $(target)_STAGE \ + $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_INST.$(bld_trg).$(bld_trg_arch) \ + $(target)_INST.$(bld_trg).$(bld_type) \ + $(target)_INST.$(bld_trg_arch) \ + $(target)_INST.$(bld_trg_cpu) \ + $(target)_INST.$(bld_trg) \ + $(target)_INST.$(bld_type) \ + $(target)_INST \ + definst \ + ,value)) + if $(words $(stage)) > 1 + $(warning kBuild: The STAGE/INST property of install '$(target)' specifies multiple location, that is not supported.) + local stage := $(word 1, $(stage)) + endif + $(target)_1_STAGE := $(stage) +else + $(target)_1_STAGE = $(error _1_STAGE not used) +endif + +if1of ($(insttype), both) + local inst := $(strip $(firstdefined \ + $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_INST.$(bld_trg).$(bld_trg_arch) \ + $(target)_INST.$(bld_trg).$(bld_type) \ + $(target)_INST.$(bld_trg_arch) \ + $(target)_INST.$(bld_trg_cpu) \ + $(target)_INST.$(bld_trg) \ + $(target)_INST.$(bld_type) \ + $(target)_INST \ + definst \ + ,value)) + if $(words $(inst)) > 1 + $(warning kBuild: The INST property of install '$(target)' specifies multiple location, that is not supported.) + local inst := $(word 1, $(inst)) + endif + ifneq ($(root $(stage)),) + $(error kBuild: The effective INST property of install '$(target)' should not start with a root specification) + endif + $(target)_1_INST := $(inst) +else + $(target)_1_INST = $(error _1_INST not used) +endif + +# Block properties that we put off setting until pass 2 for INSTALLS. +$(target)_1_STAGE_TARGET = $(error The '_1_STAGE_TARGET' property is not present on install targets. Use '_2_STAGE_TARGETS' instead (set by pass 2!).) +$(target)_1_INST_TARGET = $(error The '_1_INST_TARGET' property is not present on install targets. Use '_2_INST_TARGETS' instead (set by pass 2!).) +INSTARGET_$(target) = $(error The 'INSTARGET_' is deprecated and besides, it is being accessed to early. Consider '_2_STAGE_TARGETS' or '_2_INST_TARGETS'.) + +# INSTARGET_ later. +# PATH_* +local outbase := $(call TARGET_BASE,$(target),$(target)) +$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase))) +$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR) +endef # def_pass1_install +$(eval-opt-var def_pass1_install) + +$(foreach target, $(_ALL_INSTALLS), \ + $(evalval def_pass1_install)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done pass 1) +endif + + diff --git a/kBuild/footer-pass2-compiling-targets.kmk b/kBuild/footer-pass2-compiling-targets.kmk new file mode 100644 index 0000000..172aed9 --- /dev/null +++ b/kBuild/footer-pass2-compiling-targets.kmk @@ -0,0 +1,1069 @@ +# $Id: footer-pass2-compiling-targets.kmk 2537 2011-08-02 19:44:43Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Compiling Targets. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + + +# +# Object processing. +# + +## wrapper the compile command dependency check. +ifndef NO_COMPILE_CMDS_DEPS + if1of ($(KMK_FEATURES),dot-must-make) + _DEP_COMPILE_CMDS = + # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)) + else + _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $(obj)),FORCE) + endif +else + _DEP_COMPILE_CMDS = +endif + + +## Generates the rules for building a specific object, and the aliases +# for building a source file. +# @param $(obj) The object file. +define def_target_source_rule +ifndef NO_COMPILE_CMDS_DEPS +$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE) +endif +ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE +_OUT_FILES += $(outbase).koc +$(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \ + $($(target)_$(source)_DEPEND_) \ + $(value _DEP_COMPILE_CMDS) \ + | \ + $($(target)_$(source)_DEPORD_) \ + $$$$($(target)_INTERMEDIATES) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg)) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \ + $$$$($(target)_INTERMEDIATES.$(bld_type)) + %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) +else +$(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \ + $($(target)_$(source)_DEPEND_) \ + $(value _DEP_COMPILE_CMDS) \ + | \ + $($(target)_$(source)_DEPORD_) \ + $$$$($(target)_INTERMEDIATES) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg)) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \ + $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \ + $$$$($(target)_INTERMEDIATES.$(bld_type)) + %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) +ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT + $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) +endif +endif + +$($(target)_$(source)_CMDS_) + +ifndef NO_COMPILE_CMDS_DEPS + %$$(QUIET2)$$(APPEND) '$(dep)' + %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' + %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)' + %$$(QUIET2)$$(APPEND) '$(dep)' 'endef' +endif + +$(basename $(notdir $(obj))).o: $(obj) +$(basename $(notdir $(obj))).obj: $(obj) + +## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added. +$(target)_$(source)_CMDS_ := +$(target)_$(source)_OUTPUT_ := +$(target)_$(source)_OUTPUT_MAYBE_ := +$(target)_$(source)_DEPEND_ := +$(target)_$(source)_DEPORD_ := +endef # def_target_source_rule +$(eval-opt-var def_target_source_rule) + + +## wrapper the link command dependency check. +ifndef NO_LINK_CMDS_DEPS + if1of ($(KMK_FEATURES),dot-must-make) + _DEP_LINK_CMDS = + else + _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE) + endif +else + _DEP_LINK_CMDS = +endif + +## Generate the link rule for a target. +# @param $(target) The normalized target name. +# @param $(dirdep) Directories we depend upon begin created before linking. +# @param $(dep) The name of the dependency file. +# @param $(out) +# @param $($(target)_2_OUTPUT) Output files from the link. +# @param $($(target)_2_OUTPUT_MAYBE) Output files that the link may perhaps create. +# @param $($(target)_2_DEPEND) Dependencies. +# @param $($(target)_2_DEPORD) Dependencies which should only affect build order. +# @param $(cmds) The link commands. +# @param $($(target)_CMDS_PREV_) The link commands from the previous run. +define def_link_rule +$$(call KB_FN_ASSERT_ABSPATH,out) +ifndef NO_LINK_CMDS_DEPS +$(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE) +endif +$(out) \ ++ $($(target)_2_OUTPUT) \ ++ $($(target)_2_OUTPUT_DEBUG_FILES) \ ++ $($(target)_2_OUTPUT_DEBUG_DIRS) \ ++| $($(target)_2_OUTPUT_MAYBE) : \ + $$$$($(target)_2_DEPEND) \ + $(value _DEP_LINK_CMDS) \ + | \ + $$$$($(target)_2_DEPORD) + %$$(call MSG_LINK,$(target),$$@,$(tool_do)) + $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $($(target)_2_OUTPUT_DEBUG_FILES) +ifdef $(target)_2_OUTPUT_DEBUG_DIRS + $$(QUIET)$$(RM) -Rf -- $($(target)_2_OUTPUT_DEBUG_DIRS) +endif + +$(cmds) + +ifndef NO_LINK_CMDS_DEPS + %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_' + %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)' + %$$(QUIET2)$$(APPEND) '$(dep)' 'endef' +endif + +$(basename $(notdir $(out))):: $(out) + +endef # def_link_rule +$(eval-opt-var def_link_rule) + + +## Generate the link & lib install rule +# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode, +# pre_install_cmds, post_install_cmds +define def_link_install_rule +$$(call KB_FN_ASSERT_ABSPATH,$(target)_1_INST_TARGET) +$($(target)_1_INST_TARGET): $(out) | $$$$(dir $$$$@) + %$$(call MSG_INST_TRG,$(target),$(out),$$@) + $(pre_install_cmds) + + $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@ + $(post_install_cmds) + +endef + + +## Generate the link & lib stage installation rule +# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode, +# pre_install_cmds, post_install_cmds +define def_link_stage_rule +$$(call KB_FN_ASSERT_ABSPATH,$(target)_1_STAGE_TARGET) +$($(target)_1_STAGE_TARGET): $(out) | $$$$(dir $$$$@) + %$$(call MSG_INST_TRG,$(target),$(out),$$@) + $(pre_install_cmds) + + $$(QUIET)$$(INSTALL_STAGING) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@ + $(post_install_cmds) + + +$(basename $(notdir $(out))):: $($(target)_1_STAGE_TARGET) + +endef + + +## def_src_handler_* +# +# @{ +define def_src_handler_c +local type := C + $(kb-src-one 2) +endef + +define def_src_handler_cxx +local type := CXX + $(kb-src-one 2) +endef + +define def_src_handler_objc +local type := OBJC + $(kb-src-one 2) +endef + +define def_src_handler_objcxx +local type := OBJCXX + $(kb-src-one 2) +endef + +define def_src_handler_asm +local type := AS + $(kb-src-one 2) +endef + +define def_src_handler_rc +local type := RC + $(kb-src-one 2) +endef + +define def_src_handler_obj +ifeq ($(defpath),) + $(target)_2_OBJS += $(source) +else + $(target)_2_OBJS += $(abspathex $(source), $(defpath)) +endif +endef +## @} + +## Handle one source. +# . +define def_src_handler_one +local suff := $(suffix $(source)) +local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) )) +local handler := $(patsubst $(suff):%,%,$(src_handler)) +ifneq ($(handler),) + $(evalvalctx $(handler)) +else + othersrc += $(source) +endif +endef # def_src_handler_one + +## Generic macro for processing all target sources. +# @param $(target) Normalized target name. +# @param $(defpath) +# @param much-more... +# @returns othersrc, $(target)_2_OBJS, ++ +define def_target_sources +local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS) +$(foreach source,\ + $($(target)_SOURCES)\ + $($(target)_SOURCES.$(bld_trg))\ + $($(target)_SOURCES.$(bld_trg).$(bld_type))\ + $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\ + $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_SOURCES.$(bld_trg_arch))\ + $($(target)_SOURCES.$(bld_trg_cpu))\ + $($(target)_SOURCES.$(bld_type))\ + ,$(evalval def_src_handler_one) ) + +$(foreach source,\ + $($(target)_GEN_SOURCES_)\ + $($(target)_GEN_SOURCES_.$(bld_trg))\ + $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_type))\ + $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\ + $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_GEN_SOURCES_.$(bld_trg_arch))\ + $($(target)_GEN_SOURCES_.$(bld_trg_cpu))\ + $($(target)_GEN_SOURCES_.$(bld_type))\ + ,$(evalval def_src_handler_one) ) +endef # def_target_sources +$(eval-opt-var def_target_sources) + + +## +# Install a debug directory. +# @param debug_dir The directory name. +define def_link_install_debug_dir_rule +local dir := $(debug_inst_path)/$(debug_inst2)$(debug_dir) +$$(call KB_FN_ASSERT_ABSPATH,dir) +$$(dir): | $$$$(dir $$$$(patsubst %/,%,$$$$@)) + %$$(call MSG_INST_DIR,$$@) + $$(QUIET)$$(MKDIR) -p -- $$@ +$(target)_2_DEBUG_$(debug_var)_TARGET_DIRS += $$(dir) +endef # def_link_install_debug_dir_rule + +## +# Install a debug file. +# @param debug_file Src=>Dst file pair. +define def_link_install_debug_file_rule +local dst := $(debug_inst_path)/$(debug_inst2)$(word 2, $(subst =>,$(SP),$(debug_file))) +$$(call KB_FN_ASSERT_ABSPATH,dst) +local src := $(word 1, $(subst =>,$(SP),$(debug_file))) +$$(call KB_FN_ASSERT_ABSPATH,src) +$$(dst): $$(src) | $$$$(dir $$$$@) + %$$(call MSG_INST_FILE,$$<,$$@) + $$(QUIET)$(debug_install_cmd) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $$< $$@ +$(target)_2_DEBUG_$(debug_var)_TARGET_FILES += $$(dst) +endef # def_link_install_debug_file_rule + +## +# Install debug info to $(debug_inst), where debug_inst can be a directory or +# file (just like $(inst) and $(stage). Used for both staging and installing. +define def_target_install_only_debug +if "$(substr $(debug_inst),-1,1)" == "/" + if "$(debug_inst)" == "./" + local debug_inst2 := + else + local debug_inst2 := $(debug_inst) + endif + local debug_dirs := $(patsubst $($(target)_0_OUTDIR)/%,%,$($(target)_2_OUTPUT_DEBUG_DIRS)) + ifneq ($(strip $(root $(debug_dirs))),) + $(error kBuild: Bad tool? debug_dirs='$(debug_dirs)', expected all to be under '$(outbase)') + endif + local debug_files := $(foreach file, $(patsubst $($(target)_0_OUTDIR)/%,%,$($(target)_2_OUTPUT_DEBUG_FILES)) \ + ,$($(target)_0_OUTDIR)/$(file)=>$(file)) +else + local debug_notdir:= $(notdir $(debug_inst)) + local debug_inst2 := $(dir $(debug_inst)) + local debug_files := $(call TOOL_$(tool)_$(tool_do)_DEBUG_INSTALL_FN,$(out),$(outbase),$(debug_notdir)) + local debug_dirs := $(filter %/,$(debug_files)) + local debug_files := $(filter-out %/,$(debug_files)) +endif +$(foreach debug_dir, $(debug_dirs), $(eval $(def_link_install_debug_dir_rule))) +$(foreach debug_file, $(debug_files), $(eval $(def_link_install_debug_file_rule))) +endef + + +## Generic macro for generating the install rule(s) for a target. +# +# @param $(target) Normalized target name. +# @param $(out) The output file. +# @param $(typevar) The name of the variable with all the root targets of its type. +# @param $(target_type_mode) The default file mode implied by the target type. +define def_target_install_only +ifneq ($($(target)_1_INSTTYPE),none) + local mode := $(firstword \ + $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_MODE.$(bld_trg).$(bld_type)) \ + $($(target)_MODE.$(bld_trg_arch)) \ + $($(target)_MODE.$(bld_trg)) \ + $($(target)_MODE.$(bld_type)) \ + $($(target)_MODE) \ + $(target_type_mode) ) + local uid := $(firstword \ + $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_UID.$(bld_trg).$(bld_type)) \ + $($(target)_UID.$(bld_trg_arch)) \ + $($(target)_UID.$(bld_trg)) \ + $($(target)_UID.$(bld_type)) \ + $($(target)_UID) ) + local gid := $(firstword \ + $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_GID.$(bld_trg).$(bld_type)) \ + $($(target)_GID.$(bld_trg_arch)) \ + $($(target)_GID.$(bld_trg)) \ + $($(target)_GID.$(bld_type)) \ + $($(target)_GID) ) + local pre_install_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_INST_CMDS) + local post_install_cmds := $(evalcall def_fn_prop_get_first_defined,POST_INST_CMDS) + + # Generate the rules + ifeq ($($(target)_1_INSTTYPE),both) +$(eval $(def_link_install_rule)) + _INSTALLS_FILES += $($(target)_1_INST_TARGET) + endif +$(eval $(def_link_stage_rule)) + _STAGE_FILES += $($(target)_1_STAGE_TARGET) + $(typevar) += $($(target)_1_STAGE_TARGET) +else # INSTTYPE == none + $(typevar) += $(out) +endif # INSTTYPE == none + +# Install debug info. +$(target)_2_DEBUG_STAGE_TARGET_DIRS := +$(target)_2_DEBUG_STAGE_TARGET_FILES := +$(target)_2_DEBUG_INSTALL_TARGET_DIRS := +$(target)_2_DEBUG_INSTALL_TARGET_FILES := + +if ( defined($(target)_2_OUTPUT_DEBUG_DIRS) \ + || defined($(target)_2_OUTPUT_DEBUG_FILES) ) \ + && "$($(target)_1_DEBUG_INSTTYPE)" != "none" + local mode := $(if $(mode),$(mode)$(COMMA)a-x,0644) + + ifeq ($($(target)_1_DEBUG_INSTTYPE),both) + local debug_inst_path := $(PATH_INS) + local debug_install_cmd := $(INSTALL) + local debug_var := INSTALL + $(foreach debug_inst, $($(target)_1_DEBUG_INST), $(evalval def_target_install_only_debug)) + endif + + local debug_inst_path := $(PATH_STAGE) + local debug_install_cmd := $(INSTALL_STAGING) + local debug_var := STAGE + if1of ($($(target)_1_DEBUG_INSTTYPE), stage both) + $(foreach debug_inst, $($(target)_1_DEBUG_STAGE), $(evalval def_target_install_only_debug)) + endif + if1of ($($(target)_1_INSTTYPE), stage both) + ifndef debug_nostage + $(foreach debug_inst,$($(target)_1_STAGE), $(evalval def_target_install_only_debug)) + endif + endif + + _DEBUG_STAGE_DIRS += $($(target)_2_DEBUG_STAGE_TARGET_DIRS) + _DEBUG_STAGE_FILES += $($(target)_2_DEBUG_STAGE_TARGET_FILES) + _DEBUG_INSTALL_DIRS += $($(target)_2_DEBUG_INSTALL_TARGET_DIRS) + _DEBUG_INSTALL_FILES += $($(target)_2_DEBUG_INSTALL_TARGET_FILES) + + $(basename $(notdir $(out))):: $($(target)_2_DEBUG_STAGE_TARGET_DIRS) $($(target)_2_DEBUG_STAGE_TARGET_FILES) +endif + +endef # def_target_install_only + + + +# +# LIBRARIES +# + +## Library (one). +# @param $(target) Normalized library (target) name. +define def_lib +# library basics +## @todo prefix +local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET)) +local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) +local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) +local tool := $(call _TARGET_TOOL,$(target),AR) +ifeq ($(tool),) +$(error kBuild: Library target $(target) does not have a tool defined!) +endif +local name := $(firstword\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg).$(bld_type))\ + $($(target)_NAME.$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg))\ + $($(target)_NAME.$(bld_type))\ + $($(target)_NAME)\ + $(target)) +local outbase := $(call TARGET_BASE,$(name),$(target)) +$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase))) +$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR) +local suff := $(firstword\ + $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\ + $($(target)_LIBSUFF.$(bld_trg))\ + $($(target)_LIBSUFF)\ + $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\ + $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\ + $(TOOL_$(tool)_ARLIBSUFF)\ + $(SUFF_LIB)) +local out := $(outbase)$(suff) +local defpath := $($(target)_DEFPATH) +ifeq ($(defpath),) + local defpath := $($(target)_PATH) +endif +$(target)_1_TARGET:= $(out) +$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET) +# no local here - must be writable across some foreachs. +othersrc := +$(target)_2_OBJS := + +# Do units pre source callouts. +local units := \ + $($(target)_USES.$(bld_trg).$(bld_trg_arch))\ + $($(target)_USES.$(bld_trg_arch))\ + $($(target)_USES.$(bld_trg))\ + $($(target)_USES.$(bld_type))\ + $($(target)_USES) +$(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre)) + +# source -> object +$(evalval def_target_sources) + +# library linking +local tool := $(call _TARGET_TOOL,$(target),AR) +local name := $(firstword\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg).$(bld_type))\ + $($(target)_NAME.$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg))\ + $($(target)_NAME.$(bld_type))\ + $($(target)_NAME)\ + $(target)) +local outbase := $(call TARGET_BASE,$(name),$(target)) +local flags :=\ + $(TOOL_$(tool)_ARFLAGS)\ + $(TOOL_$(tool)_ARFLAGS.$(bld_type))\ + $(ARFLAGS)\ + $(ARFLAGS.$(bld_type))\ + $($(target)_ARFLAGS)\ + $($(target)_ARFLAGS.$(bld_type)) \ + $($(target)_ARFLAGS.$(bld_trg)) \ + $($(target)_ARFLAGS.$(bld_trg_arch)) \ + $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_ARFLAGS.$(bld_trg_cpu)) +local dirdep := $(call DIRDEP,$(dir $(out))) +local deps := \ + $($(target)_DEPS.$(bld_trg_cpu)) \ + $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_DEPS.$(bld_trg).$(bld_type)) \ + $($(target)_DEPS.$(bld_trg_arch)) \ + $($(target)_DEPS.$(bld_trg)) \ + $($(target)_DEPS.$(bld_type)) \ + $($(target)_DEPS) \ + $($(target)_LNK_DEPS.$(bld_trg_cpu)) \ + $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \ + $($(target)_LNK_DEPS.$(bld_trg_arch)) \ + $($(target)_LNK_DEPS.$(bld_trg)) \ + $($(target)_LNK_DEPS.$(bld_type)) \ + $($(target)_LNK_DEPS) +local orderdeps := \ + $($(target)_ORDERDEPS.$(bld_trg_cpu)) \ + $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \ + $($(target)_ORDERDEPS.$(bld_trg_arch)) \ + $($(target)_ORDERDEPS.$(bld_trg)) \ + $($(target)_ORDERDEPS.$(bld_type)) \ + $($(target)_ORDERDEPS) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg)) \ + $($(target)_LNK_ORDERDEPS.$(bld_type)) \ + $($(target)_LNK_ORDERDEPS) + +# Adjust paths if we got a default path. +ifneq ($(defpath),) + local deps := $(abspathex $(deps),$(defpath)) + local orderdeps := $(abspathex $(orderdeps),$(defpath)) + othersrc := $(abspathex $(othersrc),$(defpath)) +endif + + +# Custom pre-link actions. +local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS) +local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS) + +# eliminate this guy? +local objs = $($(target)_2_OBJS) + +# dependency file +local dep := $(out)$(SUFF_DEP) +ifndef NO_LINK_CMDS_DEPS + _DEPFILES_INCLUDED += $(dep) + ifdef KB_HAVE_INCLUDEDEP_QUEUE + includedep-queue $(dep) + else + includedep $(dep) + endif +endif + +# check that the tool is defined. +ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS +$(warning kBuild: tools: \ + 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ + 2 $($(target)_$(source)TOOL.$(bld_trg)) \ + 3 $($(target)_$(source)TOOL) \ + 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \ + 5 $($(target)_TOOL.$(bld_trg)) \ + 6 $($(target)_TOOL) \ + 7 $($(source)TOOL) \ + 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ + 9 $($(source)TOOL.$(bld_trg)) \ + 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \ + 11 $(TOOL.$(bld_trg)) \ + 12 $(TOOL) ) +$(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) ) +endif + +# call the tool +local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS) +ifneq ($(pre_cmds),) + local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds) +endif +ifneq ($(post_cmds),) + local cmds := $(cmds)$(NL)$(TAB)$(post_cmds) +endif +$(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT) +$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE) +$(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS) +$(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps) + +# generate the link rule. +$(eval $(def_link_rule)) + +# installing and globals. +local target_type_mode := a+r,u+w +$(evalval def_target_install_only) + +_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out) +_CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type)) +_DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type)) +_OBJS += $($(target)_2_OBJS) + +endef # def_lib +$(eval-opt-var def_lib) + +# Process libraries +typevar := _LIBS +tool_do := LINK_LIBRARY +mode := 0644 +$(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done library targets) +endif + + +# +# Link operations. +# + +## +# Link prolog +# +# @param $(target) Normalized target name. +# @param $(EXT) EXE,DLL,SYS. +# @param $(typevar) The name of the variable with all the root targets of its type. +define def_link_common +# basics +local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var))) +local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH)) +local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU)) + +local tool := $(call _TARGET_TOOL,$(target),LD) +local name := $(firstword\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg).$(bld_type))\ + $($(target)_NAME.$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg))\ + $($(target)_NAME.$(bld_type))\ + $($(target)_NAME)\ + $(target)) +local outbase := $(call TARGET_BASE,$(name),$(target)) +$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase))) +$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR) +local suff := $(firstword \ + $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ + $($(target)_$(EXT)SUFF.$(bld_trg))\ + $($(target)_$(EXT)SUFF)\ + $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ + $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\ + $(TOOL_$(tool)_LD$(EXT)SUFF)\ + $($(EXTPRE)SUFF_$(EXT)) ) +local out := $(outbase)$(suff) +$(target)_1_TARGET:= $(out) +$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET) +local defpath := $($(target)_DEFPATH) +ifeq ($(defpath),) + local defpath := $($(target)_PATH) +endif +# no local here - must be writable across some foreachs. +othersrc := +$(target)_2_OBJS := + +# Do units pre source callouts. +local units := \ + $($(target)_USES.$(bld_trg).$(bld_trg_arch))\ + $($(target)_USES.$(bld_trg_arch))\ + $($(target)_USES.$(bld_trg))\ + $($(target)_USES.$(bld_type))\ + $($(target)_USES) +$(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre)) + +# source -> object +$(evalval def_target_sources) + +# more link stuff. +local tool := $(call _TARGET_TOOL,$(target),LD) +local name := $(firstword\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\ + $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg).$(bld_type))\ + $($(target)_NAME.$(bld_trg_arch))\ + $($(target)_NAME.$(bld_trg))\ + $($(target)_NAME.$(bld_type))\ + $($(target)_NAME)\ + $(target)) +local outbase := $(call TARGET_BASE,$(name),$(target)) +local flags :=\ + $(TOOL_$(tool)_LDFLAGS)\ + $(TOOL_$(tool)_LDFLAGS.$(bld_type))\ + $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\ + $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\ + $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ + $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\ + $(foreach sdk, $(SDKS) \ + $(SDKS.$(bld_type)) \ + $(SDKS.$(bld_trg)) \ + $(SDKS.$(bld_trg_arch)) \ + $(SDKS.$(bld_trg).$(bld_trg_arch)),\ + $(SDK_$(sdk)_LDFLAGS)\ + $(SDK_$(sdk)_LDFLAGS.$(bld_type))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\ + $(LDFLAGS)\ + $(LDFLAGS.$(bld_type))\ + $(LDFLAGS.$(bld_trg))\ + $(LDFLAGS.$(bld_trg_arch))\ + $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\ + $(LDFLAGS.$(bld_trg_cpu))\ + $(foreach sdk, $($(target)_SDKS) \ + $($(target)_SDKS.$(bld_type)) \ + $($(target)_SDKS.$(bld_trg)) \ + $($(target)_SDKS.$(bld_trg_arch)) \ + $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\ + $(SDK_$(sdk)_LDFLAGS)\ + $(SDK_$(sdk)_LDFLAGS.$(bld_type))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ + $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\ + $($(target)_LDFLAGS)\ + $($(target)_LDFLAGS.$(bld_type))\ + $($(target)_LDFLAGS.$(bld_trg))\ + $($(target)_LDFLAGS.$(bld_trg_arch))\ + $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ + $($(target)_LDFLAGS.$(bld_trg_cpu)) +local libs :=\ + $($(target)_LIBS.$(bld_trg_cpu))\ + $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\ + $($(target)_LIBS.$(bld_trg_arch))\ + $($(target)_LIBS.$(bld_trg))\ + $($(target)_LIBS.$(bld_type))\ + $($(target)_LIBS)\ + $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_SDKS.$(bld_trg_arch)) \ + $($(target)_SDKS.$(bld_trg)) \ + $($(target)_SDKS.$(bld_type)) \ + $($(target)_SDKS),\ + $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\ + $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBS.$(bld_trg))\ + $(SDK_$(sdk)_LIBS.$(bld_type))\ + $(SDK_$(sdk)_LIBS))\ + $(LIBS.$(bld_trg_cpu))\ + $(LIBS.$(bld_trg).$(bld_trg_arch))\ + $(LIBS.$(bld_trg_arch))\ + $(LIBS.$(bld_trg))\ + $(LIBS.$(bld_type))\ + $(LIBS)\ + $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \ + $(SDKS.$(bld_trg_arch)) \ + $(SDKS.$(bld_trg)) \ + $(SDKS.$(bld_type)) \ + $(SDKS),\ + $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\ + $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBS.$(bld_trg))\ + $(SDK_$(sdk)_LIBS.$(bld_type))\ + $(SDK_$(sdk)_LIBS))\ + $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\ + $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\ + $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\ + $(TOOL_$(tool)_LIBS.$(bld_trg))\ + $(TOOL_$(tool)_LIBS.$(bld_type))\ + $(TOOL_$(tool)_LIBS) +local libpath :=\ + $($(target)_LIBPATH.$(bld_trg_cpu))\ + $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ + $($(target)_LIBPATH.$(bld_trg_arch))\ + $($(target)_LIBPATH.$(bld_trg))\ + $($(target)_LIBPATH.$(bld_type))\ + $($(target)_LIBPATH)\ + $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_SDKS.$(bld_trg_arch)) \ + $($(target)_SDKS.$(bld_trg)) \ + $($(target)_SDKS.$(bld_type)) \ + $($(target)_SDKS),\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg))\ + $(SDK_$(sdk)_LIBPATH.$(bld_type))\ + $(SDK_$(sdk)_LIBPATH))\ + $(LIBPATH.$(bld_trg_cpu))\ + $(LIBPATH.$(bld_trg).$(bld_trg_arch))\ + $(LIBPATH.$(bld_trg_arch))\ + $(LIBPATH.$(bld_trg))\ + $(LIBPATH.$(bld_type))\ + $(LIBPATH)\ + $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \ + $(SDKS.$(bld_trg_arch)) \ + $(SDKS.$(bld_trg)) \ + $(SDKS.$(bld_type)) \ + $(SDKS),\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\ + $(SDK_$(sdk)_LIBPATH.$(bld_trg))\ + $(SDK_$(sdk)_LIBPATH.$(bld_type))\ + $(SDK_$(sdk)_LIBPATH))\ + $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\ + $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ + $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\ + $(TOOL_$(tool)_LIBPATH.$(bld_trg))\ + $(TOOL_$(tool)_LIBPATH.$(bld_type))\ + $(TOOL_$(tool)_LIBPATH) +local dirdep := $(call DIRDEP,$(dir $(out))) +local deps := \ + $($(target)_DEPS.$(bld_trg_cpu)) \ + $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_DEPS.$(bld_trg).$(bld_type)) \ + $($(target)_DEPS.$(bld_trg_arch)) \ + $($(target)_DEPS.$(bld_trg)) \ + $($(target)_DEPS.$(bld_type)) \ + $($(target)_DEPS) \ + $($(target)_LNK_DEPS.$(bld_trg_cpu)) \ + $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \ + $($(target)_LNK_DEPS.$(bld_trg_arch)) \ + $($(target)_LNK_DEPS.$(bld_trg)) \ + $($(target)_LNK_DEPS.$(bld_type)) \ + $($(target)_LNK_DEPS) +local orderdeps := \ + $($(target)_ORDERDEPS.$(bld_trg_cpu)) \ + $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \ + $($(target)_ORDERDEPS.$(bld_trg_arch)) \ + $($(target)_ORDERDEPS.$(bld_trg)) \ + $($(target)_ORDERDEPS.$(bld_type)) \ + $($(target)_ORDERDEPS) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \ + $($(target)_LNK_ORDERDEPS.$(bld_trg)) \ + $($(target)_LNK_ORDERDEPS.$(bld_type)) \ + $($(target)_LNK_ORDERDEPS) + +# Adjust paths if we got a default path. +ifneq ($(defpath),) + local libpath := $(abspathex $(libpath),$(defpath)) + local deps := $(abspathex $(deps),$(defpath)) + local orderdeps := $(abspathex $(orderdeps),$(defpath)) + othersrc := $(abspathex $(othersrc),$(defpath)) + # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir! +endif + +# Debug info. +local ld_debug := $(evalcall def_fn_prop_get_first_defined,LD_DEBUG) +local debug_inst := $(evalcall def_fn_prop_get_first_defined,DEBUG_INST) +local debug_stage := $(evalcall def_fn_prop_get_first_defined,DEBUG_STAGE) +local debug_nostage := $(evalcall def_fn_prop_get_first_word,DEBUG_NOSTAGE) + +# Custom pre/post-link actions. +local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS) +local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS) + +# eliminate this guy? +local objs = $($(target)_2_OBJS) + +# dependency file +local dep := $(outbase)$(SUFF_DEP) +ifndef NO_LINK_CMDS_DEPS + _DEPFILES_INCLUDED += $(dep) + ifdef KB_HAVE_INCLUDEDEP_QUEUE + includedep-queue $(dep) + else + includedep $(dep) + endif +endif + +# check that the tool is defined. +ifndef TOOL_$(tool)_$(tool_do)_CMDS +$(warning kBuild: tools: \ + 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ + 2 $($(target)_$(source)TOOL.$(bld_trg)) \ + 3 $($(target)_$(source)TOOL) \ + 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \ + 5 $($(target)_TOOL.$(bld_trg)) \ + 6 $($(target)_TOOL) \ + 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ + 8 $($(source)TOOL.$(bld_trg)) \ + 9 $($(source)TOOL) \ + 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \ + 11 $(TOOL.$(bld_trg)) \ + 12 $(TOOL) ) +$(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) ) +endif + +# call the tool +local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS) +ifneq ($(pre_cmds),) + local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds) +endif +ifneq ($(post_cmds),) + local cmds := $(cmds)$(NL)$(TAB)$(post_cmds) +endif +$(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT) +$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE) +if1of ($(ld_debug), split) + $(target)_2_OUTPUT_DEBUG_FILES := $(filter-out %/,$(TOOL_$(tool)_$(tool_do)_OUTPUT_DEBUG)) + $(target)_2_OUTPUT_DEBUG_DIRS := $(filter %/,$(TOOL_$(tool)_$(tool_do)_OUTPUT_DEBUG)) +else + $(target)_2_OUTPUT_DEBUG_FILES := + $(target)_2_OUTPUT_DEBUG_DIRS := +endif +$(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS) +$(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps) + +# generate the link rule. +$(eval $(def_link_rule)) + +# installation targets +local target_type_mode := +$(evalval def_target_install_only) + +# Update globals. +_OBJS += $($(target)_2_OBJS) +_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out) +_CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type)) +_DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type)) +_INSTALLS_FILES += $(INSTARGET_$(target)) + +endef # def_link_common +$(eval-opt-var def_link_common) + + +# +# BLDPROGS +# + +# Process build programs. +EXT := EXE +EXTPRE := HOST +tool_do := LINK_PROGRAM +typevar := _BLDPROGS +mode := 0755 +bld_trg_base_var := PLATFORM +$(foreach target, $(_ALL_BLDPROGS), $(evalval def_link_common)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done build program targets) +endif + + +# +# DLLS +# + +# Process dlls +EXT := DLL +EXTPRE := +tool_do := LINK_DLL +typevar := _DLLS +mode := 0644 +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_DLLS), $(evalval def_link_common)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done dll targets) +endif + + +# +# IMPORT LIBRARIES +# +# - On OS/2 and windows these are libraries. +# - On other platforms they are fake DLLs. +# +EXTPRE := +typevar := _IMPORT_LIBS +mode := 0644 +bld_trg_base_var := TARGET +ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),) + EXT := LIB + tool_do := LINK_LIBRARY + $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_lib)) +else + EXT := DLL + tool_do := LINK_DLL + $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common)) +endif + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done import library targets) +endif + + +# +# PROGRAMS +# + +# Process programs +EXT := EXE +EXTPRE := +tool_do := LINK_PROGRAM +typevar := _PROGRAMS +mode := 0755 +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done program targets) +endif + + +# +# SYSMODS +# + +# Process sysmods +EXT := SYS +EXTPRE := +tool_do := LINK_SYSMOD +typevar := _SYSMODS +mode := 0644 +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done sysmod targets) +endif + + +# +# MISCBINS +# + +# Process MISCBINS +EXT := BIN +EXTPRE := +tool_do := LINK_MISCBIN +typevar := _MISCBINS +mode := 0644 +bld_trg_base_var := TARGET +$(foreach target, $(_ALL_MISCBINS), $(evalval def_link_common)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done misc binary targets) +endif + diff --git a/kBuild/footer-pass2-fetches.kmk b/kBuild/footer-pass2-fetches.kmk new file mode 100644 index 0000000..fda024b --- /dev/null +++ b/kBuild/footer-pass2-fetches.kmk @@ -0,0 +1,431 @@ +# $Id: footer-pass2-fetches.kmk 2521 2011-07-26 18:18:19Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Fetches. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + + +## @page pg_fetches Fetching Tools, Sources and Similar. +# +# The targets listed in the the FETCHES target list have the following attributes: +# SOURCES +# INST +# FETCHTOOL +# FETCHFLAGS +# FETCHDIR +# UNPACKTOOL +# UNPACKFLAGS +# +# As usual the target name is an alias for 'creating' the target. Other +# aliases are: +# pass_fetches +# fetch +# unfetch +# download +# unpack +# +# @remark +# +# This is a little bit complex because we must guarantee that if a source file +# changes only sligtly we must refetch it and to a proper unpacking of it. It +# is also a desire that fetched archives and unpacked files can be deleted to +# save space. +# +# Thus, we must be able to cleanup what we've unpacked should any of the +# sources be removed. We do this by maintaining a file listing the files +# and directories that was unpacked. This operation is named 'unfetch'. +# +# We make use of the SIZE and MD5 attributes for each of the sources to +# create a digest that is stored in the primary target file. Subsequent +# runswill compare their digest with it to decide if a refetch is required. +# When a refetch is found necessary, an 'unfetch' is performed first to +# clean out old files and directores. Note even changes in source order +# will cause a refetch due to the way the digest is constructed and +# evaluated. +# +# By not depending directly on the archives (nor on any unpacked files) +# but on a goal made up from the archive name, size and md5, we allow +# the user to delete the archives. Naturally, this means we'll have to +# check and fetch missing archives before attempting to unpack them. +# +# @remark +# +# This feature will *NOT* work correctly with vanilla GNU make becuase +# it makes use of includedep to avoid too many unnecessary files. +# +# @todo +# 0. Move the fetches out into a unit. +# 1. Download corruption / continuation. +# 2. It's quite possible that there is one too many indirect dependency now... +# + +## generates the fetch rule +define def_fetch_src_fetch_rule +# Indirect goal for downloading something. +.PRECIOUS: $(out) +$(out) + $($(target)_$(srcname)_FETCH_2_OUTPUT) +| $($(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE) : \ + | $($(target)_$(srcname)_FETCH_2_DEPORD) + %$$(call MSG_FETCH_DL,$(target),$(source),$(out)) + @## @todo do fancy stuff like download continuation. + $$(QUIET)$$(RM) -f -- $(out) + $(cmds) + $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out)) + + + +# Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary. +$(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_2_DEPEND) | $($(target)_$(srcname)_FETCH_2_DEPORD) + %$$(call MSG_FETCH_CHK,$(target),$(source),$(out)) + $$(QUIET)$$(RM) -f -- $$@ + @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5. + @## @todo do fancy stuff like download continuation. + $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \ + || ( $$(RM_EXT) -f $(out) \ + && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory ) + $$(QUIET2)$$(APPEND) $$@ + +_TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size) + +# Just a little precaution. +.NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size) + +endef # def_fetch_src_fetch_rule +$(eval-opt-var def_fetch_src_fetch_rule) + +## generates the unpack rule +define def_fetch_src_unpack_rule +# This is the unpack rule. it has an order-only dependency on the download check. +$(out) + $($(target)_$(srcname)_UNPACK_2_OUTPUT) +| $($(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE) : \ + $($(target)_$(srcname)_UNPACK_2_DEPEND) \ + | $($(target)_$(srcname)_UNPACK_2_DEPORD) \ + $(archive).checked_$(md5)_$(size) \ + $(dir $(out)) + %$$(call MSG_FETCH_UP,$(target),$(archive),$(inst)) + $$(QUIET)$$(RM) -f -- $(out) + $$(QUIET)$$(MKDIR) -p -- $(dir $(out)) + @# if the source archive doesn't exist fetch it (may have been deleted to save space). + $$(QUIET)test -f $(archive) \ + || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \ + && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory ) + $(cmds) + $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size)) + $$(QUIET2)$$(APPEND) $(out) $(notdir $(out)) + +$(eval _TARGET_$(target)_UNPACKED += $(out)) +_TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size) + +.NOTPARALLEL: $(out) + +endef # def_fetch_src_unpack_rule +$(eval-opt-var def_fetch_src_unpack_rule) + +## Processes a fetch source +# +define def_fetch_src +#$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)') + +# common +local srcname := $(notdir $(source)) +local inst := $(firstword \ + $($(target)_$(source)_INST)\ + $($(target)_$(srcname)_INST)\ + $($(source)_INST)\ + $($(srcname)_INST)\ + $($(target)_INST)\ +) +ifneq ($(patsubst %/,ok,$(inst)),ok) +$(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst)) +endif +## @todo Install-revamp: FIXME +INSTARGET_$(target)_$(srcname) := $(inst) +local fetchdir := $(firstword \ + $($(target)_$(source)_FETCHDIR)\ + $($(target)_$(srcname)_FETCHDIR)\ + $($(source)_FETCHDIR)\ + $($(srcname)_FETCHDIR)\ + $($(target)_FETCHDIR)\ + $(FETCHDIR)\ + $(PATH_TARGET)\ +) +local deps := \ + $($(target)_$(source)_DEPS)\ + $($(target)_$(srcname)_DEPS)\ + $($(source)_DEPS)\ + $($(srcname)_DEPS)\ + $($(target)_DEPS) +local orderdeps := \ + $($(target)_$(source)_ORDERDEPS)\ + $($(target)_$(srcname)_ORDERDEPS)\ + $($(source)_ORDERDEPS)\ + $($(srcname)_ORDERDEPS)\ + $($(target)_ORDERDEPS) +local md5 := $(firstword \ + $($(target)_$(source)_MD5)\ + $($(target)_$(srcname)_MD5)\ + $($(source)_MD5)\ + $($(srcname)_MD5)\ + $($(target)_MD5)\ +) +local size := $(firstword \ + $($(target)_$(source)_SIZE)\ + $($(target)_$(srcname)_SIZE)\ + $($(source)_SIZE)\ + $($(srcname)_SIZE)\ + $($(target)_SIZE)\ +) +clean_files += \ + $($(target)_$(source)_CLEAN)\ + $($(target)_$(srcname)_CLEAN)\ + $($(source)_CLEAN)\ + $($(srcname)_CLEAN) +local dep := # not legal for fetch and unpack tools + + +# +# The fetching. +# +local out := $(fetchdir)/$(srcname) +local archive := $(out) +$(target)_$(srcname)_1_TARGET = $(TARGET_$(target)_$(srcname)) +$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target)_$(srcname),$(TARGET_$(target)_$(srcname)),TARGET_$(target)_$(srcname)) + +local dirdep := $(call DIRDEP,$(fetchdir)) +local tool := $(firstword \ + $($(target)_$(source)_FETCHTOOL)\ + $($(target)_$(srcname)_FETCHTOOL)\ + $($(target)_$(source)_TOOL)\ + $($(target)_$(srcname)_TOOL)\ + $($(source)_FETCHTOOL)\ + $($(srcname)_FETCHTOOL)\ + $($(source)_TOOL)\ + $($(srcname)_TOOL)\ + $($(target)_FETCHTOOL)\ + $($(target)_TOOL)\ + ) +local flags :=\ + $(TOOL_$(tool)_FETCHFLAGS)\ + $(FETCHFLAGS)\ + $($(target)_FETCHFLAGS)\ + $($(srcname)_FETCHFLAGS)\ + $($(source)_FETCHFLAGS)\ + $($(target)_$(srcname)_FETCHFLAGS)\ + $($(target)_$(source)_FETCHFLAGS) + +#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size)) + +ifndef TOOL_$(tool)_FETCH_CMDS +$(warning kBuild: tools: \ + 1 $($(target)_$(source)_FETCHTOOL)\ + 2 $($(target)_$(srcname)_FETCHTOOL)\ + 3 $($(target)_$(source)_TOOL)\ + 4 $($(target)_$(srcname)_TOOL)\ + 5 $($(source)_FETCHTOOL)\ + 6 $($(srcname)_FETCHTOOL)\ + 7 $($(source)_TOOL)\ + 8 $($(srcname)_TOOL)\ + 9 $($(target)_FETCHTOOL)\ + 10 $($(target)_TOOL) ) +$(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) ) +endif + +# call the tool +local cmds := $(TOOL_$(tool)_FETCH_CMDS) +$(target)_$(srcname)_FETCH_2_OUTPUT := $(TOOL_$(tool)_FETCH_OUTPUT) +$(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE) +$(target)_$(srcname)_FETCH_2_DEPEND := $(TOOL_$(tool)_FETCH_DEPEND) $(deps) +$(target)_$(srcname)_FETCH_2_DEPORD := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps) + +# generate the fetch rule. +$(eval $(def_fetch_src_fetch_rule)) + + +# +# The unpacking / installing. +# +local out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst +local dirdep := $(call DIRDEP,$(inst)) +local tool := $(firstword \ + $($(target)_$(source)_UNPACKTOOL)\ + $($(target)_$(srcname)_UNPACKTOOL)\ + $($(target)_$(source)_TOOL)\ + $($(target)_$(srcname)_TOOL)\ + $($(source)_UNPACKTOOL)\ + $($(srcname)_UNPACKTOOL)\ + $($(source)_TOOL)\ + $($(srcname)_TOOL)\ + $($(target)_UNPACKTOOL)\ + $($(target)_TOOL) \ + ) +ifeq ($(tool),) +local tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname))))) +$(evalval def_tools_include) +endif +local flags :=\ + $(TOOL_$(tool)_UNPACKFLAGS)\ + $(UNPACKFLAGS)\ + $($(target)_UNPACKFLAGS)\ + $($(srcname)_UNPACKFLAGS)\ + $($(source)_UNPACKFLAGS)\ + $($(target)_$(srcname)_UNPACKFLAGS)\ + $($(target)_$(source)_UNPACKFLAGS) + +#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size)) +ifndef TOOL_$(tool)_UNPACK_CMDS +$(warning kBuild: tools: \ + 1 $($(target)_$(source)_UNPACKTOOL)\ + 2 $($(target)_$(srcname)_UNPACKTOOL)\ + 3 $($(target)_$(source)_TOOL)\ + 4 $($(target)_$(srcname)_TOOL)\ + 5 $($(source)_UNPACKTOOL)\ + 6 $($(srcname)_UNPACKTOOL)\ + 7 $($(source)_TOOL)\ + 8 $($(srcname)_TOOL)\ + 9 $($(target)_UNPACKTOOL)\ + 10 $($(target)_TOOL) \ + 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \ + ) +$(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) ) +endif + +# call the tool +local cmds := $(TOOL_$(tool)_UNPACK_CMDS) +$(target)_$(srcname)_UNPACK_2_OUTPUT := $(TOOL_$(tool)_UNPACK_OUTPUT) +$(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE) +$(target)_$(srcname)_UNPACK_2_DEPEND := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps) +$(target)_$(srcname)_UNPACK_2_DEPORD := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps) + +# generate the fetch rule. +$(eval $(def_fetch_src_unpack_rule)) + +_DIRS += $(inst) $(fetchdir) + +endef # def_fetch_src +$(eval-opt-var def_fetch_src) + + +## +# Define the target level rules for a fetch. +# @param target +# @param out +# @param inst +# @param _TARGET_$(target)_UNPACKED +# @param _TARGET_$(target)_DIGEST +# @param bld_trg +# @param bld_trg_arch +define def_fetch_rules + +$(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst)) + %$$(call MSG_FETCH_OK,$(target)) + $$(QUIET)$$(RM) -f -- $$@ $$@.tmp + $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))' + $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp) + $$(QUIET)$$(MV) -f -- $$@.tmp $$@ + +$(out)_unfetched: + %$$(call MSG_UNFETCH,$(target)) + $$(QUIET)$$(RM) -f -- $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d')) + $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) \ + $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null)))) + $$(QUIET)$$(RM) -f -- $(out).lst $(out) + $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) + +$(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst)) + $$(QUIET)$$(RM) -f -- $$@ + %$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(eq $$(file-size $(out).lst),-1)\ + ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target))) + $$(QUIET)$(TEST_EXT) -f $(out).lst -- $$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched + $$(QUIET)$$(if $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@)) + $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)") + +.NOTPARALLEL: $(out).lst $(out)_unfetched $(out) + +endef + + +## +# Deal with one fetch target. +# @param target +# @param bld_trg +# @param bld_trg_arch +define def_fetch +# common +## @todo Install-revamp: FIXME +INSTARGET_$(target) := $($(target)_INST) +ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok) +$(error kBuild: Bad or missing INST property for target '$(target)'. \ + $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST))) +endif +_TARGET_$(target)_FETCHED := +_TARGET_$(target)_UNPACKED := +_TARGET_$(target)_DIGEST := +local clean_files := $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(KBUILD_TYPE)) + +# The 'sources'. +#$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(KBUILD_TARGET).$(bld_trg_arch))) +$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)),\ + $(evalval def_fetch_src)) + +# The target. +local inst := $(INSTARGET_$(target)) +local out := $(inst)_kBuild_fetch_$(target) + +$(eval includedep $(out)) + +$(eval $(def_fetch_rules)) + +# Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep). +$(target): $(out) +$(target)_unfetch: $(out)_unfetched + +_FETCHES += $(out) +_DOWNLOADS += $(_TARGET_$(target)_FETCHED) +_UNPACKS += $(_TARGET_$(target)_UNPACKED) +_UNFETCHES += $(out)_unfetched +_DIRS += $(inst) +_CLEAN_FILES += $(clean_files) + +endef +$(eval-opt-var def_fetch) + +# Walk the FETCH target lists. +bld_trg := $(KBUILD_TARGET) +bld_trg_arch := $(KBUILD_TARGET_ARCH) +$(foreach target, $(_ALL_FETCHES), \ + $(evalvalctx def_fetch)) + +# some aliases. +download: $(_DOWNLOADS) +unpack: $(_UNPACKS) +fetch: $(_FETCHES) +unfetch: $(_UNFETCHES) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done fetching targets) +endif diff --git a/kBuild/footer-pass2-installs.kmk b/kBuild/footer-pass2-installs.kmk new file mode 100644 index 0000000..b8d67c4 --- /dev/null +++ b/kBuild/footer-pass2-installs.kmk @@ -0,0 +1,612 @@ +# $Id: footer-pass2-installs.kmk 2537 2011-08-02 19:44:43Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Installs. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + + +# +# INSTALLS +# + +## +# Generate the staging rules. +# +define def_install_src_rule_staging +$$(call KB_FN_ASSERT_ABSPATH, stagedst) +$$(call KB_FN_ASSERT_ABSPATH, srcsrc) +$(stagedst) : $(srcsrc) | $(dir $(stagedst)) + %$$(call MSG_INST_FILE,$(srcsrc),$(stagedst)) + $(top_pre_file_cmds) + $$(QUIET)$(stagecmd) + $(top_post_file_cmds) +endef +$(eval-opt-var def_install_src_rule_staging) + +define def_install_src_rule_installing +$$(call KB_FN_ASSERT_ABSPATH, instdst) +$$(call KB_FN_ASSERT_ABSPATH, srcsrc) +$(instdst) : $(srcsrc) | $(dir $(instdst)) + %$$(call MSG_INST_FILE,$(srcsrc),$(instdst)) + $(top_pre_file_cmds) + $$(QUIET)$(instcmd) + $(top_post_file_cmds) +endef +$(eval-opt-var def_install_src_rule_installing) + +## +# Install one file. +# +define def_install_src + +# deal with '=>' in the source file name. +ifeq ($(src),=>) + $(error kBuild: Install target '$(target)' has a bad source specifier containing '=>' without any file names) +endif +ifeq ($(substr $(src),1,2),=>) + $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src)) +endif +ifeq ($(substr $(src),-2),=>) + $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src)) +endif +local srcdst := $(subst =>, ,$(src)) +local srcsrc := $(firstword $(srcdst)) +local srcdstdir := $(dir $(word 2,$(srcdst))) +ifeq ($(srcdstdir),./) + local srcdstdir:= +endif +local srcdst := $(word $(words $(srcdst)),$(srcdst)) + +# instfun, mode, uid and gid. +ifdef $(srcsrc)_INSTFUN + local instfun := $(srcsrc)_INSTFUN +else + local instfun := $(top_instfun) +endif +local mode := $(firstword \ + $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg)) \ + $($(target)_$(srcsrc)$(source_type_prefix)_MODE) \ + $($(target)_$(srcdst)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcdst)$(source_type_prefix)_MODE.$(bld_trg)) \ + $($(target)_$(srcdst)$(source_type_prefix)_MODE) \ + $($(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(srcsrc)$(source_type_prefix)_MODE.$(bld_trg)) \ + $($(srcsrc)$(source_type_prefix)_MODE) \ + $($(srcdst)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(srcdst)$(source_type_prefix)_MODE.$(bld_trg)) \ + $($(srcdst)$(source_type_prefix)_MODE) \ + $(source_type_mode)) +local uid := $(firstword \ + $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcsrc)_UID.$(bld_trg)) \ + $($(target)_$(srcsrc)_UID) \ + $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcdst)_UID.$(bld_trg)) \ + $($(target)_$(srcdst)_UID) \ + $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(srcsrc)_UID.$(bld_trg)) \ + $($(srcsrc)_UID) \ + $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(srcdst)_UID.$(bld_trg)) \ + $($(srcdst)_UID) \ + $(top_uid)) +local gid := $(firstword \ + $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcsrc)_GID.$(bld_trg)) \ + $($(target)_$(srcsrc)_GID) \ + $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcdst)_GID.$(bld_trg)) \ + $($(target)_$(srcdst)_GID) \ + $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(srcsrc)_GID.$(bld_trg)) \ + $($(srcsrc)_GID) \ + $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(srcdst)_GID.$(bld_trg)) \ + $($(srcdst)_GID) \ + $(top_gid)) +local flags := \ + $(top_ifflags) \ + $($(srcdst)$(source_type_prefix)_IFFLAGS) \ + $($(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \ + $($(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ + $($(srcsrc)$(source_type_prefix)_IFFLAGS) \ + $($(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \ + $($(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS) \ + $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \ + $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS) \ + $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \ + $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) +clean_files += \ + $($(srcdst)_CLEAN) \ + $($(srcdst)_CLEAN.$(bld_trg)) \ + $($(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ + $($(srcsrc)_CLEAN) \ + $($(srcsrc)_CLEAN.$(bld_trg)) \ + $($(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcdst)_CLEAN) \ + $($(target)_$(srcdst)_CLEAN.$(bld_trg)) \ + $($(target)_$(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(srcsrc)_CLEAN) \ + $($(target)_$(srcsrc)_CLEAN.$(bld_trg)) \ + $($(target)_$(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) + + +# Adjust the source if we got a default PATH. (This must be done this late!) +ifdef $(target)_DEFPATH +local defpath := $($(target)_DEFPATH) +else ifdef $(target)_PATH +local defpath := $($(target)_PATH) +else +local defpath := +endif +ifneq ($(defpath),) + local srcsrc := $(abspathex $(srcsrc),$(defpath)) +endif + +# Generate the staging rule (requires double evaluation). +local stage := $(strip $(firstdefined $(srcsrc)_STAGE $(srcsrc)_INST $(target)_1_STAGE,value)) +if "$(substr $(stage),-1)" != "/" && "$(stage)" != "" + $(warning kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)') + local stage := $(stage)/ +endif +local stage := $(stage)$(dir $(srcdstdir)) +ifeq ($(root $(stage)),) + local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_STAGE)) +else + local stage := $(abspath $(stage))/ + ifeq ($(pos $(PATH_OBJ),$(stage)),1) + local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2)) + local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_OBJ)) + else + $(error kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)') + endif +endif +ifdef $(srcsrc)_INSTALLER + local stagecmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage) +else ifdef $(target)_INSTALLER + local stagecmd := $(call $(target)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage) +else + local stagecmd := $$(INSTALL_STAGING)\ + $(if $(uid),-o $(uid))\ + $(if $(gid),-g $(gid))\ + $(if $(mode),-m $(mode))\ + $(flags) -- \ + $(srcsrc) $(stagedst) +endif +$(eval $(def_install_src_rule_staging)) +$(target)_2_STAGE_TARGETS += $(stagedst) + +# Generate the install rule +ifeq ($(insttype),both) + local inst := $(strip $(firstdefined $(srcsrc)_INST $(target)_1_INST,value)) + if "$(substr $(inst),-1)" != "/" && "$(inst)" != "" + $(warning kBuild: File $(srcsrc) in install target $(target) has a INST property without a trailing slash: '$(inst)') + local inst := $(inst)/ + endif + local inst := $(inst)$(dir $(srcdstdir)) + ifneq ($(root $(inst)),) + $(error kBuild: File $(srcsrc) in install target $(target) has a INST property with an absolute path: '$(inst)') + endif + local instdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS)) + + ifdef $(srcsrc)_INSTALLER + local instcmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install) + else ifdef $(target)_INSTALLER + local instcmd := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install) + else + local instcmd := $$(INSTALL)\ + $(if $(uid),-o $(uid))\ + $(if $(gid),-g $(gid))\ + $(if $(mode),-m $(mode))\ + $(flags) -- \ + $(srcsrc) $(instdst) + endif + $(eval $(def_install_src_rule_installing)) + $(target)_2_INST_TARGETS += $(instdst) +endif + +#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst)) +endef # def_install_src +$(eval-opt-var def_install_src) + + +## +# Generate the symlink rules. +# +define def_install_symlink_rule_staging +$$(call KB_FN_ASSERT_ABSPATH, stagedst) +$(stagedst) : | $(dir $(stagedst)) + %$$(call MSG_INST_SYM,$(stagedst),$(symdst)) + $$(QUIET)$$(RM) -f -- $$@ + $(top_pre_sym_cmds) + $$(QUIET)$$(LN_SYMLINK) $(symdst) $(stagedst) + $(top_post_sym_cmds) +endef +$(eval-opt-var def_install_symlink_rule_staging) + +define def_install_symlink_rule_installing +$$(call KB_FN_ASSERT_ABSPATH, instdst) +$(instdst) : | $(dir $(instdst)) + %$$(call MSG_INST_SYM,$(instdst),$(symdst)) + $$(QUIET)$$(RM) -f -- $$@ + $(top_pre_sym_cmds) + $$(QUIET)$$(LN_SYMLINK) $(symdst) $(instdst) + $(top_post_sym_cmds) +endef +$(eval-opt-var def_install_symlink_rule_installing) + + +## +# Create one symlink. +# +define def_install_symlink + +# deal with '=>' in the source file name. +local symdst := $(subst =>, ,$(src)) +local symlnk := $(firstword $(symdst)) +local symdst := $(word $(words $(symdst)),$(symdst)) +local symlnkdir := $(dir $(symlnk)) +ifeq ($(symlnkdir),./) + local symlnkdir := +endif + +# Figure which install function to use below. +ifdef $(symlnk)_INSTFUN + local instfun := $(symlnk)_INSTFUN +else + local instfun := $(top_instfun) +endif + +# Calc stage destination and generate the rule (requires double evaluation). +local stage := $(strip $(firstdefined $(symlnk)_STAGE $(symlnk)_INST $(target)_1_STAGE,value)) +if "$(substr $(stage),-1)" != "/" && "$(stage)" != "" + $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)') + local stage := $(stage)/ +endif +local stage := $(stage)$(symlnkdir) +ifeq ($(root $(stage)),) + local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE)) +else + local stage := $(abspath $(stage))/ + ifeq ($(pos $(PATH_OBJ),$(stage)),1) + local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2)) + local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_OBJ)) + else + $(error kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)') + endif +endif + +$(eval $(def_install_symlink_rule_staging)) +$(target)_2_STAGE_TARGETS += $(stagedst) + +# Calcuate the install destiation and generate the rule (if necessary). +ifeq ($(instmode),both) + local inst := $(strip $(firstdefined $(symlnk)_INST $(target)_1_INST,value)) + if "$(substr $(inst),-1)" != "/" && "$(inst)" != "" + $(warning kBuild: Symlink $(symlnk) in install target $(target) has a INST property without a trailing slash: '$(inst)') + local inst := $(inst)/ + endif + ifneq ($(root $(inst)),) + $(error kBuild: Symlink $(symlnk) in install target $(target) has a INST property with an absolute path: '$(inst)') + endif + local inst := $(inst)$(symlnkdir) + local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS)) + $(eval $(def_install_symlink_rule_installing)) + $(target)_2_INST_TARGETS += $(instdst) +endif + +#$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)') +endef # def_install_symlink +$(optmize def_install_symlink) + + +## +# Generate an directory installtion rule. +# Note. Used both for staging and real install rules. +# +define def_install_directory_rule +$$(call KB_FN_ASSERT_ABSPATH, insdst) +$(insdst): + %$$(call MSG_INST_DIR,$(insdst)) + $(top_pre_dir_cmds) + $$(QUIET)$$(INSTALL) -d \ + $(if $(uid),-o $(uid))\ + $(if $(gid),-g $(gid))\ + $(if $(mode),-m $(mode))\ + $(flags) -- \ + $(insdst) + $(top_post_dir_cmds) + +.NOTPARALLEL: $(insdst) +endef # def_install_directory_rule +$(eval-opt-var def_install_directory_rule) + +## +# Create one directory. +# +define def_install_directory + +# gather common properties. +local mode := $(firstword \ + $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(directory)_MODE.$(bld_trg)) \ + $($(target)_$(directory)_MODE) \ + $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(directory)_MODE.$(bld_trg)) \ + $($(directory)_MODE) \ + $(top_mode) ) +local uid := $(firstword \ + $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(directory)_UID.$(bld_trg)) \ + $($(target)_$(directory)_UID) \ + $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(directory)_UID.$(bld_trg)) \ + $($(directory)_UID) \ + $(top_uid) ) +local gid := $(firstword \ + $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(directory)_GID.$(bld_trg)) \ + $($(target)_$(directory)_GID) \ + $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(directory)_GID.$(bld_trg)) \ + $($(directory)_GID) \ + $(top_gid) ) +local flags := \ + $(top_idflags) \ + $($(directory)_IDFLAGS) \ + $($(directory)_IDFLAGS.$(bld_trg)) \ + $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(directory)_IDFLAGS) \ + $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \ + $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \ + +# The staging rule (requires double evaluation). +local stage := $(strip $(firstdefined $(directory)_STAGE $(directory)_INST $(target)_1_STAGE,value)) +if "$(substr $(stage),-1)" != "/" && "$(stage)" != "" + $(warning kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)') + local stage := $(stage)/ +endif +ifeq ($(root $(stage)),) + local insdst := $(PATH_STAGE)/$(stage)$(directory)/ +else + local stage := $(abspath $(stage))/ + ifeq ($(pos $(PATH_OBJ),$(stage)),1) + local insdst := $(stage)$(directory)/ + else + $(error kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)') + endif +endif + +$(target)_2_STAGE_DIR_TARGETS += $(insdst) +$(eval $(def_install_directory_rule)) + +# The install rule. +ifeq ($(insttype),both) + local inst := $(strip $(firstdefined $(directory)_INST $(target)_1_INST,value)) + ifneq ($(substr $(inst),-1),/) + $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash: '$(inst)') + local inst := $(inst)/ + endif + ifneq ($(root $(stage)),) + $(error kBuild: Directory $(directory) in install target $(target) has a INST property with an absolute path: '$(inst)') + endif + local insdst := $(PATH_INS)/$(inst)$(directory)/ + $(target)_2_INST_DIR_TARGETS += $(insdst) + $(eval $(def_install_directory_rule)) +endif + +#$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid)) +endef # def_install_directory +$(eval-opt-var def_install_directory) + + +## +# Process one install target. +# +define def_install +# the basics. +local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) +local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET)) +local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) +local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) +local insttype := $($(target)_1_INSTTYPE) + +ifneq ($(insttype),none) + $(target)_2_STAGE_TARGETS := $($(target)_GOALS) $($(target)_STAGE_ONLY_GOALS) +else + $(target)_2_STAGE_TARGETS := +endif +$(target)_2_STAGE_DIR_TARGETS := + +ifeq ($(insttype),both) + $(target)_2_INST_TARGETS := $($(target)_GOALS) $($(target)_INST_ONLY_GOALS) +else + $(target)_2_INST_TARGETS := +endif +$(target)_2_INST_DIR_TARGETS := + + +local outbase := $(call TARGET_BASE,$(target),$(target)) +$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase))) +$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR) + +ifneq ($(insttype),none) + # Cache top level target properties. + local top_mode := $(firstword \ + $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_MODE.$(bld_trg)) \ + $($(target)_MODE) ) + local top_exec_mode := $(firstword \ + $($(target)_EXEC_MODE.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_EXEC_MODE.$(bld_trg)) \ + $($(target)_EXEC_MODE) ) + local top_uid := $(firstword \ + $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_UID.$(bld_trg)) \ + $($(target)_UID) ) + local top_gid := $(firstword \ + $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_GID.$(bld_trg)) \ + $($(target)_GID) ) + local top_ifflags := \ + $($(target)_IFFLAGS) \ + $($(target)_IFFLAGS.$(bld_trg)) \ + $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) + local top_idflags := \ + $($(target)_IDFLAGS) \ + $($(target)_IDFLAGS.$(bld_trg)) \ + $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) + ifdef $(target)_INSTFUN + local top_instfun := $(target)_INSTFUN + else + local top_instfun := _INSTALL_FILE + endif + # The user have to use double expansion and can only use the above locals. Not 100% optimal... + local top_pre_file_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_XFILE_CMDS) + local top_post_file_cmds := $(evalcall def_fn_prop_get_first_defined,POST_XFILE_CMDS) + local top_pre_sym_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_SYMLINK_CMDS) + local top_post_sym_cmds := $(evalcall def_fn_prop_get_first_defined,POST_SYMLINK_CMDS) + local top_pre_dir_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_DIRECTORY_CMDS) + local top_post_dir_cmds := $(evalcall def_fn_prop_get_first_defined,POST_DIRECTORY_CMDS) + + $(foreach directory, \ + $($(target)_DIRS) \ + $($(target)_DIRS.$(bld_trg)) \ + $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_DIRS.$(bld_trg_arch)) \ + $($(target)_DIRS.$(bld_trg_cpu)) \ + $($(target)_DIRS.$(bld_type)), \ + $(evalval def_install_directory)) + + local clean_files := \ + $($(target)_CLEAN) \ + $($(target)_CLEAN.$(bld_trg)) \ + $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_CLEAN.$(bld_trg_arch)) \ + $($(target)_CLEAN.$(bld_trg_cpu)) \ + $($(target)_CLEAN.$(bld_type)) + + local source_type_prefix := + local source_type_mode := $(firstword $(top_mode) a+r,u+w) + $(foreach src,\ + $($(target)_SOURCES) \ + $($(target)_SOURCES.$(bld_trg)) \ + $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_SOURCES.$(bld_trg_arch)) \ + $($(target)_SOURCES.$(bld_trg_cpu)) \ + $($(target)_SOURCES.$(bld_type)), \ + $(evalval def_install_src)) + + local source_type_prefix := EXEC_ + local source_type_mode := $(firstword $(top_exec_mode) a+xr,u+w) + $(foreach src,\ + $($(target)_EXEC_SOURCES) \ + $($(target)_EXEC_SOURCES.$(bld_trg)) \ + $($(target)_EXEC_SOURCES.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_EXEC_SOURCES.$(bld_trg_arch)) \ + $($(target)_EXEC_SOURCES.$(bld_trg_cpu)) \ + $($(target)_EXEC_SOURCES.$(bld_type)), \ + $(evalval def_install_src)) + + $(foreach src,\ + $($(target)_SYMLINKS) \ + $($(target)_SYMLINKS.$(bld_trg)) \ + $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_SYMLINKS.$(bld_trg_arch)) \ + $($(target)_SYMLINKS.$(bld_trg_cpu)) \ + $($(target)_SYMLINKS.$(bld_type)), \ + $(evalval def_install_symlink)) +else # none + local clean_files := +endif + +# The collection targets (staging only). +local clean_files += $($(target)_1_TARGET) +$($(target)_1_TARGET): $$($(target)_2_STAGE_TARGETS) | $$($(target)_2_STAGE_DIR_TARGETS) $$(dir $$@) + @$(QUIET2)$(APPEND) $@ + +$(target): $$($(target)_1_TARGET) + +# Update Global lists. +_INSTALLS += $($(target)_1_TARGET) +_STAGE_FILES += $($(target)_2_STAGE_TARGETS) +_STAGE_DIRS += $($(target)_2_STAGE_DIR_TARGETS) +_INSTALLS_FILES += $($(target)_2_INST_TARGETS) +_INSTALLS_DIRS += $($(target)_2_INST_DIR_TARGETS) +_CLEAN_FILES += $(clean_files) +_DIRS += \ + $($(target)_0_OUTDIR) \ + $($(target)_BLDDIRS) \ + $($(target)_BLDDIRS.$(bld_trg)) \ + $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) \ + $($(target)_BLDDIRS.$(bld_trg_arch)) \ + $($(target)_BLDDIRS.$(bld_trg_cpu)) \ + $($(target)_BLDDIRS.$(bld_type)) + +# Deprecated properties. +INSTARGET_$(target) := $($(target)_2_STAGE_TARGETS) +INSTARGET_DIRS_$(target) := $($(target)_2_STAGE_DIR_TARGETS) + +endef # def_install +$(eval-opt-var def_install) + +## Do pass 1 on the implicit targets and add them to the list. +$(foreach target, $(_ALL_INSTALLS_IMPLICIT), \ + $(evalval def_pass1_install)) +_ALL_INSTALLS += $(_ALL_INSTALLS_IMPLICIT) + +## Do pass 2 on all install targets. +$(foreach target, $(_ALL_INSTALLS), \ + $(evalvalctx def_install)) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done install targets) +endif + +# +# Some introspection targets that can be useful for package maintainers. +# +.PHONY: kbuild-show-install-files kbuild-show-install-dirs +kbuild-show-install-files:: + $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES))) + +kbuild-show-install-dirs:: + $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS))) + +kbuild-show-stage-files:: + $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_FILES))) + +kbuild-show-stage-dirs:: + $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_DIRS))) + + diff --git a/kBuild/footer-pass2-patches.kmk b/kBuild/footer-pass2-patches.kmk new file mode 100644 index 0000000..7c20527 --- /dev/null +++ b/kBuild/footer-pass2-patches.kmk @@ -0,0 +1,55 @@ +# $Id: footer-pass2-patches.kmk 2521 2011-07-26 18:18:19Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Patches. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +## +## Patching. +## +## +#define def_patch_src +# +#endef +# +# +## Deal with one patch target. +#define def_patch +# +#$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(KBUILD_TARGET_ARCH)) $($(target)_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),\ +# $(evalval def_patch_src)) +# +#_PATCHES += +#endef +# +#$(foreach target, $(_ALL_PATCHES), \ +# $(evalval def_patch)) +# + diff --git a/kBuild/footer-passes.kmk b/kBuild/footer-passes.kmk new file mode 100644 index 0000000..935d3f3 --- /dev/null +++ b/kBuild/footer-passes.kmk @@ -0,0 +1,255 @@ +# $Id: footer-passes.kmk 2521 2011-07-26 18:18:19Z bird $ +## @file +# kBuild - Footer - Target lists - Pass 2 - Passes. +# + +# +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version source of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +# +# PASSES (including directory and makefile walking) +# + +# +# First, check whether we need to order the passes explicitly or not. +# This depends on whether we're a leaf makefile or not. A leaf will +# know all its dependencies, while a recursive one relies on the +# order sub-directories and other makefiles are executed it. +# + +## Setup a pass and check for optimizations. +# @param $(PASS) Uppercase pass name. +define def_pass_setup_and_optimize + +# The setup. ## @todo This is looks a bit weird... +ifndef SUBDIRS_$(PASS) + SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) +endif +ifndef SUBDIRS_AFTER_$(PASS) + SUBDIRS_AFTER_$(PASS) := $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(KBUILD_TARGET)) $(SUBDIRS_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) +endif +ifndef MAKEFILES_BEFORE_$(PASS) + MAKEFILES_BEFORE_$(PASS) := $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(KBUILD_TARGET)) $(MAKEFILES_BEFORE.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) +endif +ifndef MAKEFILES_AFTER_$(PASS) + MAKEFILES_AFTER_$(PASS) := $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(KBUILD_TARGET)) $(MAKEFILES_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) +endif + +# The check. +ifeq ($(_KBUILD_STRICT_PASS_ORDER),nonstrict) + ifneq ($(strip \ + $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + $(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ + ),) + _KBUILD_STRICT_PASS_ORDER := strict + endif +endif # _KBUILD_STRICT_PASS_ORDER == nonstrict +endef # def_pass_setup_and_optimize +$(eval-opt-var def_pass_setup_and_optimize) + +## PASS: Setup & optimization. +# Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*), +# and set up the pass specific variables as we go along. +_KBUILD_STRICT_PASS_ORDER := nonstrict +$(foreach PASS, $(PASSES), $(evalval def_pass_setup_and_optimize)) +#$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER)) + +ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict) + if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1" +_KBUILD_STRICT_PASS_ORDER := strict_unsafe + endif +endif + + +## Subdir +# @param $(pass) Lowercase pass name. +# @param $(PASS) Uppercase pass name. +# @param $(subdir) Subdirectory +# @param $(tag) tag to attach to the rule name. +define def_pass_subdir +pass_$(pass)$(tag):: $(dep) + + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass) +endef + +## Submakefile +# @param $(pass) Lowercase pass name. +# @param $(PASS) Uppercase pass name. +# @param $(makefile) Makefile. +# @param $(tag) tag to attach to the rule name. +define def_pass_makefile +pass_$(pass)$(tag):: $(dep) + + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass) +endef + +## Execute a pass, strict order. +# @param $(pass) Lowercase pass name. +# @param $(PASS) Uppercase pass name. +define def_pass_strict +$(eval tag:=_before) +$(eval dep:= ) +$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) +$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile))) + +$(eval tag:=_after) +$(eval dep:=pass_$(pass)_doit) +$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) +$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile))) + +.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this +.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit +pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))) +pass_$(pass)_this: pass_$(pass)_before + + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit +pass_$(pass)_after:: pass_$(pass)_this +pass_$(pass): pass_$(pass)_after +#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))) +endef # def_pass_strict +$(eval-opt-var def_pass_strict) + +## Execute a pass, strict order. +# @param $(pass) Lowercase pass name. +# @param $(PASS) Uppercase pass name. +define def_pass_strict_unsafe +$(eval tag:=_before) +$(eval dep:= ) +$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) +$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile))) + +$(eval tag:=_after) +$(eval dep:=pass_$(pass)_doit) +$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) +$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile))) + +.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit +.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit +pass_$(pass)_doit: pass_$(pass)_before \ + $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))) +pass_$(pass): \ + pass_$(pass)_before \ + pass_$(pass)_doit \ + pass_$(pass)_after +#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))) +endef # def_pass_strict_unsafe +$(eval-opt-var def_pass_strict_unsafe) + +## Execute a pass, non-strict pass ordering. +# @param $(pass) Lowercase pass name. +# @param $(PASS) Uppercase pass name. +define def_pass_nonstrict +.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit +pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var))) +pass_$(pass): pass_$(pass)_doit +endef # def_pass_nonstrict + +## PASS: rules +# Generate the rules for the defined passes. +$(foreach PASS, $(PASSES), \ + $(eval pass := $(PASS_$(PASS)_pass)) \ + $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER)))) + + +## Pass order, strict. +# @param $(pass) Current pass name. +# @param $(prev_pass) The previous pass name. +define def_pass_order_strict +.PHONY: pass_$(pass)_order +.NOTPARALLEL: pass_$(pass)_order +pass_$(pass)_order: $(pass_prev) + %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass))) + + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass) +$(eval pass_prev := pass_$(pass)_order) +endef # def_pass_order_strict +$(eval-opt-var def_pass_order_strict) + +## Pass order, strict unsafe. +# @param $(pass) Current pass name. +# @param $(prev_pass) The previous pass name. +define def_pass_order_strict_unsafe +.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner +.PHONY: pass_$(pass)_order pass_$(pass)_banner +pass_$(pass)_banner: $(pass_prev) + %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass))) +pass_$(pass)_order: $(pass_prev) \ + pass_$(pass)_banner \ + pass_$(pass) +$(eval pass_prev := pass_$(pass)_order) +endef # def_pass_order_strict_unsafe +$(eval-opt-var def_pass_order_strict_unsafe) + +## Pass order, non-strict. +# @param $(pass) Current pass name. +# @param $(prev_pass) The previous pass name. +define def_pass_order_nonstrict +.PHONY: pass_$(pass)_order pass_$(pass)_banner +pass_$(pass)_banner: + %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass))) +pass_$(pass)_order: \ + $(pass_prev) \ + pass_$(pass)_banner \ + pass_$(pass) +$(eval pass_prev := pass_$(pass)_order) +endef # def_pass_order_nonstrict +$(eval-opt-var def_pass_order_nonstrict) + +## PASS: order +# Use dependencies to ensure correct pass order. +pass_prev := +$(foreach PASS,$(DEFAULT_PASSES),\ + $(eval pass := $(PASS_$(PASS)_pass)) \ + $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER)))) + +ifdef KBUILD_PROFILE_SELF + $(evalcall def_profile_self, done passes) +endif + +# Some common pass aliases +ifndef KBUILD_NO_PASS_ALIASES +.PHONY: clean +clean: pass_clean + +.PHONY: nothing +nothing: pass_nothing + +.PHONY: staging +staging: pass_staging + +.PHONY: packing +packing: pass_packing + + ifndef KBUILD_NO_TESTING_PASS_ALIASES +.PHONY: check +check:: pass_testing + +.PHONY: test +test:: pass_testing + endif # KBUILD_NO_TESTING_PASS_ALIASES +endif # KBUILD_NO_PASS_ALIASES + + diff --git a/kBuild/footer.kmk b/kBuild/footer.kmk index f45b599..a632144 100644 --- a/kBuild/footer.kmk +++ b/kBuild/footer.kmk @@ -1,10 +1,10 @@ -# $Id: footer.kmk 2318 2009-03-19 20:35:46Z bird $ +# $Id: footer.kmk 2537 2011-08-02 19:44:43Z bird $ ## @file -# kBuild - File included at top of makefile. +# kBuild - File included at bottom of a makefile. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -120,14 +120,23 @@ _DLLS := _PROGRAMS := _SYSMODS := _MISCBINS := +_STAGE_FILES := +_STAGE_DIRS := _INSTALLS := _INSTALLS_FILES := _INSTALLS_DIRS := +_DEBUG_STAGE_FILES := +_DEBUG_STAGE_DIRS := +_DEBUG_INSTALL_FILES := +_DEBUG_INSTALL_DIRS := _OTHERS := _PACKING := _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS) _IMPORT_LIBS := +# Implicit targets added while processing other targets (usually by units). +_ALL_INSTALLS_IMPLICIT := + # misc pass_prev := @@ -142,3591 +151,174 @@ pass_prev := # @param $2 tooltype. # @param bld_trg build target. # @param bld_trg_arch build target architecture. +# @param bld_type build target type. +if 0 +_TARGET_TOOL = $(strip $(firstword \ + $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \ + $($(1)_$(2)TOOL.$(bld_trg)) \ + $($(1)_$(2)TOOL) \ + $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \ + $($(1)_TOOL.$(bld_trg)) \ + $($(1)_TOOL) \ + $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \ + $($(2)TOOL.$(bld_trg)) \ + $($(2)TOOL) \ + $(TOOL.$(bld_trg).$(bld_trg_arch)) \ + $(TOOL.$(bld_trg)) \ + $(TOOL) \ +)) +else _TARGET_TOOL = $(strip $(firstword \ + $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \ + $($(1)_$(2)TOOL.$(bld_trg).$(bld_type)) \ + $($(1)_$(2)TOOL.$(bld_trg_arch)) \ $($(1)_$(2)TOOL.$(bld_trg)) \ + $($(1)_$(2)TOOL.$(bld_type)) \ $($(1)_$(2)TOOL) \ + $($(1)_TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \ + $($(1)_TOOL.$(bld_trg).$(bld_type)) \ + $($(1)_TOOL.$(bld_trg_arch)) \ $($(1)_TOOL.$(bld_trg)) \ + $($(1)_TOOL.$(bld_type)) \ $($(1)_TOOL) \ + $($(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \ + $($(2)TOOL.$(bld_trg).$(bld_type)) \ + $($(2)TOOL.$(bld_trg_arch)) \ $($(2)TOOL.$(bld_trg)) \ + $($(2)TOOL.$(bld_type)) \ $($(2)TOOL) \ + $(TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ $(TOOL.$(bld_trg).$(bld_trg_arch)) \ + $(TOOL.$(bld_trg).$(bld_type)) \ + $(TOOL.$(bld_trg_arch)) \ $(TOOL.$(bld_trg)) \ + $(TOOL.$(bld_type)) \ $(TOOL) \ - )) +)) +endif ## Figure out the actual name of an installed file. # @param $1 The file to install. # @param $2 The target name. # @param $3 The _INST value (can be empty). -# @param $4 The default directory to use when $3 is empty. -_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/)) - - - -## Converts a variable from simple to recursive flavor. -# This is used by def_inherit_template_one_accumulate_l and def_inherit_template_one_accumulate_r. -# @param $1 The variable name. -define def_simple_2_recursive -$1_DEFERRED := $$($1) -$1 = $$($1_DEFERRED) -endef - - -## Inherit one keyword in a non-accumulative manner. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -define def_inherit_one_keyword -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key)) - endif -endif -endef - - -# EXPAND_BY = overriding - -## Inherit one keyword in a non-accumulative manner. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -define def_inherit_one_keyword_overriding_now_l -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) - endif -endif -endef - -## @copydoc def_inherit_one_overriding_now_l -define def_inherit_one_keyword_overriding_now_r -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) - endif -endif -endef - -## Inherit one keyword in a non-accumulative manner, deferred expansion. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -# @remark This define relies on double evaluation -define def_inherit_one_keyword_overriding_deferred -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) - endif -endif -endef - -## @copydoc def_inherit_one_overriding_deferred -define def_inherit_one_keyword_overriding_deferred_l -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) - endif -endif -endef - -## @copydoc def_inherit_one_overriding_deferred -define def_inherit_one_keyword_overriding_deferred_r -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) - endif -endif -endef - - -# EXPAND_BY = prepending - -## Inherit one keyword in a prepending manner. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -define def_inherit_one_keyword_prepending_now_l -ifdef $(trg)_$(prop).$(src_key) - $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key)) -endif -endef - -## @copydoc def_inherit_one_prepending_now_l -define def_inherit_one_keyword_prepending_now_r -ifdef $(trg)_$(prop).$(src_key) - $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key)) -endif -endef - -## Inherit one keyword in a non-accumulative manner, deferred expansion. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -# @remark This define relies on double evaluation -define def_inherit_one_keyword_prepending_deferred -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) - endif -endif -endef - -## Inherit one keyword in a prepending manner, deferred expansion. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -define def_inherit_one_keyword_prepending_deferred_l -ifdef $(trg)_$(prop).$(src_key) - ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) - endif - $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key)) -endif -endef - -## @copydoc def_inherit_one_prepending_deferred_l -define def_inherit_one_keyword_prepending_deferred_r -ifdef $(trg)_$(prop).$(src_key) - ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) - endif - $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key)) -endif -endef - - -# EXPAND_BY = appending - -## Inherit one keyword in an appending manner. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -define def_inherit_one_keyword_appending_now_l -ifdef $(trg)_$(prop).$(src_key) - $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key)) -endif -endef - -## @copydoc def_inherit_one_appending_now_l -define def_inherit_one_keyword_appending_now_r -ifdef $(trg)_$(prop).$(src_key) - $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key)) -endif -endef - -## Inherit one keyword in a non-accumulative manner, deferred expansion. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -# @remark This define relies on double evaluation -define def_inherit_one_keyword_appending_deferred -ifdef $(trg)_$(prop).$(src_key) - ifndef $(trg)_$(prop).$(trg_key) - $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key)) - endif -endif -endef - -## Inherit one keyword in an appending manner, deferred expansion. -# @param $(trg) Target object. -# @param $(prop) The property. -# @param $(src_key) Source keyword. -# @param $(trg_key) Target keyword. -define def_inherit_one_keyword_appending_deferred_l -ifdef $(trg)_$(prop).$(src_key) - ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) - endif - $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key)) -endif -endef - -## @copydoc def_inherit_one_appending_deferred_l -define def_inherit_one_keyword_appending_deferred_r -ifdef $(trg)_$(prop).$(src_key) - ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key)) - endif - $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key)) -endif -endef - - -## Worker for def_inherit that deals with one keyword that makes -# use of inheritance. -# @param prefix_keyword key_prefix:keyword. The cool join/split game as usual. -# @param trg Object to consider for inheriting. -# @param properties List of the properties with straight expansion. -# @param properties_now_l List of the properties with immediate expansion, accumulating on the left side. -# @param properties_now_r List of the properties with immediate expansion, accumulating on the right side. -# @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative . -# @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side. -# @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side. -define def_inherit_keyword -local prefix := $(word 1,$(subst :, ,$(prefix_keyword))) -local trg_key := $(word 2,$(subst :, ,$(prefix_keyword))) -local src_key := $($(prefix)_$(trg_key)_EXTENDS) -local by := $($(prefix)_$(trg_key)_EXTENDS_BY) - -# Inherit the properties. -$(foreach prop, $(properties), $(eval $(def_inherit_one_keyword))) -$(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l))) -$(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r))) -$(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred))) -$(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l))) -$(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r))) - -endef # def_inherit_keyword - - -## Inherit one template property in a non-accumulative manner. -# @param $(prop) Property name -# @param $(src) Source (parent) object. -# @param $(trg) Target (child) object. -define def_inherit_one -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) = $($(src)_$(prop)) - endif -endif -endef - - -# EXPAND_BY = overriding - -## Inherit one template property in a non-accumulative manner. -# @param $(prop) Property name -# @param $(src) Source (parent) object. -# @param $(trg) Target (child) object. -define def_inherit_one_overriding_now_l -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) := $($(src)_$(prop)) - endif -endif -endef - -## @copydoc def_inherit_one_overriding_now_l -define def_inherit_one_overriding_now_r -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) := $($(src)_$(prop)) - endif -endif -endef - -## Inherit one template property in a non-accumulative manner, deferred expansion. -# @param $(prop) Property name -# @param $(src) Source -# @param $(trg) Target -# @remark This define relies on double evaluation -define def_inherit_one_overriding_deferred -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) = $$($(src)_$(prop)) - endif -endif -endef - -## @copydoc def_inherit_one_overriding_deferred -define def_inherit_one_overriding_deferred_l -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) = $$($(src)_$(prop)) - endif -endif -endef - -## @copydoc def_inherit_one_overriding_deferred -define def_inherit_one_overriding_deferred_r -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) = $$($(src)_$(prop)) - endif -endif -endef - - -# EXPAND_BY = prepending - -## Inherit one template property in a prepending manner. -# @param $(prop) Property name -# @param $(src) Source (parent) object. -# @param $(trg) Target (child) object. -define def_inherit_one_prepending_now_l -ifdef $(src)_$(prop) - $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop)) -endif -endef - -## @copydoc def_inherit_one_prepending_now_l -define def_inherit_one_prepending_now_r -ifdef $(src)_$(prop) - $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop)) -endif -endef - -## Inherit one template property in a non-accumulative manner, deferred expansion. -# @param $(prop) Property name -# @param $(src) Source -# @param $(trg) Target -# @remark This define relies on double evaluation -define def_inherit_one_prepending_deferred -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) = $$($(src)_$(prop)) - endif -endif -endef - -## Inherit one template property in a prepending manner, deferred expansion. -# @param $(prop) Property name -# @param $(src) Source (parent) object. -# @param $(trg) Target (child) object. -define def_inherit_one_prepending_deferred_l -ifdef $(src)_$(prop) - ifeq ($$(flavor $(trg)_$(prop)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) - endif - $(trg)_$(prop) <= $$($(src)_$(prop)) -endif -endef - -## @copydoc def_inherit_one_prepending_deferred_l -define def_inherit_one_prepending_deferred_r -ifdef $(src)_$(prop) - ifeq ($$(flavor $(trg)_$(prop)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) - endif - $(trg)_$(prop) += $$($(src)_$(prop)) -endif -endef - - -# EXPAND_BY = appending - -## Inherit one template property in an appending manner. -# @param $(prop) Property name -# @param $(src) Source (parent) object. -# @param $(trg) Target (child) object. -define def_inherit_one_appending_now_l -ifdef $(src)_$(prop) - $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop)) -endif -endef - -## @copydoc def_inherit_one_appending_now_l -define def_inherit_one_appending_now_r -ifdef $(src)_$(prop) - $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop)) -endif -endef - -## Inherit one template property in a non-accumulative manner, deferred expansion. -# @param $(prop) Property name -# @param $(src) Source -# @param $(trg) Target -# @remark This define relies on double evaluation -define def_inherit_one_appending_deferred -ifdef $(src)_$(prop) - ifndef $(trg)_$(prop) - $(trg)_$(prop) = $$($(src)_$(prop)) - endif -endif -endef - -## Inherit one template property in an appending manner, deferred expansion. -# @param $(prop) Property name -# @param $(src) Source (parent) object. -# @param $(trg) Target (child) object. -define def_inherit_one_appending_deferred_l -ifdef $(src)_$(prop) - ifeq ($$(flavor $(trg)_$(prop)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) - endif - $(trg)_$(prop) += $$($(src)_$(prop)) -endif -endef - -## @copydoc def_inherit_one_appending_deferred_l -define def_inherit_one_appending_deferred_r -ifdef $(src)_$(prop) - ifeq ($$(flavor $(trg)_$(prop)),simple) - $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop)) - endif - $(trg)_$(prop) <= $$($(src)_$(prop)) -endif -endef - - -## combines the specified properties $(1) with the $(_KEYWORDS) list. -_INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1))) - - -## Generic inheritance for use with targets templates and tools. -# @param trg Object to consider for inheriting. -# @param src_prefix What to prefix the value found in EXTENDS with to get the object. -# @param load_function Load function for stuff that needs -# @param properties List of the properties with straight expansion. -# @param properties_now_l List of the properties with immediate expansion, accumulating on the left side. -# @param properties_now_r List of the properties with immediate expansion, accumulating on the right side. -# @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative . -# @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side. -# @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side. -define def_inherit - -# Load it - loading is a mess, fix. -ifneq ($(load_function),) - local loading := $(patsubst $(src_prefix)%,%,$(trg)) - $(evalvalctx $(load_function)) -endif - -local src := $(strip $($(trg)_EXTENDS)) -ifneq ($(src),) - ifndef $(trg)_EXTENDS_STATUS_ - $(trg)_EXTENDS_STATUS_ := 0 - - # Load the source. - ifneq ($(load_function),) - local loading := $(src) - $(evalvalctx $(load_function)) - endif - - # less typing. - local src := $(src_prefix)$(src) - - # Recursivly process the parent (src) if it's inherting from somebody too. - ifdef $(src)_EXTENDS - ifneq ($($(src)_EXTENDS_STATUS_),42) - # 'foreach' will create 'trg' in a new variable context hiding - # out current variable. 'src' OTOH will be overwritten. - $(foreach trg, $(src), $(evalval def_inherit)) - local src := $(src_prefix)$(strip $($(trg)_EXTENDS)) - endif - endif - - # Get & check EXTENDS_BY. - local by = $(strip $($(trg)_EXTENDS_BY)) - ifeq ($(by),) - local by = overriding - else ifn1of ($(by), overriding appending prepending) - $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!) - endif - - # Inherit the properties. - $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one))) - $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l))) - $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r))) - $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred))) - $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l))) - $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r))) - - # Mark the target as done. - $(trg)_EXTENDS_STATUS_ := 42 - else - # Check for inheritance loops. - ifneq ($($(trg)_EXTENDS_STATUS_),42) - $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_)) - endif - endif -endif - -# Keyword inheritance. -$(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword)) - -endef # def_inherit - - -# -# Load global units before doing any inheriting so they can add new properties. -# -# This only applies to the guys listed in the global USES since there is -# no reliable way to deal with things on a target level without first -# applying templates. So, to avoid having USES mess up all targets, -# we'll make the global and per-target USES property work differently: -# The global USES does not apply to targets, just globally. -# - -## Unit load function. -# @param loading The unit name -define def_unit_load_function -ifndef UNIT_$(loading) - UNIT_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) - ifeq ($(UNIT_$(loading)_KMK_FILE),) - $(error kBuild: Cannot find include file for the unit '$(loading)'! Searched: $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS)) - endif - include $(UNIT_$(loading)_KMK_FILE) - ifndef UNIT_$(loading) - $(warning kBuild: UNIT_$(loading) was not defined by $(UNIT_$(loading)_KMK_FILE)!) - endif -endif -endef # def_unit_load_function - -$(foreach loading, \ - $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(USES.$(KBUILD_TARGET_CPU)) \ - $(USES.$(KBUILD_TARGET_ARCH)) \ - $(USES.$(KBUILD_TARGET)) \ - $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ - $(USES.$(KBUILD_HOST_CPU)) \ - $(USES.$(KBUILD_HOST_ARCH)) \ - $(USES.$(KBUILD_TARGET)) \ - $(USES.$(KBUILD_TYPE)) \ - $(USES),$(evalval def_unit_load_function)) - - -# -# Determin all the templates that is being used and make -# sure they are present before we try collect keywords. -# -_TEMPLATES := $(TEMPLATE) -define def_templates -ifdef $(target)_TEMPLATE - ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))") - $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them) - endif - _TEMPLATES += $($(target)_TEMPLATE) -endif -endef # def_templates -$(foreach target, $(_ALL_TARGETS), $(eval $(def_templates))) -_TEMPLATES := $(sort $(_TEMPLATES)) - -## Template load function. -# @param loading The template name. This is prefixed. -define def_templates_load_function -ifndef TEMPLATE_$(loading) - TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) - ifeq ($(TEMPLATE_$(loading)_KMK_FILE),) - $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS)) - endif - include $(TEMPLATE_$(loading)_KMK_FILE) - ifndef TEMPLATE_$(loading) - $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!) - endif -endif -endef # def_templates_load_function -$(foreach loading, $(_TEMPLATES), $(evalval def_templates_load_function)) - - -# -# Determin the keywords required for correct inherting and setup keyword inheritance. -# -# This means walking all the lists of immediate template and targets and -# pick up all the BLD_T* keywords. Since templates that are referenced -# indirectly in the inheritance hierarchy, the result from this exercise -# might not be 100% accurate... :-/ -# -_BLD_TYPES := $(KBUILD_TYPE) -_BLD_TARGETS := $(KBUILD_TARGET) $(KBUILD_HOSTS) -_BLD_ARCHES := $(KBUILD_TARGET_ARCH) $(KBUILD_HOST_ARCH) -_BLD_CPUS := $(KBUILD_TARGET_CPU) $(KBUILD_HOST_CPU) - -define def_collect_bld_xyz -ifdef $(src)_BLD_TYPE - ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES)) - $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!) - endif - _BLD_TYPES += $($(src)_BLD_TYPE) -endif -ifdef $(src)_BLD_TRG - ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES)) - $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!) - endif - _BLD_TARGETS += $($(src)_BLD_TRG) -endif -ifdef $(src)_BLD_TRG_ARCH - ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES)) - $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!) - endif - _BLD_ARCHES += $($(src)_BLD_TRG_ARCH) -endif -ifdef $(src)_BLD_TRG_CPU - if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES)) - $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!) - endif - _BLD_CPUS += $($(src)_BLD_TRG_CPU) -endif -endef # def_collect_bld_xyz -$(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \ - ,$(evalval def_collect_bld_xyz)) - -# Drop duplicate values. -# WARNING! These list might not include keywords only involved in inheritance. -_BLD_TYPES := $(sort $(_BLD_TYPES)) -_BLD_TARGETS := $(sort $(_BLD_TARGETS)) -_BLD_ARCHES := $(sort $(_BLD_ARCHES)) -_BLD_CPUS := $(sort $(_BLD_CPUS)) - -## Look for keywords which extends others and order them. -# @param keyword -# @param prefix -# @param valid -define def_keyword_ordering -# Check for EXTENDS, fix and validate it if found. -local src := $(strip $($(prefix)_$(keyword)_EXTENDS)) -ifneq ($(src),) - ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_ - ifn1of ($(src), $(valid)) - $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid))) - endif - - # Recursivly process the parent (src). - ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42) - $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0 - # 'foreach' will create 'keyword' in a new variable context hiding - # out current variable. 'src' OTOH will be overwritten. - $(foreach keyword, $(src), $(evalval def_keyword_ordering)) - local src := $(strip $($(prefix)_$(keyword)_EXTENDS)) - endif - - # Check and strip EXTENDS_BY. - local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY)) - ifeq ($(by),) - local by = overriding - else ifn1of ($(by), overriding appending prepending) - $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!) - endif - - # Update the attributes with stripped - $(prefix)_$(keyword)_EXTENDS_BY := $(by) - $(prefix)_$(keyword)_EXTENDS := $(src) - - # Add it to the list and mark it as done. - _KEYWORDS_EXTENDS += $(keyword) - _KEYWORDS_PREFIX += $(prefix) - $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42 - else - # Check for inheritance loops. - ifneq ($($(trg)_EXTENDS_STATUS_),42) - $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_)) - endif - endif -else - # Add it to the ordered list and mark it as done. - _KEYWORDS_ORDERED += $(keyword) - $(prefix)_$(src)_EXTENDS_STATUS_ := 42 -endif -endef # def_keyword_ordering -$(eval-opt-var def_keyword_ordering) - -# Look for keywords which extends others and their parents, and from this -# construct two lists. -_KEYWORDS_ORDERED := -_KEYWORDS_EXTENDS := -_KEYWORDS_PREFIX := - -prefix := BLD_TYPE -valid := $(KBUILD_BLD_TYPES) -$(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering)) - -prefix := BLD_TRG -valid := $(KBUILD_OSES) -$(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering)) - -prefix := BLD_ARCH -valid := $(KBUILD_ARCHES) -$(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering)) - -prefix := BLD_CPU -valid := $(KBUILD_CPUS) -$(foreach keyword, $(_BLD_CPUS) , $(evalval def_keyword_ordering)) - -## @todo Inherit bld_trg.bld_arch for too? - -# Construct all the possible keywords. -_KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \ - $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES))) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done keywords) -endif - - -# -# Target inheritance. -# -# This has to be done on a per target list basis as to avoid adding -# incorrect properties that will wast memory, time, and may confuse -# later strictness checks. This also has to be done *before* templates -# are applied to the targets. Since we're doing that part rather -# early on, the target inheritance feature is a bit restricted at -# the moment. However, this will be addressed in a little(?) while. -# - -src_prefix := -load_function := -properties_deferred_l := -properties_deferred_r := - -# Fetches. -properties := $(PROPS_FETCHES_SINGLE) -properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L) -properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R) -properties_deferred := $(PROPS_FETCHES_DEFERRED) -$(foreach trg, $(_ALL_FETCHES),$(evalval def_inherit)) +# @param $4 The installation root directory. +_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(4)/$(3),$(4)/)) -## Patches. - not implemented yet. -#properties := $(PROPS_PATCHES_SINGLE) -#properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L) -#properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R) -#properties_deferred := $(PROPS_PATCHES_DEFERRED) -#$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit)) - -# Programs and build programs. -properties := $(PROPS_PROGRAMS_SINGLE) -properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L) -properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R) -properties_deferred := $(PROPS_PROGRAMS_DEFERRED) -$(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit)) - -# Libraries and import libraries. -properties := $(PROPS_LIBRARIES_SINGLE) -properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L) -properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R) -properties_deferred := $(PROPS_LIBRARIES_DEFERRED) -if1of ($(KBUILD_TARGET), nt os2 win) - $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit)) -else - $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit)) -endif - -# DLLs. -properties := $(PROPS_DLLS_SINGLE) -properties_now_l := $(PROPS_DLLS_ACCUMULATE_L) -properties_now_r := $(PROPS_DLLS_ACCUMULATE_R) -properties_deferred := $(PROPS_DLLS_DEFERRED) -if1of ($(KBUILD_TARGET), nt os2 win) - $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit)) -else - $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit)) -endif - -# System modules. -properties := $(PROPS_SYSMODS_SINGLE) -properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L) -properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R) -properties_deferred := $(PROPS_SYSMODS_DEFERRED) -$(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit)) - -# Misc binaries. -properties := $(PROPS_MISCBINS_SINGLE) -properties_now_l := $(PROPS_MISCBINS_ACCUMULATE_L) -properties_now_r := $(PROPS_MISCBINS_ACCUMULATE_R) -properties_deferred := $(PROPS_MISCBINS_DEFERRED) -$(foreach trg, $(_ALL_MISCBINS),$(evalval def_inherit)) - -# Installs. -properties := $(PROPS_INSTALLS_SINGLE) -properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L) -properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R) -properties_deferred := $(PROPS_INSTALLS_DEFERRED) -$(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done target inheritance) -endif - - -# -# Template Inheritance. -# -# This is much the same as with target inheritance, except we cannot -# restrict the properties involved since we haven't got a clue which -# target platforms/archs are using them. But, we can drop the instance -# expansion we're doing for targets since there won't be any more -# changes to either the source nor the target templates beyond this -# exercise. -# - -src_prefix := TEMPLATE_ -load_function := def_templates_load_function -properties := -properties_now_l := -properties_now_r := -properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) -properties_deferred_l := $(PROPS_ACCUMULATE_L) -properties_deferred_r := $(PROPS_ACCUMULATE_R) -$(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit)) - -# done inheriting. -src_prefix := -load_function := -properties := -properties_now_l := -properties_now_r := -properties_deferred := -properties_deferred_l := -properties_deferred_r := - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done template inheritance) -endif - - - - -# -# Template/Target Expansion. -# -# Extend all targets with the values from the template. Doing this up front -# allows more generic code and less mess down in the pass 2 target handling. -# However it does eat a good deal of memory. -# - -if1of ($(KMK_FEATURES), kb-exp-tmpl) - $(kb-exp-tmpl 1,$(_ALL_TARGET_TARGETS),$(KBUILD_TARGET),$(KBUILD_TARGET_ARCH),$(KBUILD_TARGET_CPU),$(KBUILD_TYPE)) - $(kb-exp-tmpl 1,$(_ALL_HOST_TARGETS),$(KBUILD_HOST),$(KBUILD_HOST_ARCH),$(KBUILD_HOST_CPU),$(KBUILD_TYPE)) - -else # !kb-exp-tmpl - -## Inherit one template property in a non-accumulative manner. -# @param $(prop) Property name -# @param $(target) Target name -# @todo fix the precedence order for some properties. -define def_inherit_template_one -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) -ifndef $(target)_$(prop) -$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg) -ifndef $(target)_$(prop).$(bld_trg) -$(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch) -ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch) -$(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch) -ifndef $(target)_$(prop).$(bld_trg_arch) -$(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu) -ifndef $(target)_$(prop).$(bld_trg_cpu) -$(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) -endif -endif -endef - -## Inherit one template property in a non-accumulative manner, deferred expansion. -# @param 1: $(prop) Property name -# @param 2: $(target) Target name -# @todo fix the precedence order for some properties. -# @remark this define relies on double evaluation -define def_inherit_template_one_deferred -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) -ifndef $(target)_$(prop) -$(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg) -ifndef $(target)_$(prop).$(bld_trg) -$(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch) -ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch) -$(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch) -ifndef $(target)_$(prop).$(bld_trg_arch) -$(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) -endif -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu) -ifndef $(target)_$(prop).$(bld_trg_cpu) -$(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) -endif -endif -endef - -## Inherit one acculumlative template property where the 'most significant' items are at the left end. -# @param $(prop) Property name -# @param $(target) Target name -define def_inherit_template_one_accumulate_l -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) - ifeq ($$(flavor $(target)_$(prop)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop)) - endif -$(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(KBUILD_TYPE) - ifeq ($$(flavor $(target)_$(prop).$(KBUILD_TYPE)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(KBUILD_TYPE)) - endif -$(target)_$(prop).$(KBUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(KBUILD_TYPE)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg)) - endif -$(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg).$(bld_trg_arch)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg).$(bld_trg_arch)) - endif -$(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg_cpu)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg_cpu)) - endif -$(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg_arch)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg_arch)) - endif -$(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) -endif -endef - -## Inherit one acculumlative template property where the 'most significant' items are at the right end. -# @param $(prop) Property name -# @param $(target) Target name -define def_inherit_template_one_accumulate_r -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) - ifeq ($$(flavor $(target)_$(prop)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop)) - endif -$(target)_$(prop) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(KBUILD_TYPE) - ifeq ($$(flavor $(target)_$(prop).$(KBUILD_TYPE)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(KBUILD_TYPE)) - endif -$(target)_$(prop).$(KBUILD_TYPE) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(KBUILD_TYPE)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg)) - endif -$(target)_$(prop).$(bld_trg) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg).$(bld_trg_arch)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg).$(bld_trg_arch)) - endif -$(target)_$(prop).$(bld_trg).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg_cpu)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg_cpu)) - endif -$(target)_$(prop).$(bld_trg_cpu) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) -endif -ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch) - ifeq ($$(flavor $(target)_$(prop).$(bld_trg_arch)),simple) - $$(evalcall2 def_simple_2_recursive,$(target)_$(prop).$(bld_trg_arch)) - endif -$(target)_$(prop).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) -endif -endef - - -## Inherit template properties for on target. -# @param $(target) Target name. -define def_inherit_template -# sanity check. -ifdef _$(target)_ALREADY_PROCESSED - $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s)) -endif -_$(target)_ALREADY_PROCESSED := 1 - -# Inherit any default template. -ifdef TEMPLATE -ifeq ($($(target)_TEMPLATE),) -$(eval $(target)_TEMPLATE:=$(TEMPLATE)) -endif -endif -# Expand the template if specified. -ifneq ($($(target)_TEMPLATE),) -$(foreach prop,$(PROPS_SINGLE),$(evalval def_inherit_template_one)) -$(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value! -$(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine without value -$(foreach prop,$(PROPS_ACCUMULATE_R),$(eval $(def_inherit_template_one_accumulate_r))) # use <= (kmk addition) -endif -endef -$(eval-opt-var def_inherit_template) - -# Inherit template properties -bld_trg := $(KBUILD_TARGET) -bld_trg_arch := $(KBUILD_TARGET_ARCH) -bld_trg_cpu := $(KBUILD_TARGET_CPU) -$(foreach target, $(_ALL_TARGET_TARGETS),$(evalval def_inherit_template)) - -bld_trg := $(KBUILD_HOST) -bld_trg_arch := $(KBUILD_HOST_ARCH) -bld_trg_cpu := $(KBUILD_HOST_CPU) -$(foreach target, $(_ALL_HOST_TARGETS),$(evalval def_inherit_template)) - -endif # !kb-exp-tmpl -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done template/target expansion) -endif - - -# -# Include tools, sdks and units. -# -# The first part of this exercise is to figure out which TOOLS and SDKS -# that should be included. -# -_TOOLS := $(TOOL.$(KBUILD_TARGET)) $(TOOL.$(KBUILD_TARGET_ARCH)) $(TOOL.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(TOOL.$(KBUILD_HOST)) $(TOOL.$(KBUILD_HOST_ARCH)) $(TOOL.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ - $(TOOL) -_SDKS := $(SDKS.$(KBUILD_TARGET)) $(SDKS.$(KBUILD_TARGET_ARCH)) $(SDKS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(SDKS.$(KBUILD_HOST)) $(SDKS.$(KBUILD_HOST_ARCH)) $(SDKS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ - $(SDKS.$(KBUILD_TYPE)) \ - $(SDKS) -_USES := $(USES.$(KBUILD_TARGET)) $(USES.$(KBUILD_TARGET_ARCH)) $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(USES.$(KBUILD_HOST)) $(USES.$(KBUILD_HOST_ARCH)) $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \ - $(USES.$(KBUILD_TYPE)) \ - $(USES) -define def_tools_sdks_target_source -$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \ - $($(source)_$(prop).$(_bld_trg)) \ - $($(target)_$(source)_$(prop).$(_bld_trg)) \ - $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \ - $($(source)_$(prop).$(_bld_trg_arch)) \ - $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \ - $($(source)_$(prop)) \ - $($(target)_$(source)_$(prop)))) -$(eval _SDKS += \ - $($(source)_SDKS.$(_bld_trg)) \ - $($(target)_$(source)_SDKS.$(_bld_trg)) \ - $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \ - $($(source)_SDKS.$(_bld_trg_arch)) \ - $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \ - $($(source)_SDKS.$(KBUILD_TYPE)) \ - $($(target)_$(source)_SDKS.$(KBUILD_TYPE)) \ - $($(source)_SDKS) \ - $($(target)_$(source)_SDKS)) -$(eval _USES += \ - $($(source)_USES.$(_bld_trg)) \ - $($(target)_$(source)_USES.$(_bld_trg)) \ - $($(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_$(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \ - $($(source)_USES.$(_bld_trg_arch)) \ - $($(target)_$(source)_USES.$(_bld_trg_arch)) \ - $($(source)_USES.$(KBUILD_TYPE)) \ - $($(target)_$(source)_USES.$(KBUILD_TYPE)) \ - $($(source)_USES) \ - $($(target)_$(source)_USES)) -endef # def_tools_sdks_target_source -$(eval-opt-var def_tools_sdks_target_source) - -define def_tools_sdks_target -local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg)) -local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch)) -local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu)) - -$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \ - $($(target)_$(prop).$(_bld_trg)) \ - $($(target)_$(prop).$(_bld_trg_arch)) \ - $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_$(prop)))) -$(eval _SDKS += \ - $($(target)_SDKS.$(_bld_trg)) \ - $($(target)_SDKS.$(_bld_trg_arch)) \ - $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_SDKS)) -$(eval _USES += \ - $($(target)_USES.$(_bld_trg)) \ - $($(target)_USES.$(_bld_trg_arch)) \ - $($(target)_USES.$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_USES)) -$(foreach source, \ - $($(target)_SOURCES.$(_bld_trg)) \ - $($(target)_SOURCES.$(_bld_trg_arch)) \ - $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_SOURCES.$(_bld_trg_cpu)) \ - $($(target)_SOURCES.$(_bld_type)) \ - $($(target)_SOURCES) \ - , $(evalval def_tools_sdks_target_source)) -endef # def_tools_sdks_target -$(eval-opt-var def_tools_sdks_target) - -define def_tools_srcname_target -local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg)) -local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch)) -local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu)) - -$(foreach source, $(notdir\ - $($(target)_SOURCES.$(_bld_trg)) \ - $($(target)_SOURCES.$(_bld_trg_arch)) \ - $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \ - $($(target)_SOURCES.$(_bld_trg_cpu)) \ - $($(target)_SOURCES.$(_bld_type)) \ - $($(target)_SOURCES) \ - ), $(evalval def_tools_sdks_target_source)) -endef # def_tools_srcname_target -$(eval-opt-var def_tools_srcname_target) - -bld_trg := $(KBUILD_TARGET) -bld_trg_arch := $(KBUILD_TARGET_ARCH) -bld_trg_cpu := $(KBUILD_TARGET_CPU) -$(foreach target, $(_ALL_TARGET_TARGETS), $(evalval def_tools_sdks_target)) -$(foreach target, $(_ALL_SRCNAME_TARGETS), $(evalval def_tools_srcname_target)) - -bld_trg := $(KBUILD_HOST) -bld_trg_arch := $(KBUILD_HOST_ARCH) -bld_trg_cpu := $(KBUILD_HOST_CPU) -$(foreach target, $(_ALL_HOST_TARGETS), $(evalval def_tools_sdks_target)) - -_TOOLS := $(sort $(_TOOLS)) -_SDKS := $(sort $(_SDKS)) - -## Tool load function. -# @param loading The tool name -define def_tools_load_function -ifndef TOOL_$(loading) - TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) - ifeq ($(TOOL_$(loading)_KMK_FILE),) - $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS)) - endif - include $(TOOL_$(loading)_KMK_FILE) - ifndef TOOL_$(loading) - $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!) - endif -endif -endef # def_tools_include - -## SDK load function. -# @param loading The tool name -define def_sdk_load_function -ifndef SDK_$(loading) - SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk))) - ifeq ($(SDK_$(loading)_KMK_FILE),) - $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS)) - endif - include $(SDK_$(loading)_KMK_FILE) - ifndef SDK_$(loading) - $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!) - endif -endif -endef # def_sdk_load_function - - -properties := -properties_now_l := -properties_now_r := -properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) -properties_deferred_l := $(PROPS_ACCUMULATE_L) -properties_deferred_r := $(PROPS_ACCUMULATE_R) - -src_prefix := SDK_ -load_function := def_sdk_load_function -$(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit)) - -properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_TOOLS_ONLY) -src_prefix := TOOL_ -load_function := def_tools_load_function -$(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit)) - -# done inheriting. -src_prefix := -load_function := -properties := -properties_now_l := -properties_now_r := -properties_deferred := -properties_deferred_l := -properties_deferred_r := - -# No inheriting for the uses, they're just global 'code'. -$(foreach loading, $(_USES), $(evalval def_unit_load_function)) - - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done tools + sdks + units) -endif - - - -# -# -# Target lists - Pass 1 -# -# This pass is for defining variables that might be referenced in -# properties of other targets. -# -# - -# Don't do anything for fetch targets (yet). ## -# Link prolog for Pass 1. -# -# @param $(target) Normalized target name. -# @param $(EXT) EXE,DLL,SYS,LIB. -# @param $(EXTPRE) HOST or nothing. -# @param $(definst) The default _INST value. -# @param $(tool_prefix) LD or AR. -# @param $(bld_trg_base_var) TARGET or PLATFORM. -define def_pass1_link_common - -local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var))) -local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH)) -local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU)) - -local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix)) -local name := $(firstword\ - $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg))\ - $($(target)_NAME.$(bld_type))\ - $($(target)_NAME)\ - $(target)) -local outbase := $(call TARGET_BASE,$(name),$(target)) -$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase))) -PATH_$(target) := $($(target)_0_OUTDIR) -## @todo fix the fun at the last line (AR != LIB => mess). -local suff := $(firstword \ - $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ - $($(target)_$(EXT)SUFF.$(bld_trg))\ - $($(target)_$(EXT)SUFF)\ - $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ - $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\ - $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\ - $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) ) -local out := $(outbase)$(suff) - -# TARGET_* -TARGET_$(target) := $(out) -$(target)_1_TARGET := $(out) - -# INSTARGET_* -ifeq ($(strip $($(target)_NOINST) $($(target)_NOINST.$(bld_trg)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) $($(target)_NOINST.$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg_cpu)) $($(target)_NOINST.$(bld_trg_type))),) - ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))) - else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch))) - else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type))) - else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch))) - else ifneq ($(strip $($(target)_INST.$(bld_trg))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg))) - else ifneq ($(strip $($(target)_INST.$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type))) - else ifneq ($(strip $($(target)_INST)),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST)) - else - local inst := $(definst)/ - endif - INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst)) - -else # NOINST - INSTARGET_$(target) := -endif # NOINST - -endef -$(eval-opt-var def_pass1_link_common) - - -# -# BLDPROGS (Pass 1) -# -define def_pass1_bldprog -# set NOINST if not forced installation before doing the usual stuff. -ifndef $(target)_INST -$(target)_NOINST := 1 -endif -$(evalval def_pass1_link_common) -endef - -EXT := EXE -EXTPRE := HOST -definst := $(PATH_BIN) -tool_prefix := LD -bld_trg_base_var := PLATFORM -$(foreach target, $(_ALL_BLDPROGS), \ - $(evalval def_pass1_bldprog)) - - -# -# LIBRARIES (Pass 1) -# -EXT := LIB -EXTPRE := -definst := $(PATH_LIB) -tool_prefix := AR -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_LIBRARIES), \ - $(evalval def_pass1_link_common)) - - -# -# DLLS (Pass 1) -# -EXT := DLL -EXTPRE := -definst := $(PATH_DLL) -tool_prefix := LD -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_DLLS), \ - $(evalval def_pass1_link_common)) - - -# -# IMPORT LIBRARIES (Pass 1) -# -# - On OS/2 and windows these are libraries. -# - On other platforms they are fake DLLs. -# -if1of ($(KBUILD_TARGET), nt os2 win win64 win32) - EXT := LIB - EXTPRE := - definst := $(PATH_LIB) - tool_prefix := AR - bld_trg_base_var := TARGET - $(foreach target, $(_ALL_IMPORT_LIBS), \ - $(evalval def_pass1_link_common)) -else - EXT := DLL - EXTPRE := - definst := $(PATH_DLL) - tool_prefix := LD - bld_trg_base_var := TARGET - $(foreach target, $(_ALL_IMPORT_LIBS), \ - $(evalval def_pass1_link_common)) -endif - - -# -# PROGRAMS (Pass 1) -# -EXT := EXE -EXTPRE := -definst := $(PATH_BIN) -tool_prefix := LD -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_PROGRAMS), \ - $(evalval def_pass1_link_common)) - - -# -# SYSMODS (Pass 1) -# -EXT := SYS -EXTPRE := -definst := $(PATH_SYS) -tool_prefix := LD -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_SYSMODS), \ - $(evalval def_pass1_link_common)) - - -# -# MISCBINS (Pass 1) -# -EXT := BIN -EXTPRE := -definst := $(PATH_BIN) -tool_prefix := LD -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_MISCBINS), \ - $(evalval def_pass1_link_common)) - - -# -# INSTALLS (Pass 1) -# Note! INSTARGET_* for INSTALLS aren't available until later. -# -define def_pass1_install -local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET)) -local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) -local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) -# TARGET_* -$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins -TARGET_$(target) := $($(target)_1_TARGET) - -# INSTARGET_ later. -# PATH_* -local outbase := $(call TARGET_BASE,$(target),$(target)) -$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase))) -PATH_$(target) := $($(target)_0_OUTDIR) -endef # def_pass1_install -$(eval-opt-var def_pass1_install) -$(foreach target, $(_ALL_INSTALLS), \ - $(evalval def_pass1_install)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done pass 1) -endif - - - - -# -# -# Target lists - Pass 2 -# -# - - -## @page pg_fetches Fetching Tools, Sources and Similar. -# -# The targets listed in the the FETCHES target list have the following attributes: -# SOURCES -# INST -# FETCHTOOL -# FETCHFLAGS -# FETCHDIR -# UNPACKTOOL -# UNPACKFLAGS -# -# As usual the target name is an alias for 'creating' the target. Other -# aliases are: -# pass_fetches -# fetch -# unfetch -# download -# unpack -# -# @remark -# -# This is a little bit complex because we must guarantee that if a source file -# changes only sligtly we must refetch it and to a proper unpacking of it. It -# is also a desire that fetched archives and unpacked files can be deleted to -# save space. -# -# Thus, we must be able to cleanup what we've unpacked should any of the -# sources be removed. We do this by maintaining a file listing the files -# and directories that was unpacked. This operation is named 'unfetch'. -# -# We make use of the SIZE and MD5 attributes for each of the sources to -# create a digest that is stored in the primary target file. Subsequent -# runswill compare their digest with it to decide if a refetch is required. -# When a refetch is found necessary, an 'unfetch' is performed first to -# clean out old files and directores. Note even changes in source order -# will cause a refetch due to the way the digest is constructed and -# evaluated. -# -# By not depending directly on the archives (nor on any unpacked files) -# but on a goal made up from the archive name, size and md5, we allow -# the user to delete the archives. Naturally, this means we'll have to -# check and fetch missing archives before attempting to unpack them. -# -# @remark -# -# This feature will *NOT* work correctly with vanilla GNU make becuase -# it makes use of includedep to avoid too many unnecessary files. -# -# @todo -# 0. Move the fetches out into a unit. -# 1. Download corruption / continuation. -# 2. It's quite possible that there is one too many indirect dependency now... -# - -## generates the fetch rule -define def_fetch_src_fetch_rule -# Indirect goal for downloading something. -.PRECIOUS: $(out) -$(out) + $($(target)_$(srcname)_FETCH_2_OUTPUT) +| $($(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE) : \ - | $($(target)_$(srcname)_FETCH_2_DEPORD) - %$$(call MSG_FETCH_DL,$(target),$(source),$(out)) - @## @todo do fancy stuff like download continuation. - $$(QUIET)$$(RM) -f -- $(out) - $(cmds) - $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out)) - - - -# Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary. -$(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_2_DEPEND) | $($(target)_$(srcname)_FETCH_2_DEPORD) - %$$(call MSG_FETCH_CHK,$(target),$(source),$(out)) - $$(QUIET)$$(RM) -f -- $$@ - @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5. - @## @todo do fancy stuff like download continuation. - $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \ - || ( $$(RM_EXT) -f $(out) \ - && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory ) - $$(QUIET2)$$(APPEND) $$@ - -_TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size) - -# Just a little precaution. -.NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size) - -endef # def_fetch_src_fetch_rule -$(eval-opt-var def_fetch_src_fetch_rule) - -## generates the unpack rule -define def_fetch_src_unpack_rule -# This is the unpack rule. it has an order-only dependency on the download check. -$(out) + $($(target)_$(srcname)_UNPACK_2_OUTPUT) +| $($(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE) : \ - $($(target)_$(srcname)_UNPACK_2_DEPEND) \ - | $($(target)_$(srcname)_UNPACK_2_DEPORD) \ - $(archive).checked_$(md5)_$(size) \ - $(dir $(out)) - %$$(call MSG_FETCH_UP,$(target),$(archive),$(inst)) - $$(QUIET)$$(RM) -f -- $(out) - $$(QUIET)$$(MKDIR) -p -- $(dir $(out)) - @# if the source archive doesn't exist fetch it (may have been deleted to save space). - $$(QUIET)test -f $(archive) \ - || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \ - && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory ) - $(cmds) - $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size)) - $$(QUIET2)$$(APPEND) $(out) $(notdir $(out)) - -$(eval _TARGET_$(target)_UNPACKED += $(out)) -_TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size) - -.NOTPARALLEL: $(out) - -endef # def_fetch_src_unpack_rule -$(eval-opt-var def_fetch_src_unpack_rule) - -## Processes a fetch source -# -define def_fetch_src -#$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)') - -# common -local srcname := $(notdir $(source)) -local inst := $(firstword \ - $($(target)_$(source)_INST)\ - $($(target)_$(srcname)_INST)\ - $($(source)_INST)\ - $($(srcname)_INST)\ - $($(target)_INST)\ -) -ifneq ($(patsubst %/,ok,$(inst)),ok) -$(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst)) -endif -INSTARGET_$(target)_$(srcname) := $(inst) -local fetchdir := $(firstword \ - $($(target)_$(source)_FETCHDIR)\ - $($(target)_$(srcname)_FETCHDIR)\ - $($(source)_FETCHDIR)\ - $($(srcname)_FETCHDIR)\ - $($(target)_FETCHDIR)\ - $(FETCHDIR)\ - $(PATH_TARGET)\ +# Function for getting the first defined propert value. +# +# @param 1 The property name. +# @param 2 The default property name, empty if none. +# @param 3 What to return if all variables are empty. (optional) +# @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type. +# @returns Expanded property value. +# +define def_fn_prop_get_first_defined +local .RETURN := $(firstdefined \ + $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(target)_$(1).$(bld_trg).$(bld_trg_arch) \ + $(target)_$(1).$(bld_trg).$(bld_type) \ + $(target)_$(1).$(bld_trg_cpu) \ + $(target)_$(1).$(bld_trg_arch) \ + $(target)_$(1).$(bld_trg) \ + $(target)_$(1).$(bld_type) \ + $(target)_$(1) \ ) -local deps := \ - $($(target)_$(source)_DEPS)\ - $($(target)_$(srcname)_DEPS)\ - $($(source)_DEPS)\ - $($(srcname)_DEPS)\ - $($(target)_DEPS) -local orderdeps := \ - $($(target)_$(source)_ORDERDEPS)\ - $($(target)_$(srcname)_ORDERDEPS)\ - $($(source)_ORDERDEPS)\ - $($(srcname)_ORDERDEPS)\ - $($(target)_ORDERDEPS) -local md5 := $(firstword \ - $($(target)_$(source)_MD5)\ - $($(target)_$(srcname)_MD5)\ - $($(source)_MD5)\ - $($(srcname)_MD5)\ - $($(target)_MD5)\ -) -local size := $(firstword \ - $($(target)_$(source)_SIZE)\ - $($(target)_$(srcname)_SIZE)\ - $($(source)_SIZE)\ - $($(srcname)_SIZE)\ - $($(target)_SIZE)\ -) -clean_files += \ - $($(target)_$(source)_CLEAN)\ - $($(target)_$(srcname)_CLEAN)\ - $($(source)_CLEAN)\ - $($(srcname)_CLEAN) -local dep := # not legal for fetch and unpack tools - - -# -# The fetching. -# -local out := $(fetchdir)/$(srcname) -local archive := $(out) -TARGET_$(target)_$(srcname) := $(out) -$(target)_$(srcname)_1_TARGET = $(TARGET_$(target)_$(srcname)) -local dirdep := $(call DIRDEP,$(fetchdir)) -local tool := $(firstword \ - $($(target)_$(source)_FETCHTOOL)\ - $($(target)_$(srcname)_FETCHTOOL)\ - $($(target)_$(source)_TOOL)\ - $($(target)_$(srcname)_TOOL)\ - $($(source)_FETCHTOOL)\ - $($(srcname)_FETCHTOOL)\ - $($(source)_TOOL)\ - $($(srcname)_TOOL)\ - $($(target)_FETCHTOOL)\ - $($(target)_TOOL)\ - ) -local flags :=\ - $(TOOL_$(tool)_FETCHFLAGS)\ - $(FETCHFLAGS)\ - $($(target)_FETCHFLAGS)\ - $($(srcname)_FETCHFLAGS)\ - $($(source)_FETCHFLAGS)\ - $($(target)_$(srcname)_FETCHFLAGS)\ - $($(target)_$(source)_FETCHFLAGS) - -#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size)) - -ifndef TOOL_$(tool)_FETCH_CMDS -$(warning kBuild: tools: \ - 1 $($(target)_$(source)_FETCHTOOL)\ - 2 $($(target)_$(srcname)_FETCHTOOL)\ - 3 $($(target)_$(source)_TOOL)\ - 4 $($(target)_$(srcname)_TOOL)\ - 5 $($(source)_FETCHTOOL)\ - 6 $($(srcname)_FETCHTOOL)\ - 7 $($(source)_TOOL)\ - 8 $($(srcname)_TOOL)\ - 9 $($(target)_FETCHTOOL)\ - 10 $($(target)_TOOL) ) -$(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) ) -endif - -# call the tool -local cmds := $(TOOL_$(tool)_FETCH_CMDS) -$(target)_$(srcname)_FETCH_2_OUTPUT := $(TOOL_$(tool)_FETCH_OUTPUT) -$(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE) -$(target)_$(srcname)_FETCH_2_DEPEND := $(TOOL_$(tool)_FETCH_DEPEND) $(deps) -$(target)_$(srcname)_FETCH_2_DEPORD := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps) - -# generate the fetch rule. -$(eval $(def_fetch_src_fetch_rule)) - - -# -# The unpacking / installing. -# -local out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst -local dirdep := $(call DIRDEP,$(inst)) -local tool := $(firstword \ - $($(target)_$(source)_UNPACKTOOL)\ - $($(target)_$(srcname)_UNPACKTOOL)\ - $($(target)_$(source)_TOOL)\ - $($(target)_$(srcname)_TOOL)\ - $($(source)_UNPACKTOOL)\ - $($(srcname)_UNPACKTOOL)\ - $($(source)_TOOL)\ - $($(srcname)_TOOL)\ - $($(target)_UNPACKTOOL)\ - $($(target)_TOOL) \ - ) -ifeq ($(tool),) -local tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname))))) -$(evalval def_tools_include) -endif -local flags :=\ - $(TOOL_$(tool)_UNPACKFLAGS)\ - $(UNPACKFLAGS)\ - $($(target)_UNPACKFLAGS)\ - $($(srcname)_UNPACKFLAGS)\ - $($(source)_UNPACKFLAGS)\ - $($(target)_$(srcname)_UNPACKFLAGS)\ - $($(target)_$(source)_UNPACKFLAGS) - -#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size)) -ifndef TOOL_$(tool)_UNPACK_CMDS -$(warning kBuild: tools: \ - 1 $($(target)_$(source)_UNPACKTOOL)\ - 2 $($(target)_$(srcname)_UNPACKTOOL)\ - 3 $($(target)_$(source)_TOOL)\ - 4 $($(target)_$(srcname)_TOOL)\ - 5 $($(source)_UNPACKTOOL)\ - 6 $($(srcname)_UNPACKTOOL)\ - 7 $($(source)_TOOL)\ - 8 $($(srcname)_TOOL)\ - 9 $($(target)_UNPACKTOOL)\ - 10 $($(target)_TOOL) \ - 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \ - ) -$(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) ) -endif - -# call the tool -local cmds := $(TOOL_$(tool)_UNPACK_CMDS) -$(target)_$(srcname)_UNPACK_2_OUTPUT := $(TOOL_$(tool)_UNPACK_OUTPUT) -$(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE) -$(target)_$(srcname)_UNPACK_2_DEPEND := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps) -$(target)_$(srcname)_UNPACK_2_DEPORD := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps) - -# generate the fetch rule. -$(eval $(def_fetch_src_unpack_rule)) - -_DIRS += $(inst) $(fetchdir) - -endef # def_fetch_src -$(eval-opt-var def_fetch_src) - - -## -# Define the target level rules for a fetch. -# @param target -# @param out -# @param inst -# @param _TARGET_$(target)_UNPACKED -# @param _TARGET_$(target)_DIGEST -# @param bld_trg -# @param bld_trg_arch -define def_fetch_rules - -$(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst)) - %$$(call MSG_FETCH_OK,$(target)) - $$(QUIET)$$(RM) -f -- $$@ $$@.tmp - $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))' - $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp) - $$(QUIET)$$(MV) -f -- $$@.tmp $$@ - -$(out)_unfetched: - %$$(call MSG_UNFETCH,$(target)) - $$(QUIET)$$(RM) -f -- $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d')) - $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) \ - $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null)))) - $$(QUIET)$$(RM) -f -- $(out).lst $(out) - $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) - -$(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst)) - $$(QUIET)$$(RM) -f -- $$@ - %$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(eq $$(file-size $(out).lst),-1)\ - ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target))) - $$(QUIET)$(TEST_EXT) -f $(out).lst -- $$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched - $$(QUIET)$$(if $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@)) - $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)") - -.NOTPARALLEL: $(out).lst $(out)_unfetched $(out) - -endef - - -## -# Deal with one fetch target. -# @param target -# @param bld_trg -# @param bld_trg_arch -define def_fetch -# common -INSTARGET_$(target) := $($(target)_INST) -ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok) -$(error kBuild: Bad or missing INST property for target '$(target)'. \ - $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST))) -endif -_TARGET_$(target)_FETCHED := -_TARGET_$(target)_UNPACKED := -_TARGET_$(target)_DIGEST := -local clean_files := $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(KBUILD_TYPE)) - -# The 'sources'. -#$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(KBUILD_TARGET).$(bld_trg_arch))) -$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)),\ - $(evalval def_fetch_src)) - -# The target. -local inst := $(INSTARGET_$(target)) -local out := $(inst)_kBuild_fetch_$(target) - -$(eval includedep $(out)) - -$(eval $(def_fetch_rules)) - -# Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep). -$(target): $(out) -$(target)_unfetch: $(out)_unfetched - -_FETCHES += $(out) -_DOWNLOADS += $(_TARGET_$(target)_FETCHED) -_UNPACKS += $(_TARGET_$(target)_UNPACKED) -_UNFETCHES += $(out)_unfetched -_DIRS += $(inst) -_CLEAN_FILES += $(clean_files) - -endef -$(eval-opt-var def_fetch) - -# Walk the FETCH target lists. -bld_trg := $(KBUILD_TARGET) -bld_trg_arch := $(KBUILD_TARGET_ARCH) -$(foreach target, $(_ALL_FETCHES), \ - $(evalvalctx def_fetch)) - -# some aliases. -download: $(_DOWNLOADS) -unpack: $(_UNPACKS) -fetch: $(_FETCHES) -unfetch: $(_UNFETCHES) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done fetching targets) -endif - - - -## -## Patching. -## -## -#define def_patch_src -# -#endef -# -# -## Deal with one patch target. -#define def_patch -# -#$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(KBUILD_TARGET_ARCH)) $($(target)_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),\ -# $(evalval def_patch_src)) -# -#_PATCHES += -#endef -# -#$(foreach target, $(_ALL_PATCHES), \ -# $(evalval def_patch)) -# - - -# -# Object processing. -# - -## wrapper the compile command dependency check. -ifndef NO_COMPILE_CMDS_DEPS - if1of ($(KMK_FEATURES),dot-must-make) - _DEP_COMPILE_CMDS = - # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)) - else - _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $(obj)),FORCE) - endif -else - _DEP_COMPILE_CMDS = -endif - - -## Generates the rules for building a specific object, and the aliases -# for building a source file. -# @param $(obj) The object file. -define def_target_source_rule -ifndef NO_COMPILE_CMDS_DEPS -$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE) -endif -ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE -_OUT_FILES += $(outbase).koc -$(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \ - $($(target)_$(source)_DEPEND_) \ - $(value _DEP_COMPILE_CMDS) \ - | \ - $($(target)_$(source)_DEPORD_) \ - $$$$($(target)_INTERMEDIATES) - %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) -else -$(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \ - $($(target)_$(source)_DEPEND_) \ - $(value _DEP_COMPILE_CMDS) \ - | \ - $($(target)_$(source)_DEPORD_) \ - $$$$($(target)_INTERMEDIATES) - %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) -ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT - $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) -endif -endif - -$($(target)_$(source)_CMDS_) - -ifndef NO_COMPILE_CMDS_DEPS - %$$(QUIET2)$$(APPEND) '$(dep)' - %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' - %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)' - %$$(QUIET2)$$(APPEND) '$(dep)' 'endef' -endif - -$(basename $(notdir $(obj))).o: $(obj) -$(basename $(notdir $(obj))).obj: $(obj) - -## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added. -$(target)_$(source)_CMDS_ := -$(target)_$(source)_OUTPUT_ := -$(target)_$(source)_OUTPUT_MAYBE_ := -$(target)_$(source)_DEPEND_ := -$(target)_$(source)_DEPORD_ := -endef # def_target_source_rule -$(eval-opt-var def_target_source_rule) - - -## wrapper the link command dependency check. -ifndef NO_LINK_CMDS_DEPS - if1of ($(KMK_FEATURES),dot-must-make) - _DEP_LINK_CMDS = - else - _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE) - endif -else - _DEP_LINK_CMDS = -endif - -## Generate the link rule for a target. -# @param $(target) The normalized target name. -# @param $(dirdep) Directories we depend upon begin created before linking. -# @param $(dep) The name of the dependency file. -# @param $(out) -# @param $($(target)_2_OUTPUT) Output files from the link. -# @param $($(target)_2_OUTPUT_MAYBE) Output files that the link may perhaps create. -# @param $($(target)_2_DEPEND) Dependencies. -# @param $($(target)_2_DEPORD) Dependencies which should only affect build order. -# @param $(cmds) The link commands. -# @param $($(target)_CMDS_PREV_) The link commands from the previous run. -define def_link_rule -ifndef NO_LINK_CMDS_DEPS -$(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE) -endif -$(out) + $($(target)_2_OUTPUT) +| $($(target)_2_OUTPUT_MAYBE) : \ - $$$$($(target)_2_DEPEND) \ - $(value _DEP_LINK_CMDS) \ - | \ - $$$$($(target)_2_DEPORD) - %$$(call MSG_LINK,$(target),$$@,$(tool_do)) - $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) - -$(cmds) - -ifndef NO_LINK_CMDS_DEPS - %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_' - %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)' - %$$(QUIET2)$$(APPEND) '$(dep)' 'endef' -endif - -$(basename $(notdir $(out))):: $(out) - -endef # def_link_rule -$(eval-opt-var def_link_rule) - - -## Generate the link & lib install rule -# @param $(target) Normalized target name. -# @param $(out) The build target. -# @param $(INSTARGET_$(target)) The installation targets. -# @param $(mode) The file mode (optional) -define def_link_install_rule -$(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target)))) - %$$(call MSG_INST_TRG,$(target),$(out),$$@) - $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@ - -ifdef KBUILD_DO_AUTO_INSTALL -$(basename $(notdir $(out))):: $(INSTARGET_$(target)) -endif -endef # def_link_install_rule - - -## def_src_handler_* -# -# @{ -define def_src_handler_c -local type := C - $(kb-src-one 2) -endef - -define def_src_handler_cxx -local type := CXX - $(kb-src-one 2) -endef - -define def_src_handler_objc -local type := OBJC - $(kb-src-one 2) -endef - -define def_src_handler_asm -local type := AS - $(kb-src-one 2) -endef - -define def_src_handler_rc -local type := RC - $(kb-src-one 2) -endef - -define def_src_handler_obj -ifeq ($(defpath),) - $(target)_2_OBJS += $(source) -else - $(target)_2_OBJS += $(abspathex $(source), $(defpath)) -endif -endef -## @} - -## Handle one source. -# . -define def_src_handler_one -local suff := $(suffix $(source)) -local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) )) -local handler := $(patsubst $(suff):%,%,$(src_handler)) -ifneq ($(handler),) - $(evalvalctx $(handler)) -else - othersrc += $(source) -endif -endef - -## Generic macro for processing all target sources. -# @param $(target) Normalized target name. -# @param $(defpath) -# @param much-more... -# @returns othersrc, $(target)_2_OBJS, ++ -define def_target_sources -local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS) -$(foreach source,\ - $($(target)_SOURCES)\ - $($(target)_SOURCES.$(bld_trg))\ - $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\ - $($(target)_SOURCES.$(bld_trg_arch))\ - $($(target)_SOURCES.$(bld_trg_cpu))\ - $($(target)_SOURCES.$(bld_type))\ - ,$(evalval def_src_handler_one) ) - -$(foreach source,\ - $($(target)_GEN_SOURCES_)\ - $($(target)_GEN_SOURCES_.$(bld_trg))\ - $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\ - $($(target)_GEN_SOURCES_.$(bld_trg_arch))\ - $($(target)_GEN_SOURCES_.$(bld_trg_cpu))\ - $($(target)_GEN_SOURCES_.$(bld_type))\ - ,$(evalval def_src_handler_one) ) -endef # def_target_sources -$(eval-opt-var def_target_sources) - - - -## Generic macro for generating the install rule(s) for a target -# and update the globals with default out. -# -# @param $(target) Normalized target name. -# @param $(out) The output file. -# @param $(definst) The default _INST value. -# @param $(typevar) The name of the variable with all the root targets of its type. -# @remark Only library uses this now. -define def_target_install_pluss -ifeq ($(strip $($(target)_NOINST) $($(target)_NOINST.$(bld_trg)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) $($(target)_NOINST.$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg_cpu)) $($(target)_NOINST.$(bld_trg_type))),) - ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))) - else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch))) - else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type))) - else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch))) - else ifneq ($(strip $($(target)_INST.$(bld_trg))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg))) - else ifneq ($(strip $($(target)_INST.$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type))) - else ifneq ($(strip $($(target)_INST)),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST)) - else - local inst := $(definst)/ - endif - INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst)) - local mode := $(firstword \ - $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_MODE.$(bld_trg).$(bld_type)) \ - $($(target)_MODE.$(bld_trg_arch)) \ - $($(target)_MODE.$(bld_trg)) \ - $($(target)_MODE.$(bld_type)) \ - $($(target)_MODE) ) - local uid := $(firstword \ - $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_UID.$(bld_trg).$(bld_type)) \ - $($(target)_UID.$(bld_trg_arch)) \ - $($(target)_UID.$(bld_trg)) \ - $($(target)_UID.$(bld_type)) \ - $($(target)_UID) ) - local gid := $(firstword \ - $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_GID.$(bld_trg).$(bld_type)) \ - $($(target)_GID.$(bld_trg_arch)) \ - $($(target)_GID.$(bld_trg)) \ - $($(target)_GID.$(bld_type)) \ - $($(target)_GID) ) - - # generate the install rule -$(eval $(def_link_install_rule)) - - _INSTALLS_FILES += $(INSTARGET_$(target)) - - ifdef KBUILD_DO_AUTO_INSTALL - $(typevar) += $(INSTARGET_$(target)) +ifeq ($(.RETURN),) + ifneq ($(2),) + local .RETURN := $(firstdefined \ + $(2).$(bld_trg).$(bld_trg_arch).$(bld_type) \ + $(2).$(bld_trg).$(bld_trg_arch) \ + $(2).$(bld_trg).$(bld_type) \ + $(2).$(bld_trg_cpu) \ + $(2).$(bld_trg_arch) \ + $(2).$(bld_trg) \ + $(2).$(bld_type) \ + $(2) \ + 3 \ + ) else - $(typevar) += $(out) - endif -else # _NOINST - $(typevar) += $(out) -endif - -_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out) -_CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type)) -_DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type)) -_OBJS += $($(target)_2_OBJS) - -endef # def_target_install_pluss - - - -# -# LIBRARIES -# - -## Library (one). -# @param $(target) Normalized library (target) name. -define def_lib -# library basics -## @todo prefix -local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET)) -local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) -local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) -local tool := $(call _TARGET_TOOL,$(target),AR) -ifeq ($(tool),) -$(error kBuild: Library target $(target) does not have a tool defined!) -endif -local name := $(firstword\ - $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg))\ - $($(target)_NAME.$(bld_type))\ - $($(target)_NAME)\ - $(target)) -local outbase := $(call TARGET_BASE,$(name),$(target)) -$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase))) -PATH_$(target) := $($(target)_0_OUTDIR) -local suff := $(firstword\ - $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\ - $($(target)_LIBSUFF.$(bld_trg))\ - $($(target)_LIBSUFF)\ - $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\ - $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\ - $(TOOL_$(tool)_ARLIBSUFF)\ - $(SUFF_LIB)) -local out := $(outbase)$(suff) -local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH)) -TARGET_$(target) := $(out) -$(target)_1_TARGET:= $(out) -# no local here - must be writable across some foreachs. -othersrc := -$(target)_2_OBJS := - -# Do units pre source callouts. -local units := \ - $($(target)_USES.$(bld_trg).$(bld_trg_arch))\ - $($(target)_USES.$(bld_trg_arch))\ - $($(target)_USES.$(bld_trg))\ - $($(target)_USES.$(bld_type))\ - $($(target)_USES) -$(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre)) - -# source -> object -$(evalval def_target_sources) - -# library linking -local tool := $(call _TARGET_TOOL,$(target),AR) -local name := $(firstword\ - $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg))\ - $($(target)_NAME.$(bld_type))\ - $($(target)_NAME)\ - $(target)) -local outbase := $(call TARGET_BASE,$(name),$(target)) -local flags :=\ - $(TOOL_$(tool)_ARFLAGS)\ - $(TOOL_$(tool)_ARFLAGS.$(bld_type))\ - $(ARFLAGS)\ - $(ARFLAGS.$(bld_type))\ - $($(target)_ARFLAGS)\ - $($(target)_ARFLAGS.$(bld_type)) \ - $($(target)_ARFLAGS.$(bld_trg)) \ - $($(target)_ARFLAGS.$(bld_trg_arch)) \ - $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_ARFLAGS.$(bld_trg_cpu)) -local dirdep := $(call DIRDEP,$(dir $(out))) -local deps := \ - $($(target)_DEPS.$(bld_trg_cpu)) \ - $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_DEPS.$(bld_trg).$(bld_type)) \ - $($(target)_DEPS.$(bld_trg_arch)) \ - $($(target)_DEPS.$(bld_trg)) \ - $($(target)_DEPS.$(bld_type)) \ - $($(target)_DEPS) \ - $($(target)_LNK_DEPS.$(bld_trg_cpu)) \ - $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \ - $($(target)_LNK_DEPS.$(bld_trg_arch)) \ - $($(target)_LNK_DEPS.$(bld_trg)) \ - $($(target)_LNK_DEPS.$(bld_type)) \ - $($(target)_LNK_DEPS) -local orderdeps := \ - $($(target)_ORDERDEPS.$(bld_trg_cpu)) \ - $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \ - $($(target)_ORDERDEPS.$(bld_trg_arch)) \ - $($(target)_ORDERDEPS.$(bld_trg)) \ - $($(target)_ORDERDEPS.$(bld_type)) \ - $($(target)_ORDERDEPS) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg)) \ - $($(target)_LNK_ORDERDEPS.$(bld_type)) \ - $($(target)_LNK_ORDERDEPS) - -# Adjust paths if we got a default path. -ifneq ($(defpath),) - local deps := $(abspathex $(deps),$(defpath)) - local orderdeps := $(abspathex $(orderdeps),$(defpath)) - othersrc := $(abspathex $(othersrc),$(defpath)) -endif - - -# Custom pre-link actions. -## @todo bld_trg_cpu is missing here. -ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type)) -else ifdef $(target)_PRE_CMDS.$(bld_trg_arch) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch)) -else ifdef $(target)_PRE_CMDS.$(bld_trg) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg)) -else ifdef $(target)_PRE_CMDS.$(bld_type) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_type)) -else ifdef $(target)_PRE_CMDS - local pre_cmds := $($(target)_PRE_CMDS) -else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch) - local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef PRE_CMDS.$(bld_trg).$(bld_type) - local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type)) -else ifdef PRE_CMDS.$(bld_trg_arch) - local pre_cmds := $(PRE_CMDS.$(bld_trg_arch)) -else ifdef PRE_CMDS.$(bld_trg) - local pre_cmds := $(PRE_CMDS.$(bld_trg)) -else ifdef PRE_CMDS.$(bld_type) - local pre_cmds := $(PRE_CMDS.$(bld_type)) -else - local pre_cmds := $(PRE_CMDS) -endif - -# Custom post-link actions. -ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type)) -else ifdef $(target)_POST_CMDS.$(bld_trg_arch) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch)) -else ifdef $(target)_POST_CMDS.$(bld_trg) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg)) -else ifdef $(target)_POST_CMDS.$(bld_type) - local post_cmds := $($(target)_POST_CMDS.$(bld_type)) -else ifdef $(target)_POST_CMDS - local post_cmds := $($(target)_POST_CMDS) -else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch) - local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef POST_CMDS.$(bld_trg).$(bld_type) - local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type)) -else ifdef POST_CMDS.$(bld_trg_arch) - local post_cmds := $(POST_CMDS.$(bld_trg_arch)) -else ifdef POST_CMDS.$(bld_trg) - local post_cmds := $(POST_CMDS.$(bld_trg)) -else ifdef POST_CMDS.$(bld_type) - local post_cmds := $(POST_CMDS.$(bld_type)) -else - local post_cmds := $(POST_CMDS) -endif - -# eliminate this guy? -local objs = $($(target)_2_OBJS) - -# dependency file -local dep := $(out)$(SUFF_DEP) -ifndef NO_LINK_CMDS_DEPS - _DEPFILES_INCLUDED += $(dep) - ifdef KB_HAVE_INCLUDEDEP_QUEUE - includedep-queue $(dep) - else - includedep $(dep) - endif -endif - -# check that the tool is defined. -ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS -$(warning kBuild: tools: \ - 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ - 2 $($(target)_$(source)TOOL.$(bld_trg)) \ - 3 $($(target)_$(source)TOOL) \ - 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \ - 5 $($(target)_TOOL.$(bld_trg)) \ - 6 $($(target)_TOOL) \ - 7 $($(source)TOOL) \ - 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ - 9 $($(source)TOOL.$(bld_trg)) \ - 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \ - 11 $(TOOL.$(bld_trg)) \ - 12 $(TOOL) ) -$(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) ) -endif - -# call the tool -local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS) -ifneq ($(pre_cmds),) - local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds) -endif -ifneq ($(post_cmds),) - local cmds := $(cmds)$(NL)$(TAB)$(post_cmds) -endif -$(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT) -$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE) -$(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS) -$(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps) - -# generate the link rule. -$(eval $(def_link_rule)) - -# installing and globals -$(evalval def_target_install_pluss) -endef -$(eval-opt-var def_lib) - -# Process libraries -definst := $(PATH_LIB) -typevar := _LIBS -tool_do := LINK_LIBRARY -mode := 0644 -$(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done library targets) -endif - - -# -# Link operations. -# + local .RETURN := $(firstdefined \ + kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \ + kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch) \ + kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type) \ + kBuildGlobalDefaults_$(1).$(bld_trg_cpu) \ + kBuildGlobalDefaults_$(1).$(bld_trg_arch) \ + kBuildGlobalDefaults_$(1).$(bld_trg) \ + kBuildGlobalDefaults_$(1).$(bld_type) \ + kBuildGlobalDefaults_$(1) \ + 3 \ + ) + endif +endif +local .RETURN := $(strip $($(.RETURN))) +endef # def_fn_prop_get_first_defined ## -# Link prolog -# -# @param $(target) Normalized target name. -# @param $(EXT) EXE,DLL,SYS. -# @param $(definst) The default _INST value. -# @param $(typevar) The name of the variable with all the root targets of its type. -define def_link_common -# basics -local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var))) -local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH)) -local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU)) - -local tool := $(call _TARGET_TOOL,$(target),LD) -local name := $(firstword\ - $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg))\ - $($(target)_NAME.$(bld_type))\ - $($(target)_NAME)\ - $(target)) -local outbase := $(call TARGET_BASE,$(name),$(target)) -$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase))) -PATH_$(target) := $($(target)_0_OUTDIR) -local suff := $(firstword \ - $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ - $($(target)_$(EXT)SUFF.$(bld_trg))\ - $($(target)_$(EXT)SUFF)\ - $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\ - $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\ - $(TOOL_$(tool)_LD$(EXT)SUFF)\ - $($(EXTPRE)SUFF_$(EXT)) ) -local out := $(outbase)$(suff) -TARGET_$(target) := $(out) -$(target)_1_TARGET:= $(out) -local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH)) -# no local here - must be writable across some foreachs. -othersrc := -$(target)_2_OBJS := - -# Do units pre source callouts. -local units := \ - $($(target)_USES.$(bld_trg).$(bld_trg_arch))\ - $($(target)_USES.$(bld_trg_arch))\ - $($(target)_USES.$(bld_trg))\ - $($(target)_USES.$(bld_type))\ - $($(target)_USES) -$(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre)) - -# source -> object -$(evalval def_target_sources) - -# more link stuff. -local tool := $(call _TARGET_TOOL,$(target),LD) -local name := $(firstword\ - $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg_arch))\ - $($(target)_NAME.$(bld_trg))\ - $($(target)_NAME.$(bld_type))\ - $($(target)_NAME)\ - $(target)) -local outbase := $(call TARGET_BASE,$(name),$(target)) -local flags :=\ - $(TOOL_$(tool)_LDFLAGS)\ - $(TOOL_$(tool)_LDFLAGS.$(bld_type))\ - $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\ - $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\ - $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ - $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\ - $(foreach sdk, $(SDKS) \ - $(SDKS.$(bld_type)) \ - $(SDKS.$(bld_trg)) \ - $(SDKS.$(bld_trg_arch)) \ - $(SDKS.$(bld_trg).$(bld_trg_arch)),\ - $(SDK_$(sdk)_LDFLAGS)\ - $(SDK_$(sdk)_LDFLAGS.$(bld_type))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\ - $(LDFLAGS)\ - $(LDFLAGS.$(bld_type))\ - $(LDFLAGS.$(bld_trg))\ - $(LDFLAGS.$(bld_trg_arch))\ - $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\ - $(LDFLAGS.$(bld_trg_cpu))\ - $(foreach sdk, $($(target)_SDKS) \ - $($(target)_SDKS.$(bld_type)) \ - $($(target)_SDKS.$(bld_trg)) \ - $($(target)_SDKS.$(bld_trg_arch)) \ - $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\ - $(SDK_$(sdk)_LDFLAGS)\ - $(SDK_$(sdk)_LDFLAGS.$(bld_type))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ - $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\ - $($(target)_LDFLAGS)\ - $($(target)_LDFLAGS.$(bld_type))\ - $($(target)_LDFLAGS.$(bld_trg))\ - $($(target)_LDFLAGS.$(bld_trg_arch))\ - $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\ - $($(target)_LDFLAGS.$(bld_trg_cpu)) -local libs :=\ - $($(target)_LIBS.$(bld_trg_cpu))\ - $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\ - $($(target)_LIBS.$(bld_trg_arch))\ - $($(target)_LIBS.$(bld_trg))\ - $($(target)_LIBS.$(bld_type))\ - $($(target)_LIBS)\ - $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_SDKS.$(bld_trg_arch)) \ - $($(target)_SDKS.$(bld_trg)) \ - $($(target)_SDKS.$(bld_type)) \ - $($(target)_SDKS),\ - $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\ - $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBS.$(bld_trg))\ - $(SDK_$(sdk)_LIBS.$(bld_type))\ - $(SDK_$(sdk)_LIBS))\ - $(LIBS.$(bld_trg_cpu))\ - $(LIBS.$(bld_trg).$(bld_trg_arch))\ - $(LIBS.$(bld_trg_arch))\ - $(LIBS.$(bld_trg))\ - $(LIBS.$(bld_type))\ - $(LIBS)\ - $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \ - $(SDKS.$(bld_trg_arch)) \ - $(SDKS.$(bld_trg)) \ - $(SDKS.$(bld_type)) \ - $(SDKS),\ - $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\ - $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBS.$(bld_trg))\ - $(SDK_$(sdk)_LIBS.$(bld_type))\ - $(SDK_$(sdk)_LIBS))\ - $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\ - $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\ - $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\ - $(TOOL_$(tool)_LIBS.$(bld_trg))\ - $(TOOL_$(tool)_LIBS.$(bld_type))\ - $(TOOL_$(tool)_LIBS) -local libpath :=\ - $($(target)_LIBPATH.$(bld_trg_cpu))\ - $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ - $($(target)_LIBPATH.$(bld_trg_arch))\ - $($(target)_LIBPATH.$(bld_trg))\ - $($(target)_LIBPATH.$(bld_type))\ - $($(target)_LIBPATH)\ - $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_SDKS.$(bld_trg_arch)) \ - $($(target)_SDKS.$(bld_trg)) \ - $($(target)_SDKS.$(bld_type)) \ - $($(target)_SDKS),\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg))\ - $(SDK_$(sdk)_LIBPATH.$(bld_type))\ - $(SDK_$(sdk)_LIBPATH))\ - $(LIBPATH.$(bld_trg_cpu))\ - $(LIBPATH.$(bld_trg).$(bld_trg_arch))\ - $(LIBPATH.$(bld_trg_arch))\ - $(LIBPATH.$(bld_trg))\ - $(LIBPATH.$(bld_type))\ - $(LIBPATH)\ - $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \ - $(SDKS.$(bld_trg_arch)) \ - $(SDKS.$(bld_trg)) \ - $(SDKS.$(bld_type)) \ - $(SDKS),\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\ - $(SDK_$(sdk)_LIBPATH.$(bld_trg))\ - $(SDK_$(sdk)_LIBPATH.$(bld_type))\ - $(SDK_$(sdk)_LIBPATH))\ - $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\ - $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\ - $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\ - $(TOOL_$(tool)_LIBPATH.$(bld_trg))\ - $(TOOL_$(tool)_LIBPATH.$(bld_type))\ - $(TOOL_$(tool)_LIBPATH) -local dirdep := $(call DIRDEP,$(dir $(out))) -local deps := \ - $($(target)_DEPS.$(bld_trg_cpu)) \ - $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_DEPS.$(bld_trg).$(bld_type)) \ - $($(target)_DEPS.$(bld_trg_arch)) \ - $($(target)_DEPS.$(bld_trg)) \ - $($(target)_DEPS.$(bld_type)) \ - $($(target)_DEPS) \ - $($(target)_LNK_DEPS.$(bld_trg_cpu)) \ - $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \ - $($(target)_LNK_DEPS.$(bld_trg_arch)) \ - $($(target)_LNK_DEPS.$(bld_trg)) \ - $($(target)_LNK_DEPS.$(bld_type)) \ - $($(target)_LNK_DEPS) -local orderdeps := \ - $($(target)_ORDERDEPS.$(bld_trg_cpu)) \ - $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \ - $($(target)_ORDERDEPS.$(bld_trg_arch)) \ - $($(target)_ORDERDEPS.$(bld_trg)) \ - $($(target)_ORDERDEPS.$(bld_type)) \ - $($(target)_ORDERDEPS) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \ - $($(target)_LNK_ORDERDEPS.$(bld_trg)) \ - $($(target)_LNK_ORDERDEPS.$(bld_type)) \ - $($(target)_LNK_ORDERDEPS) - -# Adjust paths if we got a default path. -ifneq ($(defpath),) - local libpath := $(abspathex $(libpath),$(defpath)) - local deps := $(abspathex $(deps),$(defpath)) - local orderdeps := $(abspathex $(orderdeps),$(defpath)) - othersrc := $(abspathex $(othersrc),$(defpath)) - # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir! -endif - -# Custom pre-link actions. -ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type)) -else ifdef $(target)_PRE_CMDS.$(bld_trg_arch) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch)) -else ifdef $(target)_PRE_CMDS.$(bld_trg) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg)) -else ifdef $(target)_PRE_CMDS.$(bld_type) - local pre_cmds := $($(target)_PRE_CMDS.$(bld_type)) -else ifdef $(target)_PRE_CMDS - local pre_cmds := $($(target)_PRE_CMDS) -else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch) - local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef PRE_CMDS.$(bld_trg).$(bld_type) - local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type)) -else ifdef PRE_CMDS.$(bld_trg_arch) - local pre_cmds := $(PRE_CMDS.$(bld_trg_arch)) -else ifdef PRE_CMDS.$(bld_trg) - local pre_cmds := $(PRE_CMDS.$(bld_trg)) -else ifdef PRE_CMDS.$(bld_type) - local pre_cmds := $(PRE_CMDS.$(bld_type)) -else - local pre_cmds := $(PRE_CMDS) -endif - -# Custom post-link actions. -ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type)) -else ifdef $(target)_POST_CMDS.$(bld_trg_arch) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch)) -else ifdef $(target)_POST_CMDS.$(bld_trg) - local post_cmds := $($(target)_POST_CMDS.$(bld_trg)) -else ifdef $(target)_POST_CMDS.$(bld_type) - local post_cmds := $($(target)_POST_CMDS.$(bld_type)) -else ifdef $(target)_POST_CMDS - local post_cmds := $($(target)_POST_CMDS) -else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type) - local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)) -else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch) - local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch)) -else ifdef POST_CMDS.$(bld_trg).$(bld_type) - local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type)) -else ifdef POST_CMDS.$(bld_trg_arch) - local post_cmds := $(POST_CMDS.$(bld_trg_arch)) -else ifdef POST_CMDS.$(bld_trg) - local post_cmds := $(POST_CMDS.$(bld_trg)) -else ifdef POST_CMDS.$(bld_type) - local post_cmds := $(POST_CMDS.$(bld_type)) -else - local post_cmds := $(POST_CMDS) -endif - -# eliminate this guy? -local objs = $($(target)_2_OBJS) - -# installation targets -ifeq ($(strip $($(target)_NOINST) $($(target)_NOINST.$(bld_trg)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) $($(target)_NOINST.$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg_cpu)) $($(target)_NOINST.$(bld_trg_type))),) - ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))) - else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch))) - else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type))) - else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch))) - else ifneq ($(strip $($(target)_INST.$(bld_trg))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg))) - else ifneq ($(strip $($(target)_INST.$(bld_type))),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type))) - else ifneq ($(strip $($(target)_INST)),) - local inst := $(addprefix $(PATH_INS)/,$($(target)_INST)) - else - local inst := $(definst)/ - endif - INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst)) - ifdef KBUILD_DO_AUTO_INSTALL - $(typevar) += $(INSTARGET_$(target)) - else - $(typevar) += $(out) - endif - local mode := $(firstword \ - $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_MODE.$(bld_trg).$(bld_type)) \ - $($(target)_MODE.$(bld_trg_arch)) \ - $($(target)_MODE.$(bld_trg)) \ - $($(target)_MODE.$(bld_type)) \ - $($(target)_MODE) ) - local uid := $(firstword \ - $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_UID.$(bld_trg).$(bld_type)) \ - $($(target)_UID.$(bld_trg_arch)) \ - $($(target)_UID.$(bld_trg)) \ - $($(target)_UID.$(bld_type)) \ - $($(target)_UID) ) - local gid := $(firstword \ - $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \ - $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_GID.$(bld_trg).$(bld_type)) \ - $($(target)_GID.$(bld_trg_arch)) \ - $($(target)_GID.$(bld_trg)) \ - $($(target)_GID.$(bld_type)) \ - $($(target)_GID) ) - - # generate the install rule -$(eval $(def_link_install_rule)) - -else # NOINST - INSTARGET_$(target) := - $(typevar) += $(out) -endif # NOINST - -# dependency file -local dep := $(outbase)$(SUFF_DEP) -ifndef NO_LINK_CMDS_DEPS - _DEPFILES_INCLUDED += $(dep) - ifdef KB_HAVE_INCLUDEDEP_QUEUE - includedep-queue $(dep) +# Function for getting the first property value (ignoring empty defines). +# +# @param 1 The property name. +# @param 2 The default property name, empty if none. +# @param 3 What to return if all variables are empty. (optional) +# @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type. +# @returns First word. +# +define def_fn_prop_get_first_word +local .RETURN := $(firstword \ + $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(target)_$(1).$(bld_trg).$(bld_trg_arch)) \ + $($(target)_$(1).$(bld_trg).$(bld_type)) \ + $($(target)_$(1).$(bld_trg_cpu)) \ + $($(target)_$(1).$(bld_trg_arch)) \ + $($(target)_$(1).$(bld_trg)) \ + $($(target)_$(1).$(bld_type)) \ + $($(target)_$(1)) \ +) +ifeq ($(.RETURN),) + ifneq ($(2),) + local .RETURN := $(firstword \ + $($(2).$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $($(2).$(bld_trg).$(bld_trg_arch)) \ + $($(2).$(bld_trg).$(bld_type)) \ + $($(2).$(bld_trg_cpu)) \ + $($(2).$(bld_trg_arch)) \ + $($(2).$(bld_trg)) \ + $($(2).$(bld_type)) \ + $($(2)) \ + $(3) \ + ) else - includedep $(dep) + local .RETURN := $(firstword \ + $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \ + $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch)) \ + $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type)) \ + $(kBuildGlobalDefaults_$(1).$(bld_trg_cpu)) \ + $(kBuildGlobalDefaults_$(1).$(bld_trg_arch)) \ + $(kBuildGlobalDefaults_$(1).$(bld_trg)) \ + $(kBuildGlobalDefaults_$(1).$(bld_type)) \ + $(kBuildGlobalDefaults_$(1)) \ + $(3) \ + ) endif endif +endef # def_fn_prop_get_first_word -# check that the tool is defined. -ifndef TOOL_$(tool)_$(tool_do)_CMDS -$(warning kBuild: tools: \ - 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ - 2 $($(target)_$(source)TOOL.$(bld_trg)) \ - 3 $($(target)_$(source)TOOL) \ - 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \ - 5 $($(target)_TOOL.$(bld_trg)) \ - 6 $($(target)_TOOL) \ - 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \ - 8 $($(source)TOOL.$(bld_trg)) \ - 9 $($(source)TOOL) \ - 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \ - 11 $(TOOL.$(bld_trg)) \ - 12 $(TOOL) ) -$(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) ) -endif - -# call the tool -local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS) -ifneq ($(pre_cmds),) - local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds) -endif -ifneq ($(post_cmds),) - local cmds := $(cmds)$(NL)$(TAB)$(post_cmds) -endif -$(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT) -$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE) -$(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS) -$(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps) - -# generate the link rule. -$(eval $(def_link_rule)) - -# Update globals. -_OBJS += $($(target)_2_OBJS) -_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out) -_CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type)) -_DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type)) -_INSTALLS_FILES += $(INSTARGET_$(target)) - -endef # def_link_common -$(eval-opt-var def_link_common) - - -# -# BLDPROGS -# - -## Build program (one). -# @param $(target) Normalized target (program) name. -define def_bldprog - -# set NOINST if not forced installation. -ifndef $(target)_INST -$(target)_NOINST := 1 -endif - -# do the usual stuff. -$(evalval def_link_common) - -endef - -# Process build programs. -EXT := EXE -EXTPRE := HOST -tool_do := LINK_PROGRAM -definst := $(PATH_BIN) -typevar := _BLDPROGS -mode := 0755 -bld_trg_base_var := PLATFORM -$(foreach target, $(_ALL_BLDPROGS), $(evalval def_bldprog)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done build program targets) -endif - - -# -# DLLS -# - -# Process dlls -EXT := DLL -EXTPRE := -tool_do := LINK_DLL -definst := $(PATH_DLL) -typevar := _DLLS -mode := 0644 -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_DLLS), $(evalval def_link_common)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done dll targets) -endif - - -# -# IMPORT LIBRARIES # -# - On OS/2 and windows these are libraries. -# - On other platforms they are fake DLLs. +# The main body. # -EXTPRE := -typevar := _IMPORT_LIBS -mode := 0644 -bld_trg_base_var := TARGET -ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),) - EXT := LIB - tool_do := LINK_LIBRARY - definst := $(PATH_LIB) - $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_lib)) -else - EXT := DLL - tool_do := LINK_DLL - definst := $(PATH_DLL) - $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common)) -endif - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done import library targets) -endif - - -# -# PROGRAMS -# - -# Process programs -EXT := EXE -EXTPRE := -tool_do := LINK_PROGRAM -definst := $(PATH_BIN) -typevar := _PROGRAMS -mode := 0755 -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done program targets) -endif - - -# -# SYSMODS -# - -# Process sysmods -EXT := SYS -EXTPRE := -tool_do := LINK_SYSMOD -definst := $(PATH_SYS) -typevar := _SYSMODS -mode := 0644 -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done sysmod targets) -endif - - -# -# MISCBINS -# - -# Process MISCBINS -EXT := BIN -EXTPRE := -tool_do := LINK_MISCBIN -definst := $(PATH_BIN) -typevar := _MISCBINS -mode := 0644 -bld_trg_base_var := TARGET -$(foreach target, $(_ALL_MISCBINS), $(evalval def_link_common)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done misc binary targets) -endif - - -# -# OTHERS -# -_OTHERS = $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) - - -# -# INSTALLS -# - -## generate the install rule -define def_install_src_rule -# the install rule -$(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst))) - %$$(call MSG_INST_FILE,$(srcsrc),$(insdst)) - $$(QUIET)$(inscmd) -endef -$(eval-opt-var def_install_src_rule) - -## install one file -define def_install_src - -# deal with '=>' in the source file name. -ifeq ($(src),=>) - $(error kBuild: Install target '$(target)' has a bad source specifier containing '=>' without any file names) -endif -ifeq ($(substr $(src),1,2),=>) - $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src)) -endif -ifeq ($(substr $(src),-2),=>) - $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src)) -endif -local srcdst := $(subst =>, ,$(src)) -local srcsrc := $(firstword $(srcdst)) -local srcdstdir := $(dir $(word 2,$(srcdst))) -local srcdst := $(word $(words $(srcdst)),$(srcdst)) - -# _INSTFUN -ifdef $(srcsrc)_INSTFUN - local instfun := $(srcsrc)_INSTFUN -else ifdef $(target)_INSTFUN - local instfun := $(target)_INSTFUN -else - local instfun := _INSTALL_FILE -endif - -# _INST -ifdef $(srcsrc)_INST - local inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir)) -else ifdef $(target)_INST - local inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir)) -else - local inst := $(dir $(srcdstdir)) -endif - -# calc target -local insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS)) -#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst)) - -# mode, uid and gid -local mode := $(firstword \ - $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcsrc)_MODE.$(bld_trg)) \ - $($(target)_$(srcsrc)_MODE) \ - $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcdst)_MODE.$(bld_trg)) \ - $($(target)_$(srcdst)_MODE) \ - $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(srcsrc)_MODE.$(bld_trg)) \ - $($(srcsrc)_MODE) \ - $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(srcdst)_MODE.$(bld_trg)) \ - $($(srcdst)_MODE) \ - $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_MODE.$(bld_trg)) \ - $($(target)_MODE)) -local uid := $(firstword \ - $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcsrc)_UID.$(bld_trg)) \ - $($(target)_$(srcsrc)_UID) \ - $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcdst)_UID.$(bld_trg)) \ - $($(target)_$(srcdst)_UID) \ - $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(srcsrc)_UID.$(bld_trg)) \ - $($(srcsrc)_UID) \ - $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(srcdst)_UID.$(bld_trg)) \ - $($(srcdst)_UID) \ - $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_UID.$(bld_trg)) \ - $($(target)_UID)) -local gid := $(firstword \ - $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcsrc)_GID.$(bld_trg)) \ - $($(target)_$(srcsrc)_GID) \ - $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcdst)_GID.$(bld_trg)) \ - $($(target)_$(srcdst)_GID) \ - $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(srcsrc)_GID.$(bld_trg)) \ - $($(srcsrc)_GID) \ - $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(srcdst)_GID.$(bld_trg)) \ - $($(srcdst)_GID) \ - $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_GID.$(bld_trg)) \ - $($(target)_GID)) -local flags := \ - $($(target)_IFFLAGS) \ - $($(target)_IFFLAGS.$(bld_trg)) \ - $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(srcdst)_IFFLAGS) \ - $($(srcdst)_IFFLAGS.$(bld_trg)) \ - $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(srcsrc)_IFFLAGS) \ - $($(srcsrc)_IFFLAGS.$(bld_trg)) \ - $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcdst)_IFFLAGS) \ - $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \ - $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcsrc)_IFFLAGS) \ - $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \ - $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) -clean_files += \ - $($(srcdst)_CLEAN) \ - $($(srcdst)_CLEAN.$(bld_trg)) \ - $($(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ - $($(srcsrc)_CLEAN) \ - $($(srcsrc)_CLEAN.$(bld_trg)) \ - $($(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcdst)_CLEAN) \ - $($(target)_$(srcdst)_CLEAN.$(bld_trg)) \ - $($(target)_$(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(srcsrc)_CLEAN) \ - $($(target)_$(srcsrc)_CLEAN.$(bld_trg)) \ - $($(target)_$(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) - - -# Adjust the source if we got a default PATH. (This must be done this late!) -local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH)) -ifneq ($(defpath),) - local srcsrc := $(abspathex $(srcsrc),$(defpath)) -endif - -# create the command -ifdef $(srcsrc)_INSTALLER - local inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags)) -else ifdef $(target)_INSTALLER - local inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags)) -else - local inscmd := $$(INSTALL)\ - $(if $(uid),-o $(uid))\ - $(if $(gid),-g $(gid))\ - $(if $(mode),-m $(mode))\ - $(flags) -- \ - $(srcsrc) $(insdst) -endif - -# generate the rule (need double evaluation here) -$(eval $(def_install_src_rule)) - -INSTARGET_$(target) += $(insdst) -endef # def_install_src -$(eval-opt-var def_install_src) - - -## generate the symlink rule -define def_install_symlink_rule -# the install rule -$(insdst) : | $(call DIRDEP,$(dir $(insdst))) - %$$(call MSG_INST_SYM,$(insdst),$(symdst)) - $$(QUIET)$$(RM) -f -- $$@ - $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst) -endef # def_install_symlink_rule -$(eval-opt-var def_install_symlink_rule) - -## create one symlink -define def_install_symlink - -# deal with '=>' in the source file name. -local symdst := $(subst =>, ,$(src)) -local symlnk := $(firstword $(symdst)) -local symdst := $(word $(words $(symdst)),$(symdst)) - -# _INSTFUN -ifdef $(symlnk)_INSTFUN - local instfun := $(symlnk)_INSTFUN -else ifdef $(target)_INSTFUN - local instfun := $(target)_INSTFUN -else - local instfun := _INSTALL_FILE -endif - -# _INST -ifdef $(symlnk)_INST - local inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk)) -else ifdef $(target)_INST - local inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk)) -else - local inst := $(dir $(symlnk)) -endif - -# calc target -local insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS)) -#$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)') - -# generate the rule (need double evaluation here) -$(eval $(def_install_symlink_rule)) - -INSTARGET_$(target) += $(insdst) -endef # def_install_symlink -$(optmize def_install_symlink) - - -## generate the install rule -define def_install_directory_rule -# the install rule -$(insdst): - %$$(call MSG_INST_DIR,$(insdst)) - $$(QUIET)$$(INSTALL) -d \ - $(if $(uid),-o $(uid))\ - $(if $(gid),-g $(gid))\ - $(if $(mode),-m $(mode))\ - $(flags) -- \ - $(insdst) - -.NOTPARALLEL: $(insdst) -endef # def_install_directory_rule -$(eval-opt-var def_install_directory_rule) - - -## create one directory -define def_install_directory - -# _INST -ifdef $(directory)_INST - local inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST)) -else ifdef $(target)_INST - local inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST)) -else - local inst := $(PATH_INS) -endif - -local mode := $(firstword \ - $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(directory)_MODE.$(bld_trg)) \ - $($(target)_$(directory)_MODE) \ - $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(directory)_MODE.$(bld_trg)) \ - $($(directory)_MODE) \ - $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_MODE.$(bld_trg)) \ - $($(target)_MODE)) -local uid := $(firstword \ - $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(directory)_UID.$(bld_trg)) \ - $($(target)_$(directory)_UID) \ - $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(directory)_UID.$(bld_trg)) \ - $($(directory)_UID) \ - $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_UID.$(bld_trg)) \ - $($(target)_UID)) -local gid := $(firstword \ - $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(directory)_GID.$(bld_trg)) \ - $($(target)_$(directory)_GID) \ - $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(directory)_GID.$(bld_trg)) \ - $($(directory)_GID) \ - $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_GID.$(bld_trg)) \ - $($(target)_GID)) -local flags := \ - $($(target)_IDFLAGS)\ - $($(target)_IDFLAGS.$(bld_trg)) \ - $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(directory)_IDFLAGS) \ - $($(directory)_IDFLAGS.$(bld_trg)) \ - $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \ - $($(target)_$(directory)_IDFLAGS) \ - $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \ - $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) - -local insdst := $(inst)/$(directory)/ -#$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid)) - -# generate the rule (need double evaluation here) -$(eval $(def_install_directory_rule)) - -INSTARGET_DIRS_$(target) += $(insdst) -endef # def_install_directory -$(eval-opt-var def_install_directory) - - -## process one install target. -define def_install -# the basics. -local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE)) -local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET)) -local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH)) -local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU)) - -INSTARGET_$(target) := $($(target)_GOALS) -INSTARGET_DIRS_$(target) := -local outbase := $(call TARGET_BASE,$(target),$(target)) -$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase))) -PATH_$(target) := $($(target)_0_OUTDIR) - -local clean_files := $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type)) - -$(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \ - $(evalval def_install_directory)) - -$(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \ - $(evalval def_install_src)) - -$(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \ - $(evalval def_install_symlink)) - -# the collection target -local clean_files += $(PATH_TARGET)/$(target).ins -$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins -TARGET_$(target) := $($(target)_1_TARGET) -$($(target)_1_TARGET): $$(INSTARGET_$(target)) | $$(INSTARGET_DIRS_$(target)) $(call DIRDEP,$(PATH_TARGET)) - @$(QUIET2)$(APPEND) $@ - -$(target): $$($(target)_1_TARGET) - -_INSTALLS += $($(target)_1_TARGET) -_INSTALLS_FILES += $(INSTARGET_$(target)) -_INSTALLS_DIRS += $(INSTARGET_DIRS_$(target)) -_CLEAN_FILES += $(clean_files) -_DIRS += $($(target)_0_OUTDIR) $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type)) -endef # def_install -$(eval-opt-var def_install) - -## process all install targets -$(foreach target, $(_ALL_INSTALLS), \ - $(evalvalctx def_install)) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done install targets) -endif - -# Some introspection targets that can be useful for package maintainers. -.PHONY: kbuild-show-install-files kbuild-show-install-dirs -kbuild-show-install-files:: - $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES))) - -kbuild-show-install-dirs:: - $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS))) - - -# -# TESTING -# -_TESTING += $(TESTING) $(TESTING.$(KBUILD_TARGET)) $(TESTING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(TESTING.$(KBUILD_TARGET_ARCH)) $(TESTING.$(KBUILD_TARGET_CPU)) - - -# -# PACKING -# -_PACKING += $(PACKING) $(PACKING.$(KBUILD_TARGET)) $(PACKING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PACKING.$(KBUILD_TARGET_ARCH)) $(PACKING.$(KBUILD_TARGET_CPU)) - - -# -# DOCS -# - - -# -# DIRECTORIES -# -_DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES))) -$(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL)))) - - -define def_mkdir_rule -$(directory): - %$$(call MSG_MKDIR,$$@) - $$(QUIET)$$(MKDIR) -p -- $$@ -endef - -$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule))) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done directories) -endif - - -# -# NOTHING -# -do-nothing: - %$(call MSG_NOTHING) -ifdef KBUILD_PROFILE_SELF - @$(ECHO) 'prof: $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_PREV)) - executing $@' - ifeq ($(KBUILD_PROFILE_SELF),2) - @$(ECHO) 'stat: $(make-stats )' - endif -endif - - -# -# CLEAN UP -# -do-clean: - %$(call MSG_CLEAN) - $(QUIET)$(RM) -f -- $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN) - $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $(rsort $(dir $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN))) - - - -# -# PASSES (including directory and makefile walking) -# - -# -# First, check whether we need to order the passes explicitly or not. -# This depends on whether we're a leaf makefile or not. A leaf will -# know all its dependencies, while a recursive one relies on the -# order sub-directories and other makefiles are executed it. -# - -## Setup a pass and check for optimizations. -# @param $(PASS) Uppercase pass name. -define def_pass_setup_and_optimize - -# The setup. ## @todo This is looks a bit weird... -ifndef SUBDIRS_$(PASS) - SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET.$(KBUILD_TARGET_ARCH))) -endif -ifndef SUBDIRS_AFTER_$(PASS) - SUBDIRS_AFTER_$(PASS) := $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(KBUILD_TARGET)) $(SUBDIRS_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) -endif -ifndef MAKEFILES_BEFORE_$(PASS) - MAKEFILES_BEFORE_$(PASS) := $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(KBUILD_TARGET)) $(MAKEFILES_BEFORE.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) -endif -ifndef MAKEFILES_AFTER_$(PASS) - MAKEFILES_AFTER_$(PASS) := $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(KBUILD_TARGET)) $(MAKEFILES_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) -endif - -# The check. -ifeq ($(_KBUILD_STRICT_PASS_ORDER),nonstrict) - ifneq ($(strip \ - $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - $(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \ - ),) - _KBUILD_STRICT_PASS_ORDER := strict - endif -endif # _KBUILD_STRICT_PASS_ORDER == nonstrict -endef # def_pass_setup_and_optimize -$(eval-opt-var def_pass_setup_and_optimize) - -## PASS: Setup & optimization. -# Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*), -# and set up the pass specific variables as we go along. -_KBUILD_STRICT_PASS_ORDER := nonstrict -$(foreach PASS, $(PASSES), $(evalval def_pass_setup_and_optimize)) -#$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER)) - -ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict) - if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1" -_KBUILD_STRICT_PASS_ORDER := strict_unsafe - endif -endif - - -## Subdir -# @param $(pass) Lowercase pass name. -# @param $(PASS) Uppercase pass name. -# @param $(subdir) Subdirectory -# @param $(tag) tag to attach to the rule name. -define def_pass_subdir -pass_$(pass)$(tag):: $(dep) - + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass) -endef - -## Submakefile -# @param $(pass) Lowercase pass name. -# @param $(PASS) Uppercase pass name. -# @param $(makefile) Makefile. -# @param $(tag) tag to attach to the rule name. -define def_pass_makefile -pass_$(pass)$(tag):: $(dep) - + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass) -endef - -## Execute a pass, strict order. -# @param $(pass) Lowercase pass name. -# @param $(PASS) Uppercase pass name. -define def_pass_strict -$(eval tag:=_before) -$(eval dep:= ) -$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) -$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile))) - -$(eval tag:=_after) -$(eval dep:=pass_$(pass)_doit) -$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) -$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile))) - -.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this -.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit -pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))) -pass_$(pass)_this: pass_$(pass)_before - + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit -pass_$(pass)_after:: pass_$(pass)_this -pass_$(pass): pass_$(pass)_after -#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))) -endef # def_pass_strict -$(eval-opt-var def_pass_strict) - -## Execute a pass, strict order. -# @param $(pass) Lowercase pass name. -# @param $(PASS) Uppercase pass name. -define def_pass_strict_unsafe -$(eval tag:=_before) -$(eval dep:= ) -$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) -$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile))) - -$(eval tag:=_after) -$(eval dep:=pass_$(pass)_doit) -$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir))) -$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile))) - -.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit -.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit -pass_$(pass)_doit: pass_$(pass)_before \ - $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))) -pass_$(pass): \ - pass_$(pass)_before \ - pass_$(pass)_doit \ - pass_$(pass)_after -#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))) -endef # def_pass_strict_unsafe -$(eval-opt-var def_pass_strict_unsafe) - -## Execute a pass, non-strict pass ordering. -# @param $(pass) Lowercase pass name. -# @param $(PASS) Uppercase pass name. -define def_pass_nonstrict -.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit -pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var))) -pass_$(pass): pass_$(pass)_doit -endef # def_pass_nonstrict - -## PASS: rules -# Generate the rules for the defined passes. -$(foreach PASS, $(PASSES), \ - $(eval pass := $(PASS_$(PASS)_pass)) \ - $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER)))) - - -## Pass order, strict. -# @param $(pass) Current pass name. -# @param $(prev_pass) The previous pass name. -define def_pass_order_strict -.PHONY: pass_$(pass)_order -.NOTPARALLEL: pass_$(pass)_order -pass_$(pass)_order: $(pass_prev) - %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass))) - + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass) -$(eval pass_prev := pass_$(pass)_order) -endef # def_pass_order_strict -$(eval-opt-var def_pass_order_strict) - -## Pass order, strict unsafe. -# @param $(pass) Current pass name. -# @param $(prev_pass) The previous pass name. -define def_pass_order_strict_unsafe -.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner -.PHONY: pass_$(pass)_order pass_$(pass)_banner -pass_$(pass)_banner: $(pass_prev) - %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass))) -pass_$(pass)_order: $(pass_prev) \ - pass_$(pass)_banner \ - pass_$(pass) -$(eval pass_prev := pass_$(pass)_order) -endef # def_pass_order_strict_unsafe -$(eval-opt-var def_pass_order_strict_unsafe) - -## Pass order, non-strict. -# @param $(pass) Current pass name. -# @param $(prev_pass) The previous pass name. -define def_pass_order_nonstrict -.PHONY: pass_$(pass)_order pass_$(pass)_banner -pass_$(pass)_banner: - %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass))) -pass_$(pass)_order: \ - $(pass_prev) \ - pass_$(pass)_banner \ - pass_$(pass) -$(eval pass_prev := pass_$(pass)_order) -endef # def_pass_order_nonstrict -$(eval-opt-var def_pass_order_nonstrict) - -## PASS: order -# Use dependencies to ensure correct pass order. -pass_prev := -$(foreach PASS,$(DEFAULT_PASSES),\ - $(eval pass := $(PASS_$(PASS)_pass)) \ - $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER)))) - -ifdef KBUILD_PROFILE_SELF - $(evalcall def_profile_self, done passes) -endif - -# Some common pass aliases -ifndef KBUILD_NO_PASS_ALIASES -.PHONY: clean -clean: pass_clean - -.PHONY: nothing -nothing: pass_nothing - -.PHONY: packing -packing: pass_packing - - ifndef KBUILD_NO_TESTING_PASS_ALIASES -.PHONY: check -check:: pass_testing - -.PHONY: test -test:: pass_testing - endif # KBUILD_NO_TESTING_PASS_ALIASES -endif # KBUILD_NO_PASS_ALIASES +include $(KBUILD_PATH)/footer-inherit-uses-tools.kmk +include $(KBUILD_PATH)/footer-pass1.kmk +include $(KBUILD_PATH)/footer-pass2-fetches.kmk +include $(KBUILD_PATH)/footer-pass2-patches.kmk +include $(KBUILD_PATH)/footer-pass2-compiling-targets.kmk +include $(KBUILD_PATH)/footer-pass2-installs.kmk +include $(KBUILD_PATH)/footer-misc.kmk +include $(KBUILD_PATH)/footer-passes.kmk # @@ -3753,7 +345,10 @@ programs: $$(_PROGRAMS) sysmods: $$(_SYSMODS) miscbins: $$(_MISCBINS) others: $$(_OTHERS) -installs: $$(_INSTALLS) $$(_INSTALLS_DIRS) $$(_INSTALLS_FILES) +stagings: $$(_INSTALLS) $$(_STAGE_DIRS) $$(_STAGE_FILES) +installs: $$(_INSTALLS_DIRS) $$(_INSTALLS_FILES) + +install-debug: $$(_DEBUG_INSTALL_DIRS) $$(_DEBUG_INSTALL_FILES) @@ -3813,5 +408,5 @@ endif # end-of-file-content __footer_kmk__ := target -endif # __footer_kmk__ +endif # !defined(__footer_kmk__) diff --git a/kBuild/header.kmk b/kBuild/header.kmk index 6042ad6..d4c3aad 100644 --- a/kBuild/header.kmk +++ b/kBuild/header.kmk @@ -1,10 +1,10 @@ -# $Id: header.kmk 2274 2009-02-20 23:45:49Z bird $ +# $Id: header.kmk 2537 2011-08-02 19:44:43Z bird $ ## @file # kBuild - File included at top of a makefile. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -70,8 +70,8 @@ ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1) $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!) endif else - ifneq ($(int-ge $(KBUILD_VERSION_PATCH),4),1) - $(warning kBuild: kmk version mismatch! Expected 0.1.4 or later. Actual version is $(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR).$(KBUILD_VERSION_PATCH).) + if $(KBUILD_VERSION_PATCH) < 999 + $(error kBuild: kmk version mismatch! Expected 0.1.999 or later. Actual version is $(KBUILD_VERSION).) endif endif @@ -79,7 +79,7 @@ endif # The revision in which this file was last modified. # This can be useful when using development versions of kBuild. # -KMK_REVISION := $(patsubst %:,, $Rev: 2274 $ ) +KMK_REVISION := $(patsubst %:,, $Rev: 2537 $ ) # @@ -158,6 +158,18 @@ DOLLAR := $$ # Equal character. EQUAL := = +## +# Percent character. +PERCENT := % + +## +# Single quote character. +SQUOTE := ' + +## +# Double quote character. +DQUOTE := " + # # The list of standard build types in kBuild. @@ -251,7 +263,7 @@ else ifneq (.$(words $(KBUILD_HOST_CPU)).$(KBUILD_HOST_CPU).,.1.$(strip $(KBUILD_HOST_CPU)).) $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' contains spaces/tabs!) endif - if1of ($(KBUILD_HOST_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)) + if1of ($(KBUILD_HOST_CPU), $(KBUILD_OSES) $(KBUILD_ARCHES)) $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' was found in the OS or architecture keywords!) endif ifeq ($(KBUILD_HOST_CPU),$(KBUILD_TYPE)) @@ -347,7 +359,7 @@ else ifneq (.$(words $(KBUILD_TARGET_CPU)).$(KBUILD_TARGET_CPU).,.1.$(strip $(KBUILD_TARGET_CPU)).) $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' contains spaces/tabs!) endif - if1of ($(KBUILD_TARGET_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)) + if1of ($(KBUILD_TARGET_CPU), $(KBUILD_OSES) $(KBUILD_ARCHES)) $(error kBuild: The KBUILD_TARGET_CPU value was found in the OS or architecture keywords!) endif ifeq ($(KBUILD_TARGET_CPU),$(KBUILD_TYPE)) @@ -389,6 +401,43 @@ else CURSUBDIR := . endif +# Install directory layout. Relative to PATH_INS. +KBUILD_INST_PATHS := BIN DLL SYS LIB DOC DEBUG SBIN LIBEXEC SHARE +INST_BIN = bin/ +if1of ($(KBUILD_TARGET), win) +INST_DLL = bin/ +else +INST_DLL = lib/ +endif +if1of ($(KBUILD_TARGET), os2 win) +INST_SYS = drivers/ +else +INST_SYS = kernel/ +endif +INST_LIB = lib/ +INST_DOC = share/doc/ +INST_DEBUG = debug/ +INST_SBIN = sbin/ +INST_LIBEXEC = libexec/ +INST_SHARE = share/ + +# Staging directory layout. Relative to PATH_STAGE. +STAGE_BIN = $(INST_BIN) +STAGE_DLL = $(INST_DLL) +STAGE_SYS = $(INST_SYS) +STAGE_LIB = $(INST_LIB) +STAGE_DOC = $(INST_DOC) +STAGE_DEBUG = $(INST_DEBUG) +STAGE_SBIN = $(INST_SBIN) +STAGE_LIBEXEC = $(INST_LIBEXEC) +STAGE_SHARE = $(INST_SHARE) + +# Install and staging directory paths. +$(foreach path, $(KBUILD_INST_PATHS), \ + $(eval PATH_STAGE_$(path) = $$(patsubst %/,%,$$(PATH_STAGE)/$$(STAGE_$(path)))) \ + $(eval PATH_INST_$(path) = $$(patsubst %/,%,$$(PATH_INS)/$$(INST_$(path)))) \ +) + # Output directories. ifndef PATH_OUT_BASE PATH_OUT_BASE := $(PATH_ROOT)/out @@ -403,12 +452,21 @@ endif # !define PATH_OUT PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache PATH_OBJ = $(PATH_OUT)/obj PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR) -PATH_INS = $(PATH_OUT) -PATH_BIN = $(PATH_INS)/bin -PATH_DLL = $(PATH_INS)/bin -PATH_SYS = $(PATH_INS)/bin -PATH_LIB = $(PATH_INS)/lib -PATH_DOC = $(PATH_INS)/doc +PATH_STAGE = $(PATH_OUT)/stage +ifndef PATH_INS + ifdef DESTROOT +PATH_INS = $(DESTROOT) + else +PATH_INS = $(PATH_OUT)/dist + endif +endif + +# Tripwire obsolete PATH defines. +PATH_BIN = $(error kBuild: PATH_BIN is obsoleted in kBuild 0.1.2. Use PATH_STAGE_BIN or PATH_INST_BIN instead) +PATH_DLL = $(error kBuild: PATH_LIB is obsoleted in kBuild 0.1.2. Use PATH_STAGE_DLL or PATH_INST_DLL instead) +PATH_LIB = $(error kBuild: PATH_LIB is obsoleted in kBuild 0.1.2. Use PATH_STAGE_LIB or PATH_INST_LIB instead) +PATH_SYS = $(error kBuild: PATH_SYS is obsoleted in kBuild 0.1.2. Use PATH_STAGE_SYS or PATH_INST_SYS instead) +PATH_DOC = $(error kBuild: PATH_DOC is obsoleted in kBuild 0.1.2. Use PATH_STAGE_DOC or PATH_INST_DOC instead) # Development tool tree. KBUILD_DEVTOOLS = $(if $(PATH_DEVTOOLS),$(PATH_DEVTOOLS),$(PATH_ROOT)/tools) @@ -657,6 +715,13 @@ export SHELL MAKESHELL # Symlinking is problematic on some platforms... LN_SYMLINK := $(LN) -s +# When copying to the staging area, use hard links to save time and space. +ifndef KBUILD_NO_HARD_LINKING + INSTALL_STAGING := $(INSTALL) --hard-link-files-when-possible +else + INSTALL_STAGING := $(INSTALL) +endif + # # Some Functions. @@ -695,6 +760,13 @@ no-drive = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1))) # @param $1 the path no-root-slash = $(patsubst /%,%,$(1)) +## +# Similar to firstword, except it returns the value of first defined variable. +# @param $1 list of variables to probe. +define FIRST-DEFINED-VAR +local .RETURN := $(strip $(firstdefined $1, value)) +endef + ## Figure out where to put object files. # @param $1 real target name. # @param $2 normalized main target @@ -763,6 +835,63 @@ local long_options := $(filter-out =delete=%,$(subst :, =delete=,$(subst =, =del local .RETURN := $(if-expr $(pos $1,$(short_options)) != 0 || "$(filter $2,$(long_options))" != "",$4,$5) endef +## +# Make an assignment to a deprecated variable. +# +# @param $1 The variable name. +# @param $2 The value. +# @param $3 The variable to use instead. +# +ifdef KBUILD_WITH_DEPREATED_AS_ERROR + KB_FN_ASSIGN_DEPRECATED = $(eval $(subst :,$$(COLON),$1) = $2$$(error $1 is deprecated, use $3 instead)) +else + KB_FN_ASSIGN_DEPRECATED = $(eval $(subst :,$$(COLON),$1) = $2$$(warning $1 is deprecated, use $3 instead)) +endif + +## +# Show an assertion message. +# +# @param $1 The assertion name. +# @param $2 The details. +# +define KB_FN_ASSERT_MSG +$(info !! kBuild $1 Assertion Failed !!) +ifdef target + $(info !! target: $(target)) + local varloc := $(where $(target)) + if "$(varloc)" == "undefined" + local varloc := $(where $(target)_TEMPLATE) + endif + if "$(varloc)" == "undefined" + local varloc := $(where $(target)_SOURCES) + endif + if "$(varloc)" == "undefined" + local varloc := $(where $(target)_EXTENDS) + endif + if "$(varloc)" == "undefined" + local varloc := $(where target) + endif + ifneq ($(varloc),) + $(info !! location: $(varloc)) + else + $(info !! probable location: $($(target)_DEFPATH)/Makefile.kmk) + endif +endif +$(info !! $2) +$(error fixme) +endef + +## +# Throw an error if the given path $1 isn't absolute and assertions are enabled. +# +# @param $1 The name of the path variable to check. +# +ifdef KBUILD_INTERNAL_STRICT + KB_FN_ASSERT_ABSPATH = $(if-expr "$(abspath $($(strip $1)))" != "$(strip $($(strip $1)))",\ + $(evalcall KB_FN_ASSERT_MSG,abspath,$1 is:$(NLTAB)'$($(strip $1))'$(NLTAB)expected:$(NLTAB)'$(abspath $($(strip $1)))')) +else + KB_FN_ASSERT_ABSPATH := +endif # @@ -808,6 +937,8 @@ KBUILD_SRC_HANDLERS := \ .cc:def_src_handler_cxx \ .CC:def_src_handler_cxx \ .m:def_src_handler_objc \ + .M:def_src_handler_objcxx \ + .mm:def_src_handler_objcxx \ .asm:def_src_handler_asm \ .ASM:def_src_handler_asm \ .s:def_src_handler_asm \ @@ -819,26 +950,28 @@ KBUILD_SRC_HANDLERS := \ ## PROPS_TOOLS # This is a subset of PROPS_SINGLE. -PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL +PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL ## PROPS_SINGLE # The list of non-accumulative target properties. # A Config.kmk file can add it's own properties to this list and kBuild # will do the necessary inheritance for templates, sdks, tools and targets. -PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \ - OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \ - MODE UID GID +PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INSTTYPE INST STAGE NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \ + OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \ + MODE UID GID LD_DEBUG DEBUG_INSTTYPE DEBUG_INST DEBUG_STAGE ## PROPS_SINGLE_LNK # Subset of PROPS_SINGLE which applies to all linkable targets. -PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL \ +PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL \ INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \ - OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF \ - MODE UID GID + OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF \ + MODE UID GID LD_DEBUG DEBUG_INSTTYPE DEBUG_INST DEBUG_STAGE ## PROPS_DEFERRED # This list of non-accumulative target properties which are or may be # functions, and thus should not be expanded until the very last moment. -PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS NAME SONAME +PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS PRE_INST_CMDS POST_INST_CMDS \ + PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS \ + NAME SONAME ## PROPS_ACCUMULATE_R # The list of accumulative target properties where the right most value/flag @@ -851,10 +984,11 @@ PROPS_ACCUMULATE_R := \ CFLAGS CDEFS \ CXXFLAGS CXXDEFS \ OBJCFLAGS OBJCDEFS \ + OBJCXXFLAGS OBJCXXDEFS \ ASFLAGS ASDEFS \ RCFLAGS RCDEFS \ LDFLAGS \ - IDFLAGS IFDLAGS ISFLAGS \ + IDFLAGS IFFLAGS EXEC_IFFLAGS ISFLAGS \ FETCHFLAGS UNPACKFLAGS PATCHFLAGS ## PROPS_ACCUMULATE_R_LNK # Subset of PROPS_ACCUMULATE_R which applies to all linkable targets. @@ -863,9 +997,10 @@ PROPS_ACCUMULATE_R_LNK := \ CFLAGS CDEFS \ CXXFLAGS CXXDEFS \ OBJCFLAGS OBJCDEFS \ + OBJCXXFLAGS OBJCXXDEFS \ ASFLAGS ASDEFS \ RCFLAGS RCDEFS \ - IDFLAGS IFDLAGS ISFLAGS + IDFLAGS IFFLAGS ISFLAGS ## PROPS_ACCUMULATE # The list of accumulative target properties where the left most value/flag @@ -873,15 +1008,15 @@ PROPS_ACCUMULATE_R_LNK := \ # A Config.kmk file can add it's own properties to this list and kBuild # will do the necessary inheritance from templates to targets. PROPS_ACCUMULATE_L := \ - SDKS USES SOURCES SRC_HANDLERS INTERMEDIATES \ - INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \ + SDKS USES SOURCES EXEC_SOURCES SRC_HANDLERS INTERMEDIATES \ + INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \ LIBS LIBPATH \ DIRS BLDDIRS CLEAN ## PROPS_ACCUMULATE_L_LNK # Subset of PROPS_ACCUMULATE_L which applies to all linkable targets. PROPS_ACCUMULATE_L_LNK := \ - SDKS SOURCES SRC_HANDLERS \ - INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \ + SDKS USES SOURCES SRC_HANDLERS INTERMEDIATES \ + INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \ BLDDIRS CLEAN ## PROPS_ALL @@ -930,13 +1065,14 @@ PROPS_MISCBINS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH ## @name Properties valid on installs (INSTALLS) ## @{ -PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INST NOINST -PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER -PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS -PROPS_INSTALLS_ACCUMULATE_L := SOURCES DIRS CLEAN +PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU MODE UID GID +PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS \ + PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS +PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS GOALS INST_ONLY_GOALS STAGE_ONLY_GOALS IFFLAGS EXEC_IFFLAGS +PROPS_INSTALLS_ACCUMULATE_L := SOURCES EXEC_SOURCES DIRS CLEAN ## @} -## @name Properties valid on fetches (INSTALLS) +## @name Properties valid on fetches (FETCHES) ## @{ PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR PROPS_FETCHES_DEFERRED := @@ -1052,12 +1188,20 @@ PASS_OTHERS_trgs := PASS_OTHERS_vars := _OTHERS PASS_OTHERS_pass := others -## PASS: install +## PASS: staging # This pass installs the built entities to a sandbox area. ## @todo split this up into build install (to sandbox) and real installation. +PASS_STAGING := Staging +PASS_STAGING_trgs := +PASS_STAGING_vars := _STAGE_DIRS _INSTALLS _STAGE_FILES _DEBUG_STAGE_DIRS _DEBUG_STAGE_FILES +PASS_STAGING_pass := staging + +## PASS: install +# This pass installs the built entities to where they will be used (using +# DESTROOT or PATH_INS to indicate where this is). PASS_INSTALLS := Install PASS_INSTALLS_trgs := -PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES +PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS_FILES _DEBUG_INSTALL_DIRS _DEBUG_INSTALL_FILES PASS_INSTALLS_pass := installs ## PASS: testing @@ -1090,12 +1234,12 @@ PASS_NOTHING_pass := nothing ## DEFAULT_PASSES # The default passes and their order. -DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS +DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS STAGING ## PASSES # The passes that should be defined. This must include # all passes mentioned by DEFAULT_PASSES. -PASSES := FETCHES PATCHES $(DEFAULT_PASSES) TESTING PACKING CLEAN NOTHING +PASSES := FETCHES PATCHES $(DEFAULT_PASSES) INSTALLS TESTING PACKING CLEAN NOTHING # @@ -1161,15 +1305,42 @@ endif # variables and uses relative paths or paths with incorrect case. # PATH_OUT_BASE := $(abspath $(PATH_OUT_BASE)) -PATH_OUT := $(abspath $(PATH_OUT)) -PATH_OBJ := $(abspath $(PATH_OBJ)) -PATH_TARGET := $(abspath $(PATH_TARGET)) -PATH_INS := $(abspath $(PATH_INS)) -PATH_BIN := $(abspath $(PATH_BIN)) -PATH_DLL := $(abspath $(PATH_DLL)) -PATH_SYS := $(abspath $(PATH_SYS)) -PATH_LIB := $(abspath $(PATH_LIB)) -PATH_DOC := $(abspath $(PATH_DOC)) +PATH_OUT := $(abspath $(PATH_OUT)) +PATH_OBJ := $(abspath $(PATH_OBJ)) +PATH_TARGET := $(abspath $(PATH_TARGET)) +PATH_INS := $(abspath $(PATH_INS)) +PATH_STAGE := $(abspath $(PATH_STAGE)) + +# Finalize the install and staging directory layouts. +define def_kbuild_finalize_inst +local val := $(strip $($(y)_$(x))) +ifeq ($(val),) + $(error kBuild: '$(y)_$(x)' is set to an empty value.) +endif +ifneq ($(words $(val)),1) + $(error kBuild: The '$(y)_$(x)' value '$(val)' should not contain spaces.) +endif +ifneq ($(pos \,$(val)), 0) + $(error kBuild: The '$(y)_$(x)' value '$(val)' contains DOS slashes: not allowed.) +endif +ifneq ($(pos $(COLON),$(val)), 0) + $(error kBuild: The '$(y)_$(x)' value '$(val)' contains colon: not allowed.) +endif +ifneq ($(substr $(val),-1), /) + $(error kBuild: The '$(y)_$(x)' value '$(val)' has no trailing slash.) +endif +if $(pos /../,$(val)) != 0 || "$(substr $(val), 3)" == "../" + $(error kBuild: The '$(y)_$(x)' value '$(val)' contains dot-dot escape.) +endif +$($(y)_$(x) := $(val) + +local val := $(strip $(PATH_$(y)_$(x))) +ifeq ($(val),) + $(error kBuild: 'PATH_$(y)_$(x)' is set to an empty value.) +endif +PATH_$(y)_$(x) := $(val) +endef +$(foreach y, INST STAGE, $(foreach x, $(KBUILD_INST_PATHS), $(evalcall def_kbuild_finalize_inst))) # diff --git a/kBuild/msgstyles/brief.kmk b/kBuild/msgstyles/brief.kmk index 2108b8a..0a17df6 100644 --- a/kBuild/msgstyles/brief.kmk +++ b/kBuild/msgstyles/brief.kmk @@ -1,10 +1,10 @@ -# $Id: brief.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: brief.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Message Style - 'brief' # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/msgstyles/brief2.kmk b/kBuild/msgstyles/brief2.kmk new file mode 100644 index 0000000..9651256 --- /dev/null +++ b/kBuild/msgstyles/brief2.kmk @@ -0,0 +1,127 @@ +# $Id: brief2.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild Message Style - 'brief' +# + +# +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +# Indent the messages, drop the kBuild: prefix, and shorten paths. +ifndef KBUILD_VERBOSE + ifndef MSG_L1 + MSG_L1 = @$(PRINTF) " %-7s %s\n" \ + "$(subst $(PATH_ROOT)/,{R}/,$(subst $(PATH_OUT)/,{O}/,$(subst $(CURDIR)/,{C}/,$(subst $(PATH_TARGET)/,{T}/,$1))))" \ + "$(subst $(PATH_ROOT)/,{R}/,$(subst $(PATH_OUT)/,{O}/,$(subst $(CURDIR)/,{C}/,$(subst $(PATH_TARGET)/,{T}/,$2))))" + endif + ifndef MSG_L1I + MSG_L1I = @$(PRINTF) " %-7s %s\n" "$1" "$2" + endif +else + MSG_L1 ?= @$(ECHO) " $(subst $(PATH_ROOT)/,{R}/,$(subst $(PATH_OUT)/,{O}/,$(subst $(CURDIR)/,{C}/,$(subst $(PATH_TARGET)/,{T}/,$1 $2))))" + MSG_L1I?= @$(ECHO) " $1 $2" + MSG_L2 ?= @$(ECHO) " $(subst $(PATH_ROOT)/,{R}/,$(subst $(PATH_OUT)/,{O}/,$(subst $(CURDIR)/,{C}/,$(subst $(PATH_TARGET)/,{T}/,$1))))" +endif + +## Fetch starting. +# @param 1 Target name. +MSG_FETCH ?= $(call MSG_L1,FTCH,$1...) +## Re-fetch starting. +# @param 1 Target name. +MSG_REFETCH ?= $(call MSG_L1,RFTCH,$1...) +## Downloading a fetch component. +# @param 1 Target name. +# @param 2 The source URL. +# @param 3 The destination file name. +MSG_FETCH_DL ?= $(call MSG_L1,GET,$1 - $2,=> $3) +## Checking a fetch component. +# @param 1 Target name. +# @param 2 The source URL. +# @param 3 The destination file name. +MSG_FETCH_CHK?= $(call MSG_L1,CHK,$1 - $3, ($2)) +## Unpacking a fetch component. +# @param 1 Target name. +# @param 2 The archive file name. +# @param 3 The target directory. +MSG_FETCH_UP ?= $(call MSG_L1,UNPK,$1 - $2,=> $3) +## Fetch completed. +# @param 1 Target name. +MSG_FETCH_OK ?= $(call MSG_L1,DONE,$1) +## Unfetch a fetch target. +# @param 1 Target name. +MSG_UNFETCH ?= $(call MSG_L1,RM,$1...) +## Compiling a source file. +# @param 1 Target name. +# @param 2 The source filename. +# @param 3 The primary link output file name. +# @param 4 The source type (CXX,C,AS,RC,++). +MSG_COMPILE ?= $(call MSG_L1,$4,$1 - $2,=> $3) +## Tool +# @param 1 The tool name (bin2c,...) +# @param 2 Target name. +# @param 3 The source filename. +# @param 4 The primary output file name. +MSG_TOOL ?= $(call MSG_L1,$1,$2 - $3,=> $4) +## Generate a file, typically a source file. +# @param 1 Target name if applicable. +# @param 2 Output file name. +# @param 3 What it's generated from +MSG_GENERATE ?= $(call MSG_L1,GEN,$2) +## Linking a bldprog/dll/program/sysmod target. +# @param 1 Target name. +# @param 2 The primary link output file name. +# @param 3 The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++). +MSG_LINK ?= $(call MSG_L1I,$(if $(eq $3,LINK_LIBRARY),AR,LD),$1 => $2,) +## Merging a library into the target (during library linking). +# @param 1 Target name. +# @param 2 The output library name. +# @param 3 The input library name. +MSG_AR_MERGE ?= $(NO_SUCH_VARIABLE) +## Creating a directory (build). +# @param 1 Directory name. +MSG_MKDIR ?= $(call MSG_L2,DIR,$1) +## Cleaning. +MSG_CLEAN ?= $(call MSG_L1,CLEAN) +## Nothing. +MSG_NOTHING ?= $(call MSG_L1,NOTHING $(CURDIR)) +## Installing a bldprog/lib/dll/program/sysmod target. +# @param 1 Target name. +# @param 2 The source filename. +# @param 3 The destination file name. +MSG_INST_TRG ?= $(call MSG_L1I,INST,$1 => $3) +## Installing a file (install target). +# @param 1 The source filename. +# @param 2 The destination filename. +MSG_INST_FILE?= $(call MSG_L1I,IFIL,$2,(<= $1)) +## Installing a symlink. +# @param 1 Symlink +# @param 2 Link target +MSG_INST_SYM ?= $(call MSG_L1I,ISYM,$1,=> $2) +## Installing a directory. +# @param 1 Directory name. +MSG_INST_DIR ?= $(call MSG_L1I,IDIR,$1) + diff --git a/kBuild/rules.kmk b/kBuild/rules.kmk index a1d9b22..6d5ecf6 100644 --- a/kBuild/rules.kmk +++ b/kBuild/rules.kmk @@ -1,10 +1,10 @@ -# $Id: rules.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: rules.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - File included at top of makefile. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/DXSDK.kmk b/kBuild/sdks/DXSDK.kmk index 697582d..a1f044c 100644 --- a/kBuild/sdks/DXSDK.kmk +++ b/kBuild/sdks/DXSDK.kmk @@ -1,10 +1,10 @@ -# $Id: DXSDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: DXSDK.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Direct X SDK, targeting $(KBUILD_TARGET). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/DXSDKAMD64.kmk b/kBuild/sdks/DXSDKAMD64.kmk index 08579d1..6e08650 100644 --- a/kBuild/sdks/DXSDKAMD64.kmk +++ b/kBuild/sdks/DXSDKAMD64.kmk @@ -1,10 +1,10 @@ -# $Id: DXSDKAMD64.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: DXSDKAMD64.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Direct X SDK, targeting AMD64. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/DXSDKX86.kmk b/kBuild/sdks/DXSDKX86.kmk index 9bd95af..6dbb648 100644 --- a/kBuild/sdks/DXSDKX86.kmk +++ b/kBuild/sdks/DXSDKX86.kmk @@ -1,10 +1,10 @@ -# $Id: DXSDKX86.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: DXSDKX86.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Direct X SDK, targeting X86. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/LIBSDL.kmk b/kBuild/sdks/LIBSDL.kmk index 6826317..4e70de7 100644 --- a/kBuild/sdks/LIBSDL.kmk +++ b/kBuild/sdks/LIBSDL.kmk @@ -1,10 +1,10 @@ -# $Id: LIBSDL.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: LIBSDL.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - Simple DirectMedia Layer, targeting $(KBUILD_TARGET). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/MACOSX104.kmk b/kBuild/sdks/MACOSX104.kmk index b816442..bb9e029 100644 --- a/kBuild/sdks/MACOSX104.kmk +++ b/kBuild/sdks/MACOSX104.kmk @@ -1,10 +1,10 @@ -# $Id: MACOSX104.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MACOSX104.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - Mac OS X v10.4 SDK. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/MACOSX104INCS.kmk b/kBuild/sdks/MACOSX104INCS.kmk index 9f24cb3..32de67a 100644 --- a/kBuild/sdks/MACOSX104INCS.kmk +++ b/kBuild/sdks/MACOSX104INCS.kmk @@ -1,10 +1,10 @@ -# $Id: MACOSX104INCS.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MACOSX104INCS.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - Mac OS X v10.4 SDK, includes only. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/MACOSX105.kmk b/kBuild/sdks/MACOSX105.kmk index 873ce04..5d30d80 100644 --- a/kBuild/sdks/MACOSX105.kmk +++ b/kBuild/sdks/MACOSX105.kmk @@ -1,10 +1,10 @@ -# $Id: MACOSX105.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MACOSX105.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - Mac OS X v10.5 SDK. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/MACOSX105INCS.kmk b/kBuild/sdks/MACOSX105INCS.kmk index 876ad68..ab8a2e5 100644 --- a/kBuild/sdks/MACOSX105INCS.kmk +++ b/kBuild/sdks/MACOSX105INCS.kmk @@ -1,10 +1,10 @@ -# $Id: MACOSX105INCS.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MACOSX105INCS.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - Mac OS X v10.5 SDK, includes only. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/NT4DDK.kmk b/kBuild/sdks/NT4DDK.kmk index 38d292b..0f76d03 100644 --- a/kBuild/sdks/NT4DDK.kmk +++ b/kBuild/sdks/NT4DDK.kmk @@ -1,10 +1,10 @@ -# $Id: NT4DDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: NT4DDK.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Windows NT 4 DDK, targeting X86. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/OS2DDKBASE32.kmk b/kBuild/sdks/OS2DDKBASE32.kmk index 94a463c..0e039c1 100644 --- a/kBuild/sdks/OS2DDKBASE32.kmk +++ b/kBuild/sdks/OS2DDKBASE32.kmk @@ -1,10 +1,10 @@ -# $Id: OS2DDKBASE32.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: OS2DDKBASE32.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # # kBuild SDK - The OS/2 DDK, 32-bit base headers and libraries. # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/W2K3DDK.kmk b/kBuild/sdks/W2K3DDK.kmk index 3d2119c..e2025d0 100644 --- a/kBuild/sdks/W2K3DDK.kmk +++ b/kBuild/sdks/W2K3DDK.kmk @@ -1,10 +1,10 @@ -# $Id: W2K3DDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: W2K3DDK.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows 2003 DDK, targeting $(KBUILD_TARGET). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/W2K3DDKAMD64.kmk b/kBuild/sdks/W2K3DDKAMD64.kmk index 3231bd6..a4769a7 100644 --- a/kBuild/sdks/W2K3DDKAMD64.kmk +++ b/kBuild/sdks/W2K3DDKAMD64.kmk @@ -1,10 +1,10 @@ -# $Id: W2K3DDKAMD64.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: W2K3DDKAMD64.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows 2003 DDK, targeting amd64. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/W2K3DDKX86.kmk b/kBuild/sdks/W2K3DDKX86.kmk index 4c3420f..1e4c23a 100644 --- a/kBuild/sdks/W2K3DDKX86.kmk +++ b/kBuild/sdks/W2K3DDKX86.kmk @@ -1,10 +1,10 @@ -# $Id: W2K3DDKX86.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: W2K3DDKX86.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows 2003 DDK, targeting x86. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/W32API.kmk b/kBuild/sdks/W32API.kmk index d8d7bd9..f341719 100644 --- a/kBuild/sdks/W32API.kmk +++ b/kBuild/sdks/W32API.kmk @@ -1,10 +1,10 @@ -# $Id: W32API.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: W32API.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - w32api (MinGW), targeting x86. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WIN32SDK.kmk b/kBuild/sdks/WIN32SDK.kmk index 776d75b..37d165e 100644 --- a/kBuild/sdks/WIN32SDK.kmk +++ b/kBuild/sdks/WIN32SDK.kmk @@ -1,10 +1,10 @@ -# $Id: WIN32SDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WIN32SDK.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Windows Platform SDK, targeting x86. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WIN32SDK2002.kmk b/kBuild/sdks/WIN32SDK2002.kmk index 7735d91..5120d26 100644 --- a/kBuild/sdks/WIN32SDK2002.kmk +++ b/kBuild/sdks/WIN32SDK2002.kmk @@ -1,11 +1,11 @@ -# $Id: WIN32SDK2002.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WIN32SDK2002.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - Windows Platform SDK (from ~2002), targeting x86. # Differs in that it has ddraw.lib and dxguid.lib. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WIN64SDK.kmk b/kBuild/sdks/WIN64SDK.kmk index 266538a..ba464a5 100644 --- a/kBuild/sdks/WIN64SDK.kmk +++ b/kBuild/sdks/WIN64SDK.kmk @@ -1,10 +1,10 @@ -# $Id: WIN64SDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WIN64SDK.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Windows Platform SDK, targeting AMD64. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WINDDK.kmk b/kBuild/sdks/WINDDK.kmk index 7ca2a92..2736a04 100644 --- a/kBuild/sdks/WINDDK.kmk +++ b/kBuild/sdks/WINDDK.kmk @@ -1,11 +1,11 @@ -# $Id: WINDDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINDDK.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows Vista and Server 2008 DDKs. # Defaults to $(KBUILD_TARGET_ARCH). Base SDK. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WINDDKW2K.kmk b/kBuild/sdks/WINDDKW2K.kmk index e741a28..6f5ef1f 100644 --- a/kBuild/sdks/WINDDKW2K.kmk +++ b/kBuild/sdks/WINDDKW2K.kmk @@ -1,10 +1,10 @@ -# $Id: WINDDKW2K.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINDDKW2K.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows Vista and Server 2008 DDKs, Targeting Windows 2000 (x86). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WINDDKWLH.kmk b/kBuild/sdks/WINDDKWLH.kmk index ca169dc..fe7479e 100644 --- a/kBuild/sdks/WINDDKWLH.kmk +++ b/kBuild/sdks/WINDDKWLH.kmk @@ -1,10 +1,10 @@ -# $Id: WINDDKWLH.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINDDKWLH.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows Vista and Server 2008 DDKs, Targeting Vista and 2008 (KBUILD_TARGET_ARCH). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WINDDKWNET.kmk b/kBuild/sdks/WINDDKWNET.kmk index f23c514..d0fdfb7 100644 --- a/kBuild/sdks/WINDDKWNET.kmk +++ b/kBuild/sdks/WINDDKWNET.kmk @@ -1,10 +1,10 @@ -# $Id: WINDDKWNET.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINDDKWNET.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows Vista and Server 2008 DDKs, Targeting Windows Server 2003 (KBUILD_TARGET_ARCH). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WINDDKWXP.kmk b/kBuild/sdks/WINDDKWXP.kmk index 1ebcdfa..69a3a1b 100644 --- a/kBuild/sdks/WINDDKWXP.kmk +++ b/kBuild/sdks/WINDDKWXP.kmk @@ -1,10 +1,10 @@ -# $Id: WINDDKWXP.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINDDKWXP.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Microsoft Windows Vista and Server 2008 DDKs, Targeting Windows XP (x86). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/sdks/WINPSDK.kmk b/kBuild/sdks/WINPSDK.kmk index 21a61c1..21ef6f6 100644 --- a/kBuild/sdks/WINPSDK.kmk +++ b/kBuild/sdks/WINPSDK.kmk @@ -1,10 +1,10 @@ -# $Id: WINPSDK.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINPSDK.kmk 2430 2010-11-16 15:26:34Z bird $ ## @file # kBuild SDK - The Windows Platform SDK, targeting (KBUILD_TARGET). # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -68,6 +68,9 @@ endif ifndef PATH_SDK_WINPSDK_LIB.amd64 PATH_SDK_WINPSDK_LIB.amd64 := $(firstword $(wildcard $(PATH_SDK_WINPSDK)/[Ll][Ii][Bb]/[Aa][Mm][Dd]64 $(PATH_SDK_WINPSDK)/[Ll][Ii][Bb]/[xX]64) $(PATH_SDK_WINPSDK)/Lib/AMD64) endif +ifndef PATH_SDK_WINPSDK_LIB.ia64 +PATH_SDK_WINPSDK_LIB.ia64 := $(firstword $(wildcard $(PATH_SDK_WINPSDK)/[Ll][Ii][Bb]/[Ii][Aa]64) $(PATH_SDK_WINPSDK)/Lib/IA64) +endif PATH_SDK_WINPSDK_LIB ?= $(PATH_SDK_WINPSDK_LIB.$(KBUILD_TARGET_ARCH)) ifndef PATH_SDK_WINPSDK_BIN @@ -83,29 +86,79 @@ endif # General Properties used by kBuild SDK_WINPSDK_INCS ?= $(PATH_SDK_WINPSDK_INC) -SDK_WINPSDK_LIBPATH ?= $(PATH_SDK_WINPSDK_LIB) -SDK_WINPSDK_LIBS ?= \ - $(PATH_SDK_WINPSDK_LIB)/Kernel32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/User32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/Gdi32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/AdvAPI32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/Shell32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/ShLwApi.Lib \ - $(PATH_SDK_WINPSDK_LIB)/SetupAPI.Lib \ - $(PATH_SDK_WINPSDK_LIB)/Uuid.Lib \ - $(PATH_SDK_WINPSDK_LIB)/Version.Lib \ - $(PATH_SDK_WINPSDK_LIB)/WS2_32.Lib \ +SDK_WINPSDK_LIBPATH.x86 ?= $(PATH_SDK_WINPSDK_LIB.x86) +SDK_WINPSDK_LIBPATH.amd64 ?= $(PATH_SDK_WINPSDK_LIB.amd64) +SDK_WINPSDK_LIBPATH.ia64 ?= $(PATH_SDK_WINPSDK_LIB.ia64) +SDK_WINPSDK_LIBS.x86 ?= \ + $(PATH_SDK_WINPSDK_LIB.x86)/Kernel32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/User32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/Gdi32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/AdvAPI32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/Shell32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/ShLwApi.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/SetupAPI.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/Uuid.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/Version.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/WS2_32.Lib \ + \ + $(PATH_SDK_WINPSDK_LIB.x86)/Ole32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/OleAut32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/OleDlg.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/RpcRT4.Lib \ + \ + $(PATH_SDK_WINPSDK_LIB.x86)/DbgHelp.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/ImageHlp.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/IPHlpApi.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/ComCtl32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/ComDlg32.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/WinSpool.Lib \ + $(PATH_SDK_WINPSDK_LIB.x86)/WinMM.Lib +SDK_WINPSDK_LIBS.amd64 ?= \ + $(PATH_SDK_WINPSDK_LIB.amd64)/Kernel32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/User32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/Gdi32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/AdvAPI32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/Shell32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/ShLwApi.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/SetupAPI.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/Uuid.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/Version.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/WS2_32.Lib \ + \ + $(PATH_SDK_WINPSDK_LIB.amd64)/Ole32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/OleAut32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/OleDlg.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/RpcRT4.Lib \ + \ + $(PATH_SDK_WINPSDK_LIB.amd64)/DbgHelp.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/ImageHlp.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/IPHlpApi.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/ComCtl32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/ComDlg32.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/WinSpool.Lib \ + $(PATH_SDK_WINPSDK_LIB.amd64)/WinMM.Lib +SDK_WINPSDK_LIBS.ia64 ?= \ + $(PATH_SDK_WINPSDK_LIB.ia64)/Kernel32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/User32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/Gdi32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/AdvAPI32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/Shell32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/ShLwApi.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/SetupAPI.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/Uuid.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/Version.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/WS2_32.Lib \ \ - $(PATH_SDK_WINPSDK_LIB)/Ole32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/OleAut32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/OleDlg.Lib \ - $(PATH_SDK_WINPSDK_LIB)/RpcRT4.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/Ole32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/OleAut32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/OleDlg.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/RpcRT4.Lib \ \ - $(PATH_SDK_WINPSDK_LIB)/DbgHelp.Lib \ - $(PATH_SDK_WINPSDK_LIB)/ImageHlp.Lib \ - $(PATH_SDK_WINPSDK_LIB)/IPHlpApi.Lib \ - $(PATH_SDK_WINPSDK_LIB)/ComCtl32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/ComDlg32.Lib \ - $(PATH_SDK_WINPSDK_LIB)/WinSpool.Lib \ - $(PATH_SDK_WINPSDK_LIB)/WinMM.Lib + $(PATH_SDK_WINPSDK_LIB.ia64)/DbgHelp.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/ImageHlp.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/IPHlpApi.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/ComCtl32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/ComDlg32.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/WinSpool.Lib \ + $(PATH_SDK_WINPSDK_LIB.ia64)/WinMM.Lib diff --git a/kBuild/sdks/WINPSDKINCS.kmk b/kBuild/sdks/WINPSDKINCS.kmk index 61710bc..fee7a21 100644 --- a/kBuild/sdks/WINPSDKINCS.kmk +++ b/kBuild/sdks/WINPSDKINCS.kmk @@ -1,4 +1,4 @@ -# $Id: WINPSDKINCS.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WINPSDKINCS.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild SDK - The Windows Platform SDK, targeting (KBUILD_TARGET) but # without any libraries or LIBPATH properties. @@ -6,7 +6,7 @@ # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/subfooter.kmk b/kBuild/subfooter.kmk index 54ac4e2..ad7abd1 100644 --- a/kBuild/subfooter.kmk +++ b/kBuild/subfooter.kmk @@ -1,10 +1,10 @@ -# $Id: subfooter.kmk 2242 2009-01-10 02:16:34Z bird $ +# $Id: subfooter.kmk 2443 2011-07-06 12:19:50Z bird $ ## @file # kBuild - File included at bottom of a makefile or sub-makefile. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -43,12 +43,10 @@ endif # define def_subheader ifndef $(target)_PATH - ifdef $(target)_DEFPATH - $(target)_PATH := $($(target)_DEFPATH) - else - $(target)_PATH := $(PATH_SUB_CURRENT) + ifndef $(target)_DEFPATH $(target)_DEFPATH := $(PATH_SUB_CURRENT) endif + $(call KB_FN_ASSIGN_DEPRECATED,$(target)_PATH,$($(target)_DEFPATH),$(target)_DEFPATH) else ifndef $(target)_DEFPATH $(target)_DEFPATH := $($(target)_PATH) endif @@ -57,7 +55,7 @@ define def_subheader endif ifndef $(target)_0_OUTDIR $(target)_0_OUTDIR := $(call TARGET_PATH,$(target)) - PATH_$(target) := $($(target)_0_OUTDIR) + $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR),$(target)_0_OUTDIR) endif endef diff --git a/kBuild/subheader.kmk b/kBuild/subheader.kmk index a84a716..8131aa6 100644 --- a/kBuild/subheader.kmk +++ b/kBuild/subheader.kmk @@ -1,10 +1,10 @@ -# $Id: subheader.kmk 2242 2009-01-10 02:16:34Z bird $ +# $Id: subheader.kmk 2434 2011-01-09 17:45:08Z bird $ ## @file # kBuild - File included at top of a makefile or sub-makefile. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -54,12 +54,10 @@ else # define def_subfooter ifndef $(target)_PATH - ifdef $(target)_DEFPATH - $(target)_PATH := $($(target)_DEFPATH) - else - $(target)_PATH := $(PATH_SUB_CURRENT) + ifndef $(target)_DEFPATH $(target)_DEFPATH := $(PATH_SUB_CURRENT) endif + $(call KB_FN_ASSIGN_DEPRECATED,$(target)_PATH,$($(target)_DEFPATH), $(target)_DEFPATH) else ifndef $(target)_DEFPATH $(target)_DEFPATH := $($(target)_PATH) endif @@ -68,7 +66,7 @@ else endif ifndef $(target)_0_OUTDIR $(target)_0_OUTDIR := $(call TARGET_PATH,$(target)) - PATH_$(target) := $($(target)_0_OUTDIR) + $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR) endif endef diff --git a/kBuild/templates/DUMMY.kmk b/kBuild/templates/DUMMY.kmk index 7a51346..48e2ca8 100644 --- a/kBuild/templates/DUMMY.kmk +++ b/kBuild/templates/DUMMY.kmk @@ -1,10 +1,10 @@ -# $Id: DUMMY.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: DUMMY.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Template Config - Empty dummy template. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/ALP.kmk b/kBuild/tools/ALP.kmk index 568dca9..b9f1cbe 100644 --- a/kBuild/tools/ALP.kmk +++ b/kBuild/tools/ALP.kmk @@ -1,10 +1,10 @@ -# $Id: ALP.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: ALP.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - ALP or later. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/BISON.kmk b/kBuild/tools/BISON.kmk index be141e4..b2aed47 100644 --- a/kBuild/tools/BISON.kmk +++ b/kBuild/tools/BISON.kmk @@ -1,10 +1,10 @@ -# $Id: BISON.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: BISON.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # GNU bison tool # # -# Copyright (c) 2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2009-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/FLEX.kmk b/kBuild/tools/FLEX.kmk index 16a922b..7f004cb 100644 --- a/kBuild/tools/FLEX.kmk +++ b/kBuild/tools/FLEX.kmk @@ -1,10 +1,10 @@ -# $Id: FLEX.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: FLEX.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # flex tool # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/GCC.kmk b/kBuild/tools/GCC.kmk index 2065627..9a1c6cd 100644 --- a/kBuild/tools/GCC.kmk +++ b/kBuild/tools/GCC.kmk @@ -1,10 +1,10 @@ -# $Id: GCC.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GCC.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic GCC Using The System GCC. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -101,6 +101,7 @@ define TOOL_GCC_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -126,6 +127,7 @@ define TOOL_GCC_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -151,6 +153,7 @@ define TOOL_GCC_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -202,6 +205,9 @@ TOOL_GCC_LINK_PROGRAM_DEPORD = define TOOL_GCC_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_GCC_LD) $(flags) -o $(out) $(objs) \ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GCC.) +endif endef @@ -224,5 +230,8 @@ TOOL_GCC_LINK_DLL_DEPORD = define TOOL_GCC_LINK_DLL_CMDS $(QUIET)$(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $(out) $(objs) \ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GCC.) +endif endef diff --git a/kBuild/tools/GCC3.kmk b/kBuild/tools/GCC3.kmk index 1f0e813..4142bda 100644 --- a/kBuild/tools/GCC3.kmk +++ b/kBuild/tools/GCC3.kmk @@ -1,10 +1,10 @@ -# $Id: GCC3.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GCC3.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC and Binutils. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -63,6 +63,12 @@ else TOOL_GCC3_LD_MAP ?= TOOL_GCC3_LD_SYSMOD_MAP ?= endif +if1of ($(KBUILD_HOST), solaris) + TOOL_GCC3_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE) +else + TOOL_GCC3_OBJCOPY ?= objcopy$(HOSTSUFF_EXE) +endif + ifdef SLKRUNS TOOL_GCC3_CC += -fmessage-length=0 TOOL_GCC3_CXX += -fmessage-length=0 @@ -129,6 +135,7 @@ define TOOL_GCC3_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC3_COMPILE_C_OUTPUT = @@ -138,6 +145,7 @@ define TOOL_GCC3_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -171,6 +179,7 @@ define TOOL_GCC3_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC3_COMPILE_CXX_OUTPUT = @@ -180,6 +189,7 @@ define TOOL_GCC3_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -206,6 +216,7 @@ define TOOL_GCC3_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -251,6 +262,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC3_LINK_PROGRAM_OUTPUT = TOOL_GCC3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map +TOOL_GCC3_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC3_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GCC3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def, $(othersrc)) TOOL_GCC3_LINK_PROGRAM_DEPORD = @@ -260,6 +273,11 @@ define TOOL_GCC3_LINK_PROGRAM_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC3_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -278,17 +296,24 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC3_LINK_DLL_OUTPUT = TOOL_GCC3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map +TOOL_GCC3_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC3_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GCC3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def, $(othersrc)) TOOL_GCC3_LINK_DLL_DEPORD = define TOOL_GCC3_LINK_DLL_CMDS $(QUIET)$(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $(out)\ - $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\ + $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\ $(objs)\ $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC3_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -307,6 +332,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC3_LINK_SYSMOD_OUTPUT = TOOL_GCC3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map +TOOL_GCC3_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC3_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GCC3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def, $(othersrc)) TOOL_GCC3_LINK_SYSMOD_DEPORD = @@ -316,5 +343,10 @@ define TOOL_GCC3_LINK_SYSMOD_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef diff --git a/kBuild/tools/GCC32.kmk b/kBuild/tools/GCC32.kmk index 4403c29..cf3ed32 100644 --- a/kBuild/tools/GCC32.kmk +++ b/kBuild/tools/GCC32.kmk @@ -1,10 +1,10 @@ -# $Id: GCC32.kmk 2246 2009-01-18 02:08:37Z bird $ +# $Id: GCC32.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic 32-bit GCC v3.2.x or later Using The System GCC. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -58,9 +58,15 @@ TOOL_GCC32_LD_SYSMOD_MAP ?= -Zmap=$(1) else TOOL_GCC32_LD_SYSMOD_MAP ?= endif +if1of ($(KBUILD_HOST), solaris) + TOOL_GCC32_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE) +else + TOOL_GCC32_OBJCOPY ?= objcopy$(HOSTSUFF_EXE) +endif + ifdef SLKRUNS -TOOL_GCC32_CC += -fmessage-length=0 -TOOL_GCC32_CXX += -fmessage-length=0 + TOOL_GCC32_CC += -fmessage-length=0 + TOOL_GCC32_CXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -124,6 +130,7 @@ define TOOL_GCC32_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC32_COMPILE_C_OUTPUT = @@ -133,6 +140,7 @@ define TOOL_GCC32_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -166,6 +174,7 @@ define TOOL_GCC32_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE @@ -176,6 +185,7 @@ define TOOL_GCC32_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -202,6 +212,7 @@ define TOOL_GCC32_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -221,7 +232,10 @@ define TOOL_GCC32_LINK_LIBRARY_CMDS $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)' $(QUIET)$(APPEND) -n $(out).ar-script \ $(foreach o,$(objs), 'ADDMOD $(o)') \ - $(foreach o,$(othersrc), 'ADDLIB $(o)') + $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)') + $(if $(filter %.def %.imp,$(othersrc))\ + ,$(TOOL_GCC32_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\ + $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a') $(QUIET)$(APPEND) $(out).ar-script 'SAVE' $(QUIET)$(APPEND) $(out).ar-script 'END' $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC32_AR) -M @@ -243,13 +257,21 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC32_LINK_PROGRAM_OUTPUT = TOOL_GCC32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map -TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) +TOOL_GCC32_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC32_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug +TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ + $(filter %.def, $(othersrc)) TOOL_GCC32_LINK_PROGRAM_DEPORD = define TOOL_GCC32_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_GCC32_LD) $(flags) -o $(out) $(objs)\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC32_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -268,7 +290,10 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC32_LINK_DLL_OUTPUT = TOOL_GCC32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map -TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) +TOOL_GCC32_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC32_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug +TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ + $(filter %.def, $(othersrc)) TOOL_GCC32_LINK_DLL_DEPORD = define TOOL_GCC32_LINK_DLL_CMDS $(QUIET)$(TOOL_GCC32_LD) $(TOOL_GCC32_LDFLAGS.dll) $(flags) -o $(out)\ @@ -277,6 +302,11 @@ define TOOL_GCC32_LINK_DLL_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC32_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -295,12 +325,21 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC32_LINK_SYSMOD_OUTPUT = TOOL_GCC32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map -TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) +TOOL_GCC32_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC32_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug +TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ + $(filter %.def, $(othersrc)) TOOL_GCC32_LINK_SYSMOD_DEPORD = define TOOL_GCC32_LINK_SYSMOD_CMDS $(QUIET)$(TOOL_GCC32_LD_SYSMOD) $(TOOL_GCC32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\ + $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC32_LD_SYSMOD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef diff --git a/kBuild/tools/GCC3OMF.kmk b/kBuild/tools/GCC3OMF.kmk index 660034d..1d2ecb2 100644 --- a/kBuild/tools/GCC3OMF.kmk +++ b/kBuild/tools/GCC3OMF.kmk @@ -1,10 +1,10 @@ -# $Id: GCC3OMF.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GCC3OMF.kmk 2534 2011-08-02 14:13:06Z bird $ ## @file # kBuild Tool Config - GCC v3 targeting OS/2 OMF. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -116,6 +116,7 @@ define TOOL_GCC3OMF_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC3OMF_COMPILE_C_OUTPUT = @@ -125,6 +126,7 @@ define TOOL_GCC3OMF_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -159,6 +161,7 @@ define TOOL_GCC3OMF_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC3OMF_COMPILE_CXX_OUTPUT = @@ -168,6 +171,7 @@ define TOOL_GCC3OMF_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -194,6 +198,7 @@ define TOOL_GCC3OMF_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -247,6 +252,9 @@ define TOOL_GCC3OMF_LINK_PROGRAM_CMDS $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ -Zmap=$(outbase).map $(QUIET)$(TOOL_GCC3OMF_LD) @$(outbase).rsp +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requrested for $(target), but this feature is not supported by GCC3OMF.) +endif endef @@ -278,6 +286,9 @@ define TOOL_GCC3OMF_LINK_DLL_CMDS $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ -Zmap=$(outbase).map $(TOOL_GCC3OMF_LD) @$(outbase).rsp +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requrested for $(target), but this feature is not supported by GCC3OMF.) +endif endef @@ -309,5 +320,8 @@ define TOOL_GCC3OMF_LINK_SYSMOD_CMDS $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ -Zmap=$(outbase).map $(QUIET)$(TOOL_GCC3OMF_LD_SYSMOD) @$(outbase).rsp +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requrested for $(target), but this feature is not supported by GCC3OMF.) +endif endef diff --git a/kBuild/tools/GCC3PLAIN.kmk b/kBuild/tools/GCC3PLAIN.kmk index e3a5ad1..30c7673 100644 --- a/kBuild/tools/GCC3PLAIN.kmk +++ b/kBuild/tools/GCC3PLAIN.kmk @@ -1,10 +1,10 @@ -# $Id: GCC3PLAIN.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GCC3PLAIN.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -122,6 +122,7 @@ define TOOL_GCC3PLAIN_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC3PLAIN_COMPILE_C_OUTPUT = @@ -131,6 +132,7 @@ define TOOL_GCC3PLAIN_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -164,6 +166,7 @@ define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT = @@ -173,6 +176,7 @@ define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -199,6 +203,7 @@ define TOOL_GCC3PLAIN_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -252,6 +257,9 @@ define TOOL_GCC3PLAIN_LINK_PROGRAM_CMDS $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GCC3PLAIN.) +endif endef @@ -280,6 +288,9 @@ define TOOL_GCC3PLAIN_LINK_DLL_CMDS $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GCC3PLAIN.) +endif endef @@ -311,5 +322,8 @@ define TOOL_GCC3PLAIN_LINK_SYSMOD_CMDS $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GCC3PLAIN.) +endif endef diff --git a/kBuild/tools/GCC4MACHO.kmk b/kBuild/tools/GCC4MACHO.kmk index add6f10..b288e75 100644 --- a/kBuild/tools/GCC4MACHO.kmk +++ b/kBuild/tools/GCC4MACHO.kmk @@ -1,10 +1,10 @@ -# $Id: GCC4MACHO.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GCC4MACHO.kmk 2535 2011-08-02 19:05:34Z bird $ ## @file # kBuild Tool Config - GCC v4 targeting Darwin (Mac OS X) Mach-o. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -34,12 +34,15 @@ TOOL_GCC4MACHO := GCC v4 targeting Darwin (Mac OS X) Mach-o. # Tool Specific Properties -TOOL_GCC4MACHO_CC ?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_CXX ?= g++$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_OBJC?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_AS ?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_LD ?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_LD_SYSMOD ?= gcc$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_PREFIX ?= +TOOL_GCC4MACHO_SUFFIX ?= $(HOSTSUFF_EXE) +TOOL_GCC4MACHO_CC ?= $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) +TOOL_GCC4MACHO_CXX ?= $(TOOL_GCC4MACHO_PREFIX)g++$(TOOL_GCC4MACHO_SUFFIX) +TOOL_GCC4MACHO_OBJC ?= $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) +TOOL_GCC4MACHO_OBJCXX ?= $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) +TOOL_GCC4MACHO_AS ?= $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) +TOOL_GCC4MACHO_LD ?= $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) +TOOL_GCC4MACHO_LD_SYSMOD ?= $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) ifndef TOOL_GCC4MACHO_LDFLAGS.$(KBUILD_TARGET) TOOL_GCC4MACHO_LDFLAGS.dll ?= -dynamiclib else @@ -47,11 +50,13 @@ TOOL_GCC4MACHO_LDFLAGS.dll ?= $(TOOL_GCC4MACHO_LDFLAGS.$(KBUILD_TARGET)) endif TOOL_GCC4MACHO_LDFLAGS.sysmod ?= -r #TOOL_GCC4MACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2))) +TOOL_GCC4MACHO_DSYMUTIL ?= dsymutil ifdef SLKRUNS -TOOL_GCC4MACHO_CC += -fmessage-length=0 -TOOL_GCC4MACHO_CXX += -fmessage-length=0 -TOOL_GCC4MACHO_OBJC+= -fmessage-length=0 +TOOL_GCC4MACHO_CC += -fmessage-length=0 +TOOL_GCC4MACHO_CXX += -fmessage-length=0 +TOOL_GCC4MACHO_OBJC += -fmessage-length=0 +TOOL_GCC4MACHO_OBJCXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -64,7 +69,6 @@ TOOL_GCC4MACHO_CINCS ?= TOOL_GCC4MACHO_CDEFS ?= TOOL_GCC4MACHO_CXXOBJSUFF ?= .o -TOOL_GCC4MACHO_CXXOBJSUFF ?= .o TOOL_GCC4MACHO_CXXFLAGS ?= TOOL_GCC4MACHO_CXXFLAGS.debug ?= -g TOOL_GCC4MACHO_CXXFLAGS.profile ?= -g -O2 #-pg @@ -73,7 +77,6 @@ TOOL_GCC4MACHO_CXXINCS ?= TOOL_GCC4MACHO_CXXDEFS ?= TOOL_GCC4MACHO_OBJCOBJSUFF ?= .o -TOOL_GCC4MACHO_OBJCOBJSUFF ?= .o TOOL_GCC4MACHO_OBJCFLAGS ?= TOOL_GCC4MACHO_OBJCFLAGS.debug ?= -g TOOL_GCC4MACHO_OBJCFLAGS.profile?= -O2 #-g -pg @@ -81,6 +84,14 @@ TOOL_GCC4MACHO_OBJCFLAGS.release?= -O2 TOOL_GCC4MACHO_OBJCINCS ?= TOOL_GCC4MACHO_OBJCDEFS ?= +TOOL_GCC4MACHO_OBJCXXOBJSUFF ?= .o +TOOL_GCC4MACHO_OBJCXXFLAGS ?= +TOOL_GCC4MACHO_OBJCXXFLAGS.debug ?= -g +TOOL_GCC4MACHO_OBJCXXFLAGS.profile ?= -O2 #-g -pg +TOOL_GCC4MACHO_OBJCXXFLAGS.release ?= -O2 +TOOL_GCC4MACHO_OBJCXXINCS ?= +TOOL_GCC4MACHO_OBJCXXDEFS ?= + TOOL_GCC4MACHO_ASFLAGS ?= -x assembler-with-cpp TOOL_GCC4MACHO_ASFLAGS.debug ?= -g TOOL_GCC4MACHO_ASFLAGS.profile ?= -g @@ -94,6 +105,39 @@ TOOL_GCC4MACHO_LDFLAGS ?= TOOL_GCC4MACHO_LDFLAGS.debug ?= -g TOOL_GCC4MACHO_LDFLAGS.profile ?= -g +TOOL_GCC4MACHO_STRIP_PROGRAM ?= strip -SXxru +TOOL_GCC4MACHO_STRIP_DLL ?= strip -Sxru +TOOL_GCC4MACHO_STRIP_SYSMOD ?= strip -Sru + + +## +# Calculate the files in the debug bundle. +# @param 1 The whole output filename. +# @param 2 The output filename sans suffix. +TOOL_GCC4MACHO_DEBUG_BUNDLE_FN = \ + $(1).dSYM/ \ + $(1).dSYM/Contents/ \ + $(1).dSYM/Contents/Resources/ \ + $(1).dSYM/Contents/Resources/DWARF/ \ + $(1).dSYM/Contents/Info.plist \ + $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1)) + +## +# Calculate the files in the debug bundle. +# @param 1 The whole linker output filename. +# @param 2 The linker output filename sans suffix. +# @param 3 The desired install name (no dir slash). +# @remarks The Info.plist has some reference to the original name, but gdb +# does not care and only check for a symbol file in the DWARF +# directory with the same name as the debugged module. +TOOL_GCC4MACHO_DEBUG_INSTALL_FN= \ + $(3).dSYM/ \ + $(3).dSYM/Contents/ \ + $(3).dSYM/Contents/Resources/ \ + $(3).dSYM/Contents/Resources/DWARF/ \ + $(1).dSYM/Contents/Info.plist=>$(3).dSYM/Contents/Info.plist \ + $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1))=>$(3).dSYM/Contents/Resources/DWARF/$(notdir $(3)) + ## Compile C source. # @param $(target) Normalized main target name. @@ -125,6 +169,7 @@ define TOOL_GCC4MACHO_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC4MACHO_COMPILE_C_OUTPUT = @@ -134,6 +179,7 @@ define TOOL_GCC4MACHO_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KUSE_OBJCACHE @@ -167,6 +213,7 @@ define TOOL_GCC4MACHO_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC4MACHO_COMPILE_CXX_OUTPUT = @@ -176,6 +223,7 @@ define TOOL_GCC4MACHO_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -209,6 +257,7 @@ define TOOL_GCC4MACHO_COMPILE_OBJC_CMDS $(flags) -fpreprocessed -x cbjective-c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC4MACHO_COMPILE_OBJC_OUTPUT = @@ -218,6 +267,51 @@ define TOOL_GCC4MACHO_COMPILE_OBJC_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" +endef +endif # !KBUILD_USE_KOBJCACHE + + +## Compile Objective-C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_GCC4MACHO_COMPILE_OBJCXX_DEPEND = +TOOL_GCC4MACHO_COMPILE_OBJCXX_DEPORD = +ifdef KBUILD_USE_KOBJCACHE +TOOL_GCC4MACHO_COMPILE_OBJCXX_USES_KOBJCACHE = 1 +TOOL_GCC4MACHO_COMPILE_OBJCXX_OUTPUT = $(outbase).mii +define TOOL_GCC4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\ + --kObjCache-cpp $(outbase).mii\ + $(TOOL_GCC4MACHO_OBJCXX) -E -o -\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + $(abspath $(source))\ + --kObjCache-cc $(obj)\ + $(TOOL_GCC4MACHO_OBJCXX) -c\ + $(flags) -fpreprocessed -x objective-c++\ + -o $(obj)\ + - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" +endef +else # !KBUILD_USE_KOBJCACHE +TOOL_GCC4MACHO_COMPILE_OBJCXX_OUTPUT = +define TOOL_GCC4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(TOOL_GCC4MACHO_OBJCXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + -o $(obj)\ + $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -244,6 +338,7 @@ define TOOL_GCC4MACHO_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -288,6 +383,8 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC4MACHO_LINK_PROGRAM_OUTPUT = $(outbase).rsp +TOOL_GCC4MACHO_LINK_PROGRAM_OUTPUT_DEBUG = $(call TOOL_GCC4MACHO_DEBUG_BUNDLE_FN,$(out)) +TOOL_GCC4MACHO_LINK_PROGRAM_DEBUG_INSTALL_FN = $(TOOL_GCC4MACHO_DEBUG_INSTALL_FN) TOOL_GCC4MACHO_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GCC4MACHO_LINK_PROGRAM_DEPORD = define TOOL_GCC4MACHO_LINK_PROGRAM_CMDS @@ -296,9 +393,14 @@ define TOOL_GCC4MACHO_LINK_PROGRAM_CMDS -filelist $(outbase).rsp\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) + ifeq ($(ld_debug),split) + $(QUIET)$(TOOL_GCC4MACHO_DSYMUTIL) -o $(out).dSYM/ $(out) + $(QUIET)$(TOOL_GCC4MACHO_STRIP_PROGRAM) $(out) + endif endef + ## Link DLL # @param $(target) Normalized main target name. # @param $(out) Program name. @@ -313,6 +415,8 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC4MACHO_LINK_DLL_OUTPUT = $(outbase).rsp +TOOL_GCC4MACHO_LINK_DLL_OUTPUT_DEBUG = $(call TOOL_GCC4MACHO_DEBUG_BUNDLE_FN,$(out)) +TOOL_GCC4MACHO_LINK_DLL_DEBUG_INSTALL_FN = $(TOOL_GCC4MACHO_DEBUG_INSTALL_FN) TOOL_GCC4MACHO_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GCC4MACHO_LINK_DLL_DEPORD = define TOOL_GCC4MACHO_LINK_DLL_CMDS @@ -322,6 +426,10 @@ define TOOL_GCC4MACHO_LINK_DLL_CMDS -filelist $(outbase).rsp\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) + ifeq ($(ld_debug),split) + $(QUIET)$(TOOL_GCC4MACHO_DSYMUTIL) -o $(out).dSYM/ $(out) + $(QUIET)$(TOOL_GCC4MACHO_STRIP_DLL) $(out) + endif endef @@ -339,6 +447,8 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC4MACHO_LINK_SYSMOD_OUTPUT = $(outbase).rsp +TOOL_GCC4MACHO_LINK_SYSMOD_OUTPUT_DEBUG = $(call TOOL_GCC4MACHO_DEBUG_BUNDLE_FN,$(out)) +TOOL_GCC4MACHO_LINK_SYSMOD_DEBUG_INSTALL_FN = $(TOOL_GCC4MACHO_DEBUG_INSTALL_FN) TOOL_GCC4MACHO_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GCC4MACHO_LINK_SYSMOD_DEPORD = define TOOL_GCC4MACHO_LINK_SYSMOD_CMDS @@ -347,5 +457,9 @@ define TOOL_GCC4MACHO_LINK_SYSMOD_CMDS -filelist $(outbase).rsp\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) + ifeq ($(ld_debug),split) + $(QUIET)$(TOOL_GCC4MACHO_DSYMUTIL) -o $(out).dSYM/ $(out) + $(QUIET)$(TOOL_GCC4MACHO_STRIP_SYSMOD) $(out) + endif endef diff --git a/kBuild/tools/GCC64.kmk b/kBuild/tools/GCC64.kmk index 976cbc6..d2a8b27 100644 --- a/kBuild/tools/GCC64.kmk +++ b/kBuild/tools/GCC64.kmk @@ -1,10 +1,10 @@ -# $Id: GCC64.kmk 2246 2009-01-18 02:08:37Z bird $ +# $Id: GCC64.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic 64-bit GCC v3.2.x or later Using The System GCC. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -58,9 +58,15 @@ TOOL_GCC64_LD_SYSMOD_MAP ?= -Zmap=$(1) else TOOL_GCC64_LD_SYSMOD_MAP ?= endif +if1of ($(KBUILD_HOST), solaris) + TOOL_GCC64_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE) +else + TOOL_GCC64_OBJCOPY ?= objcopy$(HOSTSUFF_EXE) +endif + ifdef SLKRUNS -TOOL_GCC64_CC += -fmessage-length=0 -TOOL_GCC64_CXX += -fmessage-length=0 + TOOL_GCC64_CC += -fmessage-length=0 + TOOL_GCC64_CXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -124,6 +130,7 @@ define TOOL_GCC64_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GCC64_COMPILE_C_OUTPUT = @@ -133,6 +140,7 @@ define TOOL_GCC64_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -166,9 +174,9 @@ define TOOL_GCC64_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE - TOOL_GCC64_COMPILE_CXX_OUTPUT = define TOOL_GCC64_COMPILE_CXX_CMDS $(QUIET)$(TOOL_GCC64_CXX) -c\ @@ -176,6 +184,7 @@ define TOOL_GCC64_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -202,6 +211,7 @@ define TOOL_GCC64_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -243,6 +253,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC64_LINK_PROGRAM_OUTPUT = TOOL_GCC64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map +TOOL_GCC64_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC64_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GCC64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GCC64_LINK_PROGRAM_DEPORD = define TOOL_GCC64_LINK_PROGRAM_CMDS @@ -250,6 +262,11 @@ define TOOL_GCC64_LINK_PROGRAM_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC64_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -268,6 +285,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC64_LINK_DLL_OUTPUT = TOOL_GCC64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map +TOOL_GCC64_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC64_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GCC64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GCC64_LINK_DLL_DEPORD = define TOOL_GCC64_LINK_DLL_CMDS @@ -277,6 +296,11 @@ define TOOL_GCC64_LINK_DLL_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC64_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -295,6 +319,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GCC64_LINK_SYSMOD_OUTPUT = TOOL_GCC64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map +TOOL_GCC64_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug +TOOL_GCC64_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GCC64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GCC64_LINK_SYSMOD_DEPORD = define TOOL_GCC64_LINK_SYSMOD_CMDS @@ -302,5 +328,10 @@ define TOOL_GCC64_LINK_SYSMOD_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GCC64_LD_SYSMOD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef diff --git a/kBuild/tools/GXX.kmk b/kBuild/tools/GXX.kmk index 5fc21c6..2b87513 100644 --- a/kBuild/tools/GXX.kmk +++ b/kBuild/tools/GXX.kmk @@ -1,10 +1,10 @@ -# $Id: GXX.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GXX.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic GCC using the system GCC, for building C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -101,6 +101,7 @@ define TOOL_GXX_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -126,6 +127,7 @@ define TOOL_GXX_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -151,6 +153,7 @@ define TOOL_GXX_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -202,6 +205,9 @@ TOOL_GXX_LINK_PROGRAM_DEPORD = define TOOL_GXX_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(objs) \ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GXX.) +endif endef @@ -224,5 +230,8 @@ TOOL_GXX_LINK_DLL_DEPORD = define TOOL_GXX_LINK_DLL_CMDS $(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(objs) \ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GXX.) +endif endef diff --git a/kBuild/tools/GXX3.kmk b/kBuild/tools/GXX3.kmk index 332a00c..b1e3fa4 100644 --- a/kBuild/tools/GXX3.kmk +++ b/kBuild/tools/GXX3.kmk @@ -1,10 +1,10 @@ -# $Id: GXX3.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GXX3.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic GCC v3.2.x using the system GCC and Binutils, for building C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -63,6 +63,12 @@ else TOOL_GXX3_LD_MAP ?= TOOL_GXX3_LD_SYSMOD_MAP ?= endif +if1of ($(KBUILD_HOST), solaris) + TOOL_GXX3_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE) +else + TOOL_GXX3_OBJCOPY ?= objcopy$(HOSTSUFF_EXE) +endif + ifdef SLKRUNS TOOL_GXX3_CC += -fmessage-length=0 TOOL_GXX3_CXX += -fmessage-length=0 @@ -129,6 +135,7 @@ define TOOL_GXX3_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX3_COMPILE_C_OUTPUT = @@ -138,6 +145,7 @@ define TOOL_GXX3_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -171,6 +179,7 @@ define TOOL_GXX3_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX3_COMPILE_CXX_OUTPUT = @@ -180,6 +189,7 @@ define TOOL_GXX3_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -206,6 +216,7 @@ define TOOL_GXX3_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -251,6 +262,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX3_LINK_PROGRAM_OUTPUT = TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map +TOOL_GXX3_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX3_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def, $(othersrc)) TOOL_GXX3_LINK_PROGRAM_DEPORD = @@ -260,6 +273,11 @@ define TOOL_GXX3_LINK_PROGRAM_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX3_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -278,17 +296,24 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX3_LINK_DLL_OUTPUT = TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map +TOOL_GXX3_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX3_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def, $(othersrc)) TOOL_GXX3_LINK_DLL_DEPORD = define TOOL_GXX3_LINK_DLL_CMDS $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\ - $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\ + $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\ $(objs)\ $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX3_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -307,6 +332,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX3_LINK_SYSMOD_OUTPUT = TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map +TOOL_GXX3_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX3_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def, $(othersrc)) TOOL_GXX3_LINK_SYSMOD_DEPORD = @@ -316,5 +343,10 @@ define TOOL_GXX3_LINK_SYSMOD_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef diff --git a/kBuild/tools/GXX32.kmk b/kBuild/tools/GXX32.kmk index 1dea597..6c5b82e 100644 --- a/kBuild/tools/GXX32.kmk +++ b/kBuild/tools/GXX32.kmk @@ -1,10 +1,10 @@ -# $Id: GXX32.kmk 2246 2009-01-18 02:08:37Z bird $ +# $Id: GXX32.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -58,9 +58,15 @@ TOOL_GXX32_LD_SYSMOD_MAP ?= -Zmap=$(1) else TOOL_GXX32_LD_SYSMOD_MAP ?= endif +if1of ($(KBUILD_HOST), solaris) + TOOL_GXX32_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE) +else + TOOL_GXX32_OBJCOPY ?= objcopy$(HOSTSUFF_EXE) +endif + ifdef SLKRUNS -TOOL_GXX32_CC += -fmessage-length=0 -TOOL_GXX32_CXX += -fmessage-length=0 + TOOL_GXX32_CC += -fmessage-length=0 + TOOL_GXX32_CXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -124,6 +130,7 @@ define TOOL_GXX32_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX32_COMPILE_C_OUTPUT = @@ -133,6 +140,7 @@ define TOOL_GXX32_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -166,6 +174,7 @@ define TOOL_GXX32_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX32_COMPILE_CXX_OUTPUT = @@ -175,6 +184,7 @@ define TOOL_GXX32_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -201,6 +211,7 @@ define TOOL_GXX32_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -220,7 +231,10 @@ define TOOL_GXX32_LINK_LIBRARY_CMDS $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)' $(QUIET)$(APPEND) -n $(out).ar-script \ $(foreach o,$(objs), 'ADDMOD $(o)') \ - $(foreach o,$(othersrc), 'ADDLIB $(o)') + $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)') + $(if $(filter %.def %.imp,$(othersrc))\ + ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\ + $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a') $(QUIET)$(APPEND) $(out).ar-script 'SAVE' $(QUIET)$(APPEND) $(out).ar-script 'END' $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX32_AR) -M @@ -242,13 +256,21 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX32_LINK_PROGRAM_OUTPUT = TOOL_GXX32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map -TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) +TOOL_GXX32_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX32_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug +TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ + $(filter %.def, $(othersrc)) TOOL_GXX32_LINK_PROGRAM_DEPORD = define TOOL_GXX32_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX32_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -267,7 +289,10 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX32_LINK_DLL_OUTPUT = TOOL_GXX32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map -TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) +TOOL_GXX32_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX32_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug +TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ + $(filter %.def, $(othersrc)) TOOL_GXX32_LINK_DLL_DEPORD = define TOOL_GXX32_LINK_DLL_CMDS $(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\ @@ -276,6 +301,11 @@ define TOOL_GXX32_LINK_DLL_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX32_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -294,12 +324,21 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX32_LINK_SYSMOD_OUTPUT = TOOL_GXX32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map -TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) +TOOL_GXX32_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX32_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug +TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ + $(filter %.def, $(othersrc)) TOOL_GXX32_LINK_SYSMOD_DEPORD = define TOOL_GXX32_LINK_SYSMOD_CMDS $(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\ + $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX32_LD_SYSMOD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef diff --git a/kBuild/tools/GXX3OMF.kmk b/kBuild/tools/GXX3OMF.kmk index 58ed9de..3e413a5 100644 --- a/kBuild/tools/GXX3OMF.kmk +++ b/kBuild/tools/GXX3OMF.kmk @@ -1,10 +1,10 @@ -# $Id: GXX3OMF.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GXX3OMF.kmk 2534 2011-08-02 14:13:06Z bird $ ## @file # kBuild Tool Config - GCC v3 targeting OS/2 OMF, for building C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -116,6 +116,7 @@ define TOOL_GXX3OMF_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX3OMF_COMPILE_C_OUTPUT = @@ -125,6 +126,7 @@ define TOOL_GXX3OMF_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -159,6 +161,7 @@ define TOOL_GXX3OMF_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX3OMF_COMPILE_CXX_OUTPUT = @@ -168,6 +171,7 @@ define TOOL_GXX3OMF_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -194,6 +198,7 @@ define TOOL_GXX3OMF_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -247,6 +252,9 @@ define TOOL_GXX3OMF_LINK_PROGRAM_CMDS $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ -Zmap=$(outbase).map $(QUIET)$(TOOL_GXX3OMF_LD) @$(outbase).rsp +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requrested for $(target), but this feature is not supported by GXX3OMF.) +endif endef @@ -278,6 +286,9 @@ define TOOL_GXX3OMF_LINK_DLL_CMDS $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ -Zmap=$(outbase).map $(TOOL_GXX3OMF_LD) @$(outbase).rsp +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requrested for $(target), but this feature is not supported by GXX3OMF.) +endif endef @@ -309,5 +320,8 @@ define TOOL_GXX3OMF_LINK_SYSMOD_CMDS $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ -Zmap=$(outbase).map $(QUIET)$(TOOL_GXX3OMF_LD_SYSMOD) @$(outbase).rsp +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requrested for $(target), but this feature is not supported by GXX3OMF.) +endif endef diff --git a/kBuild/tools/GXX3PLAIN.kmk b/kBuild/tools/GXX3PLAIN.kmk index bf26958..733014e 100644 --- a/kBuild/tools/GXX3PLAIN.kmk +++ b/kBuild/tools/GXX3PLAIN.kmk @@ -1,10 +1,10 @@ -# $Id: GXX3PLAIN.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GXX3PLAIN.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -122,6 +122,7 @@ define TOOL_GXX3PLAIN_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX3PLAIN_COMPILE_C_OUTPUT = @@ -131,6 +132,7 @@ define TOOL_GXX3PLAIN_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -164,6 +166,7 @@ define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT = @@ -173,6 +176,7 @@ define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -199,6 +203,7 @@ define TOOL_GXX3PLAIN_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -252,6 +257,9 @@ define TOOL_GXX3PLAIN_LINK_PROGRAM_CMDS $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GXX3PLAIN.) +endif endef @@ -280,6 +288,9 @@ define TOOL_GXX3PLAIN_LINK_DLL_CMDS $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GXX3PLAIN.) +endif endef @@ -311,5 +322,8 @@ define TOOL_GXX3PLAIN_LINK_SYSMOD_CMDS $(filter %.def, $(othersrc))\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) +if1of ($(ld_debug), split) + $(warning kBuild: Debug splitting is requested for $(target), but this feature is not supported by GXX3PLAIN.) +endif endef diff --git a/kBuild/tools/GXX4MACHO.kmk b/kBuild/tools/GXX4MACHO.kmk index e5f1614..81789b9 100644 --- a/kBuild/tools/GXX4MACHO.kmk +++ b/kBuild/tools/GXX4MACHO.kmk @@ -1,10 +1,10 @@ -# $Id: GXX4MACHO.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: GXX4MACHO.kmk 2535 2011-08-02 19:05:34Z bird $ ## @file # kBuild Tool Config - GCC v4 targeting Darwin (Mac OS X) Mach-o, for building C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -34,12 +34,15 @@ TOOL_GXX4MACHO := GCC v4 targeting Darwin (Mac OS X) Mach-o, for building C++ code. # Tool Specific Properties -TOOL_GXX4MACHO_CC ?= gcc$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_CXX ?= g++$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_OBJC?= gcc$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_AS ?= gcc$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_LD ?= g++$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_LD_SYSMOD ?= g++$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_PREFIX ?= +TOOL_GXX4MACHO_SUFFIX ?= $(HOSTSUFF_EXE) +TOOL_GXX4MACHO_CC ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX) +TOOL_GXX4MACHO_CXX ?= $(TOOL_GXX4MACHO_PREFIX)g++$(TOOL_GXX4MACHO_SUFFIX) +TOOL_GXX4MACHO_OBJC ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX) +TOOL_GXX4MACHO_OBJCXX ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX) +TOOL_GXX4MACHO_AS ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX) +TOOL_GXX4MACHO_LD ?= $(TOOL_GXX4MACHO_PREFIX)g++$(TOOL_GXX4MACHO_SUFFIX) +TOOL_GXX4MACHO_LD_SYSMOD ?= $(TOOL_GXX4MACHO_PREFIX)g++$(TOOL_GXX4MACHO_SUFFIX) ifndef TOOL_GXX4MACHO_LDFLAGS.$(KBUILD_TARGET) TOOL_GXX4MACHO_LDFLAGS.dll ?= -dynamiclib else @@ -47,11 +50,13 @@ TOOL_GXX4MACHO_LDFLAGS.dll ?= $(TOOL_GXX4MACHO_LDFLAGS.$(KBUILD_TARGET)) endif TOOL_GXX4MACHO_LDFLAGS.sysmod ?= -r #TOOL_GXX4MACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2))) +TOOL_GXX4MACHO_DSYMUTIL ?= dsymutil ifdef SLKRUNS -TOOL_GXX4MACHO_CC += -fmessage-length=0 -TOOL_GXX4MACHO_CXX += -fmessage-length=0 -TOOL_GXX4MACHO_OBJC+= -fmessage-length=0 +TOOL_GXX4MACHO_CC += -fmessage-length=0 +TOOL_GXX4MACHO_CXX += -fmessage-length=0 +TOOL_GXX4MACHO_OBJC += -fmessage-length=0 +TOOL_GXX4MACHO_OBJCXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -64,7 +69,6 @@ TOOL_GXX4MACHO_CINCS ?= TOOL_GXX4MACHO_CDEFS ?= TOOL_GXX4MACHO_CXXOBJSUFF ?= .o -TOOL_GXX4MACHO_CXXOBJSUFF ?= .o TOOL_GXX4MACHO_CXXFLAGS ?= TOOL_GXX4MACHO_CXXFLAGS.debug ?= -g TOOL_GXX4MACHO_CXXFLAGS.profile ?= -O2 #-g -pg @@ -73,7 +77,6 @@ TOOL_GXX4MACHO_CXXINCS ?= TOOL_GXX4MACHO_CXXDEFS ?= TOOL_GXX4MACHO_OBJCOBJSUFF ?= .o -TOOL_GXX4MACHO_OBJCOBJSUFF ?= .o TOOL_GXX4MACHO_OBJCFLAGS ?= TOOL_GXX4MACHO_OBJCFLAGS.debug ?= -g TOOL_GXX4MACHO_OBJCFLAGS.profile?= -O2 #-g -pg @@ -81,6 +84,14 @@ TOOL_GXX4MACHO_OBJCFLAGS.release?= -O2 TOOL_GXX4MACHO_OBJCINCS ?= TOOL_GXX4MACHO_OBJCDEFS ?= +TOOL_GXX4MACHO_OBJCXXOBJSUFF ?= .o +TOOL_GXX4MACHO_OBJCXXFLAGS ?= +TOOL_GXX4MACHO_OBJCXXFLAGS.debug ?= -g +TOOL_GXX4MACHO_OBJCXXFLAGS.profile ?= -O2 #-g -pg +TOOL_GXX4MACHO_OBJCXXFLAGS.release ?= -O2 +TOOL_GXX4MACHO_OBJCXXINCS ?= +TOOL_GXX4MACHO_OBJCXXDEFS ?= + TOOL_GXX4MACHO_ASFLAGS ?= -x assembler-with-cpp TOOL_GXX4MACHO_ASFLAGS.debug ?= -g TOOL_GXX4MACHO_ASFLAGS.profile ?= -g @@ -94,6 +105,39 @@ TOOL_GXX4MACHO_LDFLAGS ?= TOOL_GXX4MACHO_LDFLAGS.debug ?= -g TOOL_GXX4MACHO_LDFLAGS.profile ?= -g +TOOL_GXX4MACHO_STRIP_PROGRAM ?= strip -SXxru +TOOL_GXX4MACHO_STRIP_DLL ?= strip -Sxru +TOOL_GXX4MACHO_STRIP_SYSMOD ?= strip -Sru + + +## +# Calculate the files in the debug bundle. +# @param 1 The whole output filename. +# @param 2 The output filename sans suffix. +TOOL_GXX4MACHO_DEBUG_BUNDLE_FN = \ + $(1).dSYM/ \ + $(1).dSYM/Contents/ \ + $(1).dSYM/Contents/Resources/ \ + $(1).dSYM/Contents/Resources/DWARF/ \ + $(1).dSYM/Contents/Info.plist \ + $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1)) + +## +# Calculate the files in the debug bundle. +# @param 1 The whole linker output filename. +# @param 2 The linker output filename sans suffix. +# @param 3 The desired install name (no dir slash). +# @remarks The Info.plist has some reference to the original name, but gdb +# does not care and only check for a symbol file in the DWARF +# directory with the same name as the debugged module. +TOOL_GXX4MACHO_DEBUG_INSTALL_FN= \ + $(3).dSYM/ \ + $(3).dSYM/Contents/ \ + $(3).dSYM/Contents/Resources/ \ + $(3).dSYM/Contents/Resources/DWARF/ \ + $(1).dSYM/Contents/Info.plist=>$(3).dSYM/Contents/Info.plist \ + $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1))=>$(3).dSYM/Contents/Resources/DWARF/$(notdir $(3)) + ## Compile C source. # @param $(target) Normalized main target name. @@ -125,6 +169,7 @@ define TOOL_GXX4MACHO_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX4MACHO_COMPILE_C_OUTPUT = @@ -134,6 +179,7 @@ define TOOL_GXX4MACHO_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KUSE_OBJCACHE @@ -167,6 +213,7 @@ define TOOL_GXX4MACHO_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX4MACHO_COMPILE_CXX_OUTPUT = @@ -176,8 +223,9 @@ define TOOL_GXX4MACHO_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef -endif # !KUSE_OBJCACHE +endif # !KBUILD_USE_KOBJCACHE ## Compile Objective-C source. @@ -209,6 +257,7 @@ define TOOL_GXX4MACHO_COMPILE_OBJC_CMDS $(flags) -fpreprocessed -x objective-c \ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX4MACHO_COMPILE_OBJC_OUTPUT = @@ -218,8 +267,53 @@ define TOOL_GXX4MACHO_COMPILE_OBJC_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef -endif # !KUSE_OBJCACHE +endif # !KBUILD_USE_KOBJCACHE + + +## Compile Objective-C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_GXX4MACHO_COMPILE_OBJCXX_DEPEND = +TOOL_GXX4MACHO_COMPILE_OBJCXX_DEPORD = +ifdef KBUILD_USE_KOBJCACHE +TOOL_GXX4MACHO_COMPILE_OBJCXX_USES_KOBJCACHE = 1 +TOOL_GXX4MACHO_COMPILE_OBJCXX_OUTPUT = $(outbase).mii +define TOOL_GXX4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\ + --kObjCache-cpp $(outbase).mii\ + $(TOOL_GXX4MACHO_OBJCXX) -E -o -\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + $(abspath $(source))\ + --kObjCache-cc $(obj)\ + $(TOOL_GXX4MACHO_OBJCXX) -c\ + $(flags) -fpreprocessed -x objective-c++ \ + -o $(obj)\ + - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" +endef +else # !KBUILD_USE_KOBJCACHE +TOOL_GXX4MACHO_COMPILE_OBJCXX_OUTPUT = +define TOOL_GXX4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(TOOL_GXX4MACHO_OBJCXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + -o $(obj)\ + $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" +endef +endif # !KBUILD_USE_KOBJCACHE ## Compile Assembly source. @@ -244,6 +338,7 @@ define TOOL_GXX4MACHO_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -288,6 +383,8 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX4MACHO_LINK_PROGRAM_OUTPUT = $(outbase).rsp +TOOL_GXX4MACHO_LINK_PROGRAM_OUTPUT_DEBUG = $(call TOOL_GXX4MACHO_DEBUG_BUNDLE_FN,$(out)) +TOOL_GXX4MACHO_LINK_PROGRAM_DEBUG_INSTALL_FN = $(TOOL_GXX4MACHO_DEBUG_INSTALL_FN) TOOL_GXX4MACHO_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GXX4MACHO_LINK_PROGRAM_DEPORD = define TOOL_GXX4MACHO_LINK_PROGRAM_CMDS @@ -296,6 +393,10 @@ define TOOL_GXX4MACHO_LINK_PROGRAM_CMDS -filelist $(outbase).rsp\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) + ifeq ($(ld_debug),split) + $(QUIET)$(TOOL_GXX4MACHO_DSYMUTIL) -o $(out).dSYM/ $(out) + $(QUIET)$(TOOL_GXX4MACHO_STRIP_PROGRAM) $(out) + endif endef @@ -313,6 +414,8 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX4MACHO_LINK_DLL_OUTPUT = $(outbase).rsp +TOOL_GXX4MACHO_LINK_DLL_OUTPUT_DEBUG = $(call TOOL_GXX4MACHO_DEBUG_BUNDLE_FN,$(out)) +TOOL_GXX4MACHO_LINK_DLL_DEBUG_INSTALL_FN = $(TOOL_GXX4MACHO_DEBUG_INSTALL_FN) TOOL_GXX4MACHO_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GXX4MACHO_LINK_DLL_DEPORD = define TOOL_GXX4MACHO_LINK_DLL_CMDS @@ -322,6 +425,10 @@ define TOOL_GXX4MACHO_LINK_DLL_CMDS -filelist $(outbase).rsp\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) + ifeq ($(ld_debug),split) + $(QUIET)$(TOOL_GXX4MACHO_DSYMUTIL) -o $(out).dSYM/ $(out) + $(QUIET)$(TOOL_GXX4MACHO_STRIP_DLL) $(out) + endif endef @@ -339,6 +446,8 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX4MACHO_LINK_SYSMOD_OUTPUT = $(outbase).rsp +TOOL_GXX4MACHO_LINK_SYSMOD_OUTPUT_DEBUG = $(call TOOL_GXX4MACHO_DEBUG_BUNDLE_FN,$(out)) +TOOL_GXX4MACHO_LINK_SYSMOD_DEBUG_INSTALL_FN = $(TOOL_GXX4MACHO_DEBUG_INSTALL_FN) TOOL_GXX4MACHO_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GXX4MACHO_LINK_SYSMOD_DEPORD = define TOOL_GXX4MACHO_LINK_SYSMOD_CMDS @@ -347,5 +456,9 @@ define TOOL_GXX4MACHO_LINK_SYSMOD_CMDS -filelist $(outbase).rsp\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib))) + ifeq ($(ld_debug),split) + $(QUIET)$(TOOL_GXX4MACHO_DSYMUTIL) -o $(out).dSYM/ $(out) + $(QUIET)$(TOOL_GXX4MACHO_STRIP_SYSMOD) $(out) + endif endef diff --git a/kBuild/tools/GXX64.kmk b/kBuild/tools/GXX64.kmk index 9d36160..35cabfc 100644 --- a/kBuild/tools/GXX64.kmk +++ b/kBuild/tools/GXX64.kmk @@ -1,10 +1,10 @@ -# $Id: GXX64.kmk 2246 2009-01-18 02:08:37Z bird $ +# $Id: GXX64.kmk 2541 2011-08-03 09:51:30Z bird $ ## @file # kBuild Tool Config - Generic 64-bit GCC v3.2.x or later using the system GCC, for building C++ code. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -58,9 +58,15 @@ TOOL_GXX64_LD_SYSMOD_MAP ?= -Zmap=$(1) else TOOL_GXX64_LD_SYSMOD_MAP ?= endif +if1of ($(KBUILD_HOST), solaris) + TOOL_GXX64_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE) +else + TOOL_GXX64_OBJCOPY ?= objcopy$(HOSTSUFF_EXE) +endif + ifdef SLKRUNS -TOOL_GXX64_CC += -fmessage-length=0 -TOOL_GXX64_CXX += -fmessage-length=0 + TOOL_GXX64_CC += -fmessage-length=0 + TOOL_GXX64_CXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -124,6 +130,7 @@ define TOOL_GXX64_COMPILE_C_CMDS $(flags) -fpreprocessed -x c\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX64_COMPILE_C_OUTPUT = @@ -133,6 +140,7 @@ define TOOL_GXX64_COMPILE_C_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -166,6 +174,7 @@ define TOOL_GXX64_COMPILE_CXX_CMDS $(flags) -fpreprocessed -x c++\ -o $(obj)\ - + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef else # !KBUILD_USE_KOBJCACHE TOOL_GXX64_COMPILE_CXX_OUTPUT = @@ -175,6 +184,7 @@ define TOOL_GXX64_COMPILE_CXX_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef endif # !KBUILD_USE_KOBJCACHE @@ -201,6 +211,7 @@ define TOOL_GXX64_COMPILE_AS_CMDS -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) + $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef @@ -242,6 +253,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX64_LINK_PROGRAM_OUTPUT = TOOL_GXX64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map +TOOL_GXX64_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX64_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GXX64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GXX64_LINK_PROGRAM_DEPORD = define TOOL_GXX64_LINK_PROGRAM_CMDS @@ -249,6 +262,11 @@ define TOOL_GXX64_LINK_PROGRAM_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX64_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -267,6 +285,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX64_LINK_DLL_OUTPUT = TOOL_GXX64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map +TOOL_GXX64_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX64_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GXX64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GXX64_LINK_DLL_DEPORD = define TOOL_GXX64_LINK_DLL_CMDS @@ -276,6 +296,11 @@ define TOOL_GXX64_LINK_DLL_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX64_LD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef @@ -294,6 +319,8 @@ endef # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_GXX64_LINK_SYSMOD_OUTPUT = TOOL_GXX64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map +TOOL_GXX64_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug +TOOL_GXX64_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug TOOL_GXX64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) TOOL_GXX64_LINK_SYSMOD_DEPORD = define TOOL_GXX64_LINK_SYSMOD_CMDS @@ -301,5 +328,10 @@ define TOOL_GXX64_LINK_SYSMOD_CMDS $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ $(call TOOL_GXX64_LD_SYSMOD_MAP,$(outbase).map) + ifeq ($(ld_debug),split) + $(TOOL_GXX64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug + $(CHMOD) a-x $(outbase).debug + $(TOOL_GXX64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out) + endif endef diff --git a/kBuild/tools/MASM510.kmk b/kBuild/tools/MASM510.kmk index d0ddb60..4cba932 100644 --- a/kBuild/tools/MASM510.kmk +++ b/kBuild/tools/MASM510.kmk @@ -1,10 +1,10 @@ -# $Id: MASM510.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MASM510.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - MASM v5.10 # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/MASM600.kmk b/kBuild/tools/MASM600.kmk index 62697de..07215df 100644 --- a/kBuild/tools/MASM600.kmk +++ b/kBuild/tools/MASM600.kmk @@ -1,10 +1,10 @@ -# $Id: MASM600.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MASM600.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - MASM v6.00 # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/MASM610.kmk b/kBuild/tools/MASM610.kmk index cb9d408..bf83373 100644 --- a/kBuild/tools/MASM610.kmk +++ b/kBuild/tools/MASM610.kmk @@ -1,10 +1,10 @@ -# $Id: MASM610.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MASM610.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - MASM v6.10 # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/MASM6PLUS.kmk b/kBuild/tools/MASM6PLUS.kmk index 47c3cc6..3377b98 100644 --- a/kBuild/tools/MASM6PLUS.kmk +++ b/kBuild/tools/MASM6PLUS.kmk @@ -1,10 +1,10 @@ -# $Id: MASM6PLUS.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MASM6PLUS.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - MASM v6 and later. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/MASM710.kmk b/kBuild/tools/MASM710.kmk index 12c38ad..7410907 100644 --- a/kBuild/tools/MASM710.kmk +++ b/kBuild/tools/MASM710.kmk @@ -1,10 +1,10 @@ -# $Id: MASM710.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MASM710.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - MASM v7.10 # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/MINGW32.kmk b/kBuild/tools/MINGW32.kmk index 9a62056..c3104ae 100644 --- a/kBuild/tools/MINGW32.kmk +++ b/kBuild/tools/MINGW32.kmk @@ -1,10 +1,10 @@ -# $Id: MINGW32.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MINGW32.kmk 2487 2011-07-21 20:01:27Z bird $ ## @file # kBuild Tool Config - MinGW32 GCC v3.3+. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -253,11 +253,11 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_MINGW32_LINK_DLL_OUTPUT = -TOOL_MINGW32_LINK_DLL_OUTPUT_MAYBE = $(outbase).a $(outbase).exp $(PATH_LIB)/$(notdir $(outbase)).exp $(PATH_LIB)/$(notdir $(outbase)).a +TOOL_MINGW32_LINK_DLL_OUTPUT_MAYBE = $(outbase).a $(outbase).exp $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp $(PATH_STAGE_LIB)/$(notdir $(outbase)).a ## @todo Find a better solution for installing the extra files (.a, .exp, .pdb, etc). TOOL_MINGW32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\ $(filter %.def %.res,$(othersrc)) -TOOL_MINGW32_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB)) +TOOL_MINGW32_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) define TOOL_MINGW32_LINK_DLL_CMDS $(QUIET)$(TOOL_MINGW32_DLLWRAP) $(flags)\ --dllname=$(out)\ @@ -268,6 +268,6 @@ define TOOL_MINGW32_LINK_DLL_CMDS $(objs)\ $(foreach p,$(libpath), -L$(p))\ $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) - $(QUIET)$(CP) $(outbase).exp $(outbase).a $(PATH_LIB)/ + $(QUIET)$(CP) $(outbase).exp $(outbase).a $(PATH_STAGE_LIB)/ endef ## @todo separate install stuff! diff --git a/kBuild/tools/MSLINK510.kmk b/kBuild/tools/MSLINK510.kmk index 0bcf25c..fe66aef 100644 --- a/kBuild/tools/MSLINK510.kmk +++ b/kBuild/tools/MSLINK510.kmk @@ -1,10 +1,10 @@ -# $Id: MSLINK510.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: MSLINK510.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Microsoft Link v5.10 # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/NASM.kmk b/kBuild/tools/NASM.kmk index cff10bf..83d2970 100644 --- a/kBuild/tools/NASM.kmk +++ b/kBuild/tools/NASM.kmk @@ -1,10 +1,10 @@ -# $Id: NASM.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: NASM.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Netwide Assembler v0.98+. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/OPENWATCOM-16.kmk b/kBuild/tools/OPENWATCOM-16.kmk index 7c7868b..2789afb 100644 --- a/kBuild/tools/OPENWATCOM-16.kmk +++ b/kBuild/tools/OPENWATCOM-16.kmk @@ -1,11 +1,11 @@ -# $Id: OPENWATCOM-16.kmk 2316 2009-03-19 16:31:52Z bird $ +# $Id: OPENWATCOM-16.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Open Watcom v1.4 and later, 16-bit targets. # # @remarks wrc is untested, so are DLLs, and programs. # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/OPENWATCOM-WL.kmk b/kBuild/tools/OPENWATCOM-WL.kmk index 54e2fe4..bc5d526 100644 --- a/kBuild/tools/OPENWATCOM-WL.kmk +++ b/kBuild/tools/OPENWATCOM-WL.kmk @@ -1,11 +1,11 @@ -# $Id: OPENWATCOM-WL.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: OPENWATCOM-WL.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Open Watcom v1.4 and later, using wlink. # # @remarks wrc is untested, so are DLLs, and programs. # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/OPENWATCOM.kmk b/kBuild/tools/OPENWATCOM.kmk index 4003b2f..157474a 100644 --- a/kBuild/tools/OPENWATCOM.kmk +++ b/kBuild/tools/OPENWATCOM.kmk @@ -1,10 +1,10 @@ -# $Id: OPENWATCOM.kmk 2316 2009-03-19 16:31:52Z bird $ +# $Id: OPENWATCOM.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Open Watcom v1.4 and later. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/TAR.kmk b/kBuild/tools/TAR.kmk index 1b92af0..5d1f653 100644 --- a/kBuild/tools/TAR.kmk +++ b/kBuild/tools/TAR.kmk @@ -1,10 +1,10 @@ -# $Id: TAR.kmk 2275 2009-02-20 23:46:29Z bird $ +# $Id: TAR.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - tar unpacker. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/TARBZ2.kmk b/kBuild/tools/TARBZ2.kmk index 125bf62..987321d 100644 --- a/kBuild/tools/TARBZ2.kmk +++ b/kBuild/tools/TARBZ2.kmk @@ -1,10 +1,10 @@ -# $Id: TARBZ2.kmk 2275 2009-02-20 23:46:29Z bird $ +# $Id: TARBZ2.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - tar.bz2 unpacker. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/TARGZ.kmk b/kBuild/tools/TARGZ.kmk index cac8c2f..a52ac57 100644 --- a/kBuild/tools/TARGZ.kmk +++ b/kBuild/tools/TARGZ.kmk @@ -1,10 +1,10 @@ -# $Id: TARGZ.kmk 2275 2009-02-20 23:46:29Z bird $ +# $Id: TARGZ.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - tar.gz unpacker. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/VAC308.kmk b/kBuild/tools/VAC308.kmk index e4f7a8c..79a9a8a 100644 --- a/kBuild/tools/VAC308.kmk +++ b/kBuild/tools/VAC308.kmk @@ -1,10 +1,10 @@ -# $Id: VAC308.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: VAC308.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - VisualAge for C++ v3.08. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/VCC100.kmk b/kBuild/tools/VCC100.kmk new file mode 100644 index 0000000..bec59f9 --- /dev/null +++ b/kBuild/tools/VCC100.kmk @@ -0,0 +1,348 @@ +# $Id: VCC100.kmk 2524 2011-08-01 13:37:47Z bird $ +## @file +# kBuild Tool Config - Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting $(KBUILD_TARGET). +# + +# +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +TOOL_VCC100 := Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting $(KBUILD_TARGET). + +# Tool Specific Properties +ifndef PATH_TOOL_VCC100 + PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS_TRG)/vcc/v10*) + ifeq ($(PATH_TOOL_VCC100),) + PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS)/win.x86/vcc/v10*) + endif + ifeq ($(PATH_TOOL_VCC100),) + PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS)/x86.win32/vcc/v10*) + endif + ifeq ($(PATH_TOOL_VCC100),) + PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS)/win.amd64/vcc/v10*) + endif + ifeq ($(PATH_TOOL_VCC100),) + PATH_TOOL_VCC100 := $(lastword $(sort $(PATH_TOOL_VCC100))) + endif + # if not found, we'll enter 'pathless' mode. +else + # Resolve any fancy stuff once and for all. + PATH_TOOL_VCC100 := $(PATH_TOOL_VCC100) +endif +ifneq ($(PATH_TOOL_VCC100),) + ifeq ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),win.amd64) + PATH_TOOL_VCC100_BIN.amd64 ?= $(PATH_TOOL_VCC100)/bin/amd64 + else + PATH_TOOL_VCC100_BIN.amd64 ?= $(PATH_TOOL_VCC100)/bin/x86_amd64 + endif + PATH_TOOL_VCC100_BIN.x86 ?= $(PATH_TOOL_VCC100)/bin + PATH_TOOL_VCC100_BIN ?= $(PATH_TOOL_VCC100_BIN.$(KBUILD_TARGET_ARCH)) + PATH_TOOL_VCC100_LIB.amd64 ?= $(PATH_TOOL_VCC100)/lib/amd64 + PATH_TOOL_VCC100_LIB.x86 ?= $(PATH_TOOL_VCC100)/lib + PATH_TOOL_VCC100_LIB ?= $(PATH_TOOL_VCC100_LIB.$(KBUILD_TARGET_ARCH)) + PATH_TOOL_VCC100_INC ?= $(PATH_TOOL_VCC100)/include + PATH_TOOL_VCC100_ATLMFC ?= $(PATH_TOOL_VCC100X86)/atlmfc + PATH_TOOL_VCC100_ATLMFC_INC ?= $(PATH_TOOL_VCC100_ATLMFC)/include + PATH_TOOL_VCC100_ATLMFC_LIB.amd64 ?= $(PATH_TOOL_VCC100_ATLMFC)/lib + PATH_TOOL_VCC100_ATLMFC_LIB.x86 ?= $(PATH_TOOL_VCC100_ATLMFC)/lib/amd64 + PATH_TOOL_VCC100_ATLMFC_LIB ?= $(PATH_TOOL_VCC100_ATLMFC_LIB.$(KBUILD_TARGET_ARCH)) + TOOL_VCC100_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/cl.exe + TOOL_VCC100_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/cl.exe + TOOL_VCC100_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/ml64.exe + TOOL_VCC100_RC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN.x86)/rc.exe + TOOL_VCC100_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/lib.exe + TOOL_VCC100_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/link.exe + TOOL_VCC100_MT ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN.x86)/mt.exe +else + # Pathless, relies on the environment. + TOOL_VCC100_CC ?= $(EXEC_X86_WIN32) cl.exe + TOOL_VCC100_CXX ?= $(EXEC_X86_WIN32) cl.exe + TOOL_VCC100_AS ?= $(EXEC_X86_WIN32) ml64.exe + TOOL_VCC100_RC ?= $(EXEC_X86_WIN32) rc.exe + TOOL_VCC100_AR ?= $(EXEC_X86_WIN32) lib.exe + TOOL_VCC100_LD ?= $(EXEC_X86_WIN32) link.exe + TOOL_VCC100_MT ?= $(EXEC_X86_WIN32) mt.exe +endif +## Disabled fast DEP_IDB based dependencies. +#VCC100_OLD_DEPS = 1 + +## Constructs the correct .pdb name (the name is lowercased). +# @param $(1) Base name, no extention. +# @param $(2) The extension. +TOOL_VCC100_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2) + +TOOL_VCC100_COBJSUFF ?= .obj +TOOL_VCC100_CFLAGS ?= -TC -c -nologo +TOOL_VCC100_CFLAGS.debug ?= -Od -Zi +TOOL_VCC100_CFLAGS.release ?= -O2 +TOOL_VCC100_CFLAGS.profile ?= -O2 +TOOL_VCC100_CINCS ?= $(PATH_TOOL_VCC100_INC) +TOOL_VCC100_CDEFS ?= + +TOOL_VCC100_CXXOBJSUFF ?= .obj +TOOL_VCC100_CXXFLAGS ?= -TP -c -nologo +TOOL_VCC100_CXXFLAGS.debug ?= -Od -Zi +TOOL_VCC100_CXXFLAGS.release ?= -O2 +TOOL_VCC100_CXXFLAGS.profile ?= -O2 +TOOL_VCC100_CXXINCS ?= $(PATH_TOOL_VCC100_INC) $(PATH_TOOL_VCC100_ATLMFC_INC) +TOOL_VCC100_CXXDEFS ?= + +TOOL_VCC100_ASOBJSUFF ?= .obj + +TOOL_VCC100_RCOBJSUFF ?= .res +TOOL_VCC100_RCINCS ?= $(PATH_TOOL_VCC100_INC) $(PATH_TOOL_VCC100_ATLMFC_INC) + +TOOL_VCC100_ARFLAGS.amd64 ?= -machine:amd64 +TOOL_VCC100_ARFLAGS.x86 ?= -machine:x86 +TOOL_VCC100_ARFLAGS ?= -nologo +TOOL_VCC100_ARLIBSUFF ?= .lib + +TOOL_VCC100_LDFLAGS.amd64 ?= -machine:amd64 +TOOL_VCC100_LDFLAGS.x86 ?= -machine:x86 +TOOL_VCC100_LDFLAGS ?= -nologo +TOOL_VCC100_LDFLAGS.debug ?= -debug +TOOL_VCC100_LDFLAGS.release ?= +TOOL_VCC100_LIBPATH.amd64 ?= $(PATH_TOOL_VCC100_LIB.amd64) $(PATH_TOOL_VCC100_ATLMFC_LIB.amd64) +TOOL_VCC100_LIBPATH.x86 ?= $(PATH_TOOL_VCC100_LIB.x86) $(PATH_TOOL_VCC100_ATLMFC_LIB.x86) + + + +## Compile C source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100_COMPILE_C_DEPEND = +TOOL_VCC100_COMPILE_C_DEPORD = +TOOL_VCC100_COMPILE_C_OUTPUT = $(call TOOL_VCC100_PDB, $(outbase)-obj,idb) +TOOL_VCC100_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC100_PDB, $(outbase)-obj,pdb) +define TOOL_VCC100_COMPILE_C_CMDS + $(QUIET)$(TOOL_VCC100_CC) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,$(abspath $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100_PDB,$(outbase)-obj,idb) +endef + + +## Compile C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100_COMPILE_CXX_DEPEND = +TOOL_VCC100_COMPILE_CXX_DEPORD = +TOOL_VCC100_COMPILE_CXX_OUTPUT = $(call TOOL_VCC100_PDB, $(outbase)-obj,idb) +TOOL_VCC100_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC100_PDB, $(outbase)-obj,pdb) +define TOOL_VCC100_COMPILE_CXX_CMDS + $(QUIET)$(TOOL_VCC100_CXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,$(abspath $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100_PDB,$(outbase)-obj,idb) +endef + + +## Compile resource source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100_COMPILE_RC_OUTPUT = +TOOL_VCC100_COMPILE_RC_DEPEND = +TOOL_VCC100_COMPILE_RC_DEPORD = +define TOOL_VCC100_COMPILE_RC_CMDS + $(QUIET)$(TOOL_VCC100_RC) \ + $(flags) $(addprefix /i, $(subst /,\\,$(incs))) $(addprefix /d, $(defs))\ + /fo$(obj)\ + $(subst /,\\,$(abspath $(source))) +endef + + +## Link library +# @param $(target) Normalized main target name. +# @param $(out) Library name. +# @param $(objs) Object files to put in the library. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(outbase) Output basename (full). Use this for list files and such. +# +TOOL_VCC100_LINK_LIBRARY_DEPEND = $(othersrc) +TOOL_VCC100_LINK_LIBRARY_DEPORD = +TOOL_VCC100_LINK_LIBRARY_OUTPUT = $(outbase).rsp +TOOL_VCC100_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb +define TOOL_VCC100_LINK_LIBRARY_CMDS + $(QUIET)$(APPEND) -n $(outbase).rsp \ + $(foreach arg,\ + $(subst /,\\,$(objs) \ + $(filter-out %.def,$(othersrc))) \ + $(addprefix /DEF:,$(filter %.def,$(othersrc))) \ + ,\"$(arg)\") + $(QUIET)$(TOOL_VCC100_AR) $(flags) /OUT:$(out) @$(outbase).rsp +endef + + + + +## Link program +# @param $(target) Normalized main target name. +# @param $(out) Program name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# @param $(outbase) Output basename (full). Use this for list files and such. +# +TOOL_VCC100_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100_LINK_PROGRAM_DEPORD = +TOOL_VCC100_LINK_PROGRAM_OUTPUT = $(outbase).map +TOOL_VCC100_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC100_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100_LINK_PROGRAM_CMDS + $(QUIET)$(TOOL_VCC100_LD) $(flags) \ + /OUT:$(out) \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out)) +endef + + +## Link DLL. +# @param $(target) Normalized main target name. +# @param $(out) DLL name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +TOOL_VCC100_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) +TOOL_VCC100_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp +TOOL_VCC100_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC100_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100_LINK_DLL_CMDS + $(QUIET)$(TOOL_VCC100_LD) $(flags) \ + /OUT:$(out) \ + /IMPLIB:$(outbase).lib \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + /DLL \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) +endef + + +## Link system module (windows aka driver, linux aka kernel module) +# @param $(target) Normalized main target name. +# @param $(out) System module name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +TOOL_VCC100_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100_LINK_SYSMOD_DEPORD = +TOOL_VCC100_LINK_SYSMOD_OUTPUT = $(outbase).map +TOOL_VCC100_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC100_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100_LINK_SYSMOD_CMDS + $(QUIET)$(TOOL_VCC100_LD) $(flags) \ + /OUT:$(out) \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' +endef + diff --git a/kBuild/tools/VCC100AMD64.kmk b/kBuild/tools/VCC100AMD64.kmk new file mode 100644 index 0000000..eee77af --- /dev/null +++ b/kBuild/tools/VCC100AMD64.kmk @@ -0,0 +1,366 @@ +# $Id: VCC100AMD64.kmk 2524 2011-08-01 13:37:47Z bird $ +## @file +# kBuild Tool Config - Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting AMD64. +# + +# +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +TOOL_VCC100AMD64 := Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting AMD64 + +# Tool Specific Properties +ifndef PATH_TOOL_VCC100AMD64 + PATH_TOOL_VCC100AMD64 := $(wildcard $(PATH_DEVTOOLS)/win.x86/vcc/v10*) + ifeq ($(PATH_TOOL_VCC100AMD64),) + PATH_TOOL_VCC100AMD64 := $(PATH_TOOL_VCC100) + endif + ifeq ($(PATH_TOOL_VCC100AMD64),) + PATH_TOOL_VCC100AMD64 := $(PATH_TOOL_VCC100X86) + endif + ifeq ($(PATH_TOOL_VCC100AMD64),) + PATH_TOOL_VCC100AMD64 := $(wildcard $(PATH_DEVTOOLS)/win.x86/vcc/v10*) + endif + ifneq ($(PATH_TOOL_VCC100AMD64),) + PATH_TOOL_VCC100AMD64 := $(lastword $(sort $(PATH_TOOL_VCC100AMD64))) + else + $(warning kBuild: PATH_TOOL_VCC100AMD64 cannot be determined!) + PATH_TOOL_VCC100AMD64 := $(PATH_DEVTOOLS)/win.x86/vcc/v10 + endif +else + # Resolve any fancy stuff once and for all. + PATH_TOOL_VCC100AMD64 := $(PATH_TOOL_VCC100AMD64) +endif +ifeq ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),win.amd64) +PATH_TOOL_VCC100AMD64_BIN ?= $(PATH_TOOL_VCC100AMD64)/bin/amd64 +else +PATH_TOOL_VCC100AMD64_BIN ?= $(PATH_TOOL_VCC100AMD64)/bin/x86_amd64 +endif +PATH_TOOL_VCC100AMD64_LIB ?= $(PATH_TOOL_VCC100AMD64)/lib/amd64 +PATH_TOOL_VCC100AMD64_INC ?= $(PATH_TOOL_VCC100AMD64)/include +PATH_TOOL_VCC100AMD64_ATLMFC ?= $(PATH_TOOL_VCC100AMD64)/atlmfc +PATH_TOOL_VCC100AMD64_ATLMFC_INC ?= $(PATH_TOOL_VCC100AMD64_ATLMFC)/include +PATH_TOOL_VCC100AMD64_ATLMFC_LIB ?= $(PATH_TOOL_VCC100AMD64_ATLMFC)/lib/amd64 +TOOL_VCC100AMD64_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/cl.exe +TOOL_VCC100AMD64_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/cl.exe +TOOL_VCC100AMD64_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/ml64.exe +TOOL_VCC100AMD64_RC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/../rc.exe +TOOL_VCC100AMD64_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/lib.exe +TOOL_VCC100AMD64_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/link.exe +TOOL_VCC100AMD64_MT ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100AMD64_BIN)/../mt.exe +## Disabled fast DEP_IDB based dependencies. +#VCC100AMD64_OLD_DEPS = 1 + +## Constructs the correct .pdb name (the name is lowercased). +# @param $(1) Base name, no extention. +# @param $(2) The extension. +TOOL_VCC100AMD64_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2) + +TOOL_VCC100AMD64_COBJSUFF ?= .obj +TOOL_VCC100AMD64_CFLAGS ?= -TC -c -nologo +TOOL_VCC100AMD64_CFLAGS.debug ?= -Od -Zi +TOOL_VCC100AMD64_CFLAGS.release ?= -O2 +TOOL_VCC100AMD64_CFLAGS.profile ?= -O2 +TOOL_VCC100AMD64_CINCS ?= $(PATH_TOOL_VCC100AMD64_INC) +TOOL_VCC100AMD64_CDEFS ?= + +TOOL_VCC100AMD64_CXXOBJSUFF ?= .obj +TOOL_VCC100AMD64_CXXFLAGS ?= -TP -c -nologo +TOOL_VCC100AMD64_CXXFLAGS.debug ?= -Od -Zi +TOOL_VCC100AMD64_CXXFLAGS.release ?= -O2 +TOOL_VCC100AMD64_CXXFLAGS.profile ?= -O2 +TOOL_VCC100AMD64_CXXINCS ?= $(PATH_TOOL_VCC100AMD64_INC) $(PATH_TOOL_VCC100AMD64_ATLMFC_INC) +TOOL_VCC100AMD64_CXXDEFS ?= + +TOOL_VCC100AMD64_ASOBJSUFF ?= .obj + +TOOL_VCC100AMD64_RCOBJSUFF ?= .res +TOOL_VCC100AMD64_RCINCS ?= $(PATH_TOOL_VCC100AMD64_INC) $(PATH_TOOL_VCC100AMD64_ATLMFC_INC) + +TOOL_VCC100AMD64_ARFLAGS ?= -nologo -machine:amd64 +TOOL_VCC100AMD64_ARLIBSUFF ?= .lib + +TOOL_VCC100AMD64_LDFLAGS ?= -nologo -machine:amd64 +TOOL_VCC100AMD64_LDFLAGS.debug ?= -debug +TOOL_VCC100AMD64_LDFLAGS.release ?= + + + +## Compile C source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100AMD64_COMPILE_C_DEPEND = +TOOL_VCC100AMD64_COMPILE_C_DEPORD = +TOOL_VCC100AMD64_COMPILE_C_OUTPUT = $(call TOOL_VCC100AMD64_PDB, $(outbase)-obj,idb) +TOOL_VCC100AMD64_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC100AMD64_PDB, $(outbase)-obj,pdb) +define TOOL_VCC100AMD64_COMPILE_C_CMDS + $(QUIET)$(TOOL_VCC100AMD64_CC) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,$(abspath $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100AMD64_PDB,$(outbase)-obj,idb) +endef + + +## Compile C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100AMD64_COMPILE_CXX_DEPEND = +TOOL_VCC100AMD64_COMPILE_CXX_DEPORD = +ifdef KBUILD_USE_KOBJCACHE +TOOL_VCC100AMD64_COMPILE_CXX_USES_KOBJCACHE = 1 +TOOL_VCC100AMD64_COMPILE_CXX_OUTPUT = $(call TOOL_VCC100AMD64_PDB, $(outbase)-obj,idb) $(outbase).ii +TOOL_VCC100AMD64_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC100AMD64_PDB, $(outbase)-obj,pdb) +if 1 +define TOOL_VCC100AMD64_COMPILE_CXX_CMDS + $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -r\ + --named-pipe-compile $(subst /,\\,//./pipe/kObjCache/$(translate $(outbase),:,_)/$(notdir $(source)))\ + --kObjCache-cpp $(outbase).ii\ + $(TOOL_VCC100AMD64_CXX) -E\ + $(flags)\ + $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + $(subst /,\\,$(abspath $(source))) \ + --kObjCache-cc $(obj)\ + windbg $(TOOL_VCC100AMD64_CXX) -c -TP\ + $(flags)\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,//./pipe/kObjCache/$(translate $(outbase),:,_)/$(notdir $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100AMD64_PDB,$(outbase)-obj,idb) +endef +else +define TOOL_VCC100AMD64_COMPILE_CXX_CMDS + $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -r\ + --kObjCache-cpp $(outbase).ii\ + $(TOOL_VCC100AMD64_CXX) -E\ + $(flags)\ + $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + $(subst /,\\,$(abspath $(source))) \ + --kObjCache-cc $(obj)\ + $(TOOL_VCC100AMD64_CXX) -c -TP\ + $(flags)\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(outbase).ii + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100AMD64_PDB,$(outbase)-obj,idb) +endef +endif +else # !KBUILD_USE_KOBJCACHE +TOOL_VCC100AMD64_COMPILE_CXX_OUTPUT = $(call TOOL_VCC100AMD64_PDB, $(outbase)-obj,idb) +TOOL_VCC100AMD64_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC100AMD64_PDB, $(outbase)-obj,pdb) +define TOOL_VCC100AMD64_COMPILE_CXX_CMDS + $(QUIET)$(TOOL_VCC100AMD64_CXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,$(abspath $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100AMD64_PDB,$(outbase)-obj,idb) +endef +endif # !KBUILD_USE_KOBJCACHE + +## Compile resource source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100AMD64_COMPILE_RC_DEPEND = +TOOL_VCC100AMD64_COMPILE_RC_DEPORD = +TOOL_VCC100AMD64_COMPILE_RC_OUTPUT = +define TOOL_VCC100AMD64_COMPILE_RC_CMDS + $(QUIET)$(TOOL_VCC100AMD64_RC) \ + $(flags) $(addprefix /i, $(subst /,\\,$(incs))) $(addprefix /d, $(defs))\ + /fo$(obj)\ + $(subst /,\\,$(abspath $(source))) +endef + + +## Link library +# @param $(target) Normalized main target name. +# @param $(out) Library name. +# @param $(objs) Object files to put in the library. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(outbase) Output basename (full). Use this for list files and such. +# +TOOL_VCC100AMD64_LINK_LIBRARY_DEPEND = $(othersrc) +TOOL_VCC100AMD64_LINK_LIBRARY_DEPORD = +TOOL_VCC100AMD64_LINK_LIBRARY_OUTPUT = $(outbase).rsp +TOOL_VCC100AMD64_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb +define TOOL_VCC100AMD64_LINK_LIBRARY_CMDS + $(QUIET)$(APPEND) -n $(outbase).rsp \ + $(foreach arg,\ + $(subst /,\\,$(objs) \ + $(filter-out %.def,$(othersrc))) \ + $(addprefix /DEF:,$(filter %.def,$(othersrc))) \ + ,\"$(arg)\") + $(QUIET)$(TOOL_VCC100AMD64_AR) $(flags) /OUT:$(out) @$(outbase).rsp +endef + + +## Link program +# @param $(target) Normalized main target name. +# @param $(out) Program name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# @param $(outbase) Output basename (full). Use this for list files and such. +# +TOOL_VCC100AMD64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100AMD64_LINK_PROGRAM_DEPORD = +TOOL_VCC100AMD64_LINK_PROGRAM_OUTPUT = $(outbase).map +TOOL_VCC100AMD64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC100AMD64_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100AMD64_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100AMD64_LINK_PROGRAM_CMDS + $(QUIET)$(TOOL_VCC100AMD64_LD) $(flags) \ + /OUT:$(out) \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100AMD64_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out)) +endef + + +## Link DLL. +# @param $(target) Normalized main target name. +# @param $(out) DLL name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +TOOL_VCC100AMD64_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100AMD64_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) +TOOL_VCC100AMD64_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp +TOOL_VCC100AMD64_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC100AMD64_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100AMD64_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100AMD64_LINK_DLL_CMDS + $(QUIET)$(TOOL_VCC100AMD64_LD) $(flags) \ + /OUT:$(out) \ + /IMPLIB:$(outbase).lib \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + /DLL \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100AMD64_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) +endef + + +## Link system module (windows aka driver, linux aka kernel module) +# @param $(target) Normalized main target name. +# @param $(out) System module name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +TOOL_VCC100AMD64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100AMD64_LINK_SYSMOD_DEPORD = +TOOL_VCC100AMD64_LINK_SYSMOD_OUTPUT = $(outbase).map +TOOL_VCC100AMD64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC100AMD64_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100AMD64_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100AMD64_LINK_SYSMOD_CMDS + $(QUIET)$(TOOL_VCC100AMD64_LD) $(flags) \ + /OUT:$(out) \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100AMD64_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' +endef + diff --git a/kBuild/tools/VCC100X86.kmk b/kBuild/tools/VCC100X86.kmk new file mode 100644 index 0000000..75dc242 --- /dev/null +++ b/kBuild/tools/VCC100X86.kmk @@ -0,0 +1,327 @@ +# $Id: VCC100X86.kmk 2524 2011-08-01 13:37:47Z bird $ +## @file +# kBuild Tool Config - Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting x86. +# + +# +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# As a special exception you are granted permission to include this file, via +# the kmk include directive, as you wish without this in itself causing the +# resulting makefile, program or whatever to be covered by the GPL license. +# This exception does not however invalidate any other reasons why the makefile, +# program, whatever should not be covered the GPL. +# +# + +TOOL_VCC100X86 := Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting x86. + +# Tool Specific Properties +ifndef PATH_TOOL_VCC100X86 + PATH_TOOL_VCC100X86 := $(wildcard $(PATH_DEVTOOLS)/win.x86/vcc/v10*) + ifeq ($(PATH_TOOL_VCC100X86),) + PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100) + endif + ifeq ($(PATH_TOOL_VCC100X86),) + PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100AMD64) + endif + ifeq ($(PATH_TOOL_VCC100X86),) + PATH_TOOL_VCC100X86 := $(wildcard $(PATH_DEVTOOLS)/x86.win32/vcc/v10*) + endif + ifeq ($(PATH_TOOL_VCC100X86),) + PATH_TOOL_VCC100X86 := $(wildcard $(PATH_DEVTOOLS)/win.amd64/vcc/v10*) + endif + ifneq ($(PATH_TOOL_VCC100X86),) + PATH_TOOL_VCC100X86 := $(lastword $(sort $(PATH_TOOL_VCC100X86))) + else + $(warning kBuild: PATH_TOOL_VCC100X86 cannot be determined!) + PATH_TOOL_VCC100X86 := $(PATH_DEVTOOLS)/x86.win/vcc/v10 + endif +else + # Resolve any fancy stuff once and for all. + PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100X86) +endif +PATH_TOOL_VCC100X86_BIN ?= $(PATH_TOOL_VCC100X86)/bin +PATH_TOOL_VCC100X86_LIB ?= $(PATH_TOOL_VCC100X86)/lib +PATH_TOOL_VCC100X86_INC ?= $(PATH_TOOL_VCC100X86)/include +PATH_TOOL_VCC100X86_ATLMFC ?= $(PATH_TOOL_VCC100X86)/atlmfc +PATH_TOOL_VCC100X86_ATLMFC_INC ?= $(PATH_TOOL_VCC100X86_ATLMFC)/include +PATH_TOOL_VCC100X86_ATLMFC_LIB ?= $(PATH_TOOL_VCC100X86_ATLMFC)/lib +TOOL_VCC100X86_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/cl.exe +TOOL_VCC100X86_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/cl.exe +TOOL_VCC100X86_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/ml.exe +TOOL_VCC100X86_RC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/rc.exe +TOOL_VCC100X86_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/lib.exe +TOOL_VCC100X86_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/link.exe +TOOL_VCC100X86_MT ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/mt.exe +## Disabled fast DEP_IDB based dependencies. +#VCC100X86_OLD_DEPS = 1 + +## Constructs the correct .pdb name (the name is lowercased). +# @param $(1) Base name, no extention. +# @param $(2) The extension. +TOOL_VCC100X86_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2) + + +# General Properties used by kBuild +TOOL_VCC100X86_COBJSUFF ?= .obj +TOOL_VCC100X86_CFLAGS ?= -TC -c -nologo +TOOL_VCC100X86_CFLAGS.debug ?= -Zi +TOOL_VCC100X86_CFLAGS.release ?= -O2 +TOOL_VCC100X86_CFLAGS.profile ?= -O2 +TOOL_VCC100X86_CINCS ?= $(PATH_TOOL_VCC100X86_INC) +TOOL_VCC100X86_CDEFS ?= + +TOOL_VCC100X86_CXXOBJSUFF ?= .obj +TOOL_VCC100X86_CXXFLAGS ?= -TP -c -nologo +TOOL_VCC100X86_CXXFLAGS.debug ?= -Zi +TOOL_VCC100X86_CXXFLAGS.release ?= -O2 +TOOL_VCC100X86_CXXFLAGS.profile ?= -O2 +TOOL_VCC100X86_CXXINCS ?= $(PATH_TOOL_VCC100X86_INC) $(PATH_TOOL_VCC100X86_ATLMFC_INC) +TOOL_VCC100X86_CXXDEFS ?= + +TOOL_VCC100X86_ASOBJSUFF ?= .obj + +TOOL_VCC100X86_RCOBJSUFF ?= .res +TOOL_VCC100X86_RCINCS ?= $(PATH_TOOL_VCC100X86_INC) $(PATH_TOOL_VCC100X86_ATLMFC_INC) + +TOOL_VCC100X86_ARFLAGS ?= -nologo +TOOL_VCC100X86_ARLIBSUFF ?= .lib + +TOOL_VCC100X86_LDFLAGS ?= -nologo -machine:x86 +TOOL_VCC100X86_LDFLAGS.debug ?= -debug +TOOL_VCC100X86_LDFLAGS.release ?= + + + +## Compile C source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100X86_COMPILE_C_DEPEND = +TOOL_VCC100X86_COMPILE_C_DEPORD = +TOOL_VCC100X86_COMPILE_C_OUTPUT = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,idb) +TOOL_VCC100X86_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,pdb) +define TOOL_VCC100X86_COMPILE_C_CMDS + $(QUIET)$(TOOL_VCC100X86_CC) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,$(abspath $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100X86_PDB,$(outbase)-obj,idb) +endef + + +## Compile C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100X86_COMPILE_CXX_DEPEND = +TOOL_VCC100X86_COMPILE_CXX_DEPORD = +TOOL_VCC100X86_COMPILE_CXX_OUTPUT = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,idb) +TOOL_VCC100X86_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,pdb) +define TOOL_VCC100X86_COMPILE_CXX_CMDS + $(QUIET)$(TOOL_VCC100X86_CXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Fd$(outbase)-obj.pdb \ + -FD\ + -Fo$(obj)\ + $(subst /,\\,$(abspath $(source))) + $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100X86_PDB,$(outbase)-obj,idb) +endef + +## @todo configure the assembler template. + +## Compile resource source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_VCC100X86_COMPILE_RC_DEPEND = +TOOL_VCC100X86_COMPILE_RC_DEPORD = +TOOL_VCC100X86_COMPILE_RC_OUTPUT = +define TOOL_VCC100X86_COMPILE_RC_CMDS + $(QUIET)$(TOOL_VCC100X86_RC) \ + $(flags) $(addprefix /i, $(subst /,\\,$(incs))) $(addprefix /d, $(defs))\ + /fo$(obj)\ + $(subst /,\\,$(abspath $(source))) +endef + + +## Link library +# @param $(target) Normalized main target name. +# @param $(out) Library name. +# @param $(objs) Object files to put in the library. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(outbase) Output basename (full). Use this for list files and such. +# +TOOL_VCC100X86_LINK_LIBRARY_DEPEND = $(othersrc) +TOOL_VCC100X86_LINK_LIBRARY_DEPORD = +TOOL_VCC100X86_LINK_LIBRARY_OUTPUT = $(outbase).rsp +TOOL_VCC100X86_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb +define TOOL_VCC100X86_LINK_LIBRARY_CMDS + $(QUIET)$(APPEND) -n $(outbase).rsp \ + $(foreach arg,\ + $(subst /,\\,$(objs) \ + $(filter-out %.def,$(othersrc))) \ + $(addprefix /DEF:,$(filter %.def,$(othersrc))) \ + ,\"$(arg)\") + $(QUIET)$(TOOL_VCC100X86_AR) $(flags) /OUT:$(out) @$(outbase).rsp +endef + + +## Link program +# @param $(target) Normalized main target name. +# @param $(out) Program name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# @param $(outbase) Output basename (full). Use this for list files and such. +# +TOOL_VCC100X86_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100X86_LINK_PROGRAM_DEPORD = +TOOL_VCC100X86_LINK_PROGRAM_OUTPUT = $(outbase).map +TOOL_VCC100X86_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC100X86_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100X86_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100X86_LINK_PROGRAM_CMDS + $(QUIET)$(TOOL_VCC100X86_LD) $(flags) \ + /OUT:$(out) \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100X86_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out)) +endef + + +## Link DLL. +# @param $(target) Normalized main target name. +# @param $(out) DLL name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +TOOL_VCC100X86_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100X86_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) +TOOL_VCC100X86_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp +TOOL_VCC100X86_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC100X86_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100X86_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100X86_LINK_DLL_CMDS + $(QUIET)$(TOOL_VCC100X86_LD) $(flags) \ + /OUT:$(out) \ + /IMPLIB:$(outbase).lib \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + /DLL \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) +endef + + +## Link system module (windows aka driver, linux aka kernel module) +# @param $(target) Normalized main target name. +# @param $(out) System module name. +# @param $(objs) Object files to link together. +# @param $(libs) Libraries to search. +# @param $(libpath) Library search paths. +# @param $(flags) Flags. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(othersrc) Unhandled sources. +# @param $(custom_pre) Custom step invoked before linking. +# @param $(custom_post) Custom step invoked after linking. +# +# @param $(outbase) Output basename (full). Use this for list files and such. +TOOL_VCC100X86_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) +TOOL_VCC100X86_LINK_SYSMOD_DEPORD = +TOOL_VCC100X86_LINK_SYSMOD_OUTPUT = $(outbase).map +TOOL_VCC100X86_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC100X86_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC100X86_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb +define TOOL_VCC100X86_LINK_SYSMOD_CMDS + $(QUIET)$(TOOL_VCC100X86_LD) $(flags) \ + /OUT:$(out) \ + /MAPINFO:EXPORTS /INCREMENTAL:NO \ + /MAP:$(outbase).map \ + $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \ + $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \ + $(foreach p,$(libpath), /LIBPATH:$(p)) \ + $(subst /,\\,$(objs)) \ + $(subst /,\\,$(libs)) + $(QUIET)$(TEST) -f $(out).manifest -- \ + $(TOOL_VCC100X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' +endef + diff --git a/kBuild/tools/VCC70.kmk b/kBuild/tools/VCC70.kmk index b83ec1e..02ade66 100644 --- a/kBuild/tools/VCC70.kmk +++ b/kBuild/tools/VCC70.kmk @@ -1,10 +1,10 @@ -# $Id: VCC70.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: VCC70.kmk 2524 2011-08-01 13:37:47Z bird $ ## @file # kBuild Tool Config - Visual C++ 7.0 (aka Visual Studio .NET), targeting x86. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -263,7 +263,9 @@ endef # @param $(custom_post) Custom step invoked after linking. # @param $(outbase) Output basename (full). Use this for list files and such. # -TOOL_VCC70_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk +TOOL_VCC70_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).ilk +TOOL_VCC70_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC70_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb TOOL_VCC70_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC70_LINK_PROGRAM_DEPORD = define TOOL_VCC70_LINK_PROGRAM_CMDS @@ -294,9 +296,11 @@ endef # # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_VCC70_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp -TOOL_VCC70_LINK_DLL_OUTPUT_MAYBE = $(outbase).pdb $(outbase).ilk $(PATH_LIB)/$(notdir $(outbase)).lib $(PATH_LIB)/$(notdir $(outbase)).exp +TOOL_VCC70_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC70_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC70_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb TOOL_VCC70_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) -TOOL_VCC70_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB)) +TOOL_VCC70_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) define TOOL_VCC70_LINK_DLL_CMDS $(QUIET)$(TOOL_VCC70_LD) $(flags) \ /OUT:$(out) \ @@ -309,8 +313,8 @@ define TOOL_VCC70_LINK_DLL_CMDS $(foreach p,$(libpath), /LIBPATH:$(p)) \ $(subst /,\\,$(objs)) \ $(subst /,\\,$(libs)) - $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_LIB)/ -$(eval _DIRS += $(PATH_LIB)) + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) endef @@ -329,7 +333,9 @@ endef # # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_VCC70_LINK_SYSMOD_OUTPUT = $(outbase).map -TOOL_VCC70_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk +TOOL_VCC70_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk +TOOL_VCC70_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC70_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb TOOL_VCC70_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC70_LINK_SYSMOD_DEPORD = define TOOL_VCC70_LINK_SYSMOD_CMDS diff --git a/kBuild/tools/VCC80.kmk b/kBuild/tools/VCC80.kmk index 3593fa4..f9b6703 100644 --- a/kBuild/tools/VCC80.kmk +++ b/kBuild/tools/VCC80.kmk @@ -1,10 +1,10 @@ -# $Id: VCC80.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: VCC80.kmk 2524 2011-08-01 13:37:47Z bird $ ## @file # kBuild Tool Config - Visual C++ 8.0 (aka Visual .NET 2005, or MSC v14), targeting $(KBUILD_TARGET). # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -60,16 +60,16 @@ ifneq ($(PATH_TOOL_VCC80),) PATH_TOOL_VCC80_BIN.amd64 ?= $(PATH_TOOL_VCC80)/bin/x86_amd64 endif PATH_TOOL_VCC80_BIN.x86 ?= $(PATH_TOOL_VCC80)/bin - PATH_TOOL_VCC80_BIN ?= $(PATH_TOOL_VCC80_BIN.$(KBUILD_TARGET)) + PATH_TOOL_VCC80_BIN ?= $(PATH_TOOL_VCC80_BIN.$(KBUILD_TARGET_ARCH)) PATH_TOOL_VCC80_LIB.amd64 ?= $(PATH_TOOL_VCC80)/lib/amd64 PATH_TOOL_VCC80_LIB.x86 ?= $(PATH_TOOL_VCC80)/lib - PATH_TOOL_VCC80_LIB ?= $(PATH_TOOL_VCC80_LIB.$(KBUILD_TARGET)) + PATH_TOOL_VCC80_LIB ?= $(PATH_TOOL_VCC80_LIB.$(KBUILD_TARGET_ARCH)) PATH_TOOL_VCC80_INC ?= $(PATH_TOOL_VCC80)/include PATH_TOOL_VCC80_ATLMFC ?= $(PATH_TOOL_VCC80X86)/atlmfc PATH_TOOL_VCC80_ATLMFC_INC ?= $(PATH_TOOL_VCC80_ATLMFC)/include PATH_TOOL_VCC80_ATLMFC_LIB.amd64 ?= $(PATH_TOOL_VCC80_ATLMFC)/lib PATH_TOOL_VCC80_ATLMFC_LIB.x86 ?= $(PATH_TOOL_VCC80_ATLMFC)/lib/amd64 - PATH_TOOL_VCC80_ATLMFC_LIB ?= $(PATH_TOOL_VCC80_ATLMFC_LIB.$(KBUILD_TARGET)) + PATH_TOOL_VCC80_ATLMFC_LIB ?= $(PATH_TOOL_VCC80_ATLMFC_LIB.$(KBUILD_TARGET_ARCH)) TOOL_VCC80_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80_BIN)/cl.exe TOOL_VCC80_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80_BIN)/cl.exe TOOL_VCC80_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80_BIN)/ml64.exe @@ -255,7 +255,9 @@ endef TOOL_VCC80_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC80_LINK_PROGRAM_DEPORD = TOOL_VCC80_LINK_PROGRAM_OUTPUT = $(outbase).map -TOOL_VCC80_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk $(out).manifest +TOOL_VCC80_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC80_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_VCC80_LD) $(flags) \ /OUT:$(out) \ @@ -286,9 +288,11 @@ endef # # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_VCC80_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) -TOOL_VCC80_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB)) +TOOL_VCC80_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) TOOL_VCC80_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp -TOOL_VCC80_LINK_DLL_OUTPUT_MAYBE = $(outbase).pdb $(outbase).ilk $(out).manifest $(PATH_LIB)/$(notdir $(outbase)).lib $(PATH_LIB)/$(notdir $(outbase)).exp +TOOL_VCC80_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC80_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80_LINK_DLL_CMDS $(QUIET)$(TOOL_VCC80_LD) $(flags) \ /OUT:$(out) \ @@ -303,8 +307,8 @@ define TOOL_VCC80_LINK_DLL_CMDS $(subst /,\\,$(libs)) $(QUIET)$(TEST) -f $(out).manifest -- \ $(TOOL_VCC80_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' - $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_LIB)/ -$(eval _DIRS += $(PATH_LIB)) + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) endef @@ -325,7 +329,9 @@ endef TOOL_VCC80_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC80_LINK_SYSMOD_DEPORD = TOOL_VCC80_LINK_SYSMOD_OUTPUT = $(outbase).map -TOOL_VCC80_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk $(out).manifest +TOOL_VCC80_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC80_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80_LINK_SYSMOD_CMDS $(QUIET)$(TOOL_VCC80_LD) $(flags) \ /OUT:$(out) \ diff --git a/kBuild/tools/VCC80AMD64.kmk b/kBuild/tools/VCC80AMD64.kmk index 477f4cc..bf4ce33 100644 --- a/kBuild/tools/VCC80AMD64.kmk +++ b/kBuild/tools/VCC80AMD64.kmk @@ -1,10 +1,10 @@ -# $Id: VCC80AMD64.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: VCC80AMD64.kmk 2524 2011-08-01 13:37:47Z bird $ ## @file # kBuild Tool Config - Visual C++ 8.0 (aka Visual .NET 2005, or MSC v14), targeting AMD64. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -232,7 +232,9 @@ endef TOOL_VCC80AMD64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC80AMD64_LINK_PROGRAM_DEPORD = TOOL_VCC80AMD64_LINK_PROGRAM_OUTPUT = $(outbase).map -TOOL_VCC80AMD64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk $(out).manifest +TOOL_VCC80AMD64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC80AMD64_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80AMD64_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80AMD64_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_VCC80AMD64_LD) $(flags) \ /OUT:$(out) \ @@ -263,9 +265,11 @@ endef # # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_VCC80AMD64_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) -TOOL_VCC80AMD64_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB)) +TOOL_VCC80AMD64_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) TOOL_VCC80AMD64_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp -TOOL_VCC80AMD64_LINK_DLL_OUTPUT_MAYBE = $(outbase).pdb $(outbase).ilk $(out).manifest $(PATH_LIB)/$(notdir $(outbase)).lib $(PATH_LIB)/$(notdir $(outbase)).exp +TOOL_VCC80AMD64_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC80AMD64_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80AMD64_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80AMD64_LINK_DLL_CMDS $(QUIET)$(TOOL_VCC80AMD64_LD) $(flags) \ /OUT:$(out) \ @@ -280,8 +284,8 @@ define TOOL_VCC80AMD64_LINK_DLL_CMDS $(subst /,\\,$(libs)) $(QUIET)$(TEST) -f $(out).manifest -- \ $(TOOL_VCC80AMD64_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' - $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_LIB)/ -$(eval _DIRS += $(PATH_LIB)) + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) endef @@ -302,7 +306,9 @@ endef TOOL_VCC80AMD64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC80AMD64_LINK_SYSMOD_DEPORD = TOOL_VCC80AMD64_LINK_SYSMOD_OUTPUT = $(outbase).map -TOOL_VCC80AMD64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk $(out).manifest +TOOL_VCC80AMD64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC80AMD64_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80AMD64_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80AMD64_LINK_SYSMOD_CMDS $(QUIET)$(TOOL_VCC80AMD64_LD) $(flags) \ /OUT:$(out) \ diff --git a/kBuild/tools/VCC80X86.kmk b/kBuild/tools/VCC80X86.kmk index 6ed3cbd..546b84f 100644 --- a/kBuild/tools/VCC80X86.kmk +++ b/kBuild/tools/VCC80X86.kmk @@ -1,10 +1,10 @@ -# $Id: VCC80X86.kmk 2273 2009-02-20 23:44:53Z bird $ +# $Id: VCC80X86.kmk 2524 2011-08-01 13:37:47Z bird $ ## @file # kBuild Tool Config - Visual C++ 8.0 (aka Visual .NET 2005, or MSC v14), targeting x86. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -234,7 +234,9 @@ endef TOOL_VCC80X86_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC80X86_LINK_PROGRAM_DEPORD = TOOL_VCC80X86_LINK_PROGRAM_OUTPUT = $(outbase).map -TOOL_VCC80X86_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk $(out).manifest +TOOL_VCC80X86_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC80X86_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80X86_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80X86_LINK_PROGRAM_CMDS $(QUIET)$(TOOL_VCC80X86_LD) $(flags) \ /OUT:$(out) \ @@ -265,9 +267,11 @@ endef # # @param $(outbase) Output basename (full). Use this for list files and such. TOOL_VCC80X86_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) -TOOL_VCC80X86_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB)) +TOOL_VCC80X86_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB)) TOOL_VCC80X86_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp -TOOL_VCC80X86_LINK_DLL_OUTPUT_MAYBE = $(outbase).pdb $(outbase).ilk $(out).manifest $(PATH_LIB)/$(notdir $(outbase)).lib $(PATH_LIB)/$(notdir $(outbase)).exp +TOOL_VCC80X86_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp +TOOL_VCC80X86_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80X86_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80X86_LINK_DLL_CMDS $(QUIET)$(TOOL_VCC80X86_LD) $(flags) \ /OUT:$(out) \ @@ -282,8 +286,8 @@ define TOOL_VCC80X86_LINK_DLL_CMDS $(subst /,\\,$(libs)) $(QUIET)$(TEST) -f $(out).manifest -- \ $(TOOL_VCC80X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2' - $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_LIB)/ -$(eval _DIRS += $(PATH_LIB)) + $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/ +$(eval _DIRS += $(PATH_STAGE_LIB)) endef @@ -304,7 +308,9 @@ endef TOOL_VCC80X86_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc) TOOL_VCC80X86_LINK_SYSMOD_DEPORD = TOOL_VCC80X86_LINK_SYSMOD_OUTPUT = $(outbase).map -TOOL_VCC80X86_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk $(out).manifest +TOOL_VCC80X86_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest +TOOL_VCC80X86_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb +TOOL_VCC80X86_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb define TOOL_VCC80X86_LINK_SYSMOD_CMDS $(QUIET)$(TOOL_VCC80X86_LD) $(flags) \ /OUT:$(out) \ diff --git a/kBuild/tools/WATCOMC11C-16.kmk b/kBuild/tools/WATCOMC11C-16.kmk index 470aa3d..175e5f5 100644 --- a/kBuild/tools/WATCOMC11C-16.kmk +++ b/kBuild/tools/WATCOMC11C-16.kmk @@ -1,11 +1,11 @@ -# $Id: WATCOMC11C-16.kmk 2316 2009-03-19 16:31:52Z bird $ +# $Id: WATCOMC11C-16.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Watcom C v11.0c, 16-bit targets. # # @remarks wrc is untested, so are DLLs, and programs. # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/WATCOMC11C-WL.kmk b/kBuild/tools/WATCOMC11C-WL.kmk index af9fa01..e494af5 100644 --- a/kBuild/tools/WATCOMC11C-WL.kmk +++ b/kBuild/tools/WATCOMC11C-WL.kmk @@ -1,11 +1,11 @@ -# $Id: WATCOMC11C-WL.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WATCOMC11C-WL.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Watcom C/C++ v11.0c, using wlink. # # @remarks wrc is untested, so are DLLs, and programs. # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/WATCOMC11C.kmk b/kBuild/tools/WATCOMC11C.kmk index a370376..e3328e7 100644 --- a/kBuild/tools/WATCOMC11C.kmk +++ b/kBuild/tools/WATCOMC11C.kmk @@ -1,10 +1,10 @@ -# $Id: WATCOMC11C.kmk 2316 2009-03-19 16:31:52Z bird $ +# $Id: WATCOMC11C.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - Watcom C v11.0c # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/WGET.kmk b/kBuild/tools/WGET.kmk index c4713af..b6d4022 100644 --- a/kBuild/tools/WGET.kmk +++ b/kBuild/tools/WGET.kmk @@ -1,10 +1,10 @@ -# $Id: WGET.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: WGET.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - wget fetchers. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/XGCCAMD64LINUX.kmk b/kBuild/tools/XGCCAMD64LINUX.kmk index d5b2190..1e58a0b 100644 --- a/kBuild/tools/XGCCAMD64LINUX.kmk +++ b/kBuild/tools/XGCCAMD64LINUX.kmk @@ -1,10 +1,10 @@ -# $Id: XGCCAMD64LINUX.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: XGCCAMD64LINUX.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - GCC Cross compiler for AMD64+Linux. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/YACC.kmk b/kBuild/tools/YACC.kmk index 30fc79a..06a84d6 100644 --- a/kBuild/tools/YACC.kmk +++ b/kBuild/tools/YACC.kmk @@ -1,10 +1,10 @@ -# $Id: YACC.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: YACC.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # yacc tool # # -# Copyright (c) 2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2009-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/YASM.kmk b/kBuild/tools/YASM.kmk index 113315d..8f958f0 100644 --- a/kBuild/tools/YASM.kmk +++ b/kBuild/tools/YASM.kmk @@ -1,10 +1,10 @@ -# $Id: YASM.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: YASM.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - YASM 0.4.0 or later. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/tools/ZIP.kmk b/kBuild/tools/ZIP.kmk index 51744d3..11fbf9d 100644 --- a/kBuild/tools/ZIP.kmk +++ b/kBuild/tools/ZIP.kmk @@ -1,10 +1,10 @@ -# $Id: ZIP.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: ZIP.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild Tool Config - The zip/unzip packer/unpacker. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/units/lex.kmk b/kBuild/units/lex.kmk index 497b886..dd294b7 100644 --- a/kBuild/units/lex.kmk +++ b/kBuild/units/lex.kmk @@ -1,10 +1,10 @@ -# $Id: lex.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: lex.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # lex unit. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/units/qt-Q_OBJECT.sed b/kBuild/units/qt-Q_OBJECT.sed index df75d2b..91ba65a 100644 --- a/kBuild/units/qt-Q_OBJECT.sed +++ b/kBuild/units/qt-Q_OBJECT.sed @@ -1,4 +1,4 @@ -# $Id: qt-Q_OBJECT.sed 2243 2009-01-10 02:24:02Z bird $ +# $Id: qt-Q_OBJECT.sed 2413 2010-09-11 17:43:04Z bird $ ## @file # Qt unit - sed script for checking for Q_OBJECT in a file. # @@ -9,7 +9,7 @@ # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/units/qt3.kmk b/kBuild/units/qt3.kmk index 678fd0f..4dbc1a3 100644 --- a/kBuild/units/qt3.kmk +++ b/kBuild/units/qt3.kmk @@ -1,10 +1,10 @@ -# $Id: qt3.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: qt3.kmk 2479 2011-07-20 14:16:19Z bird $ ## @file # Qt 3.3.x unit. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -159,7 +159,7 @@ ifndef PATH_SDK_QT3 # Determin the KBUILD_TARGET lib directory. ifeq ($(PATH_SDK_QT3_LIB),) - PATH_SDK_QT3_LIB := $(PATH_SDK_QT3_LIB.$(KBUILD_TARGET)) + PATH_SDK_QT3_LIB := $(PATH_SDK_QT3_LIB.$(KBUILD_TARGET_ARCH)) ifeq ($(PATH_SDK_QT3_LIB),) PATH_SDK_QT3_LIB := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \ $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \ @@ -904,7 +904,7 @@ local translations := \ $($(target)_QT_TRANSLATIONS.$(bld_type)) \ $($(target)_QT_TRANSLATIONS) ifneq ($(strip $(translations)),) - local expr := _ALL_INSTALLS += $(target)-inst-nls + local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls $(eval $(expr)) ifdef $(target)_QT_TRANSLATIONS_TEMPLATE $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE) diff --git a/kBuild/units/qt4.kmk b/kBuild/units/qt4.kmk index bdfe2fe..91ab956 100644 --- a/kBuild/units/qt4.kmk +++ b/kBuild/units/qt4.kmk @@ -1,10 +1,10 @@ -# $Id: qt4.kmk 2272 2009-02-19 01:22:28Z bird $ +# $Id: qt4.kmk 2479 2011-07-20 14:16:19Z bird $ ## @file # Qt 4 unit. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -146,7 +146,7 @@ ifndef PATH_SDK_QT4 # And finally, the library path for KBUILD_TARGET. ifeq ($(PATH_SDK_QT4_LIB),) - PATH_SDK_QT4_LIB := $(PATH_SDK_QT4_LIB.$(KBUILD_TARGET)) + PATH_SDK_QT4_LIB := $(PATH_SDK_QT4_LIB.$(KBUILD_TARGET_ARCH)) ifeq ($(PATH_SDK_QT4_LIB),) PATH_SDK_QT4_LIB := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \ $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \ @@ -401,25 +401,25 @@ define TOOL_QT4_RCC_QRC_CMDS $(flags)\ -o $(out)\ $(source) - $(APPEND) $(dep) '\' - $(APPEND) $(dep) '$(out): \' - $(APPEND) $(dep) '$(source) \' - $(SED) \ + $(QUIET2)$(APPEND) $(dep) '\' + $(QUIET2)$(APPEND) $(dep) '$(out): \' + $(QUIET2)$(APPEND) $(dep) '$(source) \' + $(QUIET2)$(SED) \ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \ -e 's|$$$$| \\|' \ --append $(dep) \ $(source) - $(APPEND) $(dep) - $(SED) \ + $(QUIET2)$(APPEND) $(dep) + $(QUIET2)$(SED) \ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \ -e 's|$$$$|:\n|' \ --append $(dep) \ $(source) - $(APPEND) $(dep) + $(QUIET2)$(APPEND) $(dep) endef ## Compile a Qt translation file (.ts). @@ -956,6 +956,7 @@ local qt_infix := $(firstword \ ifeq ($(bld_trg),darwin) # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work... $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) ) + $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT4_LIB) ) $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) ) $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/4/Headers) ) else @@ -1030,7 +1031,7 @@ local translations := \ $($(target)_QT_TRANSLATIONS.$(bld_type)) \ $($(target)_QT_TRANSLATIONS) ifneq ($(strip $(translations)),) - local expr := _ALL_INSTALLS += $(target)-inst-nls + local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls $(eval $(expr)) ifdef $(target)_QT_TRANSLATIONS_TEMPLATE $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE) diff --git a/kBuild/units/yacc.kmk b/kBuild/units/yacc.kmk index 8516c2a..18ef3c5 100644 --- a/kBuild/units/yacc.kmk +++ b/kBuild/units/yacc.kmk @@ -1,10 +1,10 @@ -# $Id: yacc.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: yacc.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # yacc/bison unit. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/kBuild/up.kmk b/kBuild/up.kmk index 32c1e51..9350160 100644 --- a/kBuild/up.kmk +++ b/kBuild/up.kmk @@ -1,11 +1,11 @@ -# $Id: up.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: up.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - File included at top of a up forwarder makefile. # This method is DEPRECATED. Use Makefile.kup files instead. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/Makefile.kmk b/src/Makefile.kmk index e690c75..4f700c7 100644 --- a/src/Makefile.kmk +++ b/src/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2315 2009-03-02 02:35:00Z bird $ +# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Sub-makefile for the source directory. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -29,11 +29,7 @@ include $(KBUILD_PATH)/subheader.kmk include $(PATH_SUB_CURRENT)/lib/Makefile.kmk include $(PATH_SUB_CURRENT)/sed/Makefile.kmk include $(PATH_SUB_CURRENT)/kmk/Makefile.kmk -if1of ($(KBUILD_TARGET), win) - include $(PATH_SUB_CURRENT)/kash/Makefile.kmk -else - include $(PATH_SUB_CURRENT)/ash/Makefile.kmk -endif +include $(PATH_SUB_CURRENT)/kash/Makefile.kmk include $(PATH_SUB_CURRENT)/kDepPre/Makefile.kmk include $(PATH_SUB_CURRENT)/kObjCache/Makefile.kmk include $(PATH_SUB_CURRENT)/misc/Makefile.kmk diff --git a/src/ash/Makefile.kmk b/src/ash/Makefile.kmk index ad1ca85..44e49e9 100644 --- a/src/ash/Makefile.kmk +++ b/src/ash/Makefile.kmk @@ -4,7 +4,7 @@ # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -47,7 +47,9 @@ kmk_ash_DEFS.dragonfly = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kmk_ash_DEFS.freebsd = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME -kmk_ash_INCS = $(PATH_kmk_ash) . # (the last is because of error.h) +kmk_ash_DEFS.openbsd = \ + HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME +kmk_ash_INCS = $(kmk_ash_0_OUTDIR) . # (the last is because of error.h) kmk_ash_CFLAGS.win = -I. ## @todo kBuild bug? kmk_ash_INCS.win = win kmk_ash_SOURCES = \ @@ -76,9 +78,9 @@ kmk_ash_SOURCES = \ bltin/echo.c \ bltin/kill.c \ bltin/test.c \ - $(PATH_kmk_ash)/builtins.c \ - $(PATH_kmk_ash)/init.c \ - $(PATH_kmk_ash)/nodes.c + $(kmk_ash_0_OUTDIR)/builtins.c \ + $(kmk_ash_0_OUTDIR)/init.c \ + $(kmk_ash_0_OUTDIR)/nodes.c kmk_ash_SOURCES.linux = \ sys_signame.c \ strlcpy.c \ @@ -96,14 +98,14 @@ kmk_ash_SOURCES.solaris = \ setmode.c kmk_ash_INTERMEDIATES = \ - $(PATH_kmk_ash)/builtins.h \ - $(PATH_kmk_ash)/nodes.h \ - $(PATH_kmk_ash)/token.h + $(kmk_ash_0_OUTDIR)/builtins.h \ + $(kmk_ash_0_OUTDIR)/nodes.h \ + $(kmk_ash_0_OUTDIR)/token.h kmk_ash_CLEAN = \ $(kmk_ash_INTERMEDIATES) \ - $(PATH_kmk_ash)/builtins.c \ - $(PATH_kmk_ash)/init.c \ - $(PATH_kmk_ash)/nodes.c + $(kmk_ash_0_OUTDIR)/builtins.c \ + $(kmk_ash_0_OUTDIR)/init.c \ + $(kmk_ash_0_OUTDIR)/nodes.c kmk_ash.man_TEMPLATE = usr.bin.man kmk_ash.man_SOURCES = \ @@ -116,12 +118,12 @@ if1of ($(KBUILD_TARGET), win nt) # Use the pregenerated code. # kmk_ash_DEPS := -kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c +kmk_ash_SOURCES += $(kmk_ash_0_OUTDIR)/arith_lex.c include $(FILE_KBUILD_SUB_FOOTER) define def_copy_generated -$(PATH_kmk_ash)/$(src): generated/$(src) +$(kmk_ash_0_OUTDIR)/$(src): generated/$(src) $$(RM) -f $$@ $$(CP) -f $$^ $$@ endef @@ -159,30 +161,30 @@ include $(FILE_KBUILD_SUB_FOOTER) # BOOTSTRAP_SHELL ?= $(SHELL) -$(PATH_kmk_ash)/builtins.h + $(PATH_kmk_ash)/builtins.c: \ +$(kmk_ash_0_OUTDIR)/builtins.h + $(kmk_ash_0_OUTDIR)/builtins.c: \ $(kmk_ash_PATH)/mkbuiltins \ $(kmk_ash_PATH)/shell.h \ $(kmk_ash_PATH)/builtins.def \ - | $(call DIRDEP,$(PATH_kmk_ash)) + | $(call DIRDEP,$(kmk_ash_0_OUTDIR)) $(BOOTSTRAP_SHELL) $+ $(dir $@) - [ -f $(PATH_kmk_ash)/builtins.h ] + [ -f $(kmk_ash_0_OUTDIR)/builtins.h ] -$(PATH_kmk_ash)/nodes.h + $(PATH_kmk_ash)/nodes.c: \ +$(kmk_ash_0_OUTDIR)/nodes.h + $(kmk_ash_0_OUTDIR)/nodes.c: \ $(kmk_ash_PATH)/mknodes.sh \ $(kmk_ash_PATH)/nodetypes \ $(kmk_ash_PATH)/nodes.c.pat \ - | $(call DIRDEP,$(PATH_kmk_ash)) + | $(call DIRDEP,$(kmk_ash_0_OUTDIR)) $(BOOTSTRAP_SHELL) $+ $(dir $@) [ -f $(dir $@)/nodes.h ] -$(PATH_kmk_ash)/token.h: $(kmk_ash_PATH)/mktokens | $(call DIRDEP,$(PATH_kmk_ash)) +$(kmk_ash_0_OUTDIR)/token.h: $(kmk_ash_PATH)/mktokens | $(call DIRDEP,$(kmk_ash_0_OUTDIR)) $(BOOTSTRAP_SHELL) $+ $(MV) token.h $@ -$(PATH_kmk_ash)/init.c: \ +$(kmk_ash_0_OUTDIR)/init.c: \ $(kmk_ash_PATH)/mkinit.sh \ - $(abspathex $(filter-out $(PATH_kmk_ash)/%,$(kmk_ash_SOURCES)), $(kmk_ash_PATH)) \ - | $(call DIRDEP,$(PATH_kmk_ash)) + $(abspathex $(filter-out $(kmk_ash_0_OUTDIR)/%,$(kmk_ash_SOURCES)), $(kmk_ash_PATH)) \ + | $(call DIRDEP,$(kmk_ash_0_OUTDIR)) $(BOOTSTRAP_SHELL) $+ $(MV) init.c $@ diff --git a/src/ash/eval.c b/src/ash/eval.c index 7e8a51c..d738c5b 100644 --- a/src/ash/eval.c +++ b/src/ash/eval.c @@ -1176,7 +1176,20 @@ breakcmd(int argc, char **argv) int returncmd(int argc, char **argv) { +#if 0 int ret = argc > 1 ? number(argv[1]) : exitstatus; +#else + int ret; + if (argc > 1) { + /* make return -1 and VSC lite work ... */ + if (argv[1][0] != '-' || !is_number(&argv[1][1])) + ret = number(argv[1]); + else + ret = -number(&argv[1][1]) & 255; /* take the bash approach */ + } else { + ret = exitstatus; + } +#endif if (funcnest) { evalskip = SKIPFUNC; diff --git a/src/ash/win/err.c b/src/ash/win/err.c index 419a4c2..5bbaa44 100644 --- a/src/ash/win/err.c +++ b/src/ash/win/err.c @@ -1,9 +1,9 @@ -/* $Id: err.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: err.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * * Override err.h so we get the program name right. * - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This program is free software; you can redistribute it and/or modify diff --git a/src/ash/win/err.h b/src/ash/win/err.h index 17360f5..1bd6945 100644 --- a/src/ash/win/err.h +++ b/src/ash/win/err.h @@ -1,9 +1,9 @@ -/* $Id: err.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: err.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * * Override err.h stuff so we get the program names right. * - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This program is free software; you can redistribute it and/or modify diff --git a/src/ash/win/mscfakes.c b/src/ash/win/mscfakes.c index 26a27a4..a20d130 100644 --- a/src/ash/win/mscfakes.c +++ b/src/ash/win/mscfakes.c @@ -1,9 +1,9 @@ -/* $Id: mscfakes.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: mscfakes.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * * Fake Unix stuff for MSC. * - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This program is free software; you can redistribute it and/or modify diff --git a/src/ash/win/mscfakes.h b/src/ash/win/mscfakes.h index b7da91e..bcb3081 100644 --- a/src/ash/win/mscfakes.h +++ b/src/ash/win/mscfakes.h @@ -1,9 +1,9 @@ -/* $Id: mscfakes.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: mscfakes.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * * Unix fakes for MSC. * - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This program is free software; you can redistribute it and/or modify diff --git a/src/fastdep/Makefile b/src/fastdep/Makefile index 8dbf2af..91f4af1 100644 --- a/src/fastdep/Makefile +++ b/src/fastdep/Makefile @@ -1,11 +1,11 @@ -# $Id: Makefile 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile 2413 2010-09-11 17:43:04Z bird $ # # Odin32 API # # Makefile for the Quick-and-Dirty dependency utility. (FastDep) # -# Copyright (c) 1999-2009 knut st. osmundsen (bird-kBuild-spamix@anduin.net) +# Copyright (c) 1999-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # GPL # diff --git a/src/fastdep/Makefile.kmk b/src/fastdep/Makefile.kmk index 60286d7..3467df9 100644 --- a/src/fastdep/Makefile.kmk +++ b/src/fastdep/Makefile.kmk @@ -4,7 +4,7 @@ # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/fastdep/fastdep.c b/src/fastdep/fastdep.c index f4bd236..72d918e 100644 --- a/src/fastdep/fastdep.c +++ b/src/fastdep/fastdep.c @@ -1,8 +1,8 @@ -/* $Id: fastdep.c 2243 2009-01-10 02:24:02Z bird $ +/* $Id: fastdep.c 2413 2010-09-11 17:43:04Z bird $ * * Fast dependents. (Fast = Quick and Dirty!) * - * Copyright (c) 1999-2009 knut st. osmundsen (bird-kBuild-spamix@anduin.net) + * Copyright (c) 1999-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * GPL * @@ -1005,7 +1005,7 @@ void syntax(void) " <files> Files to scan. Wildchars are allowed.\n" "\n" "Options and files could be mixed.\n" - " copyright (c) 1999-2009 knut st. osmundsen (bird-kBuild-spamix@anduin.net)\n", + " copyright (c) 1999-2010 knut st. osmundsen (bird-kBuild-spamx@anduin.net)\n", ODIN32_BUILD_NR, pszDefaultDepFile ); diff --git a/src/kDepPre/Makefile.kmk b/src/kDepPre/Makefile.kmk index da89058..286f242 100644 --- a/src/kDepPre/Makefile.kmk +++ b/src/kDepPre/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Sub-makefile for kDepPre, the precompiler based dependency generator. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kDepPre/kDepPre.c b/src/kDepPre/kDepPre.c index ecf6b68..0b40e51 100644 --- a/src/kDepPre/kDepPre.c +++ b/src/kDepPre/kDepPre.c @@ -1,10 +1,10 @@ -/* $Id: kDepPre.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kDepPre.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kDepPre - Dependency Generator using Precompiler output. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kObjCache/Makefile.kmk b/src/kObjCache/Makefile.kmk index b4d13d5..81e2c3d 100644 --- a/src/kObjCache/Makefile.kmk +++ b/src/kObjCache/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Sub-makefile for kObjCache. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kObjCache/kObjCache.c b/src/kObjCache/kObjCache.c index b403d58..3cec87c 100644 --- a/src/kObjCache/kObjCache.c +++ b/src/kObjCache/kObjCache.c @@ -1,10 +1,10 @@ -/* $Id: kObjCache.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kObjCache.c 2463 2011-07-08 11:54:37Z bird $ */ /** @file * kObjCache - Object Cache. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -49,6 +49,7 @@ # ifdef __OS2__ # include <unistd.h> # include <sys/wait.h> +# include <sys/time.h> # endif # if defined(_MSC_VER) # include <direct.h> @@ -63,12 +64,14 @@ #else # include <unistd.h> # include <sys/wait.h> +# include <sys/time.h> # ifndef O_BINARY # define O_BINARY 0 # endif #endif #if defined(__WIN__) # include <Windows.h> +# include "quoted_spawn.h" #endif #include "crc32.h" @@ -233,9 +236,15 @@ void *xrealloc(void *pvOld, size_t cb) char *xstrdup(const char *pszIn) { - char *psz = strdup(pszIn); - if (!psz) - FatalDie("out of memory (%d)\n", (int)strlen(pszIn)); + char *psz; + if (pszIn) + { + psz = strdup(pszIn); + if (!psz) + FatalDie("out of memory (%d)\n", (int)strlen(pszIn)); + } + else + psz = NULL; return psz; } #endif @@ -253,6 +262,27 @@ void *xmallocz(size_t cb) /** + * Returns a millisecond timestamp. + * + * @returns Millisecond timestamp. + */ +static uint32_t NowMs(void) +{ +#if defined(__WIN__) + return GetTickCount(); +#else + int iSavedErrno = errno; + struct timeval tv = {0, 0}; + + gettimeofday(&tv, NULL); + errno = iSavedErrno; + + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +#endif +} + + +/** * Gets the absolute path * * @returns A new heap buffer containing the absolute path. @@ -324,9 +354,51 @@ static char *MakePathFromDirAndFile(const char *pszName, const char *pszDir) * @returns 1 if equal, 0 otherwise. * @param pszPath1 The first path. * @param pszPath2 The second path. + */ +static int ArePathsIdentical(const char *pszPath1, const char *pszPath2) +{ +#if defined(__OS2__) || defined(__WIN__) + if (stricmp(pszPath1, pszPath2)) + { + /* Slashes may differ, compare char by char. */ + const char *psz1 = pszPath1; + const char *psz2 = pszPath2; + for (;;) + { + if (*psz1 != *psz2) + { + if ( tolower(*psz1) != tolower(*psz2) + && toupper(*psz1) != toupper(*psz2) + && *psz1 != '/' + && *psz1 != '\\' + && *psz2 != '/' + && *psz2 != '\\') + return 0; + } + if (!*psz1) + break; + psz1++; + psz2++; + } + } + return 1; +#else + return !strcmp(pszPath1, pszPath2); +#endif +} + +/** + * Compares two path strings to see if they are identical. + * + * This doesn't do anything fancy, just the case ignoring and + * slash unification. + * + * @returns 1 if equal, 0 otherwise. + * @param pszPath1 The first path. + * @param pszPath2 The second path. * @param cch The number of characters to compare. */ -static int ArePathsIdentical(const char *pszPath1, const char *pszPath2, size_t cch) +static int ArePathsIdenticalN(const char *pszPath1, const char *pszPath2, size_t cch) { #if defined(__OS2__) || defined(__WIN__) if (strnicmp(pszPath1, pszPath2, cch)) @@ -334,7 +406,7 @@ static int ArePathsIdentical(const char *pszPath1, const char *pszPath2, size_t /* Slashes may differ, compare char by char. */ const char *psz1 = pszPath1; const char *psz2 = pszPath2; - for (;cch; psz1++, psz2++, cch--) + for ( ; cch; psz1++, psz2++, cch--) { if (*psz1 != *psz2) { @@ -371,7 +443,7 @@ static char *CalcRelativeName(const char *pszPath, const char *pszDir) /* * This is indeed a bit tricky, so we'll try the easy way first... */ - if (ArePathsIdentical(pszPath, pszDir, cchDir)) + if (ArePathsIdenticalN(pszPath, pszDir, cchDir)) { if (pszPath[cchDir]) pszRet = (char *)pszPath + cchDir; @@ -381,7 +453,7 @@ static char *CalcRelativeName(const char *pszPath, const char *pszDir) else { pszAbsPath = AbsPath(pszPath); - if (ArePathsIdentical(pszAbsPath, pszDir, cchDir)) + if (ArePathsIdenticalN(pszAbsPath, pszDir, cchDir)) { if (pszPath[cchDir]) pszRet = pszAbsPath + cchDir; @@ -1007,6 +1079,9 @@ typedef struct KOCENTRY unsigned fPipedPreComp; /** Whether the compiler runs in piped mode (precompiler output on stdin). */ unsigned fPipedCompile; + /** The name of the pipe that we're feeding the precompiled output to the + * compiler via. This is a Windows thing. */ + char *pszNmPipeCompile; /** Cache entry key that's used for some quick digest validation. */ uint32_t uKey; @@ -1021,6 +1096,9 @@ typedef struct KOCENTRY size_t cbCpp; /** The precompiler output checksums that will produce the cached object. */ KOCSUM SumHead; + /** The number of milliseconds spent precompiling. */ + uint32_t cMsCpp; + /** The object filename (relative to the cache file). */ char *pszObjName; /** The compile argument vector used to build the object. */ @@ -1029,6 +1107,10 @@ typedef struct KOCENTRY unsigned cArgvCompile; /** The checksum of the compiler argument vector. */ KOCSUM SumCompArgv; + /** The number of milliseconds spent compiling. */ + uint32_t cMsCompile; + /** @todo need a list of additional output files for MSC. */ + /** The target os/arch identifier. */ char *pszTarget; } @@ -1088,8 +1170,10 @@ static PKOCENTRY kOCEntryCreate(const char *pszFilename) */ static void kOCEntryDestroy(PKOCENTRY pEntry) { + /** @todo free pEntry->pszName? */ free(pEntry->pszDir); free(pEntry->pszAbsPath); + free(pEntry->pszNmPipeCompile); kOCSumDeleteChain(&pEntry->New.SumHead); kOCSumDeleteChain(&pEntry->Old.SumHead); @@ -1143,7 +1227,7 @@ static void kOCEntryCalcArgvSum(PKOCENTRY pEntry, const char * const *papszArgv, { size_t cch = strlen(papszArgv[i]); if ( cch < cchIgnorePath - || !ArePathsIdentical(papszArgv[i] + cch - cchIgnorePath, pszIgnorePath, cch)) + || !ArePathsIdenticalN(papszArgv[i] + cch - cchIgnorePath, pszIgnorePath, cch)) kOCSumUpdate(pSum, &Ctx, papszArgv[i], cch + 1); } kOCSumFinalize(pSum, &Ctx); @@ -1169,7 +1253,9 @@ static void kOCEntryRead(PKOCENTRY pEntry) * Check the magic. */ if ( !fgets(g_szLine, sizeof(g_szLine), pFile) - || strcmp(g_szLine, "magic=kObjCacheEntry-v0.1.0\n")) + || ( strcmp(g_szLine, "magic=kObjCacheEntry-v0.1.0\n") + && strcmp(g_szLine, "magic=kObjCacheEntry-v0.1.1\n")) + ) { InfoMsg(2, "bad cache file (magic)\n"); pEntry->fNeedCompiling = 1; @@ -1226,6 +1312,15 @@ static void kOCEntryRead(PKOCENTRY pEntry) break; kOCSumAdd(&pEntry->Old.SumHead, &Sum); } + else if (!strcmp(g_szLine, "cpp-ms")) + { + char *pszNext; + if ((fBad = pEntry->Old.cMsCpp != 0)) + break; + pEntry->Old.cMsCpp = strtoul(pszVal, &pszNext, 0); + if ((fBad = pszNext && *pszNext)) + break; + } else if (!strcmp(g_szLine, "cc-argc")) { if ((fBad = pEntry->Old.papszArgvCompile != NULL)) @@ -1248,6 +1343,15 @@ static void kOCEntryRead(PKOCENTRY pEntry) if ((fBad = kOCSumInitFromString(&pEntry->Old.SumCompArgv, pszVal))) break; } + else if (!strcmp(g_szLine, "cc-ms")) + { + char *pszNext; + if ((fBad = pEntry->Old.cMsCompile != 0)) + break; + pEntry->Old.cMsCompile = strtoul(pszVal, &pszNext, 0); + if ((fBad = pszNext && *pszNext)) + break; + } else if (!strcmp(g_szLine, "target")) { if ((fBad = pEntry->Old.pszTarget != NULL)) @@ -1361,12 +1465,14 @@ static void kOCEntryWrite(PKOCENTRY pEntry) #define CHECK_LEN(expr) \ do { int cch = expr; if (cch >= KOBJCACHE_MAX_LINE_LEN) FatalDie("Line too long: %d (max %d)\nexpr: %s\n", cch, KOBJCACHE_MAX_LINE_LEN, #expr); } while (0) - fprintf(pFile, "magic=kObjCacheEntry-v0.1.0\n"); + fprintf(pFile, "magic=kObjCacheEntry-v0.1.1\n"); CHECK_LEN(fprintf(pFile, "target=%s\n", pEntry->New.pszTarget ? pEntry->New.pszTarget : pEntry->Old.pszTarget)); CHECK_LEN(fprintf(pFile, "key=%lu\n", (unsigned long)pEntry->uKey)); - CHECK_LEN(fprintf(pFile, "obj=%s\n", pEntry->New.pszObjName ? pEntry->New.pszObjName : pEntry->Old.pszObjName)); - CHECK_LEN(fprintf(pFile, "cpp=%s\n", pEntry->New.pszCppName ? pEntry->New.pszCppName : pEntry->Old.pszCppName)); - CHECK_LEN(fprintf(pFile, "cpp-size=%lu\n", pEntry->New.pszCppName ? pEntry->New.cbCpp : pEntry->Old.cbCpp)); + CHECK_LEN(fprintf(pFile, "obj=%s\n", pEntry->New.pszObjName ? pEntry->New.pszObjName : pEntry->Old.pszObjName)); + CHECK_LEN(fprintf(pFile, "cpp=%s\n", pEntry->New.pszCppName ? pEntry->New.pszCppName : pEntry->Old.pszCppName)); + CHECK_LEN(fprintf(pFile, "cpp-size=%lu\n", pEntry->New.pszCppName ? pEntry->New.cbCpp : pEntry->Old.cbCpp)); + CHECK_LEN(fprintf(pFile, "cpp-ms=%lu\n", pEntry->New.pszCppName ? pEntry->New.cMsCpp : pEntry->Old.cMsCpp)); + CHECK_LEN(fprintf(pFile, "cc-ms=%lu\n", pEntry->New.pszCppName ? pEntry->New.cMsCompile : pEntry->Old.cMsCompile)); if (!kOCSumIsEmpty(&pEntry->New.SumCompArgv)) { @@ -1541,11 +1647,15 @@ static void kOCEntrySetCppName(PKOCENTRY pEntry, const char *pszCppName) * @param pEntry The cache entry. * @param fRedirPreCompStdOut Whether the precompiler is in piped mode. * @param fRedirCompileStdIn Whether the compiler is in piped mode. + * @param pszNmPipeCompile The name of the named pipe to use to feed + * the microsoft compiler. */ -static void kOCEntrySetPipedMode(PKOCENTRY pEntry, int fRedirPreCompStdOut, int fRedirCompileStdIn) +static void kOCEntrySetPipedMode(PKOCENTRY pEntry, int fRedirPreCompStdOut, int fRedirCompileStdIn, + const char *pszNmPipeCompile) { pEntry->fPipedPreComp = fRedirPreCompStdOut; - pEntry->fPipedCompile = fRedirCompileStdIn; + pEntry->fPipedCompile = fRedirCompileStdIn || pszNmPipeCompile; + pEntry->pszNmPipeCompile = xstrdup(pszNmPipeCompile); } @@ -1554,9 +1664,14 @@ static void kOCEntrySetPipedMode(PKOCENTRY pEntry, int fRedirPreCompStdOut, int * Terminating on failure. * * @param papszArgv Argument vector. The cArgv element is NULL. + * @param pcMs The cache entry member use for time keeping. This + * will be set to the current timestamp. * @param cArgv The number of arguments in the vector. + * @param pszMsg Which operation this is, for use in messages. + * @param pszStdOut Where to redirect standard out. */ -static void kOCEntrySpawn(PCKOCENTRY pEntry, const char * const *papszArgv, unsigned cArgv, const char *pszMsg, const char *pszStdOut) +static void kOCEntrySpawn(PCKOCENTRY pEntry, uint32_t *pcMs, const char * const *papszArgv, unsigned cArgv, + const char *pszMsg, const char *pszStdOut) { #if defined(__OS2__) || defined(__WIN__) intptr_t rc; @@ -1579,13 +1694,19 @@ static void kOCEntrySpawn(PCKOCENTRY pEntry, const char * const *papszArgv, unsi } } + *pcMs = NowMs(); errno = 0; +# ifdef __WIN__ + rc = quoted_spawnvp(_P_WAIT, papszArgv[0], papszArgv); +# else rc = _spawnvp(_P_WAIT, papszArgv[0], papszArgv); +# endif + *pcMs = NowMs() - *pcMs; if (rc < 0) FatalDie("%s - _spawnvp failed (rc=0x%p): %s\n", pszMsg, rc, strerror(errno)); if (rc > 0) FatalDie("%s - failed rc=%d\n", pszMsg, (int)rc); - if (fdStdOut) + if (fdStdOut != -1) { close(STDOUT_FILENO); fdStdOut = dup2(fdStdOut, STDOUT_FILENO); @@ -1595,7 +1716,10 @@ static void kOCEntrySpawn(PCKOCENTRY pEntry, const char * const *papszArgv, unsi #else int iStatus; pid_t pidWait; - pid_t pid = fork(); + pid_t pid; + + *pcMs = NowMs(); + pid = fork(); if (!pid) { if (pszStdOut) @@ -1625,6 +1749,7 @@ static void kOCEntrySpawn(PCKOCENTRY pEntry, const char * const *papszArgv, unsi pidWait = waitpid(pid, &iStatus, 0); while (pidWait < 0 && errno == EINTR) pidWait = waitpid(pid, &iStatus, 0); + *pcMs = NowMs() - *pcMs; if (pidWait != pid) FatalDie("%s - waitpid failed rc=%d: %s\n", pszMsg, pidWait, strerror(errno)); @@ -1642,13 +1767,16 @@ static void kOCEntrySpawn(PCKOCENTRY pEntry, const char * const *papszArgv, unsi * Spawns child with optional redirection of stdin and stdout. * * @param pEntry The cache entry. + * @param pcMs The cache entry member use for time keeping. This + * will be set to the current timestamp. * @param papszArgv Argument vector. The cArgv element is NULL. * @param cArgv The number of arguments in the vector. * @param fdStdIn Child stdin, -1 if it should inherit our stdin. Will be closed. * @param fdStdOut Child stdout, -1 if it should inherit our stdout. Will be closed. * @param pszMsg Message to start the info/error messages with. */ -static pid_t kOCEntrySpawnChild(PCKOCENTRY pEntry, const char * const *papszArgv, unsigned cArgv, int fdStdIn, int fdStdOut, const char *pszMsg) +static pid_t kOCEntrySpawnChild(PCKOCENTRY pEntry, uint32_t *pcMs, const char * const *papszArgv, unsigned cArgv, + int fdStdIn, int fdStdOut, const char *pszMsg) { pid_t pid; int fdSavedStdOut = -1; @@ -1681,9 +1809,14 @@ static pid_t kOCEntrySpawnChild(PCKOCENTRY pEntry, const char * const *papszArgv /* * Create the child process. */ + *pcMs = NowMs(); #if defined(__OS2__) || defined(__WIN__) errno = 0; +# ifdef __WIN__ + pid = quoted_spawnvp(_P_NOWAIT, papszArgv[0], papszArgv); +# else pid = _spawnvp(_P_NOWAIT, papszArgv[0], papszArgv); +# endif if (pid == -1) FatalDie("precompile - _spawnvp failed: %s\n", strerror(errno)); @@ -1725,10 +1858,12 @@ static pid_t kOCEntrySpawnChild(PCKOCENTRY pEntry, const char * const *papszArgv * Waits for a child and exits fatally if the child failed in any way. * * @param pEntry The cache entry. + * @param pcMs The millisecond timestamp that should be convert to + * elapsed time. * @param pid The child to wait for. * @param pszMsg Message to start the info/error messages with. */ -static void kOCEntryWaitChild(PCKOCENTRY pEntry, pid_t pid, const char *pszMsg) +static void kOCEntryWaitChild(PCKOCENTRY pEntry, uint32_t *pcMs, pid_t pid, const char *pszMsg) { int iStatus = -1; pid_t pidWait; @@ -1736,6 +1871,7 @@ static void kOCEntryWaitChild(PCKOCENTRY pEntry, pid_t pid, const char *pszMsg) #ifdef __WIN__ pidWait = _cwait(&iStatus, pid, _WAIT_CHILD); + *pcMs = NowMs() - *pcMs; if (pidWait == -1) FatalDie("%s - waitpid failed: %s\n", pszMsg, strerror(errno)); if (iStatus) @@ -1744,6 +1880,7 @@ static void kOCEntryWaitChild(PCKOCENTRY pEntry, pid_t pid, const char *pszMsg) pidWait = waitpid(pid, &iStatus, 0); while (pidWait < 0 && errno == EINTR) pidWait = waitpid(pid, &iStatus, 0); + *pcMs = NowMs() - *pcMs; if (pidWait != pid) FatalDie("%s - waitpid failed rc=%d: %s\n", pidWait, strerror(errno)); if (!WIFEXITED(iStatus)) @@ -1761,12 +1898,31 @@ static void kOCEntryWaitChild(PCKOCENTRY pEntry, pid_t pid, const char *pszMsg) * @param pEntry The cache entry. * @param pFDs Where to store the two file descriptors. * @param pszMsg The operation message for info/error messages. + * @param pszPipeName The pipe name if it is supposed to be named. (Windows only.) */ -static void kOCEntryCreatePipe(PKOCENTRY pEntry, int *pFDs, const char *pszMsg) +static void kOCEntryCreatePipe(PKOCENTRY pEntry, int *pFDs, const char *pszPipeName, const char *pszMsg) { pFDs[0] = pFDs[1] = -1; #if defined(__WIN__) - if (_pipe(pFDs, 0, _O_NOINHERIT | _O_BINARY) < 0) + if (pszPipeName) + { + HANDLE hPipe = CreateNamedPipeA(pszPipeName, + /*PIPE_ACCESS_OUTBOUND*/ PIPE_ACCESS_DUPLEX, + PIPE_READMODE_BYTE | PIPE_WAIT, + 10 /* nMaxInstances */, + 0x10000 /* nOutBuffer */, + 0x10000 /* nInBuffer */, + NMPWAIT_WAIT_FOREVER, + NULL /* pSecurityAttributes */); + + if (hPipe == INVALID_HANDLE_VALUE) + FatalDie("%s - CreateNamedPipe(%s) failed: %d\n", pszMsg, pszPipeName, GetLastError()); + + pFDs[1 /* write */] = _open_osfhandle((intptr_t)hPipe, _O_WRONLY | _O_TEXT | _O_NOINHERIT); + if (pFDs[1 /* write */] == -1) + FatalDie("%s - _open_osfhandle failed: %d\n", pszMsg, strerror(errno)); + } + else if (_pipe(pFDs, 0, _O_NOINHERIT | _O_BINARY) < 0) #else if (pipe(pFDs) < 0) #endif @@ -1795,17 +1951,17 @@ static void kOCEntrySpawnProducer(PKOCENTRY pEntry, const char * const *papszArg int fds[2]; pid_t pid; - kOCEntryCreatePipe(pEntry, fds, pszMsg); - pid = kOCEntrySpawnChild(pEntry, papszArgv, cArgv, -1, fds[1 /* write */], pszMsg); + kOCEntryCreatePipe(pEntry, fds, NULL, pszMsg); + pid = kOCEntrySpawnChild(pEntry, &pEntry->New.cMsCpp, papszArgv, cArgv, -1, fds[1 /* write */], pszMsg); pfnConsumer(pEntry, fds[0 /* read */]); - kOCEntryWaitChild(pEntry, pid, pszMsg); + kOCEntryWaitChild(pEntry, &pEntry->New.cMsCpp, pid, pszMsg); } /** - * Spawns a child that consumes input on stdin. + * Spawns a child that consumes input on stdin or via a named pipe. * * @param papszArgv Argument vector. The cArgv element is NULL. * @param cArgv The number of arguments in the vector. @@ -1819,12 +1975,16 @@ static void kOCEntrySpawnConsumer(PKOCENTRY pEntry, const char * const *papszArg int fds[2]; pid_t pid; - kOCEntryCreatePipe(pEntry, fds, pszMsg); - pid = kOCEntrySpawnChild(pEntry, papszArgv, cArgv, fds[0 /* read */], -1, pszMsg); + kOCEntryCreatePipe(pEntry, fds, pEntry->pszNmPipeCompile, pszMsg); + pid = kOCEntrySpawnChild(pEntry, &pEntry->New.cMsCompile, papszArgv, cArgv, fds[0 /* read */], -1, pszMsg); +#ifdef __WIN__ + if (pEntry->pszNmPipeCompile && !ConnectNamedPipe((HANDLE)_get_osfhandle(fds[1 /* write */]), NULL)) + FatalDie("compile - ConnectNamedPipe failed: %d\n", GetLastError()); +#endif pfnProducer(pEntry, fds[1 /* write */]); - kOCEntryWaitChild(pEntry, pid, pszMsg); + kOCEntryWaitChild(pEntry, &pEntry->New.cMsCompile, pid, pszMsg); } @@ -1849,15 +2009,15 @@ static void kOCEntrySpawnTee(PKOCENTRY pEntry, const char * const *papszProdArgv /* * The producer. */ - kOCEntryCreatePipe(pEntry, fds, pszMsg); - pidConsumer = kOCEntrySpawnChild(pEntry, papszProdArgv, cProdArgv, -1, fds[1 /* write */], pszMsg); + kOCEntryCreatePipe(pEntry, fds, NULL, pszMsg); + pidConsumer = kOCEntrySpawnChild(pEntry, &pEntry->New.cMsCpp, papszProdArgv, cProdArgv, -1, fds[1 /* write */], pszMsg); fdIn = fds[0 /* read */]; /* * The consumer. */ - kOCEntryCreatePipe(pEntry, fds, pszMsg); - pidProducer = kOCEntrySpawnChild(pEntry, papszConsArgv, cConsArgv, fds[0 /* read */], -1, pszMsg); + kOCEntryCreatePipe(pEntry, fds, pEntry->pszNmPipeCompile, pszMsg); + pidProducer = kOCEntrySpawnChild(pEntry, &pEntry->New.cMsCompile, papszConsArgv, cConsArgv, fds[0 /* read */], -1, pszMsg); fdOut = fds[1 /* write */]; /* @@ -1868,8 +2028,8 @@ static void kOCEntrySpawnTee(PKOCENTRY pEntry, const char * const *papszProdArgv /* * Reap the children. */ - kOCEntryWaitChild(pEntry, pidProducer, pszMsg); - kOCEntryWaitChild(pEntry, pidConsumer, pszMsg); + kOCEntryWaitChild(pEntry, &pEntry->New.cMsCpp, pidProducer, pszMsg); + kOCEntryWaitChild(pEntry, &pEntry->New.cMsCompile, pidConsumer, pszMsg); } @@ -1962,8 +2122,8 @@ static void kOCEntryPreCompileConsumer(PKOCENTRY pEntry, int fdIn) if (cbLeft <= 1) { size_t off = psz - pEntry->New.pszCppMapping; - cbLeft = 4*1024*1024; - cbAlloc += cbLeft; + cbLeft += 4*1024*1024; + cbAlloc += 4*1024*1024; pEntry->New.pszCppMapping = xrealloc(pEntry->New.pszCppMapping, cbAlloc); psz = pEntry->New.pszCppMapping + off; } @@ -2020,7 +2180,7 @@ static void kOCEntryPreCompile(PKOCENTRY pEntry, const char * const *papszArgvPr * Precompile it and calculate the checksum on the output. */ InfoMsg(3, "precompiling -> '%s'...\n", pEntry->New.pszCppName); - kOCEntrySpawn(pEntry, papszArgvPreComp, cArgvPreComp, "precompile", NULL); + kOCEntrySpawn(pEntry, &pEntry->New.cMsCpp, papszArgvPreComp, cArgvPreComp, "precompile", NULL); kOCEntryReadCppOutput(pEntry, &pEntry->New, 0 /* fatal */); kOCEntryCalcChecksum(pEntry); } @@ -2107,7 +2267,19 @@ static void kOCEntryCompileProducer(PKOCENTRY pEntry, int fdOut) { if (errno == EINTR) continue; +#ifdef __WIN__ /* HACK */ + if ( errno == EINVAL + && pEntry->pszNmPipeCompile + && DisconnectNamedPipe((HANDLE)_get_osfhandle(fdOut)) + && ConnectNamedPipe((HANDLE)_get_osfhandle(fdOut), NULL)) + { + psz = pEntry->New.pszCppMapping; + cbLeft = (long)pEntry->New.cbCpp; + } + FatalDie("compile - write(%d,,%ld) failed: %s - _doserrno=%d\n", fdOut, cbLeft, strerror(errno), _doserrno); +#else FatalDie("compile - write(%d,,%ld) failed: %s\n", fdOut, cbLeft, strerror(errno)); +#endif } psz += cbWritten; cbLeft -= cbWritten; @@ -2150,15 +2322,16 @@ static void kOCEntryCompileIt(PKOCENTRY pEntry) && !pEntry->New.pszCppMapping) kOCEntryReadCppOutput(pEntry, &pEntry->New, 0 /* fatal */); InfoMsg(3, "compiling -> '%s'...\n", pEntry->New.pszObjName); - kOCEntrySpawnConsumer(pEntry, (const char * const *)pEntry->New.papszArgvCompile, pEntry->New.cArgvCompile, - "compile", kOCEntryCompileProducer); + kOCEntrySpawnConsumer(pEntry, (const char * const *)pEntry->New.papszArgvCompile, + pEntry->New.cArgvCompile, "compile", kOCEntryCompileProducer); } else { if (pEntry->fPipedPreComp) kOCEntryWriteCppOutput(pEntry, 1 /* free it */); InfoMsg(3, "compiling -> '%s'...\n", pEntry->New.pszObjName); - kOCEntrySpawn(pEntry, (const char * const *)pEntry->New.papszArgvCompile, pEntry->New.cArgvCompile, "compile", NULL); + kOCEntrySpawn(pEntry, &pEntry->New.cMsCompile, (const char * const *)pEntry->New.papszArgvCompile, + pEntry->New.cArgvCompile, "compile", NULL); } } @@ -2175,6 +2348,9 @@ static void kOCEntryCompileIt(PKOCENTRY pEntry) */ static void kOCEntryTeeConsumer(PKOCENTRY pEntry, int fdIn, int fdOut) { +#ifdef __WIN__ + unsigned fConnectedToCompiler = fdOut == -1 || pEntry->pszNmPipeCompile == NULL; +#endif KOCSUMCTX Ctx; long cbLeft; long cbAlloc; @@ -2207,6 +2383,11 @@ static void kOCEntryTeeConsumer(PKOCENTRY pEntry, int fdIn, int fdOut) */ psz[cbRead] = '\0'; kOCSumUpdate(&pEntry->New.SumHead, &Ctx, psz, cbRead); +#ifdef __WIN__ + if ( !fConnectedToCompiler + && !(fConnectedToCompiler = ConnectNamedPipe((HANDLE)_get_osfhandle(fdOut), NULL))) + FatalDie("precompile|compile - ConnectNamedPipe failed: %d\n", GetLastError()); +#endif do { long cbWritten = write(fdOut, psz, cbRead); @@ -3489,7 +3670,7 @@ static void kObjCacheRemoveEntry(PKOBJCACHE pCache, PCKOCENTRY pEntry) { PKOCDIGEST pDigest = &pCache->paDigests[i]; if (ArePathsIdentical(kOCDigestAbsPath(pDigest, pCache->pszDir), - kOCEntryAbsPath(pEntry), ~0U)) + kOCEntryAbsPath(pEntry))) { unsigned cLeft; kOCDigestPurge(pDigest); @@ -3643,7 +3824,7 @@ static int usage(FILE *pOut) " | [-n|--name <name-in-cache>] [[-d|--cache-dir <cache-dir>]] >\n" " <-f|--file <local-cache-file>>\n" " <-t|--target <target-name>>\n" - " [-r|--redir-stdout] [-p|--passthru]\n" + " [-r|--redir-stdout] [-p|--passthru] [--named-pipe-compile <pipename>]\n" " --kObjCache-cpp <filename> <precompiler + args>\n" " --kObjCache-cc <object> <compiler + args>\n" " [--kObjCache-both [args]]\n" @@ -3681,6 +3862,7 @@ int main(int argc, char **argv) unsigned cArgvCompile = 0; const char *pszObjName = NULL; int fRedirCompileStdIn = 0; + const char *pszNmPipeCompile = NULL; const char *pszTarget = NULL; @@ -3779,6 +3961,13 @@ int main(int argc, char **argv) return SyntaxError("%s requires a target platform/arch name!\n", argv[i]); pszTarget = argv[++i]; } + else if (!strcmp(argv[i], "--named-pipe-compile")) + { + if (i + 1 >= argc) + return SyntaxError("%s requires a pipe name!\n", argv[i]); + pszNmPipeCompile = argv[++i]; + fRedirCompileStdIn = 0; + } else if (!strcmp(argv[i], "-p") || !strcmp(argv[i], "--passthru")) fRedirPreCompStdOut = fRedirCompileStdIn = 1; else if (!strcmp(argv[i], "-r") || !strcmp(argv[i], "--redir-stdout")) @@ -3795,8 +3984,8 @@ int main(int argc, char **argv) } else if (!strcmp(argv[i], "-V") || !strcmp(argv[i], "--version")) { - printf("kObjCache - kBuild version %d.%d.%d ($Revision: 2243 $)\n" - "Copyright (c) 2007-2009 knut st. osmundsen\n", + printf("kObjCache - kBuild version %d.%d.%d ($Revision: 2463 $)\n" + "Copyright (c) 2007-2011 knut st. osmundsen\n", KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH); return 0; } @@ -3851,7 +4040,7 @@ int main(int argc, char **argv) kOCEntrySetCompileArgv(pEntry, papszArgvCompile, cArgvCompile); kOCEntrySetTarget(pEntry, pszTarget); kOCEntrySetCppName(pEntry, pszPreCompName); - kOCEntrySetPipedMode(pEntry, fRedirPreCompStdOut, fRedirCompileStdIn); + kOCEntrySetPipedMode(pEntry, fRedirPreCompStdOut, fRedirCompileStdIn, pszNmPipeCompile); /* * Open (& lock) the two files and do validity checks and such. diff --git a/src/kash/Makefile.kmk b/src/kash/Makefile.kmk index 1cc2b9b..6fc7ad2 100644 --- a/src/kash/Makefile.kmk +++ b/src/kash/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2315 2009-03-02 02:35:00Z bird $ +# $Id: Makefile.kmk 2498 2011-07-22 12:05:57Z bird $ ## @file # Sub-makefile for kash. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -30,8 +30,8 @@ include $(KBUILD_PATH)/subheader.kmk # The program. # PROGRAMS += kash -kash_TEMPLATE = BIN -kash_NAME.win = kmk_ash +kash_TEMPLATE = BIN-THREADED +kash_NAME = kmk_ash kash_ASTOOL = YASM kash_DEFS = lint SHELL SMALL kash_DEFS += SH_FORKED_MODE @@ -50,7 +50,9 @@ kash_DEFS.dragonfly = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kash_DEFS.freebsd = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME -kash_INCS = $(PATH_kash) . # (the last is because of error.h) +kash_DEFS.openbsd = \ + HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME +kash_INCS = $(kash_0_OUTDIR) . # (the last is because of error.h) kash_ASFLAGS.win = -g cv8 kash_ASFLAGS.win.x86 = -f win32 kash_ASFLAGS.win.amd64 = -f win64 @@ -85,11 +87,9 @@ kash_SOURCES = \ bltin/kill.c \ bltin/test.c \ \ - $(PATH_kash)/arith.c \ - $(PATH_kash)/arith_lex.c \ - $(PATH_kash)/builtins.c \ - $(PATH_kash)/init.c \ - $(PATH_kash)/nodes.c \ + $(kash_0_OUTDIR)/builtins.c \ + $(kash_0_OUTDIR)/init.c \ + $(kash_0_OUTDIR)/nodes.c \ \ setmode.c \ shinstance.c \ @@ -109,17 +109,16 @@ kash_SOURCES.solaris = \ strlcpy.c kash_INTERMEDIATES = \ - $(PATH_kash)/arith.h \ - $(PATH_kash)/builtins.h \ - $(PATH_kash)/nodes.h \ - $(PATH_kash)/token.h + $(kash_0_OUTDIR)/builtins.h \ + $(kash_0_OUTDIR)/nodes.h \ + $(kash_0_OUTDIR)/token.h kash_CLEAN = \ $(kash_INTERMEDIATES) \ - $(PATH_kash)/arith.c \ - $(PATH_kash)/arith_lex.c \ - $(PATH_kash)/builtins.c \ - $(PATH_kash)/init.c \ - $(PATH_kash)/nodes.c + $(kash_0_OUTDIR)/builtins.c \ + $(kash_0_OUTDIR)/init.c \ + $(kash_0_OUTDIR)/nodes.c + +kash_main.c_DEFS = KBUILD_SVN_REV=$(KBUILD_SVN_REV) ## ## The manual page. @@ -129,18 +128,44 @@ kash_CLEAN = \ #kash.man_SOURCES = sh.1=>kash.1 -if1of ($(KBUILD_TARGET), win) +if1of ($(KBUILD_TARGET), win os2) # # Use the pregenerated code. # -kash_INTERMEDIATES := -kash_INCS += generated -kash_SOURCES := $(patsubst $(PATH_kash)/%,generated/%,$(kash_SOURCES)) +kash_SOURCES += \ + $(kash_0_OUTDIR)/arith.c \ + $(kash_0_OUTDIR)/arith_lex.c +kash_INTERMEDIATES += \ + $(kash_0_OUTDIR)/arith.h + +define def_copy_generated +$$$$(kash_0_OUTDIR)/$(src): $(PATH_SUB_CURRENT)/generated/$(src) + $$(RM) -f $$@ + $$(CP) -f $$^ $$@ +endef + +$(foreach src, arith.h arith.c arith_lex.c builtins.h builtins.c nodes.h nodes.c token.h init.c,\ +$(eval $(def_copy_generated))) else # +# Generate the code on the fly. +# + +USES += lex yacc +kash_USES = lex yacc +kash_LEXTOOL = FLEX +kash_LEXFLAGS = -8 +#kash_YACCTOOL = BISON +kash_YACCTOOL = YACC +kash_YACCFLAGS = -ld +kash_SOURCES += \ + arith.y \ + arith_lex.l + +# # ATTENTION! ATTENTION! ATTENTION! # # Older ash versions has trouble with some of these scripts, great. @@ -149,27 +174,16 @@ else # So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea. # BOOTSTRAP_SHELL ?= $(SHELL) -ifndef YACC - YACC := $(firstword $(which byacc) $(which yacc) yacc) -endif - -$$(PATH_kash)/arith.h + $$(PATH_kash)/arith.c: arith.y | $$(dir $$@) - $(YACC) -ld $^ - $(MV) -f y.tab.c $(PATH_kash)/arith.c - $(MV) -f y.tab.h $(PATH_kash)/arith.h -$$(PATH_kash)/arith_lex.c: $$(kash_DEFPATH)/arith_lex.l | $$(dir $$@) - flex -8 -o$@ $^ # 8-bit lex scanner for arithmetic - -$$(PATH_kash)/builtins.h + $$(PATH_kash)/builtins.c: \ +$$(kash_0_OUTDIR)/builtins.h + $$(kash_0_OUTDIR)/builtins.c: \ $$(kash_DEFPATH)/mkbuiltins \ $$(kash_DEFPATH)/shell.h \ $$(kash_DEFPATH)/builtins.def \ | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(dir $@) - [ -f $(PATH_kash)/builtins.h ] + [ -f $(kash_0_OUTDIR)/builtins.h ] -$$(PATH_kash)/nodes.h + $$(PATH_kash)/nodes.c: \ +$$(kash_0_OUTDIR)/nodes.h + $$(kash_0_OUTDIR)/nodes.c: \ $$(kash_DEFPATH)/mknodes.sh \ $$(kash_DEFPATH)/nodetypes \ $$(kash_DEFPATH)/nodes.c.pat \ @@ -177,19 +191,28 @@ $$(PATH_kash)/nodes.h + $$(PATH_kash)/nodes.c: \ $(BOOTSTRAP_SHELL) $+ $(dir $@) [ -f $(dir $@)/nodes.h ] -$$(PATH_kash)/token.h: $$(kash_DEFPATH)/mktokens | $$(dir $$@) +$$(kash_0_OUTDIR)/token.h: $$(kash_DEFPATH)/mktokens | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(MV) token.h $@ -$$(PATH_kash)/init.c: \ +$$(kash_0_OUTDIR)/init.c: \ $$(kash_DEFPATH)/mkinit.sh \ - $$(abspathex $$(filter-out $$(PATH_kash)/%,$$(kash_SOURCES)), $$(kash_DEFPATH)) \ + $$(abspathex $$(filter-out $$(kash_0_OUTDIR)/%,$$(kash_SOURCES)), $$(kash_DEFPATH)) \ | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(MV) init.c $@ endif +# +# For debugging file handle inheritance on Windows. +# +if "$(KBUILD_TARGET)" == win && 0 +PROGRAMS += tstDump +tstDump_TEMPLATE = BIN +tstDump_SOURCES = tstDump.c +endif + # Include the sub-makefile. include $(PATH_SUB_CURRENT)/tests/Makefile.kmk diff --git a/src/kash/arith.y b/src/kash/arith.y index 3cb158b..f53b3da 100644 --- a/src/kash/arith.y +++ b/src/kash/arith.y @@ -56,6 +56,13 @@ void yyerror(const char *); #ifdef TESTARITH int main(int , char *[]); int error(char *); +#else +# undef malloc +# define malloc(cb) sh_malloc(NULL, (cb)) +# undef realloc +# define realloc(pv,cb) sh_realloc(NULL, (pv), (cb)) +# undef free +# define free(pv) sh_free(NULL, (pv)) #endif %} @@ -190,8 +197,10 @@ error(s) void yyerror(const char *s) { - shinstance *psh = arith_psh; + shinstance *psh = arith_psh; +#ifndef YYBISON /* yyerrok references yyerrstatus which is a local variable in yyparse().*/ yyerrok; +#endif yyclearin; arith_lex_reset(); /* reprime lex */ /** @todo unlock */ diff --git a/src/kash/arith_lex.l b/src/kash/arith_lex.l index fe8ed30..b61e15b 100644 --- a/src/kash/arith_lex.l +++ b/src/kash/arith_lex.l @@ -1,4 +1,34 @@ +%option never-interactive %option noyywrap +%option noinput +%option nounput +%option noyyget_out +%option noyy_push_state +%option noyy_pop_state +%option noyy_top_state +%option noyy_scan_buffer +%option noyy_scan_bytes +%option noyy_scan_string +%option noyyget_extra +%option noyyset_extra +%option noyyget_leng +%option noyyget_text +%option noyyget_lineno +%option noyyset_lineno +%option noyyget_in +%option noyyset_in +%option noyyget_out +%option noyyset_out +%option noyyget_lval +%option noyyset_lval +%option noyyget_lloc +%option noyyset_lloc +%option noyyget_debug +%option noyyset_debug +%option noyyalloc +%option noyyrealloc +%option noyyfree +/** @todo %option reentrant */ %{ /* $NetBSD: arith_lex.l,v 1.13 2005/03/21 22:37:09 dsl Exp $ */ @@ -42,6 +72,7 @@ __RCSID("$NetBSD: arith_lex.l,v 1.13 2005/03/21 22:37:09 dsl Exp $"); #endif /* not lint */ #endif +#include <stdio.h> #include "arith.h" #include "error.h" #include "expand.h" @@ -55,6 +86,25 @@ extern char *arith_buf, *arith_startbuf; #define YY_INPUT(buf,result,max) \ result = (*buf = *arith_buf++) ? 1 : YY_NULL; #define YY_NO_UNPUT + +/* Avoid unnecessary libc bits. */ +#undef ECHO +#define ECHO \ + do {} while (0) +#undef stdin +#define stdin \ + NULL +#undef stdout +#define stdout \ + NULL +#undef fprintf +#define fprintf(a, b, c) \ + ((void)0) +#undef exit +#define exit(rc) \ + do {} while (0) +#define YY_FATAL_ERROR(msg) \ + error(arith_psh, "arith: fatal error: %s", msg) %} %% @@ -101,3 +151,22 @@ arith_lex_reset() { YY_NEW_FILE; #endif } + +void * +yyalloc(yy_size_t cb) +{ + return sh_malloc(NULL, cb); +} + +void * +yyrealloc(void *pv, yy_size_t cb) +{ + return sh_realloc(NULL, pv, cb); +} + +void +yyfree(void *pv) +{ + sh_free(NULL, pv); +} + diff --git a/src/kash/eval.c b/src/kash/eval.c index dd304ee..665e0bf 100644 --- a/src/kash/eval.c +++ b/src/kash/eval.c @@ -44,6 +44,10 @@ __RCSID("$NetBSD: eval.c,v 1.84 2005/06/23 23:05:29 christos Exp $"); #include <stdio.h> #include <sys/types.h> #ifdef HAVE_SYSCTL_H +# ifdef __OpenBSD__ /* joyful crap */ +# include <sys/param.h> +# undef psh +# endif # include <sys/sysctl.h> #endif @@ -506,16 +510,12 @@ evalpipe(shinstance *psh, union node *n) if (forkshell(psh, jp, lp->n, n->npipe.backgnd ? FORK_BG : FORK_FG) == 0) { INTON; if (prevfd > 0) { - shfile_close(&psh->fdtab, 0); - copyfd(psh, prevfd, 0); - shfile_close(&psh->fdtab, prevfd); + movefd(psh, prevfd, 0); } if (pip[1] >= 0) { shfile_close(&psh->fdtab, pip[0]); if (pip[1] != 1) { - shfile_close(&psh->fdtab, 1); - copyfd(psh, pip[1], 1); - shfile_close(&psh->fdtab, pip[1]); + movefd(psh, pip[1], 1); } } evaltree(psh, lp->n, EV_EXIT); @@ -577,9 +577,7 @@ evalbackcmd(shinstance *psh, union node *n, struct backcmd *result) FORCEINTON; shfile_close(&psh->fdtab, pip[0]); if (pip[1] != 1) { - shfile_close(&psh->fdtab, 1); - copyfd(psh, pip[1], 1); - shfile_close(&psh->fdtab, pip[1]); + movefd(psh, pip[1], 1); } eflag(psh) = 0; evaltree(psh, n, EV_EXIT); @@ -705,7 +703,7 @@ evalcommand(shinstance *psh, union node *cmd, int flags, struct backcmd *backcmd /* First expand the arguments. */ TRACE((psh, "evalcommand(0x%lx, %d) called\n", (long)cmd, flags)); setstackmark(psh, &smark); - psh->exitstatus = 0; + psh->back_exitstatus = 0; arglist.lastp = &arglist.list; varflag = 1; @@ -906,9 +904,7 @@ normal_fork: } shfile_close(&psh->fdtab, pip[0]); if (pip[1] != 1) { - shfile_close(&psh->fdtab, 1); - copyfd(psh, pip[1], 1); - shfile_close(&psh->fdtab, pip[1]); + movefd(psh, pip[1], 1); } } flags |= EV_EXIT; @@ -1130,7 +1126,7 @@ bltincmd(shinstance *psh, int argc, char **argv) * Preserve psh->exitstatus of a previous possible redirection * as POSIX mandates */ - return psh->exitstatus; + return psh->back_exitstatus; } @@ -1167,7 +1163,20 @@ breakcmd(shinstance *psh, int argc, char **argv) int returncmd(shinstance *psh, int argc, char **argv) { +#if 0 int ret = argc > 1 ? number(psh, argv[1]) : psh->exitstatus; +#else + int ret; + if (argc > 1) { + /* make return -1 and VSC lite work ... */ + if (argv[1][0] != '-' || !is_number(&argv[1][1])) + ret = number(psh, argv[1]); + else + ret = -number(psh, &argv[1][1]) & 255; /* take the bash approach */ + } else { + ret = psh->exitstatus; + } +#endif if (psh->funcnest) { psh->evalskip = SKIPFUNC; diff --git a/src/kash/exec.h b/src/kash/exec.h index c1a15d7..25f9a8f 100644 --- a/src/kash/exec.h +++ b/src/kash/exec.h @@ -45,13 +45,15 @@ #define CMDSPLBLTIN 3 /* command is a special shell builtin */ +union param { + int index; + int (*bltin)(struct shinstance*, int, char**); + union node *func; +}; + struct cmdentry { int cmdtype; - union param { - int index; - int (*bltin)(struct shinstance*, int, char**); - union node *func; - } u; + union param u; }; diff --git a/src/kash/generated/arith.c b/src/kash/generated/arith.c index 31bc652..1f6b6e0 100644 --- a/src/kash/generated/arith.c +++ b/src/kash/generated/arith.c @@ -1,13 +1,35 @@ #ifndef lint -/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/ -static char yyrcsid[] = "$Id: arith.c 1233 2007-10-09 23:24:41Z bird $"; +static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #endif + +#include <stdlib.h> +#include <string.h> + #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING (yyerrflag!=0) +#define YYPATCH 20091027 + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +#ifdef YYPARSE_PARAM_TYPE +#define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +#else +#define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +#endif +#else +#define YYPARSE_DECL() yyparse(void) +#endif /* YYPARSE_PARAM */ + +extern int YYPARSE_DECL(); + +static int yygrowstack(void); #define YYPREFIX "yy" /* $NetBSD: arith.y,v 1.17 2003/09/17 17:33:36 jmmv Exp $ */ @@ -66,6 +88,13 @@ void yyerror(const char *); #ifdef TESTARITH int main(int , char *[]); int error(char *); +#else +# undef malloc +# define malloc(cb) sh_malloc(NULL, (cb)) +# undef realloc +# define realloc(pv,cb) sh_realloc(NULL, (pv), (cb)) +# undef free +# define free(pv) sh_free(NULL, (pv)) #endif #define ARITH_NUM 257 @@ -94,45 +123,45 @@ int error(char *); #define ARITH_NOT 280 #define ARITH_BNOT 281 #define YYERRCODE 256 -short yylhs[] = { -1, +static const short yylhs[] = { -1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -short yylen[] = { 2, +static const short yylen[] = { 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, }; -short yydefred[] = { 0, +static const short yydefred[] = { 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 24, 23, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, }; -short yydgoto[] = { 7, +static const short yydgoto[] = { 7, 8, }; -short yysindex[] = { -255, +static const short yysindex[] = { -255, 0, -255, -255, -255, -255, -255, 0, -67, -85, 0, 0, 0, 0, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, 0, -50, -34, -19, 141, -261, -233, -233, -223, -223, -223, -223, -253, -253, -248, -248, 0, 0, 0, }; -short yyrindex[] = { 0, +static const short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 140, 136, 131, 125, 109, 117, 61, 73, 85, 97, 33, 47, 1, 17, 0, 0, 0, }; -short yygindex[] = { 0, +static const short yygindex[] = { 0, 142, }; #define YYTABLESIZE 418 -short yytable[] = { 0, +static const short yytable[] = { 0, 16, 1, 2, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 17, 3, 4, 27, 28, 29, 30, 31, 5, 6, 29, 30, 31, 1, @@ -176,7 +205,7 @@ short yytable[] = { 0, 4, 3, 3, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; -short yycheck[] = { -1, +static const short yycheck[] = { -1, 0, 257, 258, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 0, 273, 274, 273, 274, 275, 276, 277, 280, 281, 275, 276, 277, 0, @@ -226,7 +255,8 @@ short yycheck[] = { -1, #endif #define YYMAXTOKEN 281 #if YYDEBUG -char *yyname[] = { +static const char *yyname[] = { + "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -239,7 +269,7 @@ char *yyname[] = { "ARITH_LSHIFT","ARITH_RSHIFT","ARITH_ADD","ARITH_SUB","ARITH_MUL","ARITH_DIV", "ARITH_REM","ARITH_UNARYMINUS","ARITH_UNARYPLUS","ARITH_NOT","ARITH_BNOT", }; -char *yyrule[] = { +static const char *yyrule[] = { "$accept : exp", "exp : expr", "expr : ARITH_LPAREN expr ARITH_RPAREN", @@ -266,33 +296,45 @@ char *yyrule[] = { "expr : ARITH_SUB expr", "expr : ARITH_ADD expr", "expr : ARITH_NUM", + }; #endif #ifndef YYSTYPE typedef int YYSTYPE; #endif +#if YYDEBUG +#include <stdio.h> +#endif + +/* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE +#define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYMAXDEPTH 500 #endif #endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; + +#define YYINITSTACKSIZE 500 + +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE +YYSTYPE yyval; +YYSTYPE yylval; + +/* variables for the parser stack */ +static short *yyss; +static short *yysslim; +static YYSTYPE *yyvs; +static unsigned yystacksize; int arith(shinstance *psh, const char *s) { @@ -369,41 +411,66 @@ error(s) void yyerror(const char *s) { - shinstance *psh = arith_psh; + shinstance *psh = arith_psh; +#ifndef YYBISON /* yyerrok references yyerrstatus which is a local variable in yyparse().*/ yyerrok; +#endif yyclearin; arith_lex_reset(); /* reprime lex */ /** @todo unlock */ error(psh, "arithmetic expression: %s: \"%s\"", s, arith_startbuf); /* NOTREACHED */ } -#define YYABORT goto yyabort +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack(void) +{ + int i; + unsigned newsize; + short *newss; + YYSTYPE *newvs; + + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = yyssp - yyss; + newss = (yyss != 0) + ? (short *)realloc(yyss, newsize * sizeof(*newss)) + : (short *)malloc(newsize * sizeof(*newss)); + if (newss == 0) + return -1; + + yyss = newss; + yyssp = newss + i; + newvs = (yyvs != 0) + ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs)) + : (YYSTYPE *)malloc(newsize * sizeof(*newvs)); + if (newvs == 0) + return -1; + + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; + return 0; +} + +#define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#ifdef __cplusplus -extern "C" { -char * getenv(); -int yylex(); -int yyparse(); -} +#define YYERROR goto yyerrlab -#endif int -#if defined(__STDC__) -yyparse(void) -#else -yyparse() -#endif +YYPARSE_DECL() { - register int yym, yyn, yystate; + int yym, yyn, yystate; #if YYDEBUG - register char *yys; -#ifndef __cplusplus - extern char *getenv(); -#endif + const char *yys; - if (yys = getenv("YYDEBUG")) + if ((yys = getenv("YYDEBUG")) != 0) { yyn = *yys; if (yyn >= '0' && yyn <= '9') @@ -413,11 +480,14 @@ yyparse() yynerrs = 0; yyerrflag = 0; - yychar = (-1); + yychar = YYEMPTY; + yystate = 0; + if (yyss == NULL && yygrowstack()) goto yyoverflow; yyssp = yyss; yyvsp = yyvs; - *yyssp = yystate = 0; + yystate = 0; + *yyssp = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; @@ -443,13 +513,14 @@ yyloop: printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yyssp >= yyss + yystacksize - 1) + if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } - *++yyssp = yystate = yytable[yyn]; + yystate = yytable[yyn]; + *++yyssp = yytable[yyn]; *++yyvsp = yylval; - yychar = (-1); + yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } @@ -460,12 +531,14 @@ yyloop: goto yyreduce; } if (yyerrflag) goto yyinrecovery; + yyerror("syntax error"); -#ifdef lint + goto yyerrlab; -#endif + yyerrlab: ++yynerrs; + yyinrecovery: if (yyerrflag < 3) { @@ -480,11 +553,12 @@ yyinrecovery: printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif - if (yyssp >= yyss + yystacksize - 1) + if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } - *++yyssp = yystate = yytable[yyn]; + yystate = yytable[yyn]; + *++yyssp = yytable[yyn]; *++yyvsp = yylval; goto yyloop; } @@ -514,9 +588,10 @@ yyinrecovery: YYPREFIX, yystate, yychar, yys); } #endif - yychar = (-1); + yychar = YYEMPTY; goto yyloop; } + yyreduce: #if YYDEBUG if (yydebug) @@ -524,90 +599,93 @@ yyreduce: YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; - yyval = yyvsp[1-yym]; + if (yym) + yyval = yyvsp[1-yym]; + else + memset(&yyval, 0, sizeof yyval); switch (yyn) { case 1: -{ + { return (yyvsp[0]); } break; case 2: -{ yyval = yyvsp[-1]; } + { yyval = yyvsp[-1]; } break; case 3: -{ yyval = yyvsp[-2] ? yyvsp[-2] : yyvsp[0] ? yyvsp[0] : 0; } + { yyval = yyvsp[-2] ? yyvsp[-2] : yyvsp[0] ? yyvsp[0] : 0; } break; case 4: -{ yyval = yyvsp[-2] ? ( yyvsp[0] ? yyvsp[0] : 0 ) : 0; } + { yyval = yyvsp[-2] ? ( yyvsp[0] ? yyvsp[0] : 0 ) : 0; } break; case 5: -{ yyval = yyvsp[-2] | yyvsp[0]; } + { yyval = yyvsp[-2] | yyvsp[0]; } break; case 6: -{ yyval = yyvsp[-2] ^ yyvsp[0]; } + { yyval = yyvsp[-2] ^ yyvsp[0]; } break; case 7: -{ yyval = yyvsp[-2] & yyvsp[0]; } + { yyval = yyvsp[-2] & yyvsp[0]; } break; case 8: -{ yyval = yyvsp[-2] == yyvsp[0]; } + { yyval = yyvsp[-2] == yyvsp[0]; } break; case 9: -{ yyval = yyvsp[-2] > yyvsp[0]; } + { yyval = yyvsp[-2] > yyvsp[0]; } break; case 10: -{ yyval = yyvsp[-2] >= yyvsp[0]; } + { yyval = yyvsp[-2] >= yyvsp[0]; } break; case 11: -{ yyval = yyvsp[-2] < yyvsp[0]; } + { yyval = yyvsp[-2] < yyvsp[0]; } break; case 12: -{ yyval = yyvsp[-2] <= yyvsp[0]; } + { yyval = yyvsp[-2] <= yyvsp[0]; } break; case 13: -{ yyval = yyvsp[-2] != yyvsp[0]; } + { yyval = yyvsp[-2] != yyvsp[0]; } break; case 14: -{ yyval = yyvsp[-2] << yyvsp[0]; } + { yyval = yyvsp[-2] << yyvsp[0]; } break; case 15: -{ yyval = yyvsp[-2] >> yyvsp[0]; } + { yyval = yyvsp[-2] >> yyvsp[0]; } break; case 16: -{ yyval = yyvsp[-2] + yyvsp[0]; } + { yyval = yyvsp[-2] + yyvsp[0]; } break; case 17: -{ yyval = yyvsp[-2] - yyvsp[0]; } + { yyval = yyvsp[-2] - yyvsp[0]; } break; case 18: -{ yyval = yyvsp[-2] * yyvsp[0]; } + { yyval = yyvsp[-2] * yyvsp[0]; } break; case 19: -{ + { if (yyvsp[0] == 0) yyerror("division by zero"); yyval = yyvsp[-2] / yyvsp[0]; } break; case 20: -{ + { if (yyvsp[0] == 0) yyerror("division by zero"); yyval = yyvsp[-2] % yyvsp[0]; } break; case 21: -{ yyval = !(yyvsp[0]); } + { yyval = !(yyvsp[0]); } break; case 22: -{ yyval = ~(yyvsp[0]); } + { yyval = ~(yyvsp[0]); } break; case 23: -{ yyval = -(yyvsp[0]); } + { yyval = -(yyvsp[0]); } break; case 24: -{ yyval = yyvsp[0]; } + { yyval = yyvsp[0]; } break; } yyssp -= yym; @@ -651,17 +729,20 @@ break; printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yyssp, yystate); #endif - if (yyssp >= yyss + yystacksize - 1) + if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } - *++yyssp = yystate; + *++yyssp = (short) yystate; *++yyvsp = yyval; goto yyloop; + yyoverflow: yyerror("yacc stack overflow"); + yyabort: return (1); + yyaccept: return (0); } diff --git a/src/kash/generated/arith_lex.c b/src/kash/generated/arith_lex.c index fd690b9..72a582c 100644 --- a/src/kash/generated/arith_lex.c +++ b/src/kash/generated/arith_lex.c @@ -1,6 +1,6 @@ -#line 2 "/home/bird/vax/gdrive/coding/kbuild/svn/trunk/out/linux.x86/release/obj/src/kash/arith_lex.c" +#line 2 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/out/darwin.x86/release/obj/kash/arith_lex.c" -#line 4 "/home/bird/vax/gdrive/coding/kbuild/svn/trunk/out/linux.x86/release/obj/src/kash/arith_lex.c" +#line 4 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/out/darwin.x86/release/obj/kash/arith_lex.c" #define YY_INT_ALIGNED short int @@ -477,8 +477,10 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "arith_lex.l" -#line 3 "arith_lex.l" +#line 1 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" +#define YY_NO_INPUT 1 +/** @todo %option reentrant */ +#line 33 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" /* $NetBSD: arith_lex.l,v 1.13 2005/03/21 22:37:09 dsl Exp $ */ /*- @@ -521,6 +523,7 @@ __RCSID("$NetBSD: arith_lex.l,v 1.13 2005/03/21 22:37:09 dsl Exp $"); #endif /* not lint */ #endif +#include <stdio.h> #include "arith.h" #include "error.h" #include "expand.h" @@ -534,7 +537,20 @@ extern char *arith_buf, *arith_startbuf; #define YY_INPUT(buf,result,max) \ result = (*buf = *arith_buf++) ? 1 : YY_NULL; #define YY_NO_UNPUT -#line 538 "/home/bird/vax/gdrive/coding/kbuild/svn/trunk/out/linux.x86/release/obj/src/kash/arith_lex.c" + +/* Avoid unnecessary libc bits. */ +#undef ECHO +#define ECHO \ + do {} while (0) +#undef stdin +#define stdin \ + NULL +#undef stdout +#define stdout \ + NULL +#define YY_FATAL_ERROR(msg) \ + error(arith_psh, "arith: fatal error: %s", msg) +#line 554 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/out/darwin.x86/release/obj/kash/arith_lex.c" #define INITIAL 0 @@ -564,8 +580,6 @@ extern int yywrap (void ); #endif #endif - static void yyunput (int c,char *buf_ptr ); - #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif @@ -687,9 +701,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 60 "arith_lex.l" +#line 104 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" -#line 693 "/home/bird/vax/gdrive/coding/kbuild/svn/trunk/out/linux.x86/release/obj/src/kash/arith_lex.c" +#line 707 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/out/darwin.x86/release/obj/kash/arith_lex.c" if ( !(yy_init) ) { @@ -748,16 +762,12 @@ yy_match: yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 48 ); + while ( yy_current_state != 38 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); yy_find_action: yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } YY_DO_BEFORE_ACTION; @@ -775,27 +785,27 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 61 "arith_lex.l" +#line 105 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { ; } YY_BREAK case 2: YY_RULE_SETUP -#line 62 "arith_lex.l" +#line 106 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); } YY_BREAK case 3: YY_RULE_SETUP -#line 63 "arith_lex.l" +#line 107 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); } YY_BREAK case 4: YY_RULE_SETUP -#line 64 "arith_lex.l" +#line 108 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); } YY_BREAK case 5: YY_RULE_SETUP -#line 65 "arith_lex.l" +#line 109 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { char *v = lookupvar(arith_psh, yytext); if (v) { yylval = strtol(v, &v, 0); @@ -807,125 +817,125 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 73 "arith_lex.l" +#line 117 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_LPAREN); } YY_BREAK case 7: YY_RULE_SETUP -#line 74 "arith_lex.l" +#line 118 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_RPAREN); } YY_BREAK case 8: YY_RULE_SETUP -#line 75 "arith_lex.l" +#line 119 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_OR); } YY_BREAK case 9: YY_RULE_SETUP -#line 76 "arith_lex.l" +#line 120 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_AND); } YY_BREAK case 10: YY_RULE_SETUP -#line 77 "arith_lex.l" +#line 121 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_BOR); } YY_BREAK case 11: YY_RULE_SETUP -#line 78 "arith_lex.l" +#line 122 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_BXOR); } YY_BREAK case 12: YY_RULE_SETUP -#line 79 "arith_lex.l" +#line 123 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_BAND); } YY_BREAK case 13: YY_RULE_SETUP -#line 80 "arith_lex.l" +#line 124 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_EQ); } YY_BREAK case 14: YY_RULE_SETUP -#line 81 "arith_lex.l" +#line 125 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_NE); } YY_BREAK case 15: YY_RULE_SETUP -#line 82 "arith_lex.l" +#line 126 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_GT); } YY_BREAK case 16: YY_RULE_SETUP -#line 83 "arith_lex.l" +#line 127 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_GE); } YY_BREAK case 17: YY_RULE_SETUP -#line 84 "arith_lex.l" +#line 128 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_LT); } YY_BREAK case 18: YY_RULE_SETUP -#line 85 "arith_lex.l" +#line 129 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_LE); } YY_BREAK case 19: YY_RULE_SETUP -#line 86 "arith_lex.l" +#line 130 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_LSHIFT); } YY_BREAK case 20: YY_RULE_SETUP -#line 87 "arith_lex.l" +#line 131 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_RSHIFT); } YY_BREAK case 21: YY_RULE_SETUP -#line 88 "arith_lex.l" +#line 132 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_MUL); } YY_BREAK case 22: YY_RULE_SETUP -#line 89 "arith_lex.l" +#line 133 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_DIV); } YY_BREAK case 23: YY_RULE_SETUP -#line 90 "arith_lex.l" +#line 134 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_REM); } YY_BREAK case 24: YY_RULE_SETUP -#line 91 "arith_lex.l" +#line 135 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_ADD); } YY_BREAK case 25: YY_RULE_SETUP -#line 92 "arith_lex.l" +#line 136 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_SUB); } YY_BREAK case 26: YY_RULE_SETUP -#line 93 "arith_lex.l" +#line 137 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_BNOT); } YY_BREAK case 27: YY_RULE_SETUP -#line 94 "arith_lex.l" +#line 138 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { return(ARITH_NOT); } YY_BREAK case 28: YY_RULE_SETUP -#line 95 "arith_lex.l" +#line 139 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" { error(arith_psh, "arith: syntax error: \"%s\"", arith_startbuf); } YY_BREAK case 29: YY_RULE_SETUP -#line 96 "arith_lex.l" +#line 140 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" ECHO; YY_BREAK -#line 929 "/home/bird/vax/gdrive/coding/kbuild/svn/trunk/out/linux.x86/release/obj/src/kash/arith_lex.c" +#line 939 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/out/darwin.x86/release/obj/kash/arith_lex.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -992,7 +1002,8 @@ case YY_STATE_EOF(INITIAL): else { - yy_cp = (yy_c_buf_p); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); goto yy_find_action; } } @@ -1246,43 +1257,6 @@ static int yy_get_next_buffer (void) return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -1331,7 +1305,7 @@ static int yy_get_next_buffer (void) case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) - return EOF; + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1467,20 +1441,6 @@ static void yy_load_buffer_state (void) yyfree((void *) b ); } -#ifndef _UNISTD_H /* assume unistd.h has isatty() for us */ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __THROW /* this is a gnuism */ -extern int isatty (int ) __THROW; -#else -extern int isatty (int ); -#endif -#ifdef __cplusplus -} -#endif -#endif - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. @@ -1504,7 +1464,7 @@ extern int isatty (int ); b->yy_bs_column = 0; } - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + b->yy_is_interactive = 0; errno = oerrno; } @@ -1630,92 +1590,6 @@ static void yyensure_buffer_stack (void) } } -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif @@ -1745,84 +1619,10 @@ static void yy_fatal_error (yyconst char* msg ) /* Accessor methods (get/set functions) to struct members. */ -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - /** Get the current token. * */ -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. @@ -1897,31 +1697,9 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - #define YYTABLES_NAME "yytables" -#line 96 "arith_lex.l" +#line 140 "/Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/arith_lex.l" @@ -1932,3 +1710,22 @@ arith_lex_reset() { #endif } +void * +yyalloc(yy_size_t cb) +{ + return sh_malloc(NULL, cb); +} + +void * +yyrealloc(void *pv,yy_size_t cb) +{ + return sh_realloc(NULL, pv, cb); +} + +void +yyfree(void *pv) +{ + sh_free(NULL, pv); +} + + diff --git a/src/kash/generated/init.c b/src/kash/generated/init.c index 6168bfe..46bb96a 100644 --- a/src/kash/generated/init.c +++ b/src/kash/generated/init.c @@ -109,6 +109,24 @@ #define CMD2_UBITS 0x10 #undef STANDARD_BITS #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) +#undef SHMEMHDR_MAGIC_FREE +#define SHMEMHDR_MAGIC_FREE 0xbeeff00d +#undef SHMEMHDR_MAGIC_USED +#define SHMEMHDR_MAGIC_USED 0xfeedface +#undef SHMEMCHUNK_MAGIC +#define SHMEMCHUNK_MAGIC 0x12345678 +#undef SHHEAP_MIN_CHUNK +#define SHHEAP_MIN_CHUNK 0x80000 //(1024*1024) +#undef SHFILE_MAX +#define SHFILE_MAX 1024 +#undef SHFILE_GROW +#define SHFILE_GROW 64 +#undef SHFILE_UNIX_MIN_FD +#define SHFILE_UNIX_MIN_FD 32 +#undef SHFILE_MAX_PATH +#define SHFILE_MAX_PATH 4096 +#undef YY_NO_UNPUT +#define YY_NO_UNPUT @@ -131,22 +149,22 @@ struct redirtab { void init(shinstance *psh) { - /* from exec.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */ { hash_special_builtins(psh); } - /* from input.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */ { psh->basepf.nextc = psh->basepf.buf = psh->basebuf; } - /* from options.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */ { memcpy(&psh->optlist[0], &ro_optlist[0], sizeof(psh->optlist)); } - /* from var.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */ { char **envp; @@ -169,21 +187,21 @@ init(shinstance *psh) { void reset(shinstance *psh) { - /* from eval.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */ { psh->evalskip = 0; psh->loopnest = 0; psh->funcnest = 0; } - /* from input.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */ { if (psh->exception != EXSHELLPROC) psh->parselleft = psh->parsenleft = 0; /* clear input buffer */ popallfiles(psh); } - /* from output.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/output.c: */ { psh->out1 = &psh->output; psh->out2 = &psh->errout; @@ -193,13 +211,13 @@ reset(shinstance *psh) { } } - /* from parser.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/parser.c: */ { psh->tokpushback = 0; psh->checkkwd = 0; } - /* from redir.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */ { while (psh->redirlist) popredir(psh); @@ -215,27 +233,27 @@ reset(shinstance *psh) { void initshellproc(shinstance *psh) { - /* from alias.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/alias.c: */ { rmaliases(psh); } - /* from eval.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */ { psh->exitstatus = 0; } - /* from exec.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */ { deletefuncs(psh); } - /* from input.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */ { popallfiles(psh); } - /* from jobs.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/jobs.c: */ { psh->backgndpid = -1; #if JOBS @@ -243,7 +261,7 @@ initshellproc(shinstance *psh) { #endif } - /* from options.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */ { int i; @@ -253,12 +271,12 @@ initshellproc(shinstance *psh) { } - /* from redir.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */ { clearredir(psh, 0); } - /* from trap.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/trap.c: */ { char *sm; @@ -269,7 +287,7 @@ initshellproc(shinstance *psh) { } } - /* from var.c: */ + /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */ { shprocvar(psh); } diff --git a/src/kash/generated/nodes.c b/src/kash/generated/nodes.c index 223bfef..95869f5 100644 --- a/src/kash/generated/nodes.c +++ b/src/kash/generated/nodes.c @@ -51,8 +51,8 @@ #include "shinstance.h" -int funcblocksize; /* size of structures in function */ -int funcstringsize; /* size of strings in node */ +size_t funcblocksize; /* size of structures in function */ +size_t funcstringsize; /* size of strings in node */ pointer funcblock; /* block to allocate function from */ char *funcstring; /* block to allocate strings from */ diff --git a/src/kash/input.c b/src/kash/input.c index d7763cc..3c9e34e 100644 --- a/src/kash/input.c +++ b/src/kash/input.c @@ -407,8 +407,7 @@ setinputfile(shinstance *psh, const char *fname, int push) if ((fd = shfile_open(&psh->fdtab, fname, O_RDONLY, 0)) < 0) error(psh, "Can't open %s", fname); if (fd < 10) { - fd2 = copyfd(psh, fd, 10); - shfile_close(&psh->fdtab, fd); + fd2 = movefd_above(psh, fd, 10); if (fd2 < 0) error(psh, "Out of file descriptors"); fd = fd2; diff --git a/src/kash/main.c b/src/kash/main.c index 619a03b..50f5f3c 100644 --- a/src/kash/main.c +++ b/src/kash/main.c @@ -476,9 +476,9 @@ version(const char *argv0) strip_argv0(argv0, &len); fprintf(stdout, - "%.*s - kBuild version %d.%d.%d\n", + "%.*s - kBuild version %d.%d.%d (r%u)\n", len, argv0, - KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH); + KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH, KBUILD_SVN_REV); return 0; } diff --git a/src/kash/miscbltin.c b/src/kash/miscbltin.c index ef128bc..446a314 100644 --- a/src/kash/miscbltin.c +++ b/src/kash/miscbltin.c @@ -62,8 +62,8 @@ __RCSID("$NetBSD: miscbltin.c,v 1.35 2005/03/19 14:22:50 dsl Exp $"); #undef rflag -void *bsd_setmode(shinstance *psh, const char *p); -mode_t bsd_getmode(const void *bbox, mode_t omode); +void *kash_setmode(shinstance *psh, const char *p); +mode_t kash_getmode(const void *bbox, mode_t omode); /* @@ -107,7 +107,7 @@ readcmd(shinstance *psh, int argc, char **argv) rflag = 1; } - if (prompt && isatty(0)) { + if (prompt && shfile_isatty(&psh->fdtab, 0)) { out2str(psh, prompt); output_flushall(psh); } @@ -270,8 +270,8 @@ umaskcmd(shinstance *psh, int argc, char **argv) void *set; INTOFF; - if ((set = bsd_setmode(psh, ap)) != 0) { - mask = bsd_getmode(set, ~mask & 0777); + if ((set = kash_setmode(psh, ap)) != 0) { + mask = kash_getmode(set, ~mask & 0777); ckfree(psh, set); } INTON; diff --git a/src/kash/nodes.c.pat b/src/kash/nodes.c.pat index 4c44510..412330a 100644 --- a/src/kash/nodes.c.pat +++ b/src/kash/nodes.c.pat @@ -47,8 +47,8 @@ #include "shinstance.h" -int funcblocksize; /* size of structures in function */ -int funcstringsize; /* size of strings in node */ +size_t funcblocksize; /* size of structures in function */ +size_t funcstringsize; /* size of strings in node */ pointer funcblock; /* block to allocate function from */ char *funcstring; /* block to allocate strings from */ diff --git a/src/kash/output.h b/src/kash/output.h index eb02807..96b60d5 100644 --- a/src/kash/output.h +++ b/src/kash/output.h @@ -38,6 +38,13 @@ #include <stdarg.h> +/* The stupid, stupid, unix specification guys added dprintf to stdio.h! + Wonder what kind of weed they were smoking when doing that... */ +#include <stdio.h> +#undef dprintf +#define dprintf mydprintf + + struct output { char *nextc; int nleft; diff --git a/src/kash/redir.c b/src/kash/redir.c index f369f08..21b3e84 100644 --- a/src/kash/redir.c +++ b/src/kash/redir.c @@ -232,8 +232,7 @@ openredirect(shinstance *psh, union node *redir, char memory[10], int flags) } if (f != fd) { - copyfd(psh, f, fd); - shfile_close(&psh->fdtab, f); + movefd(psh, f, fd); } INTON; return; @@ -301,10 +300,10 @@ popredir(shinstance *psh) if (rp->renamed[i] != EMPTY) { if (i == 0) psh->fd0_redirected--; - shfile_close(&psh->fdtab, i); if (rp->renamed[i] >= 0) { - copyfd(psh, rp->renamed[i], i); - shfile_close(&psh->fdtab, rp->renamed[i]); + movefd(psh, rp->renamed[i], i); + } else { + shfile_close(&psh->fdtab, i); } } } @@ -377,8 +376,50 @@ copyfd(shinstance *psh, int from, int to) if (newfd < 0) { if (errno == EMFILE) return EMPTY; - else - error(psh, "%d: %s", from, strerror(errno)); + error(psh, "%d: %s", from, strerror(errno)); + } + return newfd; +} + + +/* + * Move a file descriptor to be == to. Returns -1 + * if the source file descriptor is closed, EMPTY if there are no unused + * file descriptors left. + */ + +int +movefd(shinstance *psh, int from, int to) +{ + int newfd; + + newfd = shfile_movefd(&psh->fdtab, from, to); + if (newfd < 0) { + if (errno == EMFILE) + return EMPTY; + error(psh, "%d: %s", from, strerror(errno)); } return newfd; } + + +/* + * Move a file descriptor to be >= to. Returns -1 + * if the source file descriptor is closed, EMPTY if there are no unused + * file descriptors left. + */ + +int +movefd_above(shinstance *psh, int from, int to) +{ + int newfd; + + newfd = shfile_movefd_above(&psh->fdtab, from, to); + if (newfd < 0) { + if (errno == EMFILE) + return EMPTY; + error(psh, "%d: %s", from, strerror(errno)); + } + return newfd; +} + diff --git a/src/kash/redir.h b/src/kash/redir.h index 1a5e359..6a332cb 100644 --- a/src/kash/redir.h +++ b/src/kash/redir.h @@ -45,4 +45,6 @@ void popredir(struct shinstance *); int fd0_redirected_p(struct shinstance *); void clearredir(struct shinstance *, int); int copyfd(struct shinstance *, int, int); +int movefd(struct shinstance *, int, int); +int movefd_above(struct shinstance *, int, int); diff --git a/src/kash/setmode.c b/src/kash/setmode.c index eab3a15..a621b9a 100644 --- a/src/kash/setmode.c +++ b/src/kash/setmode.c @@ -93,7 +93,7 @@ static void dumpmode(BITCMD *); * bits) followed by a '+' (set bits). */ mode_t -bsd_getmode(const void *bbox, mode_t omode) +kash_getmode(const void *bbox, mode_t omode) { const BITCMD *set; mode_t clrval, newmode, value; @@ -181,7 +181,7 @@ common: if (set->cmd2 & CMD2_CLR) { #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) void * -bsd_setmode(shinstance *psh, const char *p) +kash_setmode(shinstance *psh, const char *p) { int perm, who; char op, *ep; diff --git a/src/kash/shfile.c b/src/kash/shfile.c index d092e62..89f3a64 100644 --- a/src/kash/shfile.c +++ b/src/kash/shfile.c @@ -1,9 +1,9 @@ -/* $Id: shfile.c 2312 2009-03-02 01:14:43Z bird $ */ +/* $Id: shfile.c 2425 2010-10-18 08:52:22Z bird $ */ /** @file * * File management. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -31,6 +31,7 @@ #include "shinstance.h" /* TRACE2 */ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <assert.h> #if K_OS == K_OS_WINDOWS @@ -38,7 +39,13 @@ # ifndef PIPE_BUF # define PIPE_BUF 512 # endif +# include <ntstatus.h> +# define WIN32_NO_STATUS # include <Windows.h> +# if !defined(_WIN32_WINNT) +# define _WIN32_WINNT 0x0502 /* Windows Server 2003 */ +# endif +# include <winternl.h> //NTSTATUS #else # include <unistd.h> # include <fcntl.h> @@ -53,6 +60,7 @@ * Whether the file descriptor table stuff is actually in use or not. */ #if K_OS == K_OS_WINDOWS \ + || K_OS == K_OS_OPENBSD /* because of ugly pthread library pipe hacks */ \ || !defined(SH_FORKED_MODE) # define SHFILE_IN_USE #endif @@ -85,9 +93,9 @@ # define FTEXT 0x80 # define MY_ObjectBasicInformation 0 -typedef LONG (NTAPI * PFN_NtQueryObject)(HANDLE, int, void *, size_t, size_t *); +# define MY_FileNamesInformation 12 -typedef struct MY_OBJECT_BASIC_INFORMATION +typedef struct { ULONG Attributes; ACCESS_MASK GrantedAccess; @@ -102,6 +110,46 @@ typedef struct MY_OBJECT_BASIC_INFORMATION LARGE_INTEGER CreateTime; } MY_OBJECT_BASIC_INFORMATION; +#if 0 +typedef struct +{ + union + { + LONG Status; + PVOID Pointer; + }; + ULONG_PTR Information; +} MY_IO_STATUS_BLOCK; +#else +typedef IO_STATUS_BLOCK MY_IO_STATUS_BLOCK; +#endif +typedef MY_IO_STATUS_BLOCK *PMY_IO_STATUS_BLOCK; + +typedef struct +{ + ULONG NextEntryOffset; + ULONG FileIndex; + ULONG FileNameLength; + WCHAR FileName[1]; +} MY_FILE_NAMES_INFORMATION, *PMY_FILE_NAMES_INFORMATION; + +typedef NTSTATUS (NTAPI * PFN_NtQueryObject)(HANDLE, int, void *, size_t, size_t *); +typedef NTSTATUS (NTAPI * PFN_NtQueryDirectoryFile)(HANDLE, HANDLE, void *, void *, PMY_IO_STATUS_BLOCK, void *, + ULONG, int, int, PUNICODE_STRING, int); +typedef NTSTATUS (NTAPI * PFN_RtlUnicodeStringToAnsiString)(PANSI_STRING, PCUNICODE_STRING, int); + + +#endif /* K_OS_WINDOWS */ + + +/******************************************************************************* +* Global Variables * +*******************************************************************************/ +#if K_OS == K_OS_WINDOWS +static int g_shfile_globals_initialized = 0; +static PFN_NtQueryObject g_pfnNtQueryObject = NULL; +static PFN_NtQueryDirectoryFile g_pfnNtQueryDirectoryFile = NULL; +static PFN_RtlUnicodeStringToAnsiString g_pfnRtlUnicodeStringToAnsiString = NULL; #endif /* K_OS_WINDOWS */ @@ -127,6 +175,46 @@ static void shfile_native_close(intptr_t native, unsigned flags) } /** + * Grows the descriptor table, making sure that it can hold @a fdMin, + * + * @returns The max(fdMin, fdFirstNew) on success, -1 on failure. + * @param pfdtab The table to grow. + * @param fdMin Grow to include this index. + */ +static int shfile_grow_tab_locked(shfdtab *pfdtab, int fdMin) +{ + /* + * Grow the descriptor table. + */ + int fdRet = -1; + shfile *new_tab; + int new_size = pfdtab->size + SHFILE_GROW; + while (new_size < fdMin) + new_size += SHFILE_GROW; + new_tab = sh_realloc(shthread_get_shell(), pfdtab->tab, new_size * sizeof(shfile)); + if (new_tab) + { + int i; + for (i = pfdtab->size; i < new_size; i++) + { + new_tab[i].fd = -1; + new_tab[i].oflags = 0; + new_tab[i].shflags = 0; + new_tab[i].native = -1; + } + + fdRet = pfdtab->size; + if (fdRet < fdMin) + fdRet = fdMin; + + pfdtab->tab = new_tab; + pfdtab->size = new_size; + } + + return fdRet; +} + +/** * Inserts the file into the descriptor table. * * If we're out of memory and cannot extend the table, we'll close the @@ -154,6 +242,15 @@ static int shfile_insert(shfdtab *pfdtab, intptr_t native, unsigned oflags, unsi errno = EMFILE; return -1; } +# if K_OS != K_OS_WINDOWS + if (fcntl((int)native, F_SETFD, fcntl((int)native, F_GETFD, 0) | FD_CLOEXEC) == -1) + { + int e = errno; + close((int)native); + errno = e; + return -1; + } +# endif shmtx_enter(&pfdtab->mtx, &tmp); @@ -161,41 +258,14 @@ static int shfile_insert(shfdtab *pfdtab, intptr_t native, unsigned oflags, unsi * Search for a fitting unused location. */ fd = -1; - for (i = 0; (unsigned)i < pfdtab->size; i++) - if ( i >= fdMin - && pfdtab->tab[i].fd == -1) + for (i = fdMin >= 0 ? fdMin : 0; (unsigned)i < pfdtab->size; i++) + if (pfdtab->tab[i].fd == -1) { fd = i; break; } if (fd == -1) - { - /* - * Grow the descriptor table. - */ - shfile *new_tab; - int new_size = pfdtab->size + SHFILE_GROW; - while (new_size < fdMin) - new_size += SHFILE_GROW; - new_tab = sh_realloc(shthread_get_shell(), pfdtab->tab, new_size * sizeof(shfile)); - if (new_tab) - { - for (i = pfdtab->size; i < new_size; i++) - { - new_tab[i].fd = -1; - new_tab[i].oflags = 0; - new_tab[i].shflags = 0; - new_tab[i].native = -1; - } - - fd = pfdtab->size; - if (fd < fdMin) - fd = fdMin; - - pfdtab->tab = new_tab; - pfdtab->size = new_size; - } - } + fd = shfile_grow_tab_locked(pfdtab, fdMin); /* * Fill in the entry if we've found one. @@ -218,6 +288,37 @@ static int shfile_insert(shfdtab *pfdtab, intptr_t native, unsigned oflags, unsi return fd; } +#if K_OS != K_OS_WINDOWS +/** + * Makes a copy of the native file, closes the original, and inserts the copy + * into the descriptor table. + * + * If we're out of memory and cannot extend the table, we'll close the + * file, set errno to EMFILE and return -1. + * + * @returns The file descriptor number. -1 and errno on failure. + * @param pfdtab The file descriptor table. + * @param pnative The native file handle on input, -1 on output. + * @param oflags The flags the it was opened/created with. + * @param shflags The shell file flags. + * @param fdMin The minimum file descriptor number, pass -1 if any is ok. + * @param who Who we're doing this for (for logging purposes). + */ +static int shfile_copy_insert_and_close(shfdtab *pfdtab, int *pnative, unsigned oflags, unsigned shflags, int fdMin, const char *who) +{ + int fd = -1; + int s = errno; + int native_copy = fcntl(*pnative, F_DUPFD, SHFILE_UNIX_MIN_FD); + close(*pnative); + *pnative = -1; + errno = s; + + if (native_copy != -1) + fd = shfile_insert(pfdtab, native_copy, oflags, shflags, fdMin, who); + return fd; +} +#endif /* !K_OS_WINDOWS */ + /** * Gets a file descriptor and lock the file descriptor table. * @@ -386,26 +487,37 @@ static int shfile_dos2errno(int err) return -1; } +/** + * Converts an NT status code to errno, + * assigning it to errno. + * + * @returns -1 + * @param rcNt The NT status code. + */ +static int shfile_nt2errno(NTSTATUS rcNt) +{ + switch (rcNt) + { + default: errno = EINVAL; break; + } + return -1; +} + DWORD shfile_query_handle_access_mask(HANDLE h, PACCESS_MASK pMask) { - static PFN_NtQueryObject s_pfnNtQueryObject = NULL; MY_OBJECT_BASIC_INFORMATION BasicInfo; - LONG Status; + NTSTATUS rcNt; - if (!s_pfnNtQueryObject) - { - s_pfnNtQueryObject = (PFN_NtQueryObject)GetProcAddress(GetModuleHandle("NTDLL"), "NtQueryObject"); - if (!s_pfnNtQueryObject) - return ERROR_NOT_SUPPORTED; - } + if (!g_pfnNtQueryObject) + return ERROR_NOT_SUPPORTED; - Status = s_pfnNtQueryObject(h, MY_ObjectBasicInformation, &BasicInfo, sizeof(BasicInfo), NULL); - if (Status >= 0) + rcNt = g_pfnNtQueryObject(h, MY_ObjectBasicInformation, &BasicInfo, sizeof(BasicInfo), NULL); + if (rcNt >= 0) { *pMask = BasicInfo.GrantedAccess; return NO_ERROR; } - if (Status != STATUS_INVALID_HANDLE) + if (rcNt != STATUS_INVALID_HANDLE) return ERROR_GEN_FAILURE; return ERROR_INVALID_HANDLE; } @@ -415,6 +527,28 @@ DWORD shfile_query_handle_access_mask(HANDLE h, PACCESS_MASK pMask) #endif /* SHFILE_IN_USE */ /** + * Initializes the global variables in this file. + */ +static void shfile_init_globals(void) +{ +#if K_OS == K_OS_WINDOWS + if (!g_shfile_globals_initialized) + { + HMODULE hNtDll = GetModuleHandle("NTDLL"); + g_pfnNtQueryObject = (PFN_NtQueryObject) GetProcAddress(hNtDll, "NtQueryObject"); + g_pfnNtQueryDirectoryFile = (PFN_NtQueryDirectoryFile)GetProcAddress(hNtDll, "NtQueryDirectoryFile"); + g_pfnRtlUnicodeStringToAnsiString = (PFN_RtlUnicodeStringToAnsiString)GetProcAddress(hNtDll, "RtlUnicodeStringToAnsiString"); + if ( !g_pfnRtlUnicodeStringToAnsiString + || !g_pfnNtQueryDirectoryFile) + { + /* fatal error */ + } + g_shfile_globals_initialized = 1; + } +#endif +} + +/** * Initializes a file descriptor table. * * @returns 0 on success, -1 and errno on failure. @@ -426,6 +560,8 @@ int shfile_init(shfdtab *pfdtab, shfdtab *inherit) { int rc; + shfile_init_globals(); + pfdtab->cwd = NULL; pfdtab->size = 0; pfdtab->tab = NULL; @@ -547,13 +683,67 @@ int shfile_init(shfdtab *pfdtab, shfdtab *inherit) HANDLE hFile = GetStdHandle(aStdHandles[i].dwStdHandle); if (hFile != INVALID_HANDLE_VALUE) { - int fd2 = shfile_insert(pfdtab, (intptr_t)hFile, aStdHandles[i].fFlags, 0, i, "shtab_init"); + DWORD dwType = GetFileType(hFile); + unsigned fFlags = aStdHandles[i].fFlags; + unsigned fFlags2; + int fd2; + if (dwType == FILE_TYPE_CHAR) + fFlags2 = SHFILE_FLAGS_TTY; + else if (dwType == FILE_TYPE_PIPE) + fFlags2 = SHFILE_FLAGS_PIPE; + else + fFlags2 = SHFILE_FLAGS_FILE; + fd2 = shfile_insert(pfdtab, (intptr_t)hFile, fFlags, fFlags2, i, "shtab_init"); assert(fd2 == i); (void)fd2; if (fd2 != i) rc = -1; } } # else + /* + * Annoying... + */ + int fd; + + for (fd = 0; fd < 10; fd++) + { + int oflags = fcntl(fd, F_GETFL, 0); + if (oflags != -1) + { + int cox = fcntl(fd, F_GETFD, 0); + struct stat st; + if ( cox != -1 + && fstat(fd, &st) != -1) + { + int native; + int fd2; + int fFlags2 = 0; + if (cox & FD_CLOEXEC) + fFlags2 |= SHFILE_FLAGS_CLOSE_ON_EXEC; + if (S_ISREG(st.st_mode)) + fFlags2 |= SHFILE_FLAGS_FILE; + else if (S_ISDIR(st.st_mode)) + fFlags2 |= SHFILE_FLAGS_DIR; + else if (S_ISCHR(st.st_mode)) + fFlags2 |= SHFILE_FLAGS_TTY; + else if (S_ISFIFO(st.st_mode)) + fFlags2 |= SHFILE_FLAGS_PIPE; + else + fFlags2 |= SHFILE_FLAGS_TTY; + + native = fcntl(fd, F_DUPFD, SHFILE_UNIX_MIN_FD); + if (native == -1) + native = fd; + fd2 = shfile_insert(pfdtab, native, oflags, fFlags2, fd, "shtab_init"); + assert(fd2 == fd); (void)fd2; + if (fd2 != fd) + rc = -1; + if (native != fd) + close(fd); + } + } + } + # endif } else @@ -587,7 +777,7 @@ void shfile_fork_win(shfdtab *pfdtab, int set, intptr_t *hndls) DWORD fFlag = set ? HANDLE_FLAG_INHERIT : 0; shmtx_enter(&pfdtab->mtx, &tmp); - TRACE2((NULL, "shfile_fork_win:\n")); + TRACE2((NULL, "shfile_fork_win: set=%d\n", set)); i = pfdtab->size; while (i-- > 0) @@ -597,7 +787,7 @@ void shfile_fork_win(shfdtab *pfdtab, int set, intptr_t *hndls) HANDLE hFile = (HANDLE)pfdtab->tab[i].native; if (set) TRACE2((NULL, " #%d: native=%#x oflags=%#x shflags=%#x\n", - i, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags, hFile)); + i, hFile, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags)); if (!SetHandleInformation(hFile, HANDLE_FLAG_INHERIT, fFlag)) { DWORD err = GetLastError(); @@ -611,10 +801,12 @@ void shfile_fork_win(shfdtab *pfdtab, int set, intptr_t *hndls) for (i = 0; i < 3; i++) { if ( pfdtab->size > i - && pfdtab->tab[i].fd == 0) + && pfdtab->tab[i].fd == i) hndls[i] = pfdtab->tab[i].native; else hndls[i] = (intptr_t)INVALID_HANDLE_VALUE; + TRACE2((NULL, "shfile_fork_win: i=%d size=%d fd=%d native=%d hndls[%d]=%p\n", + i, pfdtab->size, pfdtab->tab[i].fd, pfdtab->tab[i].native, i, hndls[i])); } } @@ -643,12 +835,12 @@ void *shfile_exec_win(shfdtab *pfdtab, int prepare, unsigned short *sizep, intpt unsigned i; shmtx_enter(&pfdtab->mtx, &tmp); - TRACE2((NULL, "shfile_fork_win:\n")); + TRACE2((NULL, "shfile_exec_win: prepare=%p\n", prepare)); count = pfdtab->size < (0x10000-4) / (1 + sizeof(HANDLE)) ? pfdtab->size : (0x10000-4) / (1 + sizeof(HANDLE)); - while (count > 3 && pfdtab->tab[count].fd == -1) + while (count > 3 && pfdtab->tab[count - 1].fd == -1) count--; if (prepare) @@ -668,7 +860,7 @@ void *shfile_exec_win(shfdtab *pfdtab, int prepare, unsigned short *sizep, intpt { HANDLE hFile = (HANDLE)pfdtab->tab[i].native; TRACE2((NULL, " #%d: native=%#x oflags=%#x shflags=%#x\n", - i, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags, hFile)); + i, hFile, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags)); if (!SetHandleInformation(hFile, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) { @@ -696,11 +888,13 @@ void *shfile_exec_win(shfdtab *pfdtab, int prepare, unsigned short *sizep, intpt for (i = 0; i < 3; i++) { - if ( count > i - && pfdtab->tab[i].fd == 0) + if ( i < count + && pfdtab->tab[i].fd == i) hndls[i] = pfdtab->tab[i].native; else hndls[i] = (intptr_t)INVALID_HANDLE_VALUE; + TRACE2((NULL, "shfile_exec_win: i=%d count=%d fd=%d native=%d hndls[%d]=\n", + i, count, pfdtab->tab[i].fd, pfdtab->tab[i].native, i, hndls[i])); } *sizep = (unsigned short)cbData; @@ -733,6 +927,38 @@ void *shfile_exec_win(shfdtab *pfdtab, int prepare, unsigned short *sizep, intpt #endif /* K_OS_WINDOWS */ +#if K_OS != K_OS_WINDOWS +/** + * Prepare file handles for inherting before a execve call. + * + * This is only used in the normal mode, so we've forked and need not worry + * about cleaning anything up after us. Nor do we need think about locking. + * + * @returns 0 on success, -1 on failure. + */ +int shfile_exec_unix(shfdtab *pfdtab) +{ + int rc = 0; +# ifdef SHFILE_IN_USE + unsigned fd; + + for (fd = 0; fd < pfdtab->size; fd++) + { + if ( pfdtab->tab[fd].fd != -1 + && !(pfdtab->tab[fd].shflags & SHFILE_FLAGS_CLOSE_ON_EXEC) ) + { + TRACE2((NULL, "shfile_exec_unix: %d => %d\n", pfdtab->tab[fd].native, fd)); + if (dup2(pfdtab->tab[fd].native, fd) < 0) + { + /* fatal_error(NULL, "shfile_exec_unix: failed to move %d to %d", pfdtab->tab[fd].fd, fd); */ + rc = -1; + } + } + } +# endif + return rc; +} +#endif /* !K_OS_WINDOWS */ /** * open(). @@ -815,18 +1041,9 @@ int shfile_open(shfdtab *pfdtab, const char *name, unsigned flags, mode_t mode) fd = shfile_make_path(pfdtab, name, &absname[0]); if (!fd) { - fd = open(absname, flag, mode); + fd = open(absname, flags, mode); if (fd != -1) - { - int native = fcntl(fd, F_DUPFD, SHFILE_UNIX_MIN_FD); - int s = errno; - close(fd); - errno = s; - if (native != -1) - fd = shfile_insert(pfdtab, native, flags, 0, -1, "shfile_open"); - else - fd = -1; - } + fd = shfile_copy_insert_and_close(pfdtab, &fd, flags, 0, -1, "shfile_open"); } # endif /* K_OS != K_OS_WINDOWS */ @@ -841,7 +1058,7 @@ int shfile_open(shfdtab *pfdtab, const char *name, unsigned flags, mode_t mode) int shfile_pipe(shfdtab *pfdtab, int fds[2]) { - int rc; + int rc = -1; #ifdef SHFILE_IN_USE # if K_OS == K_OS_WINDOWS HANDLE hRead = INVALID_HANDLE_VALUE; @@ -869,10 +1086,10 @@ int shfile_pipe(shfdtab *pfdtab, int fds[2]) fds[1] = fds[0] = -1; if (!pipe(native_fds)) { - fds[0] = shfile_insert(pfdtab, native_fds[0], O_RDONLY, SHFILE_FLAGS_PIPE, -1, "shfile_pipe"); + fds[0] = shfile_copy_insert_and_close(pfdtab, &native_fds[0], O_RDONLY, SHFILE_FLAGS_PIPE, -1, "shfile_pipe"); if (fds[0] != -1) { - fds[1] = shfile_insert(pfdtab, native_fds[1], O_WRONLY, SHFILE_FLAGS_PIPE, -1, "shfile_pipe"); + fds[1] = shfile_copy_insert_and_close(pfdtab, &native_fds[1], O_WRONLY, SHFILE_FLAGS_PIPE, -1, "shfile_pipe"); if (fds[1] != -1) rc = 0; } @@ -929,6 +1146,122 @@ int shfile_dup(shfdtab *pfdtab, int fd) } /** + * Move the file descriptor, closing any existing descriptor at @a fdto. + * + * @returns fdto on success, -1 and errno on failure. + * @param pfdtab The file descriptor table. + * @param fdfrom The descriptor to move. + * @param fdto Where to move it. + */ +int shfile_movefd(shfdtab *pfdtab, int fdfrom, int fdto) +{ +#ifdef SHFILE_IN_USE + int rc; + shmtxtmp tmp; + shfile *file = shfile_get(pfdtab, fdfrom, &tmp); + if (file) + { + /* prepare the new entry */ + if (fdto >= (int)pfdtab->size) + shfile_grow_tab_locked(pfdtab, fdto); + if (fdto < (int)pfdtab->size) + { + if (pfdtab->tab[fdto].fd != -1) + shfile_native_close(pfdtab->tab[fdto].native, pfdtab->tab[fdto].oflags); + + /* setup the target. */ + pfdtab->tab[fdto].fd = fdto; + pfdtab->tab[fdto].oflags = file->oflags; + pfdtab->tab[fdto].shflags = file->shflags; + pfdtab->tab[fdto].native = file->native; + + /* close the source. */ + file->fd = -1; + file->oflags = 0; + file->shflags = 0; + file->native = -1; + + rc = fdto; + } + else + { + errno = EMFILE; + rc = -1; + } + + shfile_put(pfdtab, file, &tmp); + } + else + rc = -1; + return rc; + +#else + return dup2(fdfrom, fdto); +#endif +} + +/** + * Move the file descriptor to somewhere at @a fdMin or above. + * + * @returns the new file descriptor success, -1 and errno on failure. + * @param pfdtab The file descriptor table. + * @param fdfrom The descriptor to move. + * @param fdMin The minimum descriptor. + */ +int shfile_movefd_above(shfdtab *pfdtab, int fdfrom, int fdMin) +{ +#ifdef SHFILE_IN_USE + int fdto; + shmtxtmp tmp; + shfile *file = shfile_get(pfdtab, fdfrom, &tmp); + if (file) + { + /* find a new place */ + int i; + fdto = -1; + for (i = fdMin; (unsigned)i < pfdtab->size; i++) + if (pfdtab->tab[i].fd == -1) + { + fdto = i; + break; + } + if (fdto == -1) + fdto = shfile_grow_tab_locked(pfdtab, fdMin); + if (fdto != -1) + { + /* setup the target. */ + pfdtab->tab[fdto].fd = fdto; + pfdtab->tab[fdto].oflags = file->oflags; + pfdtab->tab[fdto].shflags = file->shflags; + pfdtab->tab[fdto].native = file->native; + + /* close the source. */ + file->fd = -1; + file->oflags = 0; + file->shflags = 0; + file->native = -1; + } + else + { + errno = EMFILE; + fdto = -1; + } + + shfile_put(pfdtab, file, &tmp); + } + else + fdto = -1; + return fdto; + +#else + int fdnew = fcntl(fdfrom, F_DUPFD, fdMin); + if (fdnew >= 0) + close(fdfrom); + return fdnew; +#endif +} + +/** * close(). */ int shfile_close(shfdtab *pfdtab, unsigned fd) @@ -1019,8 +1352,29 @@ long shfile_write(shfdtab *pfdtab, int fd, const void *buf, size_t len) rc = -1; #else + if (fd != shthread_get_shell()->tracefd) + { + struct stat s; + int x; + x = fstat(fd, &s); + TRACE2((NULL, "shfile_write(%d) - %lu bytes (%d) - pos %lu - before; %o\n", + fd, (long)s.st_size, x, (long)lseek(fd, 0, SEEK_CUR), s.st_mode )); + errno = 0; + } + rc = write(fd, buf, len); #endif + +#ifdef DEBUG + if (fd != shthread_get_shell()->tracefd) + { + struct stat s; + int x; + TRACE2((NULL, "shfile_write(%d,,%d) -> %d [%d]\n", fd, len, rc, errno)); + x=fstat(fd, &s); + TRACE2((NULL, "shfile_write(%d) - %lu bytes (%d) - pos %lu - after\n", fd, (long)s.st_size, x, (long)lseek(fd, 0, SEEK_CUR) )); + } +#endif return rc; } @@ -1095,7 +1449,7 @@ int shfile_fcntl(shfdtab *pfdtab, int fd, int cmd, int arg) # else rc = fcntl(file->native, F_SETFL, arg); if (rc != -1) - file->flags = (file->flags & ~mask) | (arg & mask); + file->oflags = (file->oflags & ~mask) | (arg & mask); # endif } break; @@ -1116,9 +1470,11 @@ int shfile_fcntl(shfdtab *pfdtab, int fd, int cmd, int arg) else rc = shfile_dos2errno(GetLastError()); # else - int nativeNew = fcntl(file->native F_DUPFD, SHFILE_UNIX_MIN_FD); + int nativeNew = fcntl(file->native, F_DUPFD, SHFILE_UNIX_MIN_FD); if (nativeNew != -1) rc = shfile_insert(pfdtab, nativeNew, file->oflags, file->shflags, arg, "shfile_fcntl"); + else + rc = -1; # endif break; } @@ -1196,9 +1552,9 @@ int shfile_lstat(shfdtab *pfdtab, const char *path, struct stat *pst) */ int shfile_chdir(shfdtab *pfdtab, const char *path) { - shinstance *psh = shthread_get_shell(); int rc; #ifdef SHFILE_IN_USE + shinstance *psh = shthread_get_shell(); char abspath[SHFILE_MAX_PATH]; rc = shfile_make_path(pfdtab, path, &abspath[0]); @@ -1225,7 +1581,7 @@ int shfile_chdir(shfdtab *pfdtab, const char *path) rc = chdir(path); #endif - TRACE2((psh, "shfile_chdir(,%s) -> %d [%d]\n", path, rc, errno)); + TRACE2((NULL, "shfile_chdir(,%s) -> %d [%d]\n", path, rc, errno)); return rc; } @@ -1256,7 +1612,7 @@ char *shfile_getcwd(shfdtab *pfdtab, char *buf, int size) } else { - if (size < cwd_size) + if ((size_t)size < cwd_size) size = (int)cwd_size; ret = sh_malloc(shthread_get_shell(), size); if (ret) @@ -1349,6 +1705,7 @@ int shfile_cloexec(shfdtab *pfdtab, int fd, int closeit) else file->shflags &= ~SHFILE_FLAGS_CLOSE_ON_EXEC; shfile_put(pfdtab, file, &tmp); + rc = 0; } else rc = -1; @@ -1402,11 +1759,50 @@ void shfile_set_umask(shfdtab *pfdtab, mode_t mask) } + shdir *shfile_opendir(shfdtab *pfdtab, const char *dir) { -#ifdef SHFILE_IN_USE - errno = ENOSYS; - return NULL; +#if defined(SHFILE_IN_USE) && K_OS == K_OS_WINDOWS + shdir *pdir = NULL; + + if (g_pfnNtQueryDirectoryFile) + { + char abspath[SHFILE_MAX_PATH]; + if (shfile_make_path(pfdtab, dir, &abspath[0]) == 0) + { + HANDLE hFile; + SECURITY_ATTRIBUTES SecurityAttributes; + + SecurityAttributes.nLength = sizeof(SecurityAttributes); + SecurityAttributes.lpSecurityDescriptor = NULL; + SecurityAttributes.bInheritHandle = FALSE; + + hFile = CreateFileA(abspath, + GENERIC_READ, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + &SecurityAttributes, + OPEN_EXISTING, + FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_BACKUP_SEMANTICS, + NULL /* hTemplateFile */); + if (hFile != INVALID_HANDLE_VALUE) + { + pdir = (shdir *)sh_malloc(shthread_get_shell(), sizeof(*pdir)); + if (pdir) + { + pdir->pfdtab = pfdtab; + pdir->native = hFile; + pdir->off = ~(size_t)0; + } + else + CloseHandle(hFile); + } + else + shfile_dos2errno(GetLastError()); + } + } + else + errno = ENOSYS; + return pdir; #else return (shdir *)opendir(dir); #endif @@ -1414,8 +1810,65 @@ shdir *shfile_opendir(shfdtab *pfdtab, const char *dir) shdirent *shfile_readdir(struct shdir *pdir) { -#ifdef SHFILE_IN_USE - errno = ENOSYS; +#if defined(SHFILE_IN_USE) && K_OS == K_OS_WINDOWS + if (pdir) + { + NTSTATUS rcNt; + + if ( pdir->off == ~(size_t)0 + || pdir->off + sizeof(MY_FILE_NAMES_INFORMATION) >= pdir->cb) + { + MY_IO_STATUS_BLOCK Ios; + + memset(&Ios, 0, sizeof(Ios)); + rcNt = g_pfnNtQueryDirectoryFile(pdir->native, + NULL /*Event*/, + NULL /*ApcRoutine*/, + NULL /*ApcContext*/, + &Ios, + &pdir->buf[0], + sizeof(pdir->buf), + MY_FileNamesInformation, + FALSE /*ReturnSingleEntry*/, + NULL /*FileName*/, + pdir->off == ~(size_t)0 /*RestartScan*/); + if (rcNt >= 0 && rcNt != STATUS_PENDING) + { + pdir->cb = Ios.Information; + pdir->off = 0; + } + else if (rcNt == STATUS_NO_MORE_FILES) + errno = 0; /* wrong? */ + else + shfile_nt2errno(rcNt); + } + + if ( pdir->off != ~(size_t)0 + && pdir->off + sizeof(MY_FILE_NAMES_INFORMATION) <= pdir->cb) + { + PMY_FILE_NAMES_INFORMATION pcur = (PMY_FILE_NAMES_INFORMATION)&pdir->buf[pdir->off]; + ANSI_STRING astr; + UNICODE_STRING ustr; + + astr.Length = astr.MaximumLength = sizeof(pdir->ent.name); + astr.Buffer = &pdir->ent.name[0]; + + ustr.Length = ustr.MaximumLength = pcur->FileNameLength < ~(USHORT)0 ? (USHORT)pcur->FileNameLength : ~(USHORT)0; + ustr.Buffer = &pcur->FileName[0]; + + rcNt = g_pfnRtlUnicodeStringToAnsiString(&astr, &ustr, 0/*AllocateDestinationString*/); + if (rcNt < 0) + sprintf(pdir->ent.name, "conversion-failed-%08x-rcNt=%08x-len=%u", + pcur->FileIndex, rcNt, pcur->FileNameLength); + if (pcur->NextEntryOffset) + pdir->off += pcur->NextEntryOffset; + else + pdir->off = pdir->cb; + return &pdir->ent; + } + } + else + errno = EINVAL; return NULL; #else struct dirent *pde = readdir((DIR *)pdir); @@ -1425,8 +1878,16 @@ shdirent *shfile_readdir(struct shdir *pdir) void shfile_closedir(struct shdir *pdir) { -#ifdef SHFILE_IN_USE - errno = ENOSYS; +#if defined(SHFILE_IN_USE) && K_OS == K_OS_WINDOWS + if (pdir) + { + CloseHandle(pdir->native); + pdir->pfdtab = NULL; + pdir->native = INVALID_HANDLE_VALUE; + sh_free(shthread_get_shell(), pdir); + } + else + errno = EINVAL; #else closedir((DIR *)pdir); #endif diff --git a/src/kash/shfile.h b/src/kash/shfile.h index dfac8a8..2118017 100644 --- a/src/kash/shfile.h +++ b/src/kash/shfile.h @@ -1,9 +1,9 @@ -/* $Id: shfile.h 2307 2009-03-01 09:48:04Z bird $ */ +/* $Id: shfile.h 2498 2011-07-22 12:05:57Z bird $ */ /** @file * * File management. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -38,7 +38,7 @@ # if !defined(__sun__) # include <paths.h> # endif -# ifdef _PATH_DEVNULL +# ifndef _PATH_DEVNULL # define _PATH_DEVNULL "/dev/null" # endif # ifndef _PATH_DEFPATH @@ -131,6 +131,7 @@ typedef struct shfdtab int shfile_init(shfdtab *, shfdtab *); void shfile_fork_win(shfdtab *pfdtab, int set, intptr_t *hndls); void *shfile_exec_win(shfdtab *pfdtab, int prepare, unsigned short *sizep, intptr_t *hndls); +int shfile_exec_unix(shfdtab *pfdtab); int shfile_open(shfdtab *, const char *, unsigned, mode_t); int shfile_pipe(shfdtab *, int [2]); @@ -140,6 +141,8 @@ long shfile_write(shfdtab *, int, const void *, size_t); long shfile_lseek(shfdtab *, int, long, int); int shfile_fcntl(shfdtab *, int fd, int cmd, int arg); int shfile_dup(shfdtab *, int fd); +int shfile_movefd(shfdtab *, int fdfrom, int fdto); +int shfile_movefd_above(shfdtab *, int fdfrom, int fdmin); int shfile_stat(shfdtab *, const char *, struct stat *); int shfile_lstat(shfdtab *, const char *, struct stat *); @@ -149,7 +152,7 @@ int shfile_access(shfdtab *, const char *, int); int shfile_isatty(shfdtab *, int); int shfile_cloexec(shfdtab *, int, int); int shfile_ioctl(shfdtab *, int, unsigned long, void *); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__OS2__) # define TIOCGWINSZ 0x4201 typedef struct sh_winsize { @@ -172,9 +175,14 @@ typedef struct sh_dirent typedef struct shdir { - shfdtab *shfdtab; + shfdtab *pfdtab; void *native; shdirent ent; +#if K_OS == K_OS_WINDOWS + size_t off; + size_t cb; + char buf[32768 - sizeof(void *) * 2 - sizeof(shdirent) * 2]; +#endif } shdir; shdir *shfile_opendir(shfdtab *, const char *); diff --git a/src/kash/shfork-win.c b/src/kash/shfork-win.c index ce6df7b..0973b0c 100644 --- a/src/kash/shfork-win.c +++ b/src/kash/shfork-win.c @@ -5,6 +5,7 @@ *******************************************************************************/ #include <string.h> #include <locale.h> +#include <assert.h> #include "shinstance.h" #include <Windows.h> @@ -28,14 +29,16 @@ static void *g_stack_limit = 0; static void *shfork_string_to_ptr(const char *str, const char *argv0, const char *what); /* in shforkA-win.asm: */ +extern pid_t shfork_do_it(shinstance *psh); extern void shfork_resume(void *cur, void *base, void *limit); /* called by shforkA-win.asm: */ void *shfork_maybe_forked(int argc, char **argv, char **envp); extern int shfork_body(shinstance *psh, void *stack_ptr); +extern void init_syntax(void); -/*** +/** * Called by shforkA-win.asm to check whether we're a forked child * process or not. * @@ -63,10 +66,9 @@ void *shfork_maybe_forked(int argc, char **argv, char **envp) || strcmp(argv[6], "--stack-limit")) { char *stack; - shheap_init(); - stack = (char *)sh_malloc(NULL, SHFORK_STACK_SIZE) + SHFORK_STACK_SIZE; - g_stack_base = stack + SHFORK_STACK_SIZE; - g_stack_limit = stack; + shheap_init(NULL); + g_stack_limit = stack = (char *)sh_malloc(NULL, SHFORK_STACK_SIZE); + g_stack_base = stack += SHFORK_STACK_SIZE; return stack; } @@ -82,6 +84,8 @@ void *shfork_maybe_forked(int argc, char **argv, char **envp) stack_ptr = shfork_string_to_ptr(argv[3], argv[0], "--stack-address"); g_stack_base = shfork_string_to_ptr(argv[5], argv[0], "--stack-base"); g_stack_limit = shfork_string_to_ptr(argv[7], argv[0], "--stack-limit"); + assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base); + assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit); /* * Switch stack and jump to the fork resume point. @@ -136,7 +140,28 @@ static void *shfork_string_to_ptr(const char *str, const char *argv0, const char return (void *)ptr; } -/*** +/** + * Do the fork. + * @returns same as fork(). + * @param psh The shell that's forking. + */ +int shfork_do(shinstance *psh) +{ + /* save globals */ + void *pheap_head = shheap_get_head(); + pid_t pid = shfork_do_it(psh); + if (pid == 0) + { + /* reinit stuff, only the heap is copied! */ + shthread_set_shell(psh); + shheap_init(pheap_head); + setlocale(LC_ALL, ""); + init_syntax(); + } + return pid; +} + +/** * Create the child process making sure it inherits all our handles, * copy of the forkable heap and kick it off. * @@ -156,6 +181,9 @@ int shfork_body(shinstance *psh, void *stack_ptr) DWORD cch; int rc = 0; + assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base); + assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit); + /* * Mark all handles inheritable and get the three standard handles. */ @@ -177,6 +205,7 @@ int shfork_body(shinstance *psh, void *stack_ptr) cch += sprintf(&szCmdLine[cch], " --!forked!-- --stack-address %p --stack-base %p --stack-limit %p", stack_ptr, g_stack_base, g_stack_limit); szCmdLine[cch+1] = '\0'; + TRACE2((NULL, "shfork_body: szCmdLine=%s\n", szCmdLine)); memset(&StrtInfo, '\0', sizeof(StrtInfo)); /* just in case. */ StrtInfo.cb = sizeof(StrtInfo); @@ -190,7 +219,7 @@ int shfork_body(shinstance *psh, void *stack_ptr) StrtInfo.dwXCountChars = 0; StrtInfo.dwYCountChars = 0; StrtInfo.dwFillAttribute = 0; - StrtInfo.dwFlags = 0; + StrtInfo.dwFlags = STARTF_USESTDHANDLES;; StrtInfo.wShowWindow = 0; StrtInfo.cbReserved2 = 0; StrtInfo.lpReserved2 = NULL; diff --git a/src/kash/shforkA-win.asm b/src/kash/shforkA-win.asm index 1a68d82..6db4f28 100644 --- a/src/kash/shforkA-win.asm +++ b/src/kash/shforkA-win.asm @@ -1,10 +1,10 @@ -; $Id: shforkA-win.asm 2314 2009-03-02 01:31:03Z bird $ +; $Id: shforkA-win.asm 2416 2010-09-14 00:30:30Z bird $ ;; @file ; shforkA-win.asm - assembly routines used when forking on Windows. ; ; -; Copyright (c) 2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +; Copyright (c) 2009-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> ; ; This file is part of kBuild. ; @@ -120,7 +120,7 @@ global NAME(main) mov rdx, [rbp - 10h] ; argv mov r8, [rbp - 18h] ; envp - lea rsp, [eax - 40h] ; Switch! + lea rsp, [rax - 40h] ; Switch! %else mov [esp + 18h], eax mov [eax - 4], esp diff --git a/src/kash/shheap.c b/src/kash/shheap.c index 10a127a..2b2b582 100644 --- a/src/kash/shheap.c +++ b/src/kash/shheap.c @@ -1,10 +1,10 @@ -/* $Id: shheap.c 2308 2009-03-01 10:01:02Z bird $ */ +/* $Id: shheap.c 2416 2010-09-14 00:30:30Z bird $ */ /** @file * The shell memory heap methods. */ /* - * Copyright (c) 2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2009-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -94,7 +94,7 @@ typedef struct shmemchunk *******************************************************************************/ #define SHHEAP_ALIGN(sz) (((sz) + 31) & ~(size_t)31) #define SHHEAP_CHUNK_ALIGN(sz) (((sz) + 0xffff) & ~(size_t)0xffff) -#define SHHEAP_MIN_CHUNK 0x10000 //(1024*1024) +#define SHHEAP_MIN_CHUNK 0x80000 //(1024*1024) #ifdef NDEBUG # define SHHEAP_CHECK() do { } while (0) # define SHHEAP_CHECK_2() do { } while (0) @@ -122,12 +122,13 @@ static shmemchunk *g_sh_heap; #endif -int shheap_init(void) +int shheap_init(void *phead) { int rc; #ifdef SHHEAP_IN_USE SHHEAP_ASSERT(SHHEAP_ALIGN(sizeof(shmemhdr)) == sizeof(shmemhdr)); rc = shmtx_init(&g_sh_heap_mtx); + g_sh_heap = (shmemchunk *)phead; /* non-zero on fork() */ #else rc = 0; #endif @@ -137,6 +138,17 @@ int shheap_init(void) #ifdef SHHEAP_IN_USE # if K_OS == K_OS_WINDOWS + +/** + * Get the head so the child can pass it to shheap_init() after fork(). + * + * @returns g_sh_heap. + */ +void *shheap_get_head(void) +{ + return g_sh_heap; +} + /** * Copies the heap into the child process. * @@ -160,7 +172,7 @@ int shheap_fork_copy_to_child(void *hChild) if (chld_chnk != chunk) { err = GetLastError(); - fprintf(stderr, "shfork: VirtualAllocEx(,%p,%p,) -> %d\n", chunk, chunk->size, err); + fprintf(stderr, "shfork: VirtualAllocEx(,%p,%p,) -> %p/%d\n", chunk, chunk->size, chld_chnk, err); break; } @@ -179,8 +191,8 @@ int shheap_fork_copy_to_child(void *hChild) errno = EINVAL; return -1; } -# endif +# endif /* K_OS == K_OS_WINDOWS */ /** * Checks a heap chunk. diff --git a/src/kash/shheap.h b/src/kash/shheap.h index a8fc276..06d5343 100644 --- a/src/kash/shheap.h +++ b/src/kash/shheap.h @@ -1,10 +1,10 @@ -/* $Id: shheap.h 2293 2009-02-28 07:25:12Z bird $ */ +/* $Id: shheap.h 2416 2010-09-14 00:30:30Z bird $ */ /** @file * The shell memory heap methods. */ /* - * Copyright (c) 2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2009-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -31,7 +31,8 @@ #include "shtypes.h" /* heap */ -int shheap_init(void); +int shheap_init(void *phead); +void *shheap_get_head(void); int shheap_fork_copy_to_child(void *); void *sh_malloc(shinstance *, size_t); diff --git a/src/kash/shinstance.c b/src/kash/shinstance.c index 27e8d60..0eb052e 100644 --- a/src/kash/shinstance.c +++ b/src/kash/shinstance.c @@ -1,10 +1,10 @@ -/* $Id: shinstance.c 2311 2009-03-02 00:46:13Z bird $ */ +/* $Id: shinstance.c 2423 2010-10-17 23:43:35Z bird $ */ /** @file * The shell instance methods. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -41,7 +41,7 @@ #if K_OS == K_OS_WINDOWS # include <Windows.h> -extern pid_t shfork_do_it(shinstance *psh); /* shforkA-win.asm */ +extern pid_t shfork_do(shinstance *psh); /* shforkA-win.asm */ #endif @@ -478,7 +478,7 @@ static void sh_sig_common_handler(int signo) { shinstance *psh; - fprintf(stderr, "sh_sig_common_handler: signo=%d:%s\n", signo, sys_signame[signo]); +/* fprintf(stderr, "sh_sig_common_handler: signo=%d:%s\n", signo, sys_signame[signo]); */ /* * No need to take locks if there is only one shell. @@ -800,7 +800,7 @@ int sh_kill(shinstance *psh, pid_t pid, int signo) errno = ENOSYS; rc = -1; # else - fprintf(stderr, "kill(%d, %d)\n", pid, signo); +/* fprintf(stderr, "kill(%d, %d)\n", pid, signo);*/ rc = kill(pid, signo); # endif @@ -897,7 +897,7 @@ pid_t sh_fork(shinstance *psh) TRACE2((psh, "sh_fork\n")); #if K_OS == K_OS_WINDOWS //&& defined(SH_FORKED_MODE) - pid = shfork_do_it(psh); + pid = shfork_do(psh); #elif defined(SH_FORKED_MODE) # ifdef _MSC_VER @@ -1079,8 +1079,11 @@ int sh_execve(shinstance *psh, const char *exe, const char * const *argv, const } } rc = -1; + # else - rc = execve(exe, (char **)argv, (char **)envp); + rc = shfile_exec_unix(&psh->fdtab); + if (!rc) + rc = execve(exe, (char **)argv, (char **)envp); # endif #else @@ -1119,7 +1122,7 @@ int sh_execve(shinstance *psh, const char *exe, const char * const *argv, const cmdline_size = 2; for (i = 0; argv[i]; i++) cmdline_size += strlen(argv[i]) + 3; - cmdline = p = sh_malloc(psh, env_size); + cmdline = p = sh_malloc(psh, cmdline_size); for (i = 0; argv[i]; i++) { size_t len = strlen(argv[i]); @@ -1140,6 +1143,7 @@ int sh_execve(shinstance *psh, const char *exe, const char * const *argv, const StrtInfo.cb = sizeof(StrtInfo); /* File handles. */ + StrtInfo.dwFlags |= STARTF_USESTDHANDLES; StrtInfo.lpReserved2 = shfile_exec_win(&psh->fdtab, 1 /* prepare */, &StrtInfo.cbReserved2, hndls); StrtInfo.hStdInput = (HANDLE)hndls[0]; StrtInfo.hStdOutput = (HANDLE)hndls[1]; diff --git a/src/kash/shinstance.h b/src/kash/shinstance.h index 38dd36a..7aa0ac6 100644 --- a/src/kash/shinstance.h +++ b/src/kash/shinstance.h @@ -1,10 +1,10 @@ -/* $Id: shinstance.h 2298 2009-03-01 05:18:30Z bird $ */ +/* $Id: shinstance.h 2498 2011-07-22 12:05:57Z bird $ */ /** @file * The shell instance and it's methods. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -32,6 +32,7 @@ #include <signal.h> /* NSIG */ #ifndef _MSC_VER # include <termios.h> +# include <sys/types.h> # include <sys/ioctl.h> # include <sys/resource.h> #endif @@ -364,13 +365,22 @@ const char *sh_gethomedir(shinstance *, const char *); # define SIG_BLOCK 1 # define SIG_UNBLOCK 2 # define SIG_SETMASK 3 -# define SIGHUP 5 -# define SIGQUIT 9 -# define SIGPIPE 12 -# define SIGTTOU 17 -# define SIGTSTP 18 -# define SIGTTIN 19 + +# define SIGHUP 1 /* _SIGHUP_IGNORE */ +/*# define SIGINT 2 */ +# define SIGQUIT 3 /* _SIGQUIT_IGNORE */ +/*# define SIGILL 4 */ +/*# define SIGFPE 8 */ +/*# define SIGSEGV 11 */ +# define SIGPIPE 13 /* _SIGPIPE_IGNORE */ +/*# define SIGTERM 15 */ +# define SIGTTIN 16 /* _SIGIOINT_IGNORE */ +# define SIGTSTP 17 /* _SIGSTOP_IGNORE */ +# define SIGTTOU 18 # define SIGCONT 20 +/*# define SIGBREAK 21 */ +/*# define SIGABRT 22 */ + # define sys_siglist sys_signame #endif /* _MSC_VER */ #ifdef __sun__ diff --git a/src/kash/show.c b/src/kash/show.c index 5cd4f77..699c6cd 100644 --- a/src/kash/show.c +++ b/src/kash/show.c @@ -272,8 +272,8 @@ indent(int amount, char *pfx, FILE *fp) * if it's NULL and returning (void) if that fails. */ # define TRY_GET_PSH_OR_RETURN(psh) \ if (!(psh)) { \ - psh = shthread_get_shell(); \ - if (!psh) \ + (psh) = shthread_get_shell(); \ + if (!(psh)) \ return; \ } else do { } while (0) @@ -515,6 +515,7 @@ opentrace(shinstance *psh) } want_fd = ((want_fd + 1) / 2) - 1; } + shfile_cloexec(&psh->fdtab, psh->tracefd, 1 /* close it */); } if (psh->tracefd == -1) { fprintf(stderr, "Can't open %s\n", s); diff --git a/src/kash/shthread.c b/src/kash/shthread.c index f1b440f..ebe87b1 100644 --- a/src/kash/shthread.c +++ b/src/kash/shthread.c @@ -1,9 +1,9 @@ -/* $Id: shthread.c 2312 2009-03-02 01:14:43Z bird $ */ +/* $Id: shthread.c 2498 2011-07-22 12:05:57Z bird $ */ /** @file * * Shell Thread Management. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. @@ -101,7 +101,7 @@ struct shinstance *shthread_get_shell(void) #if K_OS == K_OS_WINDOWS psh = (shinstance *)TlsGetValue(sh_tls); #elif K_OS == K_OS_OS2 - psh = (shinstance *)__libc_TLSGet(iTls) + psh = (shinstance *)__libc_TLSGet(sh_tls); #else psh = (shinstance *)pthread_getspecific(sh_tls); #endif diff --git a/src/kash/shthread.h b/src/kash/shthread.h index 10d5a50..62ec1e9 100644 --- a/src/kash/shthread.h +++ b/src/kash/shthread.h @@ -1,9 +1,9 @@ -/* $Id: shthread.h 2289 2009-02-26 04:58:49Z bird $ */ +/* $Id: shthread.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * * Shell thread methods. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. diff --git a/src/kash/shtypes.h b/src/kash/shtypes.h index 3106b0e..0957dc1 100644 --- a/src/kash/shtypes.h +++ b/src/kash/shtypes.h @@ -1,9 +1,9 @@ -/* $Id: shtypes.h 2314 2009-03-02 01:31:03Z bird $ */ +/* $Id: shtypes.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * * Wrapper for missing types and such. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kBuild. diff --git a/src/kash/tests/Makefile.kmk b/src/kash/tests/Makefile.kmk index 4a848f7..ea216af 100644 --- a/src/kash/tests/Makefile.kmk +++ b/src/kash/tests/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2288 2009-02-25 06:21:10Z bird $ +# $Id: Makefile.kmk 2423 2010-10-17 23:43:35Z bird $ ## @file # Sub-makefile for kash tests. # # -# Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -23,7 +23,7 @@ # # -SUB_DEPTH = ../.. +SUB_DEPTH = ../../.. include $(KBUILD_PATH)/subheader.kmk # @@ -32,7 +32,7 @@ include $(KBUILD_PATH)/subheader.kmk TESTING += kash_tests -KASH_TEST_BIN = $(if $(kash_1_TARGET),$(kash_1_TARGET),$(PATH_INS)/$(TEMPLATE_BIN_INST)kash$(SUFF_EXE)) +KASH_TEST_BIN = $(if $(kash_1_TARGET),$(kash_1_TARGET),$(PATH_INS)/$(TEMPLATE_BIN_INST)kmk_ash$(SUFF_EXE)) KASH_TEST_DIR := $(PATH_SUB_CURRENT) KASH_TESTCASES := $(addprefix $(KASH_TEST_DIR)/,\ trap-exit-1 \ @@ -44,6 +44,7 @@ KASH_TESTCASES := $(addprefix $(KASH_TEST_DIR)/,\ redirect-3 \ pipe-1 \ pipe-2 \ + exec-1 \ ) diff --git a/src/kash/tstDump.c b/src/kash/tstDump.c new file mode 100644 index 0000000..2ef959e --- /dev/null +++ b/src/kash/tstDump.c @@ -0,0 +1,75 @@ +/* $Id: tstDump.c 2413 2010-09-11 17:43:04Z bird $ */
+/** @file
+ * tstDump - dump inherited file handle information on Windows.
+ */
+
+/*
+ * Copyright (c) 2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
+ *
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/*******************************************************************************
+* Header Files *
+*******************************************************************************/
+#include <Windows.h>
+#include <stdio.h>
+
+
+int main()
+{
+ STARTUPINFO Info;
+ GetStartupInfo(&Info);
+
+ printf("tst: hStdInput =%p / %p\n", Info.hStdInput, GetStdHandle(STD_INPUT_HANDLE));
+ printf("tst: hStdOutput=%p / %p\n", Info.hStdOutput, GetStdHandle(STD_OUTPUT_HANDLE));
+ printf("tst: hStdError =%p / %p\n", Info.hStdError, GetStdHandle(STD_ERROR_HANDLE));
+ printf("tst: cbReserved2=%d (%#x) lpReserved2=%p\n",
+ Info.cbReserved2, Info.cbReserved2, Info.lpReserved2);
+
+ if (Info.cbReserved2 > sizeof(int) && Info.lpReserved2)
+ {
+ int count = *(int *)Info.lpReserved2;
+ unsigned char *paf = (unsigned char *)Info.lpReserved2 + sizeof(int);
+ HANDLE *pah = (HANDLE *)(paf + count);
+ int i;
+
+ printf("tst: count=%d\n", count);
+ for (i = 0; i < count; i++)
+ {
+ if (paf[i] == 0 && pah[i] == INVALID_HANDLE_VALUE)
+ continue;
+
+ printf("tst: #%02d: native=%#p flags=%#x", i, pah[i], paf[i]);
+ if (paf[i] & 0x01) printf(" FOPEN");
+ if (paf[i] & 0x02) printf(" FEOFLAG");
+ if (paf[i] & 0x02) printf(" FEOFLAG");
+ if (paf[i] & 0x04) printf(" FCRLF");
+ if (paf[i] & 0x08) printf(" FPIPE");
+ if (paf[i] & 0x10) printf(" FNOINHERIT");
+ if (paf[i] & 0x20) printf(" FAPPEND");
+ if (paf[i] & 0x40) printf(" FDEV");
+ if (paf[i] & 0x80) printf(" FTEXT");
+ printf("\n");
+ }
+ }
+
+ return 0;
+}
+
diff --git a/src/kash/var.c b/src/kash/var.c index 9848bf6..250047b 100644 --- a/src/kash/var.c +++ b/src/kash/var.c @@ -264,7 +264,11 @@ initvar(shinstance *psh) if (find_var(psh, "PS1", &vpp, &psh->vps1.name_len) == NULL) { psh->vps1.next = *vpp; *vpp = &psh->vps1; +#ifdef KBUILD_VERSION_MAJOR + psh->vps1.text = sh_strdup(psh, sh_geteuid(psh) ? "PS1=kash$ " : "PS1=kash# "); +#else psh->vps1.text = sh_strdup(psh, sh_geteuid(psh) ? "PS1=$ " : "PS1=# "); +#endif psh->vps1.flags = VSTRFIXED|VTEXTFIXED; } } diff --git a/src/kmk/Makefile.am b/src/kmk/Makefile.am index 6c1068c..45e788d 100644 --- a/src/kmk/Makefile.am +++ b/src/kmk/Makefile.am @@ -128,25 +128,29 @@ DEFS = \ -DCONFIG_WITH_INCLUDEDEP \ -DCONFIG_WITHOUT_THREADS \ -DCONFIG_WITH_VALUE_LENGTH \ - -DCONFIG_WITH_RSORT \ + \ -DCONFIG_WITH_ABSPATHEX \ - -DCONFIG_WITH_COMPARE \ - -DCONFIG_WITH_STACK \ + -DCONFIG_WITH_COMMANDS_FUNC \ + -DCONFIG_WITH_DATE \ + -DCONFIG_WITH_DEFINED_FUNCTIONS \ + -DCONFIG_WITH_EVALPLUS \ + -DCONFIG_WITH_FILE_SIZE \ + -DCONFIG_WITH_LOOP_FUNCTIONS \ -DCONFIG_WITH_MATH \ - -DCONFIG_WITH_XARGS \ -DCONFIG_WITH_NANOTS \ + -DCONFIG_WITH_ROOT_FUNC \ + -DCONFIG_WITH_RSORT \ + -DCONFIG_WITH_STACK \ + -DCONFIG_WITH_STRING_FUNCTIONS \ + -DCONFIG_WITH_WHERE_FUNCTION \ + -DCONFIG_WITH_WHICH \ + -DCONFIG_WITH_XARGS \ + \ + -DCONFIG_WITH_COMPARE \ -DCONFIG_WITH_SET_CONDITIONALS \ -DCONFIG_WITH_IF_CONDITIONALS \ - -DCONFIG_WITH_DATE \ - -DCONFIG_WITH_FILE_SIZE \ - -DCONFIG_WITH_WHICH \ -DCONFIG_WITH_PRINTF \ - -DCONFIG_WITH_EVALPLUS \ -DCONFIG_WITH_MINIMAL_STATS \ - -DCONFIG_WITH_COMMANDS_FUNC \ - -DCONFIG_WITH_STRING_FUNCTIONS \ - -DCONFIG_WITH_LOOP_FUNCTIONS \ - -DCONFIG_WITH_ROOT_FUNC \ -DCONFIG_PRETTY_COMMAND_PRINTING \ -DCONFIG_WITH_PRINT_STATS_SWITCH \ -DCONFIG_WITH_PRINT_TIME_SWITCH \ @@ -161,7 +165,7 @@ DEFS = \ -DKBUILD_SVN_REV=1 \ -DKBUILD_VERSION_MAJOR=0 \ -DKBUILD_VERSION_MINOR=1 \ - -DKBUILD_VERSION_PATCH=98 \ + -DKBUILD_VERSION_PATCH=9998 \ \ -DCONFIG_WITH_KMK_BUILTIN \ @DEFS@ diff --git a/src/kmk/Makefile.kmk b/src/kmk/Makefile.kmk index 5eb7885..fe2cd43 100644 --- a/src/kmk/Makefile.kmk +++ b/src/kmk/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2263 2009-01-23 00:22:47Z bird $ +# $Id: Makefile.kmk 2532 2011-08-02 13:05:37Z bird $ ## @file # Sub-makefile for kmk / GNU Make. # # -# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -31,39 +31,40 @@ include $(KBUILD_PATH)/subheader.kmk # Template for kmk and the kmk_* binaries in this makefile. # TEMPLATE_BIN-KMK = Template for src/gmake binaries -TEMPLATE_BIN-KMK_EXTENDS = BIN +TEMPLATE_BIN-KMK_EXTENDS = BIN-THREADED TEMPLATE_BIN-KMK_DEFS = \ HAVE_CONFIG_H \ $(TEMPLATE_BIN_DEFS) \ KBUILD_SVN_REV=$(KBUILD_SVN_REV) \ KBUILD_TYPE=\"$(KBUILD_TYPE)\" TEMPLATE_BIN-KMK_DEPS = \ - $(PATH_kmk)/config.h \ - $(PATH_kmk)/fts.h + $(kmk_0_OUTDIR)/config.h \ + $(kmk_0_OUTDIR)/fts.h TEMPLATE_BIN-KMK_CLEAN = $(TEMPLATE_BIN-KMK_DEPS) TEMPLATE_BIN-KMK_DEPS.solaris = \ - $(PATH_kmk)/paths.h + $(kmk_0_OUTDIR)/paths.h TEMPLATE_BIN-KMK_CLEAN.solaris = $(TEMPLATE_BIN-KMK_DEPS.solaris) TEMPLATE_BIN-KMK_DEPS.win = \ - $(PATH_kmk)/sysexits.h \ - $(PATH_kmk)/unistd.h \ - $(PATH_kmk)/paths.h \ - $(PATH_kmk)/grp.h \ - $(PATH_kmk)/pwd.h \ - $(PATH_kmk)/inttypes.h -TEMPLATE_BIN-KMK_CFLAGS.win.amd64 = $(TEMPLATE_BIN_CFLAGS.win.amd64) -wd4244 -wd4267 + $(kmk_0_OUTDIR)/sysexits.h \ + $(kmk_0_OUTDIR)/unistd.h \ + $(kmk_0_OUTDIR)/paths.h \ + $(kmk_0_OUTDIR)/grp.h \ + $(kmk_0_OUTDIR)/pwd.h \ + $(kmk_0_OUTDIR)/inttypes.h +TEMPLATE_BIN-KMK_CFLAGS.win.amd64 = $(TEMPLATE_BIN-THREADED_CFLAGS.win.amd64) -wd4244 -wd4267 TEMPLATE_BIN-KMK_CLEAN.win = $(TEMPLATE_BIN-KMK_DEPS.win) -TEMPLATE_BIN-KMK_INCS = $(PATH_kmk) . $(TEMPLATE_BIN_INCS) +TEMPLATE_BIN-KMK_INCS = $(kmk_0_OUTDIR) . $(TEMPLATE_BIN-THREADED_INCS) TEMPLATE_BIN-KMK_INCS.darwin = glob TEMPLATE_BIN-KMK_INCS.dragonfly = glob TEMPLATE_BIN-KMK_INCS.freebsd = glob +TEMPLATE_BIN-KMK_INCS.openbsd = glob TEMPLATE_BIN-KMK_INCS.solaris = glob -TEMPLATE_BIN-KMK_LIBS = $(TEMPLATE_BIN_LIBS) $(TARGET_kmkmissing) $(LIB_KUTIL) +TEMPLATE_BIN-KMK_LIBS = $(TEMPLATE_BIN-THREADED_LIBS) $(kmkmissing_1_TARGET) $(LIB_KUTIL) ifdef ELECTRIC_HEAP # for electric heap (see electric.c) - windows only. ifeq ($(KBUILD_TARGET),win) - TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) /FI$(kmk_PATH)/electric.h -DELECTRIC_HEAP=1 + TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN-THREADED_CFLAGS) /FI$(kmk_DEFPATH)/electric.h -DELECTRIC_HEAP=1 else - TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) -include $(kmk_PATH)/electric.h -DELECTRIC_HEAP=1 + TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN-THREADED_CFLAGS) -include $(kmk_DEFPATH)/electric.h -DELECTRIC_HEAP=1 endif endif @@ -103,6 +104,10 @@ kmkmissing_SOURCES.freebsd = \ kmkmissing_SOURCES.linux += \ kmkbuiltin/strlcpy.c +kmkmissing_SOURCES.openbsd = \ + kmkbuiltin/openbsd.c \ + glob/glob.c + kmkmissing_SOURCES.solaris = \ kmkbuiltin/strlcpy.c \ kmkbuiltin/solfakes.c \ @@ -148,29 +153,33 @@ kmk_DEFS = \ CONFIG_NO_DEFAULT_TERMINAL_RULES \ CONFIG_NO_DEFAULT_SUFFIX_RULES \ CONFIG_NO_DEFAULT_VARIABLES \ + \ + CONFIG_WITH_ABSPATHEX \ + CONFIG_WITH_COMMANDS_FUNC \ + CONFIG_WITH_DATE \ + CONFIG_WITH_DEFINED_FUNCTIONS \ + CONFIG_WITH_EVALPLUS \ + CONFIG_WITH_FILE_SIZE \ + CONFIG_WITH_LOOP_FUNCTIONS \ + CONFIG_WITH_MATH \ + CONFIG_WITH_NANOTS \ + CONFIG_WITH_ROOT_FUNC \ + CONFIG_WITH_RSORT \ + CONFIG_WITH_STACK \ + CONFIG_WITH_STRING_FUNCTIONS \ + CONFIG_WITH_WHERE_FUNCTION \ + CONFIG_WITH_WHICH \ + CONFIG_WITH_XARGS \ + \ CONFIG_WITH_EXTENDED_NOTPARALLEL \ CONFIG_WITH_INCLUDEDEP \ CONFIG_WITH_VALUE_LENGTH \ - CONFIG_WITH_RSORT \ - CONFIG_WITH_ABSPATHEX \ CONFIG_WITH_COMPARE \ - CONFIG_WITH_STACK \ - CONFIG_WITH_MATH \ - CONFIG_WITH_XARGS \ - CONFIG_WITH_NANOTS \ CONFIG_WITH_SET_CONDITIONALS \ CONFIG_WITH_IF_CONDITIONALS \ - CONFIG_WITH_DATE \ - CONFIG_WITH_FILE_SIZE \ - CONFIG_WITH_WHICH \ CONFIG_WITH_PRINTF \ - CONFIG_WITH_EVALPLUS \ CONFIG_WITH_MINIMAL_STATS \ - CONFIG_WITH_COMMANDS_FUNC \ - CONFIG_WITH_PRINTF \ - CONFIG_WITH_STRING_FUNCTIONS \ - CONFIG_WITH_LOOP_FUNCTIONS \ - CONFIG_WITH_ROOT_FUNC \ + \ CONFIG_PRETTY_COMMAND_PRINTING \ CONFIG_WITH_PRINT_STATS_SWITCH \ CONFIG_WITH_PRINT_TIME_SWITCH \ @@ -215,12 +224,11 @@ kmk_SOURCES = \ vpath.c \ remote-stub.c +kmk_DEFS.freebsd.x86 = CONFIG_WITHOUT_THREADS + #kmk_LIBS.solaris = malloc #kmk_DEFS.solaris += HAVE_MALLINFO -kmk_LIBS.freebsd.amd64 = pthread -kmk_DEFS.freebsd.x86 = CONFIG_WITHOUT_THREADS - # # kmkbuiltin commands # @@ -401,9 +409,9 @@ PROGRAMS += kmk_gmake kmk_gmake_TEMPLATE = BIN-KMK kmk_gmake_DEFS = \ HAVE_CONFIG_H \ - NO_ARCHIVES \ CONFIG_WITH_TOUPPER_TOLOWER \ EXPERIMENTAL +# NO_ARCHIVES kmk_gmake_SOURCES = \ main.c \ @@ -486,33 +494,33 @@ include $(FILE_KBUILD_SUB_FOOTER) # # Use checked in config.h instead of running ./Configure for it. # -kmk_config.h.$(KBUILD_TARGET) := $(kmk_PATH)/config.h.$(KBUILD_TARGET) -$(PATH_kmk)/config.h: $(kmk_config.h.$(KBUILD_TARGET)) +kmk_config.h.$(KBUILD_TARGET) := $(kmk_DEFPATH)/config.h.$(KBUILD_TARGET) +$(kmk_0_OUTDIR)/config.h: $(kmk_config.h.$(KBUILD_TARGET)) $(MKDIR) -p $(dir $@) $(CP) $^ $@ # # Some missing headers. # -$(PATH_kmk)/fts.h: $(kmk_PATH)/kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/fts.h: $(kmk_DEFPATH)/kmkbuiltin/ftsfake.h | $(call DIRDEP,$(kmk_0_OUTDIR)) $(CP) $^ $@ -$(PATH_kmk)/unistd.h: | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/unistd.h: | $(call DIRDEP,$(kmk_0_OUTDIR)) $(ECHO_EXT) > $@ -$(PATH_kmk)/sysexits.h: | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/sysexits.h: | $(call DIRDEP,$(kmk_0_OUTDIR)) $(ECHO_EXT) > $@ -$(PATH_kmk)/inttypes.h: | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/inttypes.h: | $(call DIRDEP,$(kmk_0_OUTDIR)) $(ECHO_EXT) > $@ -$(PATH_kmk)/paths.h: | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/paths.h: | $(call DIRDEP,$(kmk_0_OUTDIR)) $(ECHO_EXT) > $@ -$(PATH_kmk)/pwd.h: | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/pwd.h: | $(call DIRDEP,$(kmk_0_OUTDIR)) $(ECHO_EXT) > $@ -$(PATH_kmk)/grp.h: | $(call DIRDEP,$(PATH_kmk)) +$(kmk_0_OUTDIR)/grp.h: | $(call DIRDEP,$(kmk_0_OUTDIR)) $(ECHO_EXT) > $@ @@ -566,22 +574,25 @@ test_shell_newline: test_stack: - $(MAKE) -f $(kmk_PATH)/testcase-stack.kmk + $(MAKE) -f $(kmk_DEFPATH)/testcase-stack.kmk test_math: - $(MAKE) -f $(kmk_PATH)/testcase-math.kmk + $(MAKE) -f $(kmk_DEFPATH)/testcase-math.kmk test_if1of: - $(MAKE) -f $(kmk_PATH)/testcase-if1of.kmk + $(MAKE) -f $(kmk_DEFPATH)/testcase-if1of.kmk test_local: - $(MAKE) -f $(kmk_PATH)/testcase-local.kmk + $(MAKE) -f $(kmk_DEFPATH)/testcase-local.kmk test_includedep: - $(MAKE) -f $(kmk_PATH)/testcase-includedep.kmk + $(MAKE) -f $(kmk_DEFPATH)/testcase-includedep.kmk + +test_root: + $(MAKE) -f $(kmk_DEFPATH)/testcase-root.kmk test_2ndtargetexp: - $(MAKE) -f $(kmk_PATH)/testcase-2ndtargetexp.kmk + $(MAKE) -f $(kmk_DEFPATH)/testcase-2ndtargetexp.kmk test_30_continued_on_failure_worker: this_executable_does_not_exist.exe @@ -598,9 +609,19 @@ test_30_continued_on_failure: fi test_lazy_deps_vars: - $(MAKE) -C $(kmk_PATH) -f testcase-lazy-deps-vars.kmk - - -test_all: test_math test_stack test_shell test_if1of test_local test_includedep test_2ndtargetexp test_30_continued_on_failure test_lazy_deps_vars + $(MAKE) -C $(kmk_DEFPATH) -f testcase-lazy-deps-vars.kmk + + +test_all: \ + test_math \ + test_stack \ + test_shell \ + test_if1of \ + test_local \ + test_root \ + test_includedep \ + test_2ndtargetexp \ + test_30_continued_on_failure \ + test_lazy_deps_vars diff --git a/src/kmk/alloccache.c b/src/kmk/alloccache.c index 8c40663..82202c7 100644 --- a/src/kmk/alloccache.c +++ b/src/kmk/alloccache.c @@ -1,4 +1,4 @@ -/* $Id: alloccache.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: alloccache.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * alloccache - Fixed sized allocation cache. * @@ -15,7 +15,7 @@ */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/electric.c b/src/kmk/electric.c index e756a33..c8d0235 100644 --- a/src/kmk/electric.c +++ b/src/kmk/electric.c @@ -1,10 +1,10 @@ -/* $Id: electric.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: electric.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * A simple electric heap implementation. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/electric.h b/src/kmk/electric.h index 4333c39..eb39082 100644 --- a/src/kmk/electric.h +++ b/src/kmk/electric.h @@ -1,10 +1,10 @@ -/* $Id: electric.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: electric.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * A simple electric heap implementation, wrapper header. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/expreval.c b/src/kmk/expreval.c index 1a48e60..0e7f6b7 100644 --- a/src/kmk/expreval.c +++ b/src/kmk/expreval.c @@ -1,11 +1,11 @@ #ifdef CONFIG_WITH_IF_CONDITIONALS -/* $Id: expreval.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: expreval.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * expreval - Expressions evaluator, C / BSD make / nmake style. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/function.c b/src/kmk/function.c index 3708ebc..7fe5f4c 100644 --- a/src/kmk/function.c +++ b/src/kmk/function.c @@ -676,6 +676,29 @@ func_flavor (char *o, char **argv, const char *funcname UNUSED) return o; } +#ifdef CONFIG_WITH_WHERE_FUNCTION +static char * +func_where (char *o, char **argv, const char *funcname UNUSED) +{ + struct variable *v = lookup_variable (argv[0], strlen (argv[0])); + char buf[64]; + + if (v == 0) + o = variable_buffer_output (o, "undefined", 9); + else + if (v->fileinfo.filenm) + { + o = variable_buffer_output (o, v->fileinfo.filenm, strlen(v->fileinfo.filenm)); + sprintf (buf, ":%lu", v->fileinfo.lineno); + o = variable_buffer_output (o, buf, strlen(buf)); + } + else + o = variable_buffer_output (o, "no-location", 11); + + return o; +} +#endif /* CONFIG_WITH_WHERE_FUNCTION */ + #ifdef VMS # define IS_PATHSEP(c) ((c) == ']') #else @@ -801,6 +824,7 @@ func_basename_dir (char *o, char **argv, const char *funcname) } #ifdef CONFIG_WITH_ROOT_FUNC + /* $(root path) @@ -874,7 +898,7 @@ func_root (char *o, char **argv, const char *funcname UNUSED) #endif if (p2 != NULL) { - /* Include all subsequent path seperators. */ + /* Include all subsequent path separators. */ while (len > 0 && IS_PATHSEP(*p2)) p2++, len--; @@ -890,6 +914,87 @@ func_root (char *o, char **argv, const char *funcname UNUSED) return o; } + +/* + $(notroot path) + + This is mainly for dealing with drive letters and UNC paths on Windows + and OS/2. + */ +static char * +func_notroot (char *o, char **argv, const char *funcname UNUSED) +{ + const char *paths = argv[0] ? argv[0] : ""; + int doneany = 0; + const char *p; + unsigned int len; + + while ((p = find_next_token (&paths, &len)) != 0) + { + const char *p2 = p; + +#ifdef HAVE_DOS_PATHS + if ( len >= 2 + && p2[1] == ':' + && ( (p2[0] >= 'A' && p2[0] <= 'Z') + || (p2[0] >= 'a' && p2[0] <= 'z'))) + { + p2 += 2; + len -= 2; + } + else if (len >= 4 && IS_PATHSEP(p2[0]) && IS_PATHSEP(p2[1]) + && !IS_PATHSEP(p2[2])) + { + /* Min recognized UNC: "//./" - find the next slash + Typical root: "//srv/shr/" */ + /* XXX: Check if //./ needs special handling. */ + unsigned int saved_len = len; + + p2 += 3; + len -= 3; + while (len > 0 && !IS_PATHSEP(*p2)) + p2++, len--; + + if (len && IS_PATHSEP(p2[0]) && (len == 1 || !IS_PATHSEP(p2[1]))) + { + p2++; + len--; + + if (len) /* optional share */ + while (len > 0 && !IS_PATHSEP(*p2)) + p2++, len--; + } + else + { + p2 = p; + len = saved_len; + } + } + +#elif defined (VMS) || defined (AMGIA) + /* XXX: VMS and AMGIA */ + fatal (NILF, _("$(root ) is not implemented on this platform")); +#endif + + /* Exclude all subsequent / leading path separators. */ + + while (len > 0 && IS_PATHSEP(*p2)) + p2++, len--; + if (len > 0) + o = variable_buffer_output (o, p2, len); + else + o = variable_buffer_output (o, ".", 1); + o = variable_buffer_output (o, " ", 1); + doneany = 1; + } + + if (doneany) + /* Kill last space. */ + --o; + + return o; +} + #endif /* CONFIG_WITH_ROOT_FUNC */ static char * @@ -931,6 +1036,119 @@ func_subst (char *o, char **argv, const char *funcname UNUSED) return o; } +#ifdef CONFIG_WITH_DEFINED_FUNCTIONS + +/* Used by func_firstdefined and func_lastdefined to parse the optional last + argument. Returns 0 if the variable name is to be returned and 1 if it's + the variable value value. */ +static int +parse_value_name_argument (const char *arg1, const char *funcname) +{ + const char *end; + int rc; + + if (arg1 == NULL) + return 0; + + end = strchr (arg1, '\0'); + strip_whitespace (&arg1, &end); + + if (!strncmp (arg1, "name", end - arg1)) + rc = 0; + else if (!strncmp (arg1, "value", end - arg1)) + rc = 1; + else +#if 1 /* FIXME: later */ + fatal (*expanding_var, + _("second argument to `%s' function must be `name' or `value', not `%s'"), + funcname, arg1); +#else + { + /* check the expanded form */ + char *exp = expand_argument (arg1, strchr (arg1, '\0')); + arg1 = exp; + end = strchr (arg1, '\0'); + strip_whitespace (&arg1, &end); + + if (!strncmp (arg1, "name", end - arg1)) + rc = 0; + else if (!strncmp (arg1, "value", end - arg1)) + rc = 1; + else + fatal (*expanding_var, + _("second argument to `%s' function must be `name' or `value', not `%s'"), + funcname, exp); + free (exp); + } +#endif + + return rc; +} + +/* Given a list of variable names (ARGV[0]), returned the first variable which + is defined (i.e. value is not empty). ARGV[1] indicates whether to return + the variable name or its value. */ +static char * +func_firstdefined (char *o, char **argv, const char *funcname) +{ + unsigned int i; + const char *words = argv[0]; /* Use a temp variable for find_next_token */ + const char *p; + int ret_value = parse_value_name_argument (argv[1], funcname); + + /* FIXME: Optimize by not expanding the arguments, but instead expand them + one by one here. This will require a find_next_token variant which + takes `$(' and `)' into account. */ + while ((p = find_next_token (&words, &i)) != NULL) + { + struct variable *v = lookup_variable (p, i); + if (v && v->value_length) + { + if (ret_value) + variable_expand_string_2 (o, v->value, v->value_length, &o); + else + o = variable_buffer_output (o, p, i); + break; + } + } + + return o; +} + +/* Given a list of variable names (ARGV[0]), returned the last variable which + is defined (i.e. value is not empty). ARGV[1] indicates whether to return + the variable name or its value. */ +static char * +func_lastdefined (char *o, char **argv, const char *funcname) +{ + struct variable *last_v = NULL; + unsigned int i; + const char *words = argv[0]; /* Use a temp variable for find_next_token */ + const char *p; + int ret_value = parse_value_name_argument (argv[1], funcname); + + /* FIXME: Optimize this. Walk from the end on unexpanded arguments. */ + while ((p = find_next_token (&words, &i)) != NULL) + { + struct variable *v = lookup_variable (p, i); + if (v && v->value_length) + { + last_v = v; + break; + } + } + + if (last_v != NULL) + { + if (ret_value) + variable_expand_string_2 (o, last_v->value, last_v->value_length, &o); + else + o = variable_buffer_output (o, last_v->name, last_v->length); + } + return o; +} + +#endif /* CONFIG_WITH_DEFINED_FUNCTIONS */ static char * func_firstword (char *o, char **argv, const char *funcname UNUSED) @@ -2476,9 +2694,9 @@ static char * func_insert (char *o, char **argv, const char *funcname UNUSED) { const char *in = argv[0]; - size_t in_len = strlen (in); + math_int in_len = (math_int)strlen (in); const char *str = argv[1]; - size_t str_len = strlen (str); + math_int str_len = (math_int)strlen (str); math_int n = 0; math_int length = str_len; const char *pad = " "; @@ -2617,7 +2835,7 @@ static char * func_substr (char *o, char **argv, const char *funcname UNUSED) { const char *str = argv[0]; - size_t str_len = strlen (str); + math_int str_len = (math_int)strlen (str); math_int start = math_int_from_string (argv[1]); math_int length = 0; const char *pad = NULL; @@ -3401,9 +3619,10 @@ func_abspathex (char *o, char **argv, const char *funcname UNUSED) /* cwd needs leading spaces chopped and may be optional, in which case we're exactly like $(abspath ). */ - while (isblank(*cwd)) - cwd++; - if (!*cwd) + if (cwd) + while (isblank (*cwd)) + cwd++; + if (!cwd || !*cwd) o = func_abspath (o, argv, funcname); else { @@ -4443,7 +4662,7 @@ math_int_from_string (const char *str) ch -= 'A' - 10; else { - error (NILF, _("bad number: '%s' (base=%d, pos=%d)\n"), start, base, str - start); + error (NILF, _("bad number: '%s' (base=%u, pos=%lu)\n"), start, base, (unsigned long)(str - start)); return 0; } num *= base; @@ -5047,15 +5266,22 @@ static struct function_table_entry function_table_init[] = { STRING_SIZE_TUPLE("notdir"), 0, 1, 1, func_notdir_suffix}, #ifdef CONFIG_WITH_ROOT_FUNC { STRING_SIZE_TUPLE("root"), 0, 1, 1, func_root}, + { STRING_SIZE_TUPLE("notroot"), 0, 1, 1, func_notroot}, #endif { STRING_SIZE_TUPLE("subst"), 3, 3, 1, func_subst}, { STRING_SIZE_TUPLE("suffix"), 0, 1, 1, func_notdir_suffix}, { STRING_SIZE_TUPLE("filter"), 2, 2, 1, func_filter_filterout}, { STRING_SIZE_TUPLE("filter-out"), 2, 2, 1, func_filter_filterout}, { STRING_SIZE_TUPLE("findstring"), 2, 2, 1, func_findstring}, +#ifdef CONFIG_WITH_DEFINED_FUNCTIONS + { STRING_SIZE_TUPLE("firstdefined"), 0, 2, 1, func_firstdefined}, +#endif { STRING_SIZE_TUPLE("firstword"), 0, 1, 1, func_firstword}, { STRING_SIZE_TUPLE("flavor"), 0, 1, 1, func_flavor}, { STRING_SIZE_TUPLE("join"), 2, 2, 1, func_join}, +#ifdef CONFIG_WITH_DEFINED_FUNCTIONS + { STRING_SIZE_TUPLE("lastdefined"), 0, 2, 1, func_lastdefined}, +#endif { STRING_SIZE_TUPLE("lastword"), 0, 1, 1, func_lastword}, { STRING_SIZE_TUPLE("patsubst"), 3, 3, 1, func_patsubst}, { STRING_SIZE_TUPLE("realpath"), 0, 1, 1, func_realpath}, @@ -5065,6 +5291,9 @@ static struct function_table_entry function_table_init[] = { STRING_SIZE_TUPLE("shell"), 0, 1, 1, func_shell}, { STRING_SIZE_TUPLE("sort"), 0, 1, 1, func_sort}, { STRING_SIZE_TUPLE("strip"), 0, 1, 1, func_strip}, +#ifdef CONFIG_WITH_WHERE_FUNCTION + { STRING_SIZE_TUPLE("where"), 0, 1, 1, func_where}, +#endif { STRING_SIZE_TUPLE("wildcard"), 0, 1, 1, func_wildcard}, { STRING_SIZE_TUPLE("word"), 2, 2, 1, func_word}, { STRING_SIZE_TUPLE("wordlist"), 3, 3, 1, func_wordlist}, diff --git a/src/kmk/incdep.c b/src/kmk/incdep.c index 42ea7c7..140e0f8 100644 --- a/src/kmk/incdep.c +++ b/src/kmk/incdep.c @@ -1,11 +1,11 @@ #ifdef CONFIG_WITH_INCLUDEDEP -/* $Id: incdep.c 2283 2009-02-24 04:54:00Z bird $ */ +/* $Id: incdep.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * incdep - Simple dependency files. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/job.c b/src/kmk/job.c index 6d14300..a2c55ff 100644 --- a/src/kmk/job.c +++ b/src/kmk/job.c @@ -1008,6 +1008,7 @@ static void set_child_handler_action_flags (int set_handler, int set_alarm) { struct sigaction sa; + int rval = 0; #if defined(__EMX__) && !defined(__KLIBC__) /* bird */ /* The child handler must be turned off here. */ @@ -1018,11 +1019,13 @@ set_child_handler_action_flags (int set_handler, int set_alarm) sa.sa_handler = child_handler; sa.sa_flags = set_handler ? 0 : SA_RESTART; #if defined SIGCHLD - sigaction (SIGCHLD, &sa, NULL); + rval = sigaction (SIGCHLD, &sa, NULL); #endif #if defined SIGCLD && SIGCLD != SIGCHLD - sigaction (SIGCLD, &sa, NULL); + rval = sigaction (SIGCLD, &sa, NULL); #endif + if (rval != 0) + fprintf (stderr, "sigaction: %s (%d)\n", strerror (errno), errno); #if defined SIGALRM if (set_alarm) { diff --git a/src/kmk/kbuild.c b/src/kmk/kbuild.c index ee2e55c..28a24cb 100644 --- a/src/kmk/kbuild.c +++ b/src/kmk/kbuild.c @@ -1,10 +1,10 @@ -/* $Id: kbuild.c 2248 2009-01-19 04:34:56Z bird $ */ +/* $Id: kbuild.c 2540 2011-08-02 20:13:24Z bird $ */ /** @file * kBuild specific make functionality. */ /* - * Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -154,7 +154,7 @@ void init_kbuild(int argc, char **argv) memcpy(szTmp, pszImageName, cchImageName + 1); rc = 0; } - } + } } # endif @@ -2109,22 +2109,33 @@ func_kbuild_source_one(char *o, char **argv, const char *pszFuncName) memcpy(pszDst, "_CMDS_", sizeof("_CMDS_")); pVar = kbuild_get_recursive_variable(pszSrcVar); do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, - !pVar->recursive, 0, o_file, f_simple, 0 /* !target_var */); + !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); + do_variable_definition_2(NILF, "kbsrc_cmds", pVar->value, pVar->value_length, + !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); memcpy(pszSrc, "_OUTPUT", sizeof("_OUTPUT")); memcpy(pszDst, "_OUTPUT_", sizeof("_OUTPUT_")); pVar = kbuild_get_recursive_variable(pszSrcVar); pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, - !pVar->recursive, 0, o_file, f_simple, 0 /* !target_var */); + !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); + pOutput = do_variable_definition_2(NILF, "kbsrc_output", pVar->value, pVar->value_length, + !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); memcpy(pszSrc, "_OUTPUT_MAYBE", sizeof("_OUTPUT_MAYBE")); memcpy(pszDst, "_OUTPUT_MAYBE_", sizeof("_OUTPUT_MAYBE_")); pVar = kbuild_query_recursive_variable(pszSrcVar); if (pVar) + { pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, - !pVar->recursive, 0, o_file, f_simple, 0 /* !target_var */); + !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); + pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", pVar->value, pVar->value_length, + !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); + } else - pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_file, f_simple, 0 /* !target_var */); + { + pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */); + pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */); + } memcpy(pszSrc, "_DEPEND", sizeof("_DEPEND")); memcpy(pszDst, "_DEPEND_", sizeof("_DEPEND_")); @@ -2137,7 +2148,10 @@ func_kbuild_source_one(char *o, char **argv, const char *pszFuncName) memcpy(psz, pSource->value, pSource->value_length + 1); do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length, !pVar->recursive && !pDeps->recursive && !pSource->recursive, - pszVal, o_file, f_simple, 0 /* !target_var */); + NULL, o_local, f_simple, 0 /* !target_var */); + do_variable_definition_2(NILF, "kbsrc_depend", pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length, + !pVar->recursive && !pDeps->recursive && !pSource->recursive, + pszVal, o_local, f_simple, 0 /* !target_var */); memcpy(pszSrc, "_DEPORD", sizeof("_DEPORD")); memcpy(pszDst, "_DEPORD_", sizeof("_DEPORD_")); @@ -2151,7 +2165,11 @@ func_kbuild_source_one(char *o, char **argv, const char *pszFuncName) do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length, !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive, - pszVal, o_file, f_simple, 0 /* !target_var */); + NULL, o_local, f_simple, 0 /* !target_var */); + do_variable_definition_2(NILF, "kbsrc_depord", pszVal, + pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length, + !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive, + pszVal, o_local, f_simple, 0 /* !target_var */); /* _OUT_FILES += $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) @@ -2472,16 +2490,19 @@ func_kbuild_expand_template(char *o, char **argv, const char *pszFuncName) aKeys[0].cch = 0; aKeys[0].psz = NULL; + /* .$(bld_type) */ aKeys[1].cch = cchBldType + 1; aKeys[1].psz = xmalloc (aKeys[1].cch + 1); aKeys[1].psz[0] = '.'; memcpy(aKeys[1].psz + 1, pszBldType, cchBldType + 1); + /* .$(bld_trg) */ aKeys[2].cch = cchBldTrg + 1; aKeys[2].psz = xmalloc (aKeys[2].cch + 1); aKeys[2].psz[0] = '.'; memcpy(aKeys[2].psz + 1, pszBldTrg, cchBldTrg + 1); + /* .$(bld_trg).$(bld_trg_arch) */ aKeys[3].cch = cchBldTrg + 1 + cchBldTrgArch + 1; aKeys[3].psz = xmalloc (aKeys[3].cch + 1); aKeys[3].psz[0] = '.'; @@ -2489,11 +2510,13 @@ func_kbuild_expand_template(char *o, char **argv, const char *pszFuncName) aKeys[3].psz[1 + cchBldTrg] = '.'; memcpy(aKeys[3].psz + 1 + cchBldTrg + 1, pszBldTrgArch, cchBldTrgArch + 1); + /* .$(bld_trg_cpu) */ aKeys[4].cch = cchBldTrgCpu + 1; aKeys[4].psz = xmalloc (aKeys[4].cch + 1); aKeys[4].psz[0] = '.'; memcpy(aKeys[4].psz + 1, pszBldTrgCpu, cchBldTrgCpu + 1); + /* .$(bld_trg_arch) */ aKeys[5].cch = cchBldTrgArch + 1; aKeys[5].psz = xmalloc (aKeys[5].cch + 1); aKeys[5].psz[0] = '.'; diff --git a/src/kmk/kbuild.h b/src/kmk/kbuild.h index 1f7f438..5d06d31 100644 --- a/src/kmk/kbuild.h +++ b/src/kmk/kbuild.h @@ -1,10 +1,10 @@ -/* $Id: kbuild.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kbuild.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kBuild specific make functionality. */ /* - * Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kdepdb.c b/src/kmk/kdepdb.c new file mode 100644 index 0000000..c90cd6b --- /dev/null +++ b/src/kmk/kdepdb.c @@ -0,0 +1,1087 @@ +/* $Id: incdep.c 2283 2009-02-24 04:54:00Z bird $ */ +/** @file + * kdepdb - Dependency database. + */ + +/* + * Copyright (c) 2009-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> + * + * This file is part of kBuild. + * + * kBuild is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * kBuild is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with kBuild. If not, see <http://www.gnu.org/licenses/> + * + */ + +/******************************************************************************* +* Header Files * +*******************************************************************************/ +#include "make.h" +#include "../lib/k/kDefs.h" +#include "../lib/k/kTypes.h" +#include <assert.h> +#include <glob.h> + +#include "dep.h" +#include "filedef.h" +#include "job.h" +#include "commands.h" +#include "variable.h" +#include "rule.h" +#include "debug.h" +#include "strcache2.h" + +#ifdef HAVE_FCNTL_H +# include <fcntl.h> +#else +# include <sys/file.h> +#endif + +#if K_OS == K_WINDOWS +# include <Windows.h> +#else +# include <unistd.h> +# include <sys/mman.h> +#endif + + +/******************************************************************************* +* Defined Constants And Macros * +*******************************************************************************/ +/** @def KDEPDB_ASSERT_SIZE + * Check the size of an on-disk type. + * + * @param Type The type which size it being checked. + * @param Size The size it should have. + */ +#ifdef __GNUC__ +# define KDEPDB_ASSERT_SIZE(Type, Size) \ + extern int kDepDbAssertSize[1] __attribute__((unused)), \ + kDepDbAssertSize[sizeof(Type) == (Size)] __attribute__((unused)) +#else +# define KDEPDB_ASSERT_SIZE(Type, Size) \ + typedef int kDepDbAssertSize[sizeof(Type) == (Size)] +#endif +KDEPDB_ASSERT_SIZE(KU8, 1); +KDEPDB_ASSERT_SIZE(KU16, 2); +KDEPDB_ASSERT_SIZE(KU32, 4); +KDEPDB_ASSERT_SIZE(KU64, 8); + + +/******************************************************************************* +* Structures and Typedefs * +*******************************************************************************/ +/** + * File header. + * + * @remarks All on-disk formats are in little-endian format. + */ +typedef struct KDEPDBHDR +{ + /** The file magic. */ + KU8 szMagic[8]; + /** The major file format version. */ + KU8 uVerMajor; + /** The minor file format version. */ + KU8 uVerMinor; + /** Reserved \#2. */ + KU16 uReserved2; + /** Reserved \#1. */ + KU32 uReserved1; + /** The internal name of this file. */ + KU8 szName[16]; +} KDEPDBHDR; +KDEPDB_ASSERT_SIZE(KDEPDBHDR, 32); + +/** The file header magic value. */ +#define KDEPDBHDR_MAGIC "kDepDb\0" +/** The current major file format version number. */ +#define KDEPDBHDR_VERSION_MAJOR 0 +/** The current minor file format version number. + * Numbers above 240 indicate unsupported development variants. */ +#define KDEPDBHDR_VERSION_MINOR 240 + + +/** + * Hash table file. + * + * The hash table is recreated in a new file when we have to grow it. + */ +typedef struct KDEPDBHASH +{ + /** The file header. */ + KDEPDBHDR Hdr; + /** The number of hash table entries. */ + KU32 cEntries; + /** The number of hash table entries with content. */ + KU32 cUsedEntries; + /** The number of collisions on insert. */ + KU32 cCollisions; + /** Reserved member \#5. */ + KU32 uReserved5; + /** Reserved member \#4. */ + KU32 uReserved4; + /** Reserved member \#3. */ + KU32 uReserved3; + /** Reserved member \#2. */ + KU32 uReserved2; + /** Reserved member \#1. */ + KU32 uReserved1; + /** The hash table. */ + KU32 auEntries[32]; +} KDEPDBHASH; +KDEPDB_ASSERT_SIZE(KDEPDBHASH, 32+32+4*32); + +/** The item value indicating that it is unused. */ +#define KDEPDBHASH_UNUSED KU32_C(0xffffffff) +/** The item indicating that it hash been deleted. */ +#define KDEPDBHASH_DELETED KU32_C(0xfffffffe) +/** The first special item value. */ +#define KDEPDBHASH_END KU32_C(0xfffffff0) + + +/** + * A string table string entry. + * + * This should be a multiple of 32 bytes. + */ +typedef struct KDEPDBSTRING +{ + /** The hash number for the string. */ + KU32 uHash; + /** The string length, excluding the zero terminator. */ + KU32 cchString; + /** The string. */ + KU8 szString[24]; +} KDEPDBSTRING; +KDEPDB_ASSERT_SIZE(KDEPDBSTRING, 32); + + +/** + * String table file. + * + * The file is insertion only and will grow forever. + */ +typedef struct KDEPDBSTRTAB +{ + /** The file header. */ + KDEPDBHDR Hdr; + /** The end of the valid string table indexes. */ + KU32 iStringEnd; + /** Reserved member \#7. */ + KU32 uReserved7; + /** Reserved member \#6. */ + KU32 uReserved6; + /** Reserved member \#5. */ + KU32 uReserved5; + /** Reserved member \#4. */ + KU32 uReserved4; + /** Reserved member \#3. */ + KU32 uReserved3; + /** Reserved member \#2. */ + KU32 uReserved2; + /** Reserved member \#1. */ + KU32 uReserved1; + /** The string table. */ + KDEPDBSTRING aStrings[1]; +} KDEPDBSTRTAB; +KDEPDB_ASSERT_SIZE(KDEPDBSTRTAB, 32+32+32); + +/** The end of the valid string table indexes (exclusive). */ +#define KDEPDBG_STRTAB_IDX_END KU32_C(0x80000000) +/** The string was not found. */ +#define KDEPDBG_STRTAB_IDX_NOT_FOUND KU32_C(0xfffffffd) +/** Error during string table operation. */ +#define KDEPDBG_STRTAB_IDX_ERROR KU32_C(0xfffffffe) +/** Generic invalid string table index. */ +#define KDEPDBG_STRTAB_IDX_INVALID KU32_C(0xffffffff) + + +/** + * Directory entry. + */ +typedef struct KDEPDBDIRENTRY +{ + /** The string table index of the entry name. + * Unused entries are set to KDEPDBG_STRTAB_IDX_INVALID. */ + KU32 iName; + /** The actual data stream size. + * Unused entries are set to KU32_MAX. */ + KU32 cbData; + /** The number of blocks allocated for this stream. + * Unused entries are set to KU32_MAX. */ + KU32 cBlocks; + /** The start block number. + * The stream is a contiguous sequence of blocks. This optimizes and + * simplifies reading the stream at the expense of operations extending it. + * + * In unused entries, this serves as the free chain pointer with KU32_MAX as + * nil value. */ + KU32 iStartBlock; +} KDEPDBDIRENTRY; +KDEPDB_ASSERT_SIZE(KDEPDBDIRENTRY, 16); + +/** + * Directory file. + */ +typedef struct KDEPDBDIR +{ + /** The file header. */ + KDEPDBHDR Hdr; + /** The number of entries. */ + KU32 cEntries; + /** The head of the free chain. (Index into aEntries.) */ + KU32 iFreeHead; + /** Reserved member \#6. */ + KU32 uReserved6; + /** Reserved member \#5. */ + KU32 uReserved5; + /** Reserved member \#4. */ + KU32 uReserved4; + /** Reserved member \#3. */ + KU32 uReserved3; + /** Reserved member \#2. */ + KU32 uReserved2; + /** Reserved member \#1. */ + KU32 uReserved1; + /** Directory entries. */ + KDEPDBDIRENTRY aEntries[2]; +} KDEPDBDIR; +KDEPDB_ASSERT_SIZE(KDEPDBDIR, 32+32+32); + + +/** + * A block allocation bitmap. + * + * This can track 2^(12+8) = 2^20 = 1M blocks. + */ +typedef struct KDEPDBDATABITMAP +{ + /** Bitmap where each bit is a block. + * 0 indicates unused blocks and 1 indicates used ones. */ + KU8 bm[4096]; +} KDEPDBDATABITMAP; +KDEPDB_ASSERT_SIZE(KDEPDBDATABITMAP, 4096); + +/** + * Data file. + * + * The block numbering starts with this structure as block 0. + */ +typedef struct KDEPDBDATA +{ + /** The file header. */ + KDEPDBHDR Hdr; + /** The size of a block. */ + KU32 cbBlock; + /** Reserved member \#7. */ + KU32 uReserved7; + /** Reserved member \#6. */ + KU32 uReserved6; + /** Reserved member \#5. */ + KU32 uReserved5; + /** Reserved member \#4. */ + KU32 uReserved4; + /** Reserved member \#3. */ + KU32 uReserved3; + /** Reserved member \#2. */ + KU32 uReserved2; + /** Reserved member \#1. */ + KU32 uReserved1; + + /** Block numbers for the allocation bitmaps. */ + KU32 aiBitmaps[4096]; +} KDEPDBDATA; + +/** The end of the valid block indexes (exclusive). */ +#define KDEPDB_BLOCK_IDX_END KU32_C(0xfffffff0) +/** The index of an unallocated bitmap block. */ +#define KDEPDB_BLOCK_IDX_UNALLOCATED KU32_C(0xffffffff) + + +/** + * Stream storing dependencies. + * + * The stream name gives the output file name, so all that we need is the list + * of files it depends on. These are serialized as a list of string table + * indexes. + */ +typedef struct KDEPDBDEPSTREAM +{ + /** String table indexes for the dependencies. */ + KU32 aiDeps[1]; +} KDEPDBDEPSTREAM; + + +/** + * A file handle structure. + */ +typedef struct KDEPDBFH +{ +#if K_OS == K_OS_WINDOWS + /** The file handle. */ + HANDLE hFile; + /** The mapping object handle. */ + HANDLE hMapObj; +#else + /** The file handle. */ + int fd; +#endif + /** The current file size. */ + KU32 cb; +} KDEPDBFH; + + +/** + * Internal control structure for a string table. + */ +typedef struct KDEPDBINTSTRTAB +{ + /** The hash file. */ + KDEPDBHASH *pHash; + /** The handle of the hash file. */ + KDEPDBFH hHash; + /** The string table file. */ + KDEPDBSTRTAB *pStrTab; + /** The handle of the string table file. */ + KDEPDBFH hStrTab; + /** The end of the allocated string table indexes (i.e. when to grow the + * file). */ + KU32 iStringAlloced; +} KDEPDBINTSTRTAB; + + +/** + * Internal control structure for a data set. + * + * This governs the directory file, the directory hash file and the data file. + */ +typedef struct KDEPDBINTDATASET +{ + /** The hash file. */ + KDEPDBHASH pHash; + /** The size of the hash file. */ + KU32 cbHash; + /** The size of the directory file. */ + KU32 cbDir; + /** The mapping of the directory file. */ + KDEPDBHASH pDir; + /** The data file. */ + KDEPDBDATA pData; + /** The size of the data file. */ + KU32 cbData; + /** The handle of the hash file. */ + KDEPDBFH hHash; + /** The handle of the directory file. */ + KDEPDBFH hDir; + /** The handle of the data file. */ + KDEPDBFH hData; +} KDEPDBINTDATASET; + + +/** + * The database instance. + * + * To simplifiy things the database uses 8 files for storing the different kinds + * of data. This greatly reduces the complexity compared to a single file + * solution. + */ +typedef struct KDEPDB +{ + /** The string table. */ + KDEPDBINTSTRTAB StrTab; + /** The variable data set. */ + KDEPDBINTDATASET DepSet; + /** The command data set. */ + KDEPDBINTDATASET CmdSet; +} KDEPDB; + + +/******************************************************************************* +* Internal Functions * +*******************************************************************************/ +static void *kDepDbAlloc(KSIZE cb); +static void kDepDbFree(void *pv); +static void kDepDbFHInit(KDEPDBFH *pFH); +static int kDepDbFHUpdateSize(KDEPDBFH *pFH); +static int kDepDbFHOpen(KDEPDBFH *pFH, const char *pszFilename, KBOOL fCreate, KBOOL *pfNew); +static int kDepDbFHClose(KDEPDBFH *pFH); +static int kDepDbFHWriteAt(KDEPDBFH *pFH, KU32 off, void const *pvBuf, KSIZE cbBuf); +static int kDepDbFHMap(KDEPDBFH *pFH, void **ppvMap); +static int kDepDbFHUnmap(KDEPDBFH *pFH, void **ppvMap); +static int kDepDbFHGrow(KDEPDBFH *pFH, KSIZE cbNew, void **ppvMap); +static KU32 kDepDbHashString(const char *pszString, size_t cchString); + + +/** xmalloc wrapper. */ +static void *kDepDbAlloc(KSIZE cb) +{ + return xmalloc(cb); +} + +/** free wrapper. */ +static void kDepDbFree(void *pv) +{ + if (pv) + free(pv); +} + + +/** + * Initializes the file handle structure so closing it without first opening it + * will work smoothly. + * + * @param pFH The file handle structure. + */ +static void kDepDbFHInit(KDEPDBFH *pFH) +{ +#if K_OS == K_OS_WINDOWS + pFH->hFile = INVALID_HANDLE_VALUE; + pFH->hMapObj = INVALID_HANDLE_VALUE; +#else + pFH->fd = -1; +#endif + pFH->cb = 0; +} + +/** + * Updates the file size. + * + * @returns 0 on success. Some non-zero native error code on failure. + * @param pFH The file handle structure. + */ +static int kDepDbFHUpdateSize(KDEPDBFH *pFH) +{ +#if K_OS == K_OS_WINDOWS + DWORD rc; + DWORD dwHigh; + DWORD dwLow; + + SetLastError(0); + dwLow = GetFileSize(File, &High); + rc = GetLastError(); + if (rc) + { + pFH->cb = 0; + return (int)rc; + } + if (High) + pFH->cb = KU32_MAX; + else + pFH->cb = dwLow; +#else + off_t cb; + + cb = lseek(pFH->fd, 0, SEEK_END); + if (cb == -1) + { + pFH->cb = 0; + return errno; + } + pFH->cb = cb; + if ((off_t)pFH->cb != cb) + pFH->cb = KU32_MAX; +#endif + return 0; +} + +/** + * Opens an existing file or creates a new one. + * + * @returns 0 on success. Some non-zero native error code on failure. + * + * @param pFH The file handle structure. + * @param pszFilename The name of the file. + * @param fCreate Whether we should create the file or not. + * @param pfCreated Where to return whether we created it or not. + */ +static int kDepDbFHOpen(KDEPDBFH *pFH, const char *pszFilename, KBOOL fCreate, KBOOL *pfCreated) +{ + int rc; +#if K_OS == K_OS_WINDOWS + SECURITY_ATTRIBUTES SecAttr; + + SecAttr.bInheritHandle = FALSE; + SecAttr.lpSecurityDescriptor = NULL; + SecAttr.nLength = 0; + pFH->cb = 0; + SetLastError(0); + pFH->hFile = CreateFile(pszFilename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, &SecAttr, + fCreate ? OPEN_ALWAYS : OPEN_EXISTING, 0, NULL); + if (pFH->hFile == INVALID_HANDLE_VALUE) + return GetLastError(); + *pfCreated = GetLastError() == 0; + +#else + int fFlags = O_RDWR; +# ifdef O_BINARY + fFlags |= O_BINARY; +# endif + pFH->cb = 0; + pFH->fd = open(pszFilename, fFlags, 0); + if (pFH->fd >= 0) + *pfCreated = K_FALSE; + else if (!fCreate) + return errno; + else + { + pFH->fd = open(pszFilename, fFlags | O_EXCL | O_CREAT, 0666); + if (pFH->fd < 0) + return errno; + *pfCreated = K_TRUE; + } + fcntl(pFH->fd, F_SETFD, FD_CLOEXEC); +#endif + + /* update the size */ + rc = kDepDbFHUpdateSize(pFH); + if (rc) + kDepDbFHClose(pFH); + return rc; +} + +/** + * Closes an open file. + * + * @returns 0 on success. Some non-zero native error code on failure. + * + * @param pFH The file handle structure. + */ +static int kDepDbFHClose(KDEPDBFH *pFH) +{ +#if K_OS == K_OS_WINDOWS + if (pFH->hFile != INVALID_HANDLE_VALUE) + { + if (!CloseHandle(pFH->hFile)) + return GetLastError(); + pFH->hFile = INVALID_HANDLE_VALUE; + } + +#else + if (pFH->fd >= 0) + { + if (close(pFH->fd) != 0) + return errno; + pFH->fd = -1; + } +#endif + pFH->cb = 0; + return 0; +} + +/** + * Writes to a file. + * + * @returns 0 on success. Some non-zero native error code on failure. + * + * @param pFH The file handle structure. + * @param off The offset into the file to start writing at. + * @param pvBuf What to write. + * @param cbBuf How much to write. + */ +static int kDepDbFHWriteAt(KDEPDBFH *pFH, KU32 off, void const *pvBuf, KSIZE cbBuf) +{ +#if K_OS == K_OS_WINDOWS + ULONG cbWritten; + + if (SetFilePointer(pFH->hFile, off, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER) + return GetLastError(); + + if (!WriteFile(pFH->hFile, pvBuf, cbBuf, &cbWritten, NULL)) + return GetLastError(); + if (cbWritten != cbBuf) + return -1; + +#else + ssize_t cbWritten; + if (lseek(pFH->fd, off, SEEK_SET) == -1) + return errno; + errno = 0; + cbWritten = write(pFH->fd, pvBuf, cbBuf); + if ((size_t)cbWritten != cbBuf) + return errno ? errno : EIO; +#endif + return kDepDbFHUpdateSize(pFH); +} + + +/** + * Creates a memory mapping of the file. + * + * @returns 0 on success. Some non-zero native error code on failure. + * + * @param pFH The file handle structure. + * @param ppvMap Where to return the map address. + */ +static int kDepDbFHMap(KDEPDBFH *pFH, void **ppvMap) +{ +#if K_OS == K_OS_WINDOWS + *ppvMap = NULL; + return -1; +#else + *ppvMap = mmap(NULL, pFH->cb, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, pFH->fd, 0); + if (*ppvMap == (void *)-1) + { + *ppvMap = NULL; + return errno; + } +#endif + return 0; +} + + +/** + * Flushes and destroys a memory of the file. + * + * @returns 0 on success. Some non-zero native error code on failure. + * + * @param pFH The file handle structure. + * @param ppvMap The pointer to the mapping pointer. This will be set to + * NULL on success. + */ +static int kDepDbFHUnmap(KDEPDBFH *pFH, void **ppvMap) +{ +#if K_OS == K_OS_WINDOWS + return -1; +#else + if (msync(*ppvMap, pFH->cb, MS_SYNC) == -1) + return errno; + if (munmap(*ppvMap, pFH->cb) == -1) + return errno; + *ppvMap = NULL; +#endif + return 0; +} + + +/** + * Grows the memory mapping of the file. + * + * The content of the new space is undefined. + * + * @returns 0 on success. Some non-zero native error code on failure. + * + * @param pFH The file handle structure. + * @param cbNew The new mapping size. + * @param ppvMap The pointer to the mapping pointer. This may change and + * may be set to NULL on failure. + */ +static int kDepDbFHGrow(KDEPDBFH *pFH, KSIZE cbNew, void **ppvMap) +{ +#if K_OS == K_OS_WINDOWS + return -1; +#else + if ((KU32)cbNew != cbNew) + return ERANGE; + if (cbNew <= pFH->cb) + return 0; + + if (munmap(*ppvMap, pFH->cb) == -1) + return errno; + *ppvMap = NULL; + + pFH->cb = cbNew; + return kDepDbFHMap(pFH, ppvMap); +#endif +} + + +/** Macro for reading an potentially unaligned 16-bit word from a string. */ +# if K_ARCH == K_ARCH_AMD64 \ + || K_ARCH == K_ARCH_X86_32 \ + || K_ARCH == K_ARCH_X86_16 +# define kDepDbHashString_get_unaligned_16bits(ptr) ( *((const KU16 *)(ptr)) ) +# elif K_ENDIAN == K_ENDIAN_LITTLE +# define kDepDbHashString_get_unaligned_16bits(ptr) ( (((const KU8 *)(ptr))[0]) \ + | (((const KU8 *)(ptr))[1] << 8) ) +# else +# define kDepDbHashString_get_unaligned_16bits(ptr) ( (((const KU8 *)(ptr))[0] << 8) \ + | (((const KU8 *)(ptr))[1]) ) +# endif + + +/** + * Hash a string. + * + * @returns Hash value. + * + * @param pszString The string to hash. + * @param cchString How much to hash. + */ +static KU32 kDepDbHashString(const char *pszString, size_t cchString) +{ + /* + * Paul Hsieh hash SuperFast function: + * http://www.azillionmonkeys.com/qed/hash.html + */ + /** @todo A path for well aligned data should be added to speed up execution on + * alignment sensitive systems. */ + unsigned int uRem; + KU32 uHash; + KU32 uTmp; + + assert(sizeof(KU8) == sizeof(char)); + + /* main loop, walking on 2 x KU16 */ + uHash = cchString; + uRem = cchString & 3; + cchString >>= 2; + while (cchString > 0) + { + uHash += kDepDbHashString_get_unaligned_16bits(pszString); + uTmp = (kDepDbHashString_get_unaligned_16bits(pszString + 2) << 11) ^ uHash; + uHash = (uHash << 16) ^ uTmp; + pszString += 2 * sizeof(KU16); + uHash += uHash >> 11; + cchString--; + } + + /* the remainder */ + switch (uRem) + { + case 3: + uHash += kDepDbHashString_get_unaligned_16bits(pszString); + uHash ^= uHash << 16; + uHash ^= pszString[sizeof(KU16)] << 18; + uHash += uHash >> 11; + break; + case 2: + uHash += kDepDbHashString_get_unaligned_16bits(pszString); + uHash ^= uHash << 11; + uHash += uHash >> 17; + break; + case 1: + uHash += *pszString; + uHash ^= uHash << 10; + uHash += uHash >> 1; + break; + } + + /* force "avalanching" of final 127 bits. */ + uHash ^= uHash << 3; + uHash += uHash >> 5; + uHash ^= uHash << 4; + uHash += uHash >> 17; + uHash ^= uHash << 25; + uHash += uHash >> 6; + + return uHash; +} + + +/*** + * Looks up a string in the string table. + * + * @returns The string table index. + * @retval KDEPDBG_STRTAB_IDX_NOT_FOUND is not found. + * @retval KDEPDBG_STRTAB_IDX_ERROR on internal inconsistency. + * + * @param pStrTab The string table. + * @param pszString The string. + * @param cchStringIn The string length. + * @param uHash The hash of the string. + */ +static KU32 kDepDbStrTabLookupHashed(KDEPDBINTSTRTAB const *pStrTab, const char *pszString, size_t cchStringIn, KU32 uHash) +{ + KU32 const cchString = (KU32)cchStringIn; + KDEPDBHASH const *pHash = pStrTab->pHash; + KDEPDBSTRING const *paStrings = &pStrTab->pStrTab->aStrings[0]; + KU32 const iStringEnd = K_LE2H_U32(pStrTab->pStrTab->iStringEnd); + KU32 iHash; + + /* sanity */ + if (cchString != cchStringIn) + return KDEPDBG_STRTAB_IDX_NOT_FOUND; + + /* + * Hash lookup of the string. + */ + iHash = uHash % pHash->cEntries; + for (;;) + { + KU32 iString = K_LE2H_U32(pHash->auEntries[iHash]); + if (iString < iStringEnd) + { + KDEPDBSTRING const *pString = &paStrings[iString]; + if ( K_LE2H_U32(pString->uHash) == uHash + && K_LE2H_U32(pString->cchString) == cchString + && !memcmp(pString->szString, pszString, cchString)) + return iString; + } + else if (iString == KDEPDBHASH_UNUSED) + return KDEPDBG_STRTAB_IDX_NOT_FOUND; + else if (iString != KDEPDBHASH_DELETED) + return KDEPDBG_STRTAB_IDX_ERROR; + + /* advance */ + iHash = (iHash + 1) % pHash->cEntries; + } +} + + +/** + * Doubles the hash table size and rehashes it. + * + * @returns 0 on success, -1 on failure. + * @param pStrTab The string table. + * @todo Rebuild from string table, we'll be accessing it anyways. + */ +static int kDepDbStrTabReHash(KDEPDBINTSTRTAB *pStrTab) +{ + KDEPDBSTRING const *paStrings = &pStrTab->pStrTab->aStrings[0]; + KU32 const iStringEnd = K_LE2H_U32(pStrTab->pStrTab->iStringEnd); + KDEPDBHASH *pHash = pStrTab->pHash; + KDEPDBHASH HashHdr = *pHash; + KU32 *pauNew; + KU32 cEntriesNew; + KU32 i; + + /* + * Calc the size of the new hash table. + */ + if (pHash->cEntries >= KU32_C(0x80000000)) + return -1; + cEntriesNew = 1024; + while (cEntriesNew <= pHash->cEntries) + cEntriesNew <<= 1; + + /* + * Allocate and initialize an empty hash table in memory. + */ + pauNew = kDepDbAlloc(cEntriesNew * sizeof(KU32)); + if (!pauNew) + return -1; + i = cEntriesNew; + while (i-- > 0) + pauNew[i] = KDEPDBHASH_UNUSED; + + /* + * Popuplate the new table. + */ + HashHdr.cEntries = K_LE2H_U32(cEntriesNew); + HashHdr.cCollisions = 0; + HashHdr.cUsedEntries = 0; + i = pHash->cEntries; + while (i-- > 0) + { + KU32 iString = K_LE2H_U32(pHash->auEntries[i]); + if (iString < iStringEnd) + { + KU32 iHash = (paStrings[iString].uHash % cEntriesNew); + if (pauNew[iHash] != K_H2LE_U32(KDEPDBHASH_UNUSED)) + { + do + { + iHash = (iHash + 1) % cEntriesNew; + HashHdr.cCollisions++; + } while (pauNew[iHash] != K_H2LE_U32(KDEPDBHASH_UNUSED)); + } + pauNew[iHash] = iString; + HashHdr.cUsedEntries++; + } + else if ( iString != KDEPDBHASH_UNUSED + && iString != KDEPDBHASH_DELETED) + { + kDepDbFree(pauNew); + return -1; + } + } + HashHdr.cCollisions = K_H2LE_U32(HashHdr.cCollisions); + HashHdr.cUsedEntries = K_H2LE_U32(HashHdr.cUsedEntries); + + /* + * Unmap the hash, write the new hash table and map it again. + */ + if (!kDepDbFHUnmap(&pStrTab->hHash, (void **)&pStrTab->pHash)) + { + if ( !kDepDbFHWriteAt(&pStrTab->hHash, 0, &HashHdr, K_OFFSETOF(KDEPDBHASH, auEntries)) + && !kDepDbFHWriteAt(&pStrTab->hHash, K_OFFSETOF(KDEPDBHASH, auEntries), pauNew, sizeof(pauNew[0]) * cEntriesNew)) + { + kDepDbFree(pauNew); + pauNew = NULL; + if (!kDepDbFHMap(&pStrTab->hHash, (void **)&pStrTab->pHash)) + return 0; + } + else + kDepDbFHWriteAt(&pStrTab->hHash, 0, "\0\0\0\0", 4); /* file is screwed, trash the magic. */ + } + + kDepDbFree(pauNew); + return -1; +} + + +/** + * Add a string to the string table. + * + * If already in the table, the index of the existing entry is returned. + * + * @returns String index on success, + * @retval KDEPDBG_STRTAB_IDX_ERROR on I/O and inconsistency errors. + * + * @param pStrTab The string table. + * @param pszString The string to add. + * @param cchStringIn The length of the string. + * @param uHash The hash of the string. + */ +static KU32 kDepDbStrTabAddHashed(KDEPDBINTSTRTAB *pStrTab, const char *pszString, size_t cchStringIn, KU32 uHash) +{ + KU32 const cchString = (KU32)cchStringIn; + KDEPDBHASH *pHash = pStrTab->pHash; + KDEPDBSTRING *paStrings = &pStrTab->pStrTab->aStrings[0]; + KU32 const iStringEnd = K_LE2H_U32(pStrTab->pStrTab->iStringEnd); + KU32 iInsertAt = KDEPDBHASH_UNUSED; + KU32 cCollisions = 0; + KU32 iHash; + KU32 iString; + KU32 cEntries; + KDEPDBSTRING *pNewString; + + /* sanity */ + if (cchString != cchStringIn) + return KDEPDBG_STRTAB_IDX_NOT_FOUND; + + /* + * Hash lookup of the string, finding either an existing copy or where to + * insert the new string at in the hash table. + */ + iHash = uHash % pHash->cEntries; + for (;;) + { + iString = K_LE2H_U32(pHash->auEntries[iHash]); + if (iString < iStringEnd) + { + KDEPDBSTRING const *pString = &paStrings[iString]; + if ( K_LE2H_U32(pString->uHash) == uHash + && K_LE2H_U32(pString->cchString) == cchString + && !memcmp(pString->szString, pszString, cchString)) + return iString; + } + else + { + if (iInsertAt == KDEPDBHASH_UNUSED) + iInsertAt = iHash; + if (iString == KDEPDBHASH_UNUSED) + break; + if (iString != KDEPDBHASH_DELETED) + return KDEPDBG_STRTAB_IDX_ERROR; + } + + /* advance */ + cCollisions++; + iHash = (iHash + 1) % pHash->cEntries; + } + + /* + * Add string to the string table. + * The string table file is grown in 256KB increments and ensuring at least 64KB unused new space. + */ + cEntries = cchString + 1 <= sizeof(paStrings[0].szString) + ? 1 + : (cchString + 1 - sizeof(paStrings[0].szString) + sizeof(KDEPDBSTRING) - 1) / sizeof(KDEPDBSTRING); + if (iStringEnd + cEntries > pStrTab->iStringAlloced) + { + KSIZE cbNewSize = K_ALIGN_Z((iStringEnd + cEntries) * sizeof(KDEPDBSTRING) + 64*1024, 256*1024); + KU32 iStringAlloced = (pStrTab->hStrTab.cb - K_OFFSETOF(KDEPDBSTRTAB, aStrings)) / sizeof(KDEPDBSTRING); + if ( iStringAlloced <= pStrTab->iStringAlloced + || iStringAlloced >= KDEPDBG_STRTAB_IDX_END + || iStringAlloced >= KDEPDBHASH_END) + return KDEPDBG_STRTAB_IDX_ERROR; + if (kDepDbFHGrow(&pStrTab->hStrTab, cbNewSize, (void **)&pStrTab->pStrTab) != 0) + return KDEPDBG_STRTAB_IDX_ERROR; + pStrTab->iStringAlloced = iStringAlloced; + paStrings = &pStrTab->pStrTab->aStrings[0]; + } + + pNewString = &paStrings[iStringEnd]; + pNewString->uHash = K_H2LE_U32(uHash); + pNewString->cchString = K_H2LE_U32(cchString); + memcpy(&pNewString->szString, pszString, cchString); + pNewString->szString[cchString] = '\0'; + + pStrTab->pStrTab->iStringEnd = K_H2LE_U32(iStringEnd + cEntries); + + /* + * Insert hash table entry, rehash it if necessary. + */ + pHash->auEntries[iInsertAt] = K_H2LE_U32(iStringEnd); + pHash->cUsedEntries = K_H2LE_U32(K_LE2H_U32(pHash->cUsedEntries) + 1); + pHash->cCollisions = K_H2LE_U32(K_LE2H_U32(pHash->cCollisions) + cCollisions); + if ( K_LE2H_U32(pHash->cUsedEntries) > K_LE2H_U32(pHash->cEntries) / 3 * 2 + && kDepDbStrTabReHash(pStrTab) != 0) + return KDEPDBG_STRTAB_IDX_ERROR; + + return iStringEnd; +} + + +/** Wrapper for kDepDbStrTabLookupHashed. */ +static KU32 kDepDbStrTabLookupN(KDEPDBINTSTRTAB const *pStrTab, const char *pszString, size_t cchString) +{ + return kDepDbStrTabLookupHashed(pStrTab, pszString, cchString, kDepDbHashString(pszString, cchString)); +} + + +/** Wrapper for kDepDbStrTabAddHashed. */ +static KU32 kDepDbStrTabAddN(KDEPDBINTSTRTAB *pStrTab, const char *pszString, size_t cchString) +{ + return kDepDbStrTabAddHashed(pStrTab, pszString, cchString, kDepDbHashString(pszString, cchString)); +} + + +/** Wrapper for kDepDbStrTabLookupHashed. */ +static KU32 kDepDbStrTabLookup(KDEPDBINTSTRTAB const *pStrTab, const char *pszString) +{ + return kDepDbStrTabLookupN(pStrTab, pszString, strlen(pszString)); +} + + +/** Wrapper for kDepDbStrTabAddHashed. */ +static KU32 kDepDbStrTabAdd(KDEPDBINTSTRTAB *pStrTab, const char *pszString) +{ + return kDepDbStrTabAddN(pStrTab, pszString, strlen(pszString)); +} + + +/** + * Opens the string table files, creating them if necessary. + */ +static int kDepDbStrTabInit(KDEPDBINTSTRTAB *pStrTab, const char *pszFilenameBase) +{ + size_t cchFilenameBase = strlen(pszFilenameBase); + char szPath[4096]; + int rc; + KBOOL fNew; + + /* Basic member init, so kDepDbStrTabTerm always works. */ + pStrTab->pHash = NULL; + kDepDbFHInit(&pStrTab->hHash); + pStrTab->pStrTab = NULL; + kDepDbFHInit(&pStrTab->hStrTab); + pStrTab->iStringAlloced = 0; + + /* check the length. */ + if (cchFilenameBase + sizeof(".strtab.hash") > sizeof(szPath)) + return -1; + + /* + * Open the string table first. + */ + memcpy(szPath, pszFilenameBase, cchFilenameBase); + memcpy(&szPath[cchFilenameBase], ".strtab", sizeof(".strtab")); + rc = kDepDbFHOpen(&pStrTab->hStrTab, szPath, K_TRUE, &fNew); + + + return -1; +} + diff --git a/src/kmk/kmkbuiltin.c b/src/kmk/kmkbuiltin.c index 4d923d6..1926a85 100644 --- a/src/kmk/kmkbuiltin.c +++ b/src/kmk/kmkbuiltin.c @@ -1,10 +1,10 @@ -/* $Id: kmkbuiltin.c 2263 2009-01-23 00:22:47Z bird $ */ +/* $Id: kmkbuiltin.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kMk Builtin command execution. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin.h b/src/kmk/kmkbuiltin.h index 3db949f..3d1eb44 100644 --- a/src/kmk/kmkbuiltin.h +++ b/src/kmk/kmkbuiltin.h @@ -1,10 +1,10 @@ -/* $Id: kmkbuiltin.h 2263 2009-01-23 00:22:47Z bird $ */ +/* $Id: kmkbuiltin.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kMk Builtin command handling. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/append.c b/src/kmk/kmkbuiltin/append.c index 42418f9..aac2e5b 100644 --- a/src/kmk/kmkbuiltin/append.c +++ b/src/kmk/kmkbuiltin/append.c @@ -1,10 +1,10 @@ -/* $Id: append.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: append.c 2466 2011-07-12 09:52:39Z bird $ */ /** @file * kMk Builtin command - append text to file. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -177,7 +177,7 @@ int kmk_builtin_append(int argc, char **argv, char **envp) iFile = i; pFile = fopen(argv[i], fTruncate ? "w" : "a"); if (!pFile) - return err(1, "failed to open '%s'.", argv[i]); + return err(1, "failed to open '%s'", argv[i]); /* * Start define? diff --git a/src/kmk/kmkbuiltin/chmod.c b/src/kmk/kmkbuiltin/chmod.c index 3e1eaec..6d360af 100644 --- a/src/kmk/kmkbuiltin/chmod.c +++ b/src/kmk/kmkbuiltin/chmod.c @@ -67,7 +67,7 @@ extern void * bsd_setmode(const char *p); extern mode_t bsd_getmode(const void *bbox, mode_t omode); extern void bsd_strmode(mode_t mode, char *p); -#if defined(__APPLE__) && !defined(_DARWIN_FEATURE_UNIX_CONFORMANCE) +#if (defined(__APPLE__) && !defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)) || defined(__OpenBSD__) extern int lchmod(const char *, mode_t); #endif @@ -195,12 +195,12 @@ done: argv += optind; fts_set(ftsp, p, FTS_SKIP); continue; case FTS_DNR: /* Warn, chmod, continue. */ - warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); + warnx("fts: %s: %s", p->fts_path, strerror(p->fts_errno)); rval = 1; break; case FTS_ERR: /* Warn, continue. */ case FTS_NS: - warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); + warnx("fts: %s: %s", p->fts_path, strerror(p->fts_errno)); rval = 1; continue; case FTS_SL: /* Ignore. */ @@ -221,7 +221,7 @@ done: argv += optind; if ((newmode & ALLPERMS) == (p->fts_statp->st_mode & ALLPERMS)) continue; if ((*change_mode)(p->fts_accpath, newmode) && !fflag) { - warn("%s", p->fts_path); + warn("%schmod: %s", hflag ? "l" : "", p->fts_path); rval = 1; } else { if (vflag) { diff --git a/src/kmk/kmkbuiltin/cp.c b/src/kmk/kmkbuiltin/cp.c index 44b76ab..9622cd1 100644 --- a/src/kmk/kmkbuiltin/cp.c +++ b/src/kmk/kmkbuiltin/cp.c @@ -336,7 +336,7 @@ kmk_builtin_cp(int argc, char *argv[], char **envp) r = stat(to.p_path, &to_stat); if (r == -1 && errno != ENOENT) { kBuildProtectionTerm(&g_ProtData); - return err(1, "%s", to.p_path); + return err(1, "stat: %s", to.p_path); } if (r == -1 || !S_ISDIR(to_stat.st_mode)) { /* @@ -423,14 +423,14 @@ copy(char *argv[], enum op type, int fts_options) if ( cp_ignore_non_existing && curr->fts_errno == ENOENT) { if (vflag) { - warnx("%s: %s", curr->fts_path, + warnx("fts: %s: %s", curr->fts_path, strerror(curr->fts_errno)); } continue; } case FTS_DNR: case FTS_ERR: - warnx("%s: %s", + warnx("fts: %s: %s", curr->fts_path, strerror(curr->fts_errno)); badcp = rval = 1; continue; @@ -593,10 +593,10 @@ copy(char *argv[], enum op type, int fts_options) if (dne) { if (mkdir(to.p_path, curr->fts_statp->st_mode | S_IRWXU) < 0) - return err(1, "%s", to.p_path); + return err(1, "mkdir: %s", to.p_path); } else if (!S_ISDIR(to_stat.st_mode)) { errno = ENOTDIR; - return err(1, "%s", to.p_path); + return err(1, "to-mode: %s", to.p_path); } /* * Arrange to correct directory attributes later diff --git a/src/kmk/kmkbuiltin/cp_utils.c b/src/kmk/kmkbuiltin/cp_utils.c index 1773815..a966fdd 100644 --- a/src/kmk/kmkbuiltin/cp_utils.c +++ b/src/kmk/kmkbuiltin/cp_utils.c @@ -97,7 +97,7 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) *pcopied = 0; if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) { - warn("%s", entp->fts_path); + warn("open: %s", entp->fts_path); return (1); } @@ -123,7 +123,7 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) if (lseek(from_fd, 0, SEEK_SET) != 0) { close(from_fd); if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) { - warn("%s", entp->fts_path); + warn("open: %s", entp->fts_path); return (1); } } @@ -161,7 +161,7 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) fs->st_mode & ~(S_ISUID | S_ISGID)); if (to_fd == -1) { - warn("%s", to.p_path); + warn("open: %s", to.p_path); (void)close(from_fd); return (1); } @@ -179,7 +179,7 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) fs->st_size <= 8 * 1048576) { if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { - warn("%s", entp->fts_path); + warn("mmap: %s", entp->fts_path); rval = 1; } else { wtotal = 0; @@ -199,12 +199,12 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) break; } if (wcount != (ssize_t)wresid) { - warn("%s", to.p_path); + warn("write[%zd != %zu]: %s", wcount, wresid, to.p_path); rval = 1; } /* Some systems don't unmap on close(2). */ if (munmap(p, fs->st_size) < 0) { - warn("%s", entp->fts_path); + warn("munmap: %s", entp->fts_path); rval = 1; } } @@ -229,13 +229,13 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) break; } if (wcount != (ssize_t)wresid) { - warn("%s", to.p_path); + warn("write[%zd != %zu]: %s", wcount, wresid, to.p_path); rval = 1; break; } } if (rcount < 0) { - warn("%s", entp->fts_path); + warn("read: %s", entp->fts_path); rval = 1; } } @@ -251,7 +251,7 @@ copy_file(const FTSENT *entp, int dne, int changed_only, int *pcopied) rval = 1; (void)close(from_fd); if (close(to_fd)) { - warn("%s", to.p_path); + warn("close: %s", to.p_path); rval = 1; } return (rval); diff --git a/src/kmk/kmkbuiltin/darwin.c b/src/kmk/kmkbuiltin/darwin.c index 7c3bfdd..bc35e68 100644 --- a/src/kmk/kmkbuiltin/darwin.c +++ b/src/kmk/kmkbuiltin/darwin.c @@ -1,10 +1,10 @@ -/* $Id: darwin.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: darwin.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Missing BSD functions on Darwin / Mac OS X. */ /* - * Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/err.c b/src/kmk/kmkbuiltin/err.c index e6d4e7a..230b2fe 100644 --- a/src/kmk/kmkbuiltin/err.c +++ b/src/kmk/kmkbuiltin/err.c @@ -1,10 +1,10 @@ -/* $Id: err.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: err.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Override err.h so we get the program name right. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/err.h b/src/kmk/kmkbuiltin/err.h index eb61c62..726a97b 100644 --- a/src/kmk/kmkbuiltin/err.h +++ b/src/kmk/kmkbuiltin/err.h @@ -1,10 +1,10 @@ -/* $Id: err.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: err.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Override err.h stuff so we get the program names right. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/install.c b/src/kmk/kmkbuiltin/install.c index 9ab4b00..6c4b1cc 100644 --- a/src/kmk/kmkbuiltin/install.c +++ b/src/kmk/kmkbuiltin/install.c @@ -122,10 +122,11 @@ extern mode_t bsd_getmode(const void *bbox, mode_t omode); static gid_t gid; static uid_t uid; -static int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose; +static int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose, mode_given; static mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; static const char *suffix = BACKUP_SUFFIX; static int ignore_perm_errors; +static int hard_link_files_when_possible; static struct option long_options[] = { @@ -133,6 +134,8 @@ static struct option long_options[] = { "version", no_argument, 0, 262 }, { "ignore-perm-errors", no_argument, 0, 263 }, { "no-ignore-perm-errors", no_argument, 0, 264 }, + { "hard-link-files-when-possible", no_argument, 0, 265 }, + { "no-hard-link-files-when-possible", no_argument, 0, 266 }, { 0, 0, 0, 0 }, }; @@ -168,8 +171,9 @@ kmk_builtin_install(int argc, char *argv[], char ** envp) suffix = BACKUP_SUFFIX; gid = 0; uid = 0; - dobackup = docompare = dodir = dopreserve = dostrip = nommap = safecopy = verbose = 0; + dobackup = docompare = dodir = dopreserve = dostrip = nommap = safecopy = verbose = mode_given = 0; ignore_perm_errors = geteuid() != 0; + hard_link_files_when_possible = 0; /* reset getopt and set progname. */ g_progname = argv[0]; @@ -219,6 +223,7 @@ kmk_builtin_install(int argc, char *argv[], char ** envp) optarg); mode = bsd_getmode(set, 0); free(set); + mode_given = 1; break; case 'o': owner = optarg; @@ -246,6 +251,12 @@ kmk_builtin_install(int argc, char *argv[], char ** envp) case 264: ignore_perm_errors = 0; break; + case 265: + hard_link_files_when_possible = 1; + break; + case 266: + hard_link_files_when_possible = 0; + break; case '?': default: return usage(stderr); @@ -334,7 +345,8 @@ kmk_builtin_install(int argc, char *argv[], char ** envp) if (to_sb.st_dev == from_sb.st_dev && to_sb.st_dev != 0 && to_sb.st_ino == from_sb.st_ino && - to_sb.st_ino != 0) + to_sb.st_ino != 0 && + !hard_link_files_when_possible) return errx(EX_USAGE, "%s and %s are the same file", *argv, to_name); } @@ -384,9 +396,9 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) #if defined(__EMX__) || defined(_MSC_VER) || ( stricmp(from_name, _PATH_DEVNULL) && stricmp(from_name, "nul") -#ifdef __EMX__ +# ifdef __EMX__ && stricmp(from_name, "/dev/nul") -#endif +# endif ) #else || strcmp(from_name, _PATH_DEVNULL) @@ -422,6 +434,67 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) /* Only copy safe if the target exists. */ tempcopy = safecopy && target; + /* Try hard linking if wanted and possible. */ + if (hard_link_files_when_possible) + { +#ifdef KBUILD_OS_OS2 + const char *why_not = "not supported on OS/2"; +#else + const char *why_not = NULL; + if (devnull) { + why_not = "/dev/null"; + } else if (dostrip) { + why_not = "strip (-s)"; + } else if (docompare) { + why_not = "compare (-C)"; + } else if (dobackup) { + why_not = "backup (-b/-B)"; + } else if (safecopy) { + why_not = "safe copy (-S)"; + } else if (lstat(from_name, &temp_sb)) { + why_not = "lstat on source failed"; + } else if (S_ISLNK(temp_sb.st_mode)) { + why_not = "symlink"; + } else if (!S_ISREG(temp_sb.st_mode)) { + why_not = "not regular file"; +# if defined(KBUILD_OS_WINDOWS) || defined(KBUILD_OS_OS2) + } else if ((mode & S_IWUSR) != (from_sb.st_mode & S_IWUSR)) { +# else + } else if (mode != (from_sb.st_mode & ALLPERMS)) { +# endif + printf("install: warning: Not hard linking, mode differs: 0%03o, desires 0%03o\n" + "install: src path '%s'\n" + "install: dst path '%s'\n", + (from_sb.st_mode & ALLPERMS), mode, from_name, to_name); + why_not = NULL; + } else if (uid != (uid_t)-1 && gid != from_sb.st_uid) { + why_not = "uid mismatch"; + } else if (gid != (gid_t)-1 && gid != from_sb.st_gid) { + why_not = "gid mismatch"; + } else { + int rcLink = link(from_name, to_name); + if (rcLink != 0 && errno == EEXIST) { + unlink(to_name); + rcLink = link(from_name, to_name); + } + if (rcLink == 0) { + if (verbose) + printf("install: %s -> %s (hardlinked)\n", from_name, to_name); + goto l_done; + } + if (verbose) + printf("install: hard linking '%s' to '%s' failed: %s\n", + to_name, from_name, strerror(errno)); + why_not = NULL; + } +#endif + if (verbose && why_not) + printf("install: not hard linking '%s' to '%s' because: %s\n", + to_name, from_name, why_not); + + /* Can't hard link or we failed, continue as nothing happend. */ + } + if (!devnull && (from_fd = open(from_name, O_RDONLY | O_BINARY, 0)) < 0) return err(EX_OSERR, "%s", from_name); @@ -683,7 +756,7 @@ l_done: (void)close(to_fd); if (temp_fd >= 0) (void)close(temp_fd); - if (!devnull) + if (from_fd >= 0 && !devnull) (void)close(from_fd); return rc; } @@ -972,7 +1045,8 @@ static int usage(FILE *pf) { fprintf(pf, -"usage: %s [-bCcpSsv] [--[no-]ignore-perm-errors] [-B suffix] [-f flags]\n" +"usage: %s [-bCcpSsv] [--[no-]hard-link-files-when-possible]\n" +" [--[no-]ignore-perm-errors] [-B suffix] [-f flags]\n" " [-g group] [-m mode] [-o owner] file1 file2\n" " or: %s [-bCcpSsv] [--[no-]ignore-perm-errors] [-B suffix] [-f flags]\n" " [-g group] [-m mode] [-o owner] file1 ... fileN directory\n" diff --git a/src/kmk/kmkbuiltin/kDepIDB.c b/src/kmk/kmkbuiltin/kDepIDB.c index d377ef2..e5fd714 100644 --- a/src/kmk/kmkbuiltin/kDepIDB.c +++ b/src/kmk/kmkbuiltin/kDepIDB.c @@ -1,10 +1,10 @@ -/* $Id: kDepIDB.c 2263 2009-01-23 00:22:47Z bird $ */ +/* $Id: kDepIDB.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kDepIDB - Extract dependency information from a MS Visual C++ .idb file. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/kDepObj.c b/src/kmk/kmkbuiltin/kDepObj.c index 270044d..6f6bfc6 100644 --- a/src/kmk/kmkbuiltin/kDepObj.c +++ b/src/kmk/kmkbuiltin/kDepObj.c @@ -1,10 +1,10 @@ -/* $Id: kDepObj.c 2278 2009-02-24 02:19:35Z bird $ */ +/* $Id: kDepObj.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kDepObj - Extract dependency information from an object file. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/kbuild_protection.c b/src/kmk/kmkbuiltin/kbuild_protection.c index ba5e877..6a98f80 100644 --- a/src/kmk/kmkbuiltin/kbuild_protection.c +++ b/src/kmk/kmkbuiltin/kbuild_protection.c @@ -1,10 +1,10 @@ -/* $Id: kbuild_protection.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kbuild_protection.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Simple File Protection. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/kbuild_protection.h b/src/kmk/kmkbuiltin/kbuild_protection.h index 78ecf23..5f8c8ec 100644 --- a/src/kmk/kmkbuiltin/kbuild_protection.h +++ b/src/kmk/kmkbuiltin/kbuild_protection.h @@ -1,10 +1,10 @@ -/* $Id: kbuild_protection.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kbuild_protection.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Simple File Protection. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/kbuild_version.c b/src/kmk/kmkbuiltin/kbuild_version.c index 98b19e1..ec0613b 100644 --- a/src/kmk/kmkbuiltin/kbuild_version.c +++ b/src/kmk/kmkbuiltin/kbuild_version.c @@ -1,10 +1,10 @@ -/* $Id: kbuild_version.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: kbuild_version.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kbuild_version(), helper function. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/ln.c b/src/kmk/kmkbuiltin/ln.c index 73fe5db..2756ec8 100644 --- a/src/kmk/kmkbuiltin/ln.c +++ b/src/kmk/kmkbuiltin/ln.c @@ -154,10 +154,10 @@ kmk_builtin_ln(int argc, char *argv[], char **envp) * the target--simulate "not a directory" error */ errno = ENOTDIR; - return err(1, "%s", sourcedir); + return err(1, "st_mode: %s", sourcedir); } if (stat(sourcedir, &sb)) - return err(1, "%s", sourcedir); + return err(1, "stat: %s", sourcedir); if (!S_ISDIR(sb.st_mode)) return usage(stderr); for (exitval = 0; *argv != sourcedir; ++argv) @@ -176,13 +176,13 @@ linkit(const char *target, const char *source, int isdir) if (!sflag) { /* If target doesn't exist, quit now. */ if (stat(target, &sb)) { - warn("%s", target); + warn("stat: %s", target); return (1); } /* Only symbolic links to directories. */ if (S_ISDIR(sb.st_mode)) { errno = EISDIR; - warn("%s", target); + warn("st_mode: %s", target); return (1); } } @@ -209,7 +209,7 @@ linkit(const char *target, const char *source, int isdir) if (snprintf(path, sizeof(path), "%s/%s", source, p) >= (ssize_t)sizeof(path)) { errno = ENAMETOOLONG; - warn("%s", target); + warn("snprintf: %s", target); return (1); } source = path; @@ -222,7 +222,7 @@ linkit(const char *target, const char *source, int isdir) */ if (fflag && exists) { if (unlink(source)) { - warn("%s", source); + warn("unlink: %s", source); return (1); } } else if (iflag && exists) { @@ -238,14 +238,14 @@ linkit(const char *target, const char *source, int isdir) } if (unlink(source)) { - warn("%s", source); + warn("unlink: %s", source); return (1); } } /* Attempt the link. */ if ((*linkf)(target, source)) { - warn("%s", source); + warn("%s: %s", linkf == link ? "link" : "symlink", source); return (1); } if (vflag) diff --git a/src/kmk/kmkbuiltin/md5sum.c b/src/kmk/kmkbuiltin/md5sum.c index 0e673b9..c56dc07 100644 --- a/src/kmk/kmkbuiltin/md5sum.c +++ b/src/kmk/kmkbuiltin/md5sum.c @@ -1,10 +1,10 @@ -/* $Id: md5sum.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: md5sum.c 2414 2010-09-12 18:42:06Z bird $ */ /** @file * md5sum. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -169,8 +169,8 @@ static void *open_file(const char *pszFilename, unsigned fText) #elif defined(_O_SEQUENTIAL) fFlags |= _O_SEQUENTIAL; #endif -#ifdef _O_BINARY - if (!fText) fFlags |= _O_BINARY; +#ifdef O_BINARY + if (!fText) fFlags |= O_BINARY; #elif defined(_O_BINARY) if (!fText) fFlags |= _O_BINARY; #endif diff --git a/src/kmk/kmkbuiltin/mkdir.c b/src/kmk/kmkbuiltin/mkdir.c index e066460..3b75e64 100644 --- a/src/kmk/kmkbuiltin/mkdir.c +++ b/src/kmk/kmkbuiltin/mkdir.c @@ -143,9 +143,9 @@ kmk_builtin_mkdir(int argc, char *argv[], char **envp) success = 0; } else if (mkdir(*argv, omode) < 0) { if (errno == ENOTDIR || errno == ENOENT) - warn("%s", dirname(*argv)); + warn("mkdir: %s", dirname(*argv)); else - warn("%s", *argv); + warn("mkdir: %s", *argv); success = 0; } else if (vflag) (void)printf("%s\n", *argv); @@ -160,7 +160,7 @@ kmk_builtin_mkdir(int argc, char *argv[], char **envp) * as chmod will (obviously) ignore the umask. */ if (success && mode != NULL && chmod(*argv, omode) == -1) { - warn("%s", *argv); + warn("chmod: %s", *argv); exitval = 1; } } @@ -241,9 +241,11 @@ build(char *path, mode_t omode) if (last) (void)umask(oumask); if (mkdir(path, last ? omode : S_IRWXU | S_IRWXG | S_IRWXO) < 0) { - if (errno == EEXIST || errno == EISDIR || errno == ENOSYS /* (solaris crap) */) { + if (errno == EEXIST || errno == EISDIR + || errno == ENOSYS /* (solaris crap) */ + || errno == EACCES /* (ditto) */) { if (stat(path, &sb) < 0) { - warn("%s", path); + warn("stat: %s", path); retval = 1; break; } else if (!S_ISDIR(sb.st_mode)) { @@ -251,12 +253,12 @@ build(char *path, mode_t omode) errno = EEXIST; else errno = ENOTDIR; - warn("%s", path); + warn("st_mode: %s", path); retval = 1; break; } } else { - warn("%s", path); + warn("mkdir: %s", path); retval = 1; break; } diff --git a/src/kmk/kmkbuiltin/mscfakes.c b/src/kmk/kmkbuiltin/mscfakes.c index c3be36f..7d040ff 100644 --- a/src/kmk/kmkbuiltin/mscfakes.c +++ b/src/kmk/kmkbuiltin/mscfakes.c @@ -1,10 +1,10 @@ -/* $Id: mscfakes.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: mscfakes.c 2484 2011-07-21 19:01:08Z bird $ */ /** @file * Fake Unix stuff for MSC. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -157,6 +157,9 @@ msc_set_errno(DWORD dwErr) case ERROR_ALREADY_EXISTS: errno = EEXIST; break; case ERROR_FILENAME_EXCED_RANGE: errno = ENOENT; break; case ERROR_NESTING_NOT_ALLOWED: errno = EAGAIN; break; +#ifdef EMLINK + case ERROR_TOO_MANY_LINKS: errno = EMLINK; break; +#endif } return -1; @@ -212,7 +215,6 @@ int lchmod(const char *pszPath, mode_t mode) int msc_chmod(const char *pszPath, mode_t mode) { int rc = 0; - int saved_errno; int fMustBeDir; char *pszPathFree = msc_fix_path(&pszPath, &fMustBeDir); @@ -255,11 +257,32 @@ int msc_chmod(const char *pszPath, mode_t mode) } +typedef BOOL (WINAPI *PFNCREATEHARDLINKA)(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES); int link(const char *pszDst, const char *pszLink) { - errno = ENOSYS; - err(1, "link() is not implemented on windows!"); - return -1; + static PFNCREATEHARDLINKA s_pfnCreateHardLinkA = NULL; + static int s_fTried = FALSE; + + /* The API was introduced in Windows 2000, so resolve it dynamically. */ + if (!s_pfnCreateHardLinkA) + { + if (!s_fTried) + { + HMODULE hmod = LoadLibrary("KERNEL32.DLL"); + if (hmod) + *(FARPROC *)&s_pfnCreateHardLinkA = GetProcAddress(hmod, "CreateHardLinkA"); + s_fTried = TRUE; + } + if (!s_pfnCreateHardLinkA) + { + errno = ENOSYS; + return -1; + } + } + + if (s_pfnCreateHardLinkA(pszLink, pszDst, NULL)) + return 0; + return msc_set_errno(GetLastError()); } diff --git a/src/kmk/kmkbuiltin/mscfakes.h b/src/kmk/kmkbuiltin/mscfakes.h index 320543b..705a3dc 100644 --- a/src/kmk/kmkbuiltin/mscfakes.h +++ b/src/kmk/kmkbuiltin/mscfakes.h @@ -1,10 +1,10 @@ -/* $Id: mscfakes.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: mscfakes.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Unix fakes for MSC. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/mv.c b/src/kmk/kmkbuiltin/mv.c index 2233c56..8ebf1ce 100644 --- a/src/kmk/kmkbuiltin/mv.c +++ b/src/kmk/kmkbuiltin/mv.c @@ -99,7 +99,7 @@ static int usage(FILE *); extern void bsd_strmode(mode_t mode, char *p); -#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__DragonFly__) +#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__OpenBSD__) # ifdef __OS2__ static # endif diff --git a/src/kmk/kmkbuiltin/openbsd.c b/src/kmk/kmkbuiltin/openbsd.c new file mode 100644 index 0000000..b6b59db --- /dev/null +++ b/src/kmk/kmkbuiltin/openbsd.c @@ -0,0 +1,54 @@ +/* $Id: openbsd.c 2421 2010-10-17 21:27:53Z bird $ */ +/** @file + * Missing BSD functions in OpenBSD. + */ + +/* + * Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> + * + * This file is part of kBuild. + * + * kBuild is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * kBuild is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with kBuild. If not, see <http://www.gnu.org/licenses/> + * + */ + +/******************************************************************************* +* Header Files * +*******************************************************************************/ +#include "config.h" +#include <sys/stat.h> +#include <unistd.h> + + +int lchmod(const char *path, mode_t mode) +{ + struct stat st; + if (lstat(path, &st)) + return -1; + if (S_ISLNK(st.st_mode)) + return 0; /* pretend success */ + return chmod(path, mode); +} + + +int lutimes(const char *path, const struct timeval *tvs) +{ + struct stat st; + if (lstat(path, &st)) + return -1; + if (S_ISLNK(st.st_mode)) + return 0; /* pretend success */ + return utimes(path, tvs); +} + diff --git a/src/kmk/kmkbuiltin/osdep.c b/src/kmk/kmkbuiltin/osdep.c index 8e16094..d8201df 100644 --- a/src/kmk/kmkbuiltin/osdep.c +++ b/src/kmk/kmkbuiltin/osdep.c @@ -1,10 +1,10 @@ -/* $Id: osdep.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: osdep.c 2421 2010-10-17 21:27:53Z bird $ */ /** @file * Include all the OS dependent bits when bootstrapping. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -38,5 +38,8 @@ #elif defined(__APPLE__) # include "darwin.c" +#elif defined(__OpenBSD__) +# include "openbsd.c" + #endif diff --git a/src/kmk/kmkbuiltin/redirect.c b/src/kmk/kmkbuiltin/redirect.c index 109a393..c3f3cda 100644 --- a/src/kmk/kmkbuiltin/redirect.c +++ b/src/kmk/kmkbuiltin/redirect.c @@ -1,10 +1,10 @@ -/* $Id: redirect.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: redirect.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kmk_redirect - Do simple program <-> file redirection (++). */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/rm.c b/src/kmk/kmkbuiltin/rm.c index 1b6522c..4134a6d 100644 --- a/src/kmk/kmkbuiltin/rm.c +++ b/src/kmk/kmkbuiltin/rm.c @@ -38,7 +38,7 @@ static const char copyright[] = static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94"; #endif /* not lint */ #include <sys/cdefs.h> -//__FBSDID("$FreeBSD: src/bin/rm/rm.c,v 1.47 2004/04/06 20:06:50 markm Exp $"); +/*__FBSDID("$FreeBSD: src/bin/rm/rm.c,v 1.47 2004/04/06 20:06:50 markm Exp $");*/ #endif #include "config.h" @@ -119,6 +119,13 @@ static int rm_overwrite(char *, struct stat *); static int rm_tree(char **); static int usage(FILE *); +#if 1 +#define CUR_LINE_H2(x) "[line " #x "]" +#define CUR_LINE_H1(x) CUR_LINE_H2(x) +#define CUR_LINE() CUR_LINE_H1(__LINE__) +#else +# define CUR_LINE() +#endif /* @@ -279,17 +286,18 @@ rm_tree(char **argv) return err(1, "fts_open"); } while ((p = fts_read(fts)) != NULL) { + const char *operation = "chflags"; switch (p->fts_info) { case FTS_DNR: if (!fflag || p->fts_errno != ENOENT) { - fprintf(stderr, "%s: %s: %s\n", + fprintf(stderr, "fts: %s: %s: %s" CUR_LINE() "\n", argv0, p->fts_path, strerror(p->fts_errno)); eval = 1; } continue; case FTS_ERR: fts_close(fts); - return errx(1, "%s: %s", p->fts_path, strerror(p->fts_errno)); + return errx(1, "fts: %s: %s " CUR_LINE(), p->fts_path, strerror(p->fts_errno)); case FTS_NS: /* * Assume that since fts_read() couldn't stat the @@ -298,7 +306,7 @@ rm_tree(char **argv) if (!needstat) break; if (!fflag || p->fts_errno != ENOENT) { - fprintf(stderr, "%s: %s: %s\n", + fprintf(stderr, "fts: %s: %s: %s " CUR_LINE() "\n", argv0, p->fts_path, strerror(p->fts_errno)); eval = 1; } @@ -362,6 +370,7 @@ rm_tree(char **argv) p->fts_path); continue; } + operation = "mkdir"; break; #ifdef FTS_W @@ -373,6 +382,7 @@ rm_tree(char **argv) p->fts_path); continue; } + operation = "undelete"; break; #endif @@ -402,16 +412,18 @@ rm_tree(char **argv) p->fts_path); continue; } + operation = "unlink"; + break; } } #ifdef UF_APPEND err: #endif - fprintf(stderr, "%s: %s: %s\n", argv0, p->fts_path, strerror(errno)); + fprintf(stderr, "%s: %s: %s: %s " CUR_LINE() "\n", operation, argv0, p->fts_path, strerror(errno)); eval = 1; } if (errno) { - fprintf(stderr, "%s: fts_read: %s\n", argv0, strerror(errno)); + fprintf(stderr, "%s: fts_read: %s " CUR_LINE() "\n", argv0, strerror(errno)); eval = 1; } fts_close(fts); @@ -439,6 +451,7 @@ rm_file(char **argv) * to remove a directory is an error, so must always stat the file. */ while ((f = *argv++) != NULL) { + const char *operation = "?"; /* Assume if can't stat the file, can't unlink it. */ if (lstat(f, &sb)) { #ifdef FTS_WHITEOUT @@ -449,7 +462,7 @@ rm_file(char **argv) { #endif if (!fflag || errno != ENOENT) { - fprintf(stderr, "%s: %s: %s\n", argv0, f, strerror(errno)); + fprintf(stderr, "lstat: %s: %s: %s " CUR_LINE() "\n", argv0, f, strerror(errno)); eval = 1; } continue; @@ -477,11 +490,13 @@ rm_file(char **argv) rval = chflags(f, sb.st_flags & ~(UF_APPEND|UF_IMMUTABLE)); #endif if (rval == 0) { - if (S_ISWHT(sb.st_mode)) + if (S_ISWHT(sb.st_mode)) { rval = undelete(f); - else if (S_ISDIR(sb.st_mode)) + operation = "undelete"; + } else if (S_ISDIR(sb.st_mode)) { rval = rmdir(f); - else { + operation = "rmdir"; + } else { if (Pflag) if (!rm_overwrite(f, &sb)) continue; @@ -492,10 +507,11 @@ rm_file(char **argv) rval = unlink(f); } #endif + operation = "unlink"; } } if (rval && (!fflag || errno != ENOENT)) { - fprintf(stderr, "%s: %s: %s\n", argv0, f, strerror(errno)); + fprintf(stderr, "%s: %s: %s: %s" CUR_LINE() "\n", operation, argv0, f, strerror(errno)); eval = 1; } if (vflag && rval == 0) @@ -525,6 +541,7 @@ rm_overwrite(char *file, struct stat *sbp) off_t len; int bsize, fd, wlen; char *buf = NULL; + const char *operation = "lstat"; fd = -1; if (sbp == NULL) { @@ -534,6 +551,7 @@ rm_overwrite(char *file, struct stat *sbp) } if (!S_ISREG(sbp->st_mode)) return (1); + operation = "open"; if ((fd = open(file, O_WRONLY, 0)) == -1) goto err; #ifdef HAVE_FSTATFS @@ -549,6 +567,7 @@ rm_overwrite(char *file, struct stat *sbp) exit(err(1, "%s: malloc", file)); #define PASS(byte) { \ + operation = "write"; \ memset(buf, byte, bsize); \ for (len = sbp->st_size; len > 0; len -= wlen) { \ wlen = len < bsize ? len : bsize; \ @@ -557,9 +576,11 @@ rm_overwrite(char *file, struct stat *sbp) } \ } PASS(0xff); + operation = "fsync/lseek"; if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) goto err; PASS(0x00); + operation = "fsync/lseek"; if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) goto err; PASS(0xff); @@ -567,13 +588,14 @@ rm_overwrite(char *file, struct stat *sbp) free(buf); return (1); } + operation = "fsync/close"; err: eval = 1; if (buf) free(buf); if (fd != -1) close(fd); - fprintf(stderr, "%s: %s: %s\n", argv0, file, strerror(errno)); + fprintf(stderr, "%s: %s: %s: %s" CUR_LINE() "\n", operation, argv0, file, strerror(errno)); return (0); } diff --git a/src/kmk/kmkbuiltin/rmdir.c b/src/kmk/kmkbuiltin/rmdir.c index 0e6da6a..34771dd 100644 --- a/src/kmk/kmkbuiltin/rmdir.c +++ b/src/kmk/kmkbuiltin/rmdir.c @@ -127,7 +127,7 @@ kmk_builtin_rmdir(int argc, char *argv[], char **envp) if (rmdir(*argv) < 0) { if ( (!ignore_fail_on_non_empty || (errno != ENOTEMPTY && errno != EPERM && errno != EACCES && errno != EINVAL && errno != EEXIST)) && (!ignore_fail_on_not_exist || errno != ENOENT)) { - warn("%s", *argv); + warn("rmdir: %s", *argv); errors = 1; continue; } @@ -180,7 +180,7 @@ rm_path(char *path) if (ignore_fail_on_non_empty && (errno == ENOTEMPTY || errno == EPERM || errno == EACCES || errno == EINVAL || errno == EEXIST)) break; if (!ignore_fail_on_not_exist || errno != ENOENT) { - warn("%s", path); + warn("rmdir: %s", path); return (1); } } diff --git a/src/kmk/kmkbuiltin/sleep.c b/src/kmk/kmkbuiltin/sleep.c index f3a778d..a5365dc 100644 --- a/src/kmk/kmkbuiltin/sleep.c +++ b/src/kmk/kmkbuiltin/sleep.c @@ -1,10 +1,10 @@ -/* $Id: sleep.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: sleep.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kmk_sleep - suspend execution for an interval of time. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/solfakes.c b/src/kmk/kmkbuiltin/solfakes.c index 25d7734..2f4b818 100644 --- a/src/kmk/kmkbuiltin/solfakes.c +++ b/src/kmk/kmkbuiltin/solfakes.c @@ -1,10 +1,10 @@ -/* $Id: solfakes.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: solfakes.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Fake Unix stuff for Solaris. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/kmkbuiltin/solfakes.h b/src/kmk/kmkbuiltin/solfakes.h index 2792efb..010d809 100644 --- a/src/kmk/kmkbuiltin/solfakes.h +++ b/src/kmk/kmkbuiltin/solfakes.h @@ -1,10 +1,10 @@ -/* $Id: solfakes.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: solfakes.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Unix fakes for Solaris. */ /* - * Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/maintMakefile b/src/kmk/maintMakefile index 276457f..5b27cab 100644 --- a/src/kmk/maintMakefile +++ b/src/kmk/maintMakefile @@ -3,7 +3,11 @@ # tree, not a dist copy. # We like mondo-warnings! +ifeq ($(KBUILD_TARGET),openbsd) # bird +AM_CFLAGS += -Wall -Wshadow -Wpointer-arith -Wbad-function-cast +else AM_CFLAGS += -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast +endif # I want this one but I have to wait for the const cleanup! # -Wwrite-strings diff --git a/src/kmk/read.c b/src/kmk/read.c index 8bbf4ff..dddf54b 100644 --- a/src/kmk/read.c +++ b/src/kmk/read.c @@ -480,7 +480,12 @@ eval_makefile (const char *filename, int flags) { int stream_buf_size = 256*1024; if (st.st_size < stream_buf_size) - stream_buf_size = (st.st_size + 0xfff) & ~0xfff; + { + if (st.st_size) + stream_buf_size = (st.st_size + 0xfff) & ~0xfff; + else + stream_buf_size = 0x1000; + } stream_buf = xmalloc (stream_buf_size); setvbuf (ebuf.fp, stream_buf, _IOFBF, stream_buf_size); } @@ -2082,7 +2087,7 @@ conditional_line (char *line, char *eol, int len, const struct floc *flocp) unsigned int l; char termin = *line == '(' ? ',' : *line; #ifdef CONFIG_WITH_VALUE_LENGTH - char *buf_pos; + char *s1_end, *s2_end; #endif if (termin != ',' && termin != '"' && termin != '\'') @@ -2135,8 +2140,7 @@ conditional_line (char *line, char *eol, int len, const struct floc *flocp) s1 = alloca (l + 1); memcpy (s1, s2, l + 1); #else - s1 = variable_expand_string_2 (NULL, s1, l, &buf_pos); - ++buf_pos; + s1 = variable_expand_string_2 (NULL, s1, l, &s1_end); #endif if (termin != ',') @@ -2187,10 +2191,9 @@ conditional_line (char *line, char *eol, int len, const struct floc *flocp) #ifndef CONFIG_WITH_VALUE_LENGTH s2 = variable_expand (s2); #else - if ((size_t)buf_pos & 7) - buf_pos = variable_buffer_output (buf_pos, "\0\0\0\0\0\0\0\0", - 8 - ((size_t)buf_pos & 7)); - s2 = variable_expand_string_2 (buf_pos, s2, l, &buf_pos); + s2 = variable_expand_string_2 (s1_end + 1, s2, l, &s2_end); + if (s2 != s1_end + 1) + s1 += s2 - s1_end - 1; /* the variable buffer was reallocated */ #endif #ifdef CONFIG_WITH_SET_CONDITIONALS if (cmdtype == c_if1of || cmdtype == c_ifn1of) diff --git a/src/kmk/strcache2.c b/src/kmk/strcache2.c index 807d587..861d27a 100644 --- a/src/kmk/strcache2.c +++ b/src/kmk/strcache2.c @@ -1,10 +1,10 @@ -/* $Id: strcache2.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: strcache2.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * strcache2 - New string cache. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/strcache2.h b/src/kmk/strcache2.h index 3619b6b..8ef8650 100644 --- a/src/kmk/strcache2.h +++ b/src/kmk/strcache2.h @@ -1,10 +1,10 @@ -/* $Id: strcache2.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: strcache2.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * strcache - New string cache. */ /* - * Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/kmk/testcase-2ndtargetexp.kmk b/src/kmk/testcase-2ndtargetexp.kmk index d5730fe..1e19a8b 100644 --- a/src/kmk/testcase-2ndtargetexp.kmk +++ b/src/kmk/testcase-2ndtargetexp.kmk @@ -1,10 +1,10 @@ -# $Id: testcase-2ndtargetexp.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-2ndtargetexp.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the 2nd target expansion feature. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-if1of.kmk b/src/kmk/testcase-if1of.kmk index f8c9553..dc878ba 100644 --- a/src/kmk/testcase-if1of.kmk +++ b/src/kmk/testcase-if1of.kmk @@ -1,10 +1,10 @@ -# $Id: testcase-if1of.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-if1of.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the if1of and ifn1of conditionals. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-includedep-sub.kmk b/src/kmk/testcase-includedep-sub.kmk index d95e142..b5bf546 100644 --- a/src/kmk/testcase-includedep-sub.kmk +++ b/src/kmk/testcase-includedep-sub.kmk @@ -1,11 +1,11 @@ -# $Id: testcase-includedep-sub.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-includedep-sub.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the includdep directive, helper file # that gets included all the time. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-includedep.kmk b/src/kmk/testcase-includedep.kmk index 0f8912a..685f527 100644 --- a/src/kmk/testcase-includedep.kmk +++ b/src/kmk/testcase-includedep.kmk @@ -1,10 +1,10 @@ -# $Id: testcase-includedep.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-includedep.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the includedep directive. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-lazy-deps-vars.kmk b/src/kmk/testcase-lazy-deps-vars.kmk index 01f0e34..75b6b9b 100644 --- a/src/kmk/testcase-lazy-deps-vars.kmk +++ b/src/kmk/testcase-lazy-deps-vars.kmk @@ -1,10 +1,10 @@ -# $Id: testcase-lazy-deps-vars.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-lazy-deps-vars.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the lazy dependency lists. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-math.kmk b/src/kmk/testcase-math.kmk index 0572eae..bd4fb7e 100644 --- a/src/kmk/testcase-math.kmk +++ b/src/kmk/testcase-math.kmk @@ -1,10 +1,10 @@ -# $Id: testcase-math.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-math.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the math functions. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-root.kmk b/src/kmk/testcase-root.kmk new file mode 100644 index 0000000..92de5c5 --- /dev/null +++ b/src/kmk/testcase-root.kmk @@ -0,0 +1,30 @@ +# +# The $(root ...) and $(notroot ) functions. +# + + + +x := $(root /a) +y := $(notroot /a) +ifneq ($x,/) + $(error x=$x) +endif +ifneq ($y,a) + $(error y=$y) +endif + +x := $(root /a /b /) +y := $(notroot /a /b /) +ifneq ($x,/ / /) + $(error x=$x) +endif +ifneq ($y,a b .) + $(error y=$y) +endif + + +# dummy +all: + echo The root and notroot functions works. + + diff --git a/src/kmk/testcase-stack.kmk b/src/kmk/testcase-stack.kmk index 66f6aad..e610319 100644 --- a/src/kmk/testcase-stack.kmk +++ b/src/kmk/testcase-stack.kmk @@ -1,10 +1,10 @@ -# $Id: testcase-stack.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-stack.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the functions. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/testcase-xargs.kmk b/src/kmk/testcase-xargs.kmk index 984a9c2..ee6b5a8 100644 --- a/src/kmk/testcase-xargs.kmk +++ b/src/kmk/testcase-xargs.kmk @@ -1,11 +1,11 @@ -# $Id: testcase-xargs.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: testcase-xargs.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # kBuild - testcase for the xargs function. # Requires manual inspection of the output. # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/features/ifcond b/src/kmk/tests/scripts/features/ifcond index 5c20aed..b492e77 100644 --- a/src/kmk/tests/scripts/features/ifcond +++ b/src/kmk/tests/scripts/features/ifcond @@ -1,10 +1,10 @@ -# $Id: ifcond 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: ifcond 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # if conditionals. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/evalcall b/src/kmk/tests/scripts/functions/evalcall index c955f4d..f0213c2 100644 --- a/src/kmk/tests/scripts/functions/evalcall +++ b/src/kmk/tests/scripts/functions/evalcall @@ -1,10 +1,10 @@ -# $Id: evalcall 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: evalcall 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(evalcall var,argN...) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/expr b/src/kmk/tests/scripts/functions/expr index 36fc481..a68205f 100644 --- a/src/kmk/tests/scripts/functions/expr +++ b/src/kmk/tests/scripts/functions/expr @@ -1,10 +1,10 @@ -# $Id: expr 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: expr 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(expr expr) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/for b/src/kmk/tests/scripts/functions/for index 8b4affe..0152395 100644 --- a/src/kmk/tests/scripts/functions/for +++ b/src/kmk/tests/scripts/functions/for @@ -1,10 +1,10 @@ -# $Id: for 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: for 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(for init,condition,next,body) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/if-expr b/src/kmk/tests/scripts/functions/if-expr index 91ba633..764522d 100644 --- a/src/kmk/tests/scripts/functions/if-expr +++ b/src/kmk/tests/scripts/functions/if-expr @@ -1,10 +1,10 @@ -# $Id: if-expr 2277 2009-02-24 02:18:24Z bird $ -*-perl-*- +# $Id: if-expr 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(if-expr expr, if-expand, else-expand) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/insert b/src/kmk/tests/scripts/functions/insert index 152edff..6a597c6 100644 --- a/src/kmk/tests/scripts/functions/insert +++ b/src/kmk/tests/scripts/functions/insert @@ -1,10 +1,10 @@ -# $Id: insert 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: insert 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(insert in, str[, n[, length[, pad]]]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/intersects b/src/kmk/tests/scripts/functions/intersects index 469401a..8d136fb 100644 --- a/src/kmk/tests/scripts/functions/intersects +++ b/src/kmk/tests/scripts/functions/intersects @@ -1,10 +1,10 @@ -# $Id: intersects 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: intersects 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(intersects set-a,set-b) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/lastpos b/src/kmk/tests/scripts/functions/lastpos index 277b0de..248db2b 100644 --- a/src/kmk/tests/scripts/functions/lastpos +++ b/src/kmk/tests/scripts/functions/lastpos @@ -1,10 +1,10 @@ -# $Id: lastpos 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: lastpos 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(lastpos needle, haystack[, start]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/length b/src/kmk/tests/scripts/functions/length index 0d68099..c8ea34d 100644 --- a/src/kmk/tests/scripts/functions/length +++ b/src/kmk/tests/scripts/functions/length @@ -1,10 +1,10 @@ -# $Id: length 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: length 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(length text) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/length-var b/src/kmk/tests/scripts/functions/length-var index 2baaac9..0583713 100644 --- a/src/kmk/tests/scripts/functions/length-var +++ b/src/kmk/tests/scripts/functions/length-var @@ -1,10 +1,10 @@ -# $Id: length-var 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: length-var 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(length-var var) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/pos b/src/kmk/tests/scripts/functions/pos index 74d3fab..bdc3d40 100644 --- a/src/kmk/tests/scripts/functions/pos +++ b/src/kmk/tests/scripts/functions/pos @@ -1,10 +1,10 @@ -# $Id: pos 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: pos 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(pos needle, haystack[, start]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/printf b/src/kmk/tests/scripts/functions/printf index 75094d8..cb20168 100644 --- a/src/kmk/tests/scripts/functions/printf +++ b/src/kmk/tests/scripts/functions/printf @@ -1,10 +1,10 @@ -# $Id: printf 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: printf 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(printf fmt[,args...]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/root b/src/kmk/tests/scripts/functions/root index 8922168..46abbd1 100644 --- a/src/kmk/tests/scripts/functions/root +++ b/src/kmk/tests/scripts/functions/root @@ -1,10 +1,10 @@ -# $Id: root 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: root 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(root path...) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/select b/src/kmk/tests/scripts/functions/select index 340e164..843ff2e 100644 --- a/src/kmk/tests/scripts/functions/select +++ b/src/kmk/tests/scripts/functions/select @@ -1,10 +1,10 @@ -# $Id: select 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: select 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(select when1-cond, when1-body[,whenN-cond, whenN-body]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/substr b/src/kmk/tests/scripts/functions/substr index 821f906..bf0eba9 100644 --- a/src/kmk/tests/scripts/functions/substr +++ b/src/kmk/tests/scripts/functions/substr @@ -1,10 +1,10 @@ -# $Id: substr 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: substr 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(substr str, start[, length[, pad]]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/translate b/src/kmk/tests/scripts/functions/translate index 1937478..2dcf83f 100644 --- a/src/kmk/tests/scripts/functions/translate +++ b/src/kmk/tests/scripts/functions/translate @@ -1,10 +1,10 @@ -# $Id: translate 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: translate 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(translate string, from-set[, to-set[, pad-char]]) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/functions/while b/src/kmk/tests/scripts/functions/while index 2f43a1a..c0e6481 100644 --- a/src/kmk/tests/scripts/functions/while +++ b/src/kmk/tests/scripts/functions/while @@ -1,10 +1,10 @@ -# $Id: while 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: while 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # $(while condition,body) # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/tests/scripts/variables/must_make b/src/kmk/tests/scripts/variables/must_make index f5d2dca..83a8275 100644 --- a/src/kmk/tests/scripts/variables/must_make +++ b/src/kmk/tests/scripts/variables/must_make @@ -1,10 +1,10 @@ -# $Id: must_make 2243 2009-01-10 02:24:02Z bird $ -*-perl-*- +# $Id: must_make 2413 2010-09-11 17:43:04Z bird $ -*-perl-*- ## @file # .MUST_MAKE target variable. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/variable.c b/src/kmk/variable.c index ffa0a25..02dca60 100644 --- a/src/kmk/variable.c +++ b/src/kmk/variable.c @@ -32,6 +32,11 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ #include "hash.h" #ifdef KMK # include "kbuild.h" +# ifdef WINDOWS32 +# include <Windows.h> +# else +# include <sys/utsname.h> +# endif #endif #ifdef CONFIG_WITH_STRCACHE2 # include <stddef.h> @@ -1072,6 +1077,30 @@ merge_variable_set_lists (struct variable_set_list **setlist0, } } +#if defined(KMK) && !defined(WINDOWS32) +/* Parses out the next number from the uname release level string. Fast + forwards to the end of the string when encountering some non-conforming + chars. */ + +static unsigned long parse_release_number (const char **ppsz) +{ + unsigned long ul; + char *psz = (char *)*ppsz; + if (ISDIGIT (*psz)) + { + ul = strtoul (psz, &psz, 10); + if (psz != NULL && *psz == '.') + psz++; + else + psz = strchr (*ppsz, '\0'); + *ppsz = psz; + } + else + ul = 0; + return ul; +} +#endif + /* Define the automatic variables, and record the addresses of their structures so we can change their values quickly. */ @@ -1091,6 +1120,12 @@ define_automatic_variables (void) const char *val; struct variable *envvar1; struct variable *envvar2; +# ifdef WINDOWS32 + OSVERSIONINFOEX oix; +# else + struct utsname uts; +# endif + unsigned long ulMajor = 0, ulMinor = 0, ulPatch = 0, ul4th = 0; #endif sprintf (buf, "%u", makelevel); @@ -1165,6 +1200,58 @@ define_automatic_variables (void) define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1, val, o_default, 0); + /* The host kernel version. */ +#if defined(WINDOWS32) + memset (&oix, '\0', sizeof (oix)); + oix.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + if (!GetVersionEx ((LPOSVERSIONINFO)&oix)) + { + memset (&oix, '\0', sizeof (oix)); + oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + GetVersionEx ((LPOSVERSIONINFO)&oix); + } + if (oix.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + ulMajor = oix.dwMajorVersion; + ulMinor = oix.dwMinorVersion; + ulPatch = oix.wServicePackMajor; + ul4th = oix.wServicePackMinor; + } + else + { + ulMajor = oix.dwPlatformId == 1 ? 0 /*Win95/98/ME*/ + : oix.dwPlatformId == 3 ? 1 /*WinCE*/ + : 2; /*??*/ + ulMinor = oix.dwMajorVersion; + ulPatch = oix.dwMinorVersion; + ul4th = oix.wServicePackMajor; + } +#else + memset (&uts, 0, sizeof(uts)); + uname (&uts); + val = uts.release; + ulMajor = parse_release_number (&val); + ulMinor = parse_release_number (&val); + ulPatch = parse_release_number (&val); + ul4th = parse_release_number (&val); +#endif + + sprintf (buf, "%lu.%lu.%lu.%lu", ulMajor, ulMinor, ulPatch, ul4th); + define_variable ("KBUILD_HOST_VERSION", sizeof ("KBUILD_HOST_VERSION") - 1, + buf, o_default, 0); + + sprintf (buf, "%lu", ulMajor); + define_variable ("KBUILD_HOST_VERSION_MAJOR", sizeof ("KBUILD_HOST_VERSION_MAJOR") - 1, + buf, o_default, 0); + + sprintf (buf, "%lu", ulMinor); + define_variable ("KBUILD_HOST_VERSION_MINOR", sizeof ("KBUILD_HOST_VERSION_MINOR") - 1, + buf, o_default, 0); + + sprintf (buf, "%lu", ulPatch); + define_variable ("KBUILD_HOST_VERSION_PATCH", sizeof ("KBUILD_HOST_VERSION_PATCH") - 1, + buf, o_default, 0); + /* The kBuild locations. */ define_variable ("KBUILD_PATH", sizeof ("KBUILD_PATH") - 1, get_kbuild_path (), o_default, 0); @@ -1191,6 +1278,7 @@ define_automatic_variables (void) && defined (CONFIG_WITH_SET_CONDITIONALS) \ && defined (CONFIG_WITH_DATE) \ && defined (CONFIG_WITH_FILE_SIZE) \ + && defined (CONFIG_WITH_WHERE_FUNCTION) \ && defined (CONFIG_WITH_WHICH) \ && defined (CONFIG_WITH_EVALPLUS) \ && (defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)) \ @@ -1199,9 +1287,10 @@ define_automatic_variables (void) && defined (CONFIG_WITH_LOOP_FUNCTIONS) \ && defined (CONFIG_WITH_ROOT_FUNC) \ && defined (CONFIG_WITH_STRING_FUNCTIONS) \ + && defined (CONFIG_WITH_DEFINED_FUNCTIONS) \ && defined (KMK_HELPERS) (void) define_variable ("KMK_FEATURES", 12, - "append-dash-n abspath includedep-queue" + "append-dash-n abspath includedep-queue install-hard-linking" " rsort" " abspathex" " toupper tolower" @@ -1217,6 +1306,7 @@ define_automatic_variables (void) " date" " file-size" " expr if-expr select" + " where" " which" " evalctx evalval evalvalctx evalcall evalcall2 eval-opt-var" " make-stats" @@ -1226,10 +1316,11 @@ define_automatic_variables (void) " root" " length insert pos lastpos substr translate" " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl " + " firstdefined lastdefined " , o_default, 0); # else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */ # error "All features should be enabled by default!" - strcpy (buf, "append-dash-n abspath includedep-queue"); + strcpy (buf, "append-dash-n abspath includedep-queue install-hard-linking"); # if defined (CONFIG_WITH_RSORT) strcat (buf, " rsort"); # endif @@ -1275,6 +1366,9 @@ define_automatic_variables (void) # if defined (CONFIG_WITH_IF_CONDITIONALS) strcat (buf, " expr if-expr select"); # endif +# if defined (CONFIG_WITH_WHERE_FUNCTION) + strcat (buf, " where"); +# endif # if defined (CONFIG_WITH_WHICH) strcat (buf, " which"); # endif @@ -1299,6 +1393,9 @@ define_automatic_variables (void) # if defined (CONFIG_WITH_STRING_FUNCTIONS) strcat (buf, " length insert pos lastpos substr translate"); # endif +# if defined (CONFIG_WITH_DEFINED_FUNCTIONS) + strcat (buf, " firstdefined lastdefined"); +# endif # if defined (KMK_HELPERS) strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl"); # endif diff --git a/src/kmk/w32/Makefile.kmk b/src/kmk/w32/Makefile.kmk index 8eae64b..a6ef432 100644 --- a/src/kmk/w32/Makefile.kmk +++ b/src/kmk/w32/Makefile.kmk @@ -4,7 +4,7 @@ # # -# Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/kmk/w32/pathstuff.c b/src/kmk/w32/pathstuff.c index aafbd53..eca3f24 100644 --- a/src/kmk/w32/pathstuff.c +++ b/src/kmk/w32/pathstuff.c @@ -1,6 +1,6 @@ /* Path conversion for Windows pathnames. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -2007 Free Software Foundation, Inc. +2007, 2009 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify it under the @@ -51,6 +51,9 @@ convert_Path_to_windows32(char *Path, char to_delim) char *p; /* points to element of old Path */ /* is this a multi-element Path ? */ + /* FIXME: Perhaps use ":;\"" in strpbrk to convert all quotes to + delimiters as well, as a way to handle quoted directories in + PATH? */ for (p = Path, etok = strpbrk(p, ":;"); etok; etok = strpbrk(p, ":;")) @@ -76,8 +79,11 @@ convert_Path_to_windows32(char *Path, char to_delim) for (p++; *p && *p != '"'; p++) /* skip quoted part */ ; etok = strpbrk(p, ":;"); /* find next delimiter */ - *etok = to_delim; - p = ++etok; + if (etok) { + *etok = to_delim; + p = ++etok; + } else + p += strlen(p); } else { /* found another one, no drive letter */ *etok = to_delim; diff --git a/src/kmk/w32/tstFileInfo.c b/src/kmk/w32/tstFileInfo.c index 53a0962..94d47bb 100644 --- a/src/kmk/w32/tstFileInfo.c +++ b/src/kmk/w32/tstFileInfo.c @@ -4,7 +4,7 @@ */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/lib/Makefile.kmk b/src/lib/Makefile.kmk index 421ffb2..e89a302 100644 --- a/src/lib/Makefile.kmk +++ b/src/lib/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2469 2011-07-12 12:52:34Z bird $ ## @file # Sub-makefile for various libraries and stuff. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -37,7 +37,13 @@ LIBRARIES += kUtil kUtil_TEMPLATE = LIB kUtil_DEFS.win = __WIN__ kUtil_SOURCES = crc32.c md5.c -kUtil_SOURCES.win = nt_fullpath.c +kUtil_SOURCES.win = \ + nt_fullpath.c \ + quoted_spawn.c +kUtil_SOURCES.solaris = \ + restartable-syscall-wrappers.c +#kUtil_SOURCES.linux = \ +# restartable-syscall-wrappers.c kUtil_NOINST = 1 LIBRARIES.win += kWinStartup diff --git a/src/lib/k/kDefs.h b/src/lib/k/kDefs.h index ead7fd0..9e6187d 100644 --- a/src/lib/k/kDefs.h +++ b/src/lib/k/kDefs.h @@ -3,7 +3,7 @@ * * kTypes - Defines and Macros. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of k*. @@ -360,6 +360,34 @@ # define K_BE2H_U64(u64) ((KU64)(u32)) #endif +/** @def K_H2LE_U16 + * Unsigned 16-bit host endian to little-endian.. */ +/** @def K_H2LE_U32 + * Unsigned 32-bit host endian to little-endian.. */ +/** @def K_H2LE_U64 + * Unsigned 64-bit host endian to little-endian.. */ +/** @def K_H2BE_U16 + * Unsigned 16-bit host endian to big-endian.. */ +/** @def K_H2BE_U32 + * Unsigned 32-bit host endian to big-endian.. */ +/** @def K_H2BE_U64 + * Unsigned 64-bit host endian to big-endian.. */ +#if K_ENDIAN == K_ENDIAN_LITTLE +# define K_H2LE_U16(u16) ((KU16)(u16)) +# define K_H2LE_U32(u32) ((KU32)(u32)) +# define K_H2LE_U64(u64) ((KU64)(u32)) +# define K_H2BE_U16(u16) K_E2E_U16(u16) +# define K_H2BE_U32(u32) K_E2E_U32(u32) +# define K_H2BE_U64(u64) K_E2E_U64(u64) +#else +# define K_H2LE_U16(u16) K_E2E_U16(u16) +# define K_H2LE_U32(u32) K_E2E_U32(u32) +# define K_H2LE_U64(u64) K_E2E_U64(u64) +# define K_H2BE_U16(u16) ((KU16)(u16)) +# define K_H2BE_U32(u32) ((KU32)(u32)) +# define K_H2BE_U64(u64) ((KU64)(u32)) +#endif + /** @def K_INLINE diff --git a/src/lib/k/kTypes.h b/src/lib/k/kTypes.h index 8fc626f..4178f37 100644 --- a/src/lib/k/kTypes.h +++ b/src/lib/k/kTypes.h @@ -3,7 +3,7 @@ * * kTypes - Typedefs And Related Constants And Macros. * - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * * This file is part of kStuff. diff --git a/src/lib/kDep.c b/src/lib/kDep.c index 1d68589..118176e 100644 --- a/src/lib/kDep.c +++ b/src/lib/kDep.c @@ -1,10 +1,10 @@ -/* $Id: kDep.c 2270 2009-01-26 00:01:01Z bird $ */ +/* $Id: kDep.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kDep - Common Dependency Managemnt Code. */ /* - * Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -387,7 +387,8 @@ void depHexDump(const KU8 *pb, size_t cb, size_t offBase) while (off < cb) { unsigned i; - printf("%s%0*x %04x:", off ? "\n" : "", sizeof(pb) * 2, offBase + off, off); + printf("%s%0*lx %04lx:", off ? "\n" : "", (int)sizeof(pb) * 2, + (unsigned long)offBase + (unsigned long)off, (unsigned long)off); for (i = 0; i < cchWidth && off + i < cb ; i++) printf(off + i < cb ? !(i & 7) && i ? "-%02x" : " %02x" : " ", pb[i]); diff --git a/src/lib/kDep.h b/src/lib/kDep.h index bfaa09d..d9742f1 100644 --- a/src/lib/kDep.h +++ b/src/lib/kDep.h @@ -1,10 +1,10 @@ -/* $Id: kDep.h 2263 2009-01-23 00:22:47Z bird $ */ +/* $Id: kDep.h 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kDep - Common Dependency Managemnt Code. */ /* - * Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/lib/md5.c b/src/lib/md5.c index cff542d..e9d9474 100644 --- a/src/lib/md5.c +++ b/src/lib/md5.c @@ -19,18 +19,10 @@ #include "md5.h" #define uint32 uint32_t -#if 0 /* don't need 100% correct md5, just fast md5. */ -#ifdef sgi -#define HIGHFIRST -#endif - -#ifdef sun -#define HIGHFIRST -#endif -#endif /* skip this */ +#include "k/kDefs.h" -#ifndef HIGHFIRST -#define byteReverse(buf, len) /* Nothing */ +#if K_ENDIAN == K_ENDIAN_LITTLE +# define byteReverse(buf, len) do { /* Nothing */ } while (0) #else /* * Note: this code is harmless on little-endian machines. @@ -111,7 +103,7 @@ void MD5Update(struct MD5Context *ctx, const unsigned char *buf, unsigned len) } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) diff --git a/src/lib/mytypes.h b/src/lib/mytypes.h index 288dca2..f546a20 100644 --- a/src/lib/mytypes.h +++ b/src/lib/mytypes.h @@ -1,10 +1,10 @@ -/* $Id: mytypes.h 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: mytypes.h 2442 2011-07-06 12:19:16Z bird $ */ /** @file * mytypes - wrapper that ensures the necessary uintXY_t types are defined. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -27,6 +27,7 @@ #define ___mytypes_h__ #include <stdlib.h> +#include <stddef.h> /* MSC: intptr_t */ #include <sys/types.h> #if defined(_MSC_VER) diff --git a/src/lib/nt_fullpath.c b/src/lib/nt_fullpath.c index 4b19e2e..3b59826 100644 --- a/src/lib/nt_fullpath.c +++ b/src/lib/nt_fullpath.c @@ -1,10 +1,10 @@ -/* $Id: nt_fullpath.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: nt_fullpath.c 2455 2011-07-07 23:16:02Z bird $ */ /** @file * fixcase - fixes the case of paths, windows specific. */ /* - * Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * @@ -283,14 +283,14 @@ typedef struct MY_FILE_FS_DEVICE_INFORMATION #define MY_FILE_DEVICE_VIRTUAL_DISK 36 -typedef struct _IO_STATUS_BLOCK +typedef struct { union { - LONG Status; - PVOID Pointer; + LONG Status; + PVOID Pointer; }; - ULONG_PTR Information; + ULONG_PTR Information; } MY_IO_STATUS_BLOCK, *PMY_IO_STATUS_BLOCK; static BOOL g_fInitialized = FALSE; diff --git a/src/lib/quoted_spawn.c b/src/lib/quoted_spawn.c new file mode 100644 index 0000000..648a3a9 --- /dev/null +++ b/src/lib/quoted_spawn.c @@ -0,0 +1,276 @@ +/* $Id: quoted_spawn.c 2413 2010-09-11 17:43:04Z bird $ */ +/** @file + * quote_spawn - Correctly Quote The _spawnvp arguments, windows specific. + */ + +/* + * Copyright (c) 2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> + * + * This file is part of kBuild. + * + * kBuild is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * kBuild is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with kBuild. If not, see <http://www.gnu.org/licenses/> + * + */ + +/******************************************************************************* +* Header Files * +*******************************************************************************/ +#include "quoted_spawn.h" + +#include <process.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <assert.h> + + +/** + * Tests if a strings needs quoting. + * + * @returns 1 if needs, 0 if it doesn't. + * @param pszArg The string in question. + */ +static int quoted_spawn_need_quoting(const char *pszArg) +{ + for (;;) + switch (*pszArg++) + { + case 0: + return 0; + + case ' ': + case '"': + case '&': + case '>': + case '<': + case '|': + case '%': + /* Quote the control chars (tab is included). */ + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + return 1; + } +} + +/** + * Frees any quoted arguments. + * + * @returns NULL. + * @param papszArgsOrg The original argument vector. + * @param papszArgsQuoted The quoted argument vector. + * @param cArgs The number of arguments in the vector. + */ +static const char * const * +quoted_spawn_free(const char * const *papszArgsOrg, const char * const *papszArgsQuoted, unsigned cArgs) +{ + if ( papszArgsOrg != papszArgsQuoted + && papszArgsQuoted != NULL) + { + int iSavedErrno = errno; /* A bit of paranoia. */ + unsigned i = cArgs; + while (i-- > 0) + if (papszArgsQuoted[i] != papszArgsOrg[i]) + free((char *)papszArgsQuoted[i]); + free((void *)papszArgsQuoted); + errno = iSavedErrno; + } + return NULL; +} + +/** + * Quote an argument string. + * + * @returns Quoted argument string (new). + * @param pszArgOrg The original string. + */ +static const char *quoted_spawn_quote_arg(const char *pszArgOrg) +{ + size_t cchArgOrg = strlen(pszArgOrg); + size_t cchArgNew = 1 + cchArgOrg * 2 + 1 + 1; + char *pszArgNew = malloc(cchArgNew); + if (pszArgNew) + { + char ch; + char *pszDst = pszArgNew; + *pszDst++ = '"'; + while ((ch = *pszArgOrg++)) + { + if (ch == '\\') + { + size_t cSlashes = 1; + for (;;) + { + *pszDst++ = '\\'; + ch = *pszArgOrg; + if (ch != '\\') + break; + pszArgOrg++; + cSlashes++; + } + if (ch == '"' || ch == '\0') + { + while (cSlashes-- > 0) + *pszDst++ = '\\'; + if (ch == '\0') + break; + *pszDst++ = '\\'; + *pszDst++ = '"'; + } + } + else if (ch == '"') + { + *pszDst++ = '\\'; + *pszDst++ = '"'; + } + else + *pszDst++ = ch; + } + *pszDst++ = '"'; + *pszDst = '\0'; + assert((size_t)(pszDst - pszArgNew) < cchArgNew - 1); + } + return pszArgNew; +} + +/** + * Quotes the arguments in an argument vector, producing a new vector. + * + * @returns The quoted argument vector. + * @param papszArgsOrg The vector which arguments to quote. + * @param iFirstArg The first argument that needs quoting. + * @param pcArgs Where to return the argument count. + */ +static const char * const * +quoted_spawn_quote_vector(const char * const *papszArgsOrg, unsigned iFirstArg, unsigned *pcArgs) +{ + const char **papszArgsQuoted; + unsigned cArgs; + unsigned iArg; + + /* finish counting them and allocate the result array. */ + cArgs = iFirstArg; + while (papszArgsOrg[cArgs]) + cArgs++; + *pcArgs = cArgs; + + papszArgsQuoted = (const char **)calloc(sizeof(const char *), cArgs + 1); + if (!papszArgsQuoted) + return NULL; + + /* Process the arguments up to the first quoted one (no need to + re-examine them). */ + for (iArg = 0; iArg < iFirstArg; iArg++) + papszArgsQuoted[iArg] = papszArgsOrg[iArg]; + + papszArgsQuoted[iArg] = quoted_spawn_quote_arg(papszArgsOrg[iArg]); + if (!papszArgsQuoted[iArg]) + return quoted_spawn_free(papszArgsOrg, papszArgsQuoted, cArgs); + + /* Process the remaining arguments. */ + while (iArg < cArgs) + { + if (!quoted_spawn_need_quoting(papszArgsOrg[iArg])) + papszArgsQuoted[iArg] = papszArgsOrg[iArg]; + else + { + papszArgsQuoted[iArg] = quoted_spawn_quote_arg(papszArgsOrg[iArg]); + if (!papszArgsQuoted[iArg]) + return quoted_spawn_free(papszArgsOrg, papszArgsQuoted, cArgs); + } + iArg++; + } + + return papszArgsQuoted; +} + +/** + * Checks if any of the arguments in the vector needs quoting and does the job. + * + * @returns If anything needs quoting a new vector is returned, otherwise the + * original is returned. + * @param papszArgsOrg The argument vector to check. + * @param pcArgs Where to return the argument count. + */ +static const char * const * +quoted_spawn_maybe_quote(const char * const *papszArgsOrg, unsigned *pcArgs) +{ + unsigned iArg; + for (iArg = 0; papszArgsOrg[iArg]; iArg++) + if (quoted_spawn_need_quoting(papszArgsOrg[iArg])) + return quoted_spawn_quote_vector(papszArgsOrg, iArg, pcArgs); + *pcArgs = iArg; + return papszArgsOrg; +} + +/** + * Wrapper for _spawnvp. + * + * @returns The process handle, see _spawnvp for details. + * @param fMode The spawn mode, see _spawnvp for details. + * @param pszExecPath The path to the executable, or just the name + * if a PATH search is desired. + * @param papszArgs The arguments to pass to the new process. + */ +intptr_t quoted_spawnvp(int fMode, const char *pszExecPath, const char * const *papszArgs) +{ + intptr_t hProcess; + unsigned cArgs; + const char * const *papszArgsQuoted = quoted_spawn_maybe_quote(papszArgs, &cArgs); + if (papszArgsQuoted) + { +//unsigned i; +//fprintf(stderr, "debug: spawning '%s'\n", pszExecPath); +//for (i = 0; i < cArgs; i++) +// fprintf(stderr, "debug: #%02u: '%s'\n", i, papszArgsQuoted[i]); + hProcess = _spawnvp(fMode, pszExecPath, papszArgsQuoted); + quoted_spawn_free(papszArgs, papszArgsQuoted, cArgs); + } + else + { + errno = ENOMEM; + hProcess = -1; + } + + return hProcess; +} + diff --git a/src/lib/quoted_spawn.h b/src/lib/quoted_spawn.h new file mode 100644 index 0000000..ae8310d --- /dev/null +++ b/src/lib/quoted_spawn.h @@ -0,0 +1,34 @@ +/* $Id: quoted_spawn.h 2413 2010-09-11 17:43:04Z bird $ */ +/** @file + * quote_spawn - Correctly Quote The _spawnvp arguments, windows specific. + */ + +/* + * Copyright (c) 2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> + * + * This file is part of kBuild. + * + * kBuild is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * kBuild is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with kBuild. If not, see <http://www.gnu.org/licenses/> + * + */ + + +#ifndef ___quoted_spawn_h___ +#define ___quoted_spawn_h___ + +#include "mytypes.h" +intptr_t quoted_spawnvp(int fMode, const char *pszExecPath, const char * const *papszArgs); + +#endif + diff --git a/src/lib/restartable-syscall-wrappers.c b/src/lib/restartable-syscall-wrappers.c new file mode 100644 index 0000000..f2ec221 --- /dev/null +++ b/src/lib/restartable-syscall-wrappers.c @@ -0,0 +1,282 @@ +/* $Id: restartable-syscall-wrappers.c 2507 2011-07-24 15:42:39Z bird $ */ +/** @file + * restartable-syscall-wrappers.c - Workaround for annoying S11 "features". + * + * The symptoms are that open or mkdir occationally fails with EINTR when + * receiving SIGCHLD at the wrong time. With a enough cores, this start + * happening on a regular basis. + * + * The workaround here is to create our own wrappers for these syscalls which + * will restart the syscall when appropriate. This depends on the libc + * providing alternative names for the syscall entry points. + */ + +/* + * Copyright (c) 2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net> + * + * This file is part of kBuild. + * + * kBuild is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * kBuild is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with kBuild. If not, see <http://www.gnu.org/licenses/> + * + */ + + +/******************************************************************************* +* Header Files * +*******************************************************************************/ +#include <sys/types.h> +#ifdef KBUILD_OS_SOLARIS +# include <string.h> /* Try drag in feature_tests.h. */ +# include <ctype.h> +# undef _RESTRICT_KYWD +# define _RESTRICT_KYWD +# undef __PRAGMA_REDEFINE_EXTNAME +#endif +#include <sys/stat.h> +#include <utime.h> +#include <dlfcn.h> +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdio.h> + + +/******************************************************************************* +* Defined Constants And Macros * +*******************************************************************************/ +/** Mangle a syscall name to it's weak alias. */ +#ifdef KBUILD_OS_SOLARIS +# define WRAP(a_name) _##a_name +#elif defined(KBUILD_OS_LINUX) +# define WRAP(a_name) __##a_name +#else +# error "Port Me" +#endif + +/** Mangle a syscall name with optional '64' suffix. */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# define WRAP64(a_name) WRAP(a_name)##64 +#else +# define WRAP64(a_name) WRAP(a_name) +#endif + +/** Check whether errno indicates restart. */ +#ifdef ERESTART +# define SHOULD_RESTART() (errno == EINTR || errno == ERESTART) +#else +# define SHOULD_RESTART() (errno == EINTR) +#endif + +/** Used by XSTR. */ +#define XSTR_INNER(x) #x +/** Returns the expanded argument as a string. */ +#define XSTR(x) XSTR_INNER(x) + + +static int dlsym_libc(const char *pszSymbol, void **ppvSym) +{ + static void *s_pvLibc = NULL; + void *pvLibc; + void *pvSym; + + /* + * Use the RTLD_NEXT dl feature if present, it's designed for doing + * exactly what we want here. + */ +#ifdef RTLD_NEXT + pvSym = dlsym(RTLD_NEXT, pszSymbol); + if (pvSym) + { + *ppvSym = pvSym; + return 0; + } +#endif + + /* + * Open libc. + */ + pvLibc = s_pvLibc; + if (!pvLibc) + { +#ifdef RTLD_NOLOAD + unsigned fFlags = RTLD_NOLOAD | RTLD_NOW; +#else + unsigned fFlags = RTLD_GLOBAL | RTLD_NOW; +#endif +#ifdef KBUILD_OS_LINUX + pvLibc = dlopen("/lib/libc.so.6", fFlags); +#else + pvLibc = dlopen("/lib/libc.so", fFlags); +#endif + if (!pvLibc) + { + fprintf(stderr, "restartable-syscall-wrappers: failed to dlopen libc for resolving %s: %s\n", + pszSymbol, dlerror()); + errno = ENOSYS; + return -1; + } + /** @todo check standard symbol? */ + } + + /* + * Resolve the symbol. + */ + pvSym = dlsym(pvLibc, pszSymbol); + if (!pvSym) + { + fprintf(stderr, "restartable-syscall-wrappers: failed to resolve %s: %s\n", + pszSymbol, dlerror()); + errno = ENOSYS; + return -1; + } + + *ppvSym = pvSym; + return 0; +} + + +#undef open +int open(const char *pszPath, int fFlags, ...) +{ + mode_t fMode; + va_list va; + int fd; + static union + { + int (* pfnReal)(const char *, int, ...); + void *pvSym; + } s_u; + + if ( !s_u.pfnReal + && dlsym_libc("open", &s_u.pvSym) != 0) + return -1; + + va_start(va, fFlags); + fMode = va_arg(va, mode_t); + va_end(va); + + do + fd = s_u.pfnReal(pszPath, fFlags, fMode); + while (fd == -1 && SHOULD_RESTART()); + return fd; +} + +#undef open64 +int open64(const char *pszPath, int fFlags, ...) +{ + mode_t fMode; + va_list va; + int fd; + static union + { + int (* pfnReal)(const char *, int, ...); + void *pvSym; + } s_u; + + if ( !s_u.pfnReal + && dlsym_libc("open64", &s_u.pvSym) != 0) + return -1; + + va_start(va, fFlags); + fMode = va_arg(va, mode_t); + va_end(va); + + do + fd = s_u.pfnReal(pszPath, fFlags, fMode); + while (fd == -1 && SHOULD_RESTART()); + return fd; +} + +#define WRAP_FN(a_Name, a_ParamsWithTypes, a_ParamsNoType, a_RetType, a_RetFailed) \ + a_RetType a_Name a_ParamsWithTypes \ + { \ + static union \ + { \ + a_RetType (* pfnReal) a_ParamsWithTypes; \ + void *pvSym; \ + } s_u; \ + a_RetType rc; \ + \ + if ( !s_u.pfnReal \ + && dlsym_libc(#a_Name, &s_u.pvSym) != 0) \ + return a_RetFailed; \ + \ + do \ + rc = s_u.pfnReal a_ParamsNoType; \ + while (rc == a_RetFailed && SHOULD_RESTART()); \ + return rc; \ + } typedef int ignore_semi_colon_##a_Name + +#undef mkdir +WRAP_FN(mkdir, (const char *pszPath, mode_t fMode), (pszPath, fMode), int, -1); + +#undef rmdir +WRAP_FN(rmdir, (const char *pszPath, mode_t fMode), (pszPath, fMode), int, -1); + +#undef unlink +WRAP_FN(unlink, (const char *pszPath), (pszPath), int, -1); + +#undef remove +WRAP_FN(remove, (const char *pszPath), (pszPath), int, -1); + +#undef symlink +WRAP_FN(symlink, (const char *pszFrom, const char *pszTo), (pszFrom, pszTo), int, -1); + +#undef link +WRAP_FN(link, (const char *pszFrom, const char *pszTo), (pszFrom, pszTo), int, -1); + +#undef stat +WRAP_FN(stat, (const char *pszPath, struct stat *pStBuf), (pszPath, pStBuf), int, -1); +#undef lstat +WRAP_FN(lstat, (const char *pszPath, struct stat *pStBuf), (pszPath, pStBuf), int, -1); + +#undef stat64 +WRAP_FN(stat64, (const char *pszPath, struct stat64 *pStBuf), (pszPath, pStBuf), int, -1); +#undef lstat64 +WRAP_FN(lstat64, (const char *pszPath, struct stat64 *pStBuf), (pszPath, pStBuf), int, -1); + +#undef read +WRAP_FN(read, (int fd, void *pvBuf, size_t cbBuf), (fd, pvBuf, cbBuf), ssize_t, -1); + +#undef write +WRAP_FN(write, (int fd, void *pvBuf, size_t cbBuf), (fd, pvBuf, cbBuf), ssize_t, -1); + +#undef fopen +WRAP_FN(fopen, (const char *pszPath, const char *pszMode), (pszPath, pszMode), FILE *, NULL); +#undef fopen64 +WRAP_FN(fopen64, (const char *pszPath, const char *pszMode), (pszPath, pszMode), FILE *, NULL); + +#undef chmod +WRAP_FN(chmod, (const char *pszPath, mode_t fMode), (pszPath, fMode), int, -1); +#undef lchmod +WRAP_FN(lchmod, (const char *pszPath, mode_t fMode), (pszPath, fMode), int, -1); + +#undef chown +WRAP_FN(chown, (const char *pszPath, uid_t uid, gid_t gid), (pszPath, uid, gid), int, -1); +#undef lchown +WRAP_FN(lchown, (const char *pszPath, uid_t uid, gid_t gid), (pszPath, uid, gid), int, -1); + +#undef utime +WRAP_FN(utime, (const char *pszPath, const struct utimbuf *pTimes), (pszPath, pTimes), int, -1); + +#undef utimes +WRAP_FN(utimes, (const char *pszPath, const struct timeval *paTimes), (pszPath, paTimes), int, -1); + +#undef pathconf +WRAP_FN(pathconf, (const char *pszPath, int iCfgNm), (pszPath, iCfgNm), long, -1); + +#undef readlink +WRAP_FN(readlink, (const char *pszPath, char *pszBuf, size_t cbBuf), (pszPath, pszBuf, cbBuf), ssize_t, -1); + diff --git a/src/lib/startuphacks-win.c b/src/lib/startuphacks-win.c index 06aa852..9ac0dab 100644 --- a/src/lib/startuphacks-win.c +++ b/src/lib/startuphacks-win.c @@ -1,4 +1,4 @@ -/* $Id: startuphacks-win.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: startuphacks-win.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kBuild - Alternative argument parser for the windows startup code. * @@ -6,7 +6,7 @@ */ /* - * Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * parse_args(): Copyright (c) 1992-1998 by Eberhard Mattes * diff --git a/src/lib/test-eintr-bug-1.c b/src/lib/test-eintr-bug-1.c new file mode 100644 index 0000000..51e0973 --- /dev/null +++ b/src/lib/test-eintr-bug-1.c @@ -0,0 +1,89 @@ + + +/******************************************************************************* +* Header Files * +*******************************************************************************/ +//#define _XOPEN_SOURCE +//#define _BSD_SOURCE +#include <sys/time.h> +#include <sys/stat.h> +#include <stdio.h> +#include <signal.h> +#include <string.h> +#include <errno.h> + + +volatile unsigned long g_cInts = 0; + +static void SigAlaramHandler(int iSig) +{ + g_cInts++; + (void)iSig; +} + + +int main(int argc, char **argv) +{ + struct itimerval TmrVal; + void (*rcSig)(int); + int i; + int rc; + char szName[256]; + + /* + * Set up the timer signal. + */ + rcSig = bsd_signal(SIGALRM, SigAlaramHandler); + if (rcSig == SIG_ERR) + { + fprintf(stderr, "bsd_signal failed: %s\n", strerror(errno)); + return 1; + } + if (argc == 2) /* testing... */ + siginterrupt(SIGALRM, 1); + + memset(&TmrVal, '\0', sizeof(TmrVal)); + TmrVal.it_interval.tv_sec = TmrVal.it_value.tv_sec = 0; + TmrVal.it_interval.tv_usec = TmrVal.it_value.tv_usec = 1; + rc = setitimer(ITIMER_REAL, &TmrVal, NULL); + if (rc != 0) + { + fprintf(stderr, "setitimer failed: %s\n", strerror(errno)); + return 1; + } + printf("interval %d.%06d\n", (int)TmrVal.it_interval.tv_sec, (int)TmrVal.it_interval.tv_usec); + + /* + * Do path related stuff. + */ + snprintf(szName, sizeof(szName), "%s/fooled/you", argv[0]); + for (i = 0; i < 100*1000*1000; i++) + { + struct stat St; + rc = stat(argv[0], &St); + if (rc == 0) + rc = stat(szName, &St); + if (rc != 0 && errno == EINTR) + { + printf("iteration %d: stat: %s (%u)\n", i, strerror(errno), errno); + break; + } + if ((i % 100000) == 0) + { + printf("."); + if ((i % 1000000) == 0) + printf("[%u/%lu]", i, g_cInts); + fflush(stdout); + } + } + + if (!rc) + printf("No EINTR in %d iterations - system is working nicely!\n", i); + + TmrVal.it_interval.tv_sec = TmrVal.it_value.tv_sec = 0; + TmrVal.it_interval.tv_usec = TmrVal.it_value.tv_usec = 0; + setitimer(ITIMER_REAL, &TmrVal, NULL); + + return rc ? 1 : 0; +} + diff --git a/src/lib/test-eintr-bug-2.c b/src/lib/test-eintr-bug-2.c new file mode 100644 index 0000000..f945d2c --- /dev/null +++ b/src/lib/test-eintr-bug-2.c @@ -0,0 +1,154 @@ + + +/******************************************************************************* +* Header Files * +*******************************************************************************/ +#define _BSD_SOURCE +#define _GNU_SOURCE +#include <sys/time.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <time.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <pthread.h> +#include <signal.h> +#include <unistd.h> + + +/******************************************************************************* +* Global Variables * +*******************************************************************************/ +/** The number of signals. */ +static volatile long g_cSigs = 0; +/** Number of signals received on threads other than the main one. */ +static volatile long g_cSigsOther = 0; +/** Whether to shutdown or not. */ +static volatile int g_fShutdown = 0; +/** The handle of the main thread. */ +static pthread_t g_hMainThread; + + +static void SigHandler(int iSig) +{ + g_cSigs++; + if (pthread_self() != g_hMainThread) + g_cSigsOther++; + + (void)iSig; +} + + +static void NanoSleep(unsigned long cNanoSecs) +{ + struct timespec Ts; + Ts.tv_sec = 0; + Ts.tv_nsec = cNanoSecs; + nanosleep(&Ts, NULL); +} + + +static void *ThreadProc(void *pvIgnored) +{ + int volatile i = 0; + while (!g_fShutdown) + { +// NanoSleep(850); + if (g_fShutdown) + break; + + pthread_kill(g_hMainThread, SIGALRM); + for (i = 6666; i > 0; i--) + /* nothing */; + } + return NULL; +} + + +int main(int argc, char **argv) +{ + void (*rcSig)(int); + pthread_t hThread; + char szName[1024]; + int i; + int rc; + + /* + * Set up the signal handlers. + */ + rcSig = bsd_signal(SIGALRM, SigHandler); + if (rcSig != SIG_ERR) + rcSig = bsd_signal(SIGCHLD, SigHandler); + if (rcSig == SIG_ERR) + { + fprintf(stderr, "bsd_signal failed: %s\n", strerror(errno)); + return 1; + } + if (argc == 2) /* testing... */ + { + siginterrupt(SIGALRM, 1); + siginterrupt(SIGCHLD, 1); + } + + /* + * Kick off a thread that will signal us like there was no tomorrow. + */ + g_hMainThread = pthread_self(); + rc = pthread_create(&hThread, NULL, ThreadProc, NULL); + if (rc != 0) + { + fprintf(stderr, "pthread_create failed: %s\n", strerror(rc)); + return 1; + } + + /* + * Do path related stuff. + */ + snprintf(szName, sizeof(szName), "%s-test2", argv[0]); + for (i = 0; i < 100*1000*1000; i++) + { + struct stat St; + int fd; + + rc = stat(argv[0], &St); + if (rc == 0 || errno != EINTR) + rc = stat(szName, &St); + if (errno == EINTR && rc != 0) + { + printf("iteration %d: stat: %u\n", i, errno); + break; + } + + fd = open(szName, O_CREAT | O_RDWR, 0666); + if (errno == EINTR && fd < 0) + { + printf("iteration %d: open: %u\n", i, errno); + break; + } + close(fd); + rc = unlink(szName); + if (errno == EINTR && rc != 0) + { + printf("iteration %d: unlink: %u\n", i, errno); + break; + } + + /* Show progress info */ + if ((i % 100000) == 0) + { + printf("."); + if ((i % 1000000) == 0) + printf("[%d/%ld/%ld]\n", i, g_cSigs, g_cSigsOther); + fflush(stdout); + } + } + + g_fShutdown = 1; + if (rc) + printf("No EINTR in %d iterations - system is working nicely!\n", i); + NanoSleep(10000000); + + return rc ? 1 : 0; +} + diff --git a/src/lib/wrapper.c b/src/lib/wrapper.c index 9c771ff..fd097b7 100644 --- a/src/lib/wrapper.c +++ b/src/lib/wrapper.c @@ -1,10 +1,10 @@ -/* $Id: wrapper.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: wrapper.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Wrapper program for various debugging purposes. */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/misc/Makefile.kmk b/src/misc/Makefile.kmk index e514d09..afa900c 100644 --- a/src/misc/Makefile.kmk +++ b/src/misc/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Sub-makefile for kmk_time. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/src/misc/kmk_time.c b/src/misc/kmk_time.c index 811ea91..beccbe0 100644 --- a/src/misc/kmk_time.c +++ b/src/misc/kmk_time.c @@ -1,4 +1,4 @@ -/* $Id: kmk_time.c 2264 2009-01-23 00:31:38Z bird $ */ +/* $Id: kmk_time.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * kmk_time - Time program execution. * @@ -6,7 +6,7 @@ */ /* - * Copyright (c) 2007-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/src/sed/Makefile.kmk b/src/sed/Makefile.kmk index 30c3585..eeae26f 100644 --- a/src/sed/Makefile.kmk +++ b/src/sed/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2506 2011-07-23 10:58:06Z bird $ ## @file # Sub-Makefile for kmk_sed. # # -# Copyright (c) 2006-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -33,16 +33,19 @@ PROGRAMS += kmk_sed kmk_sed_TEMPLATE = BIN kmk_sed_DEPS = \ - $(PATH_kmk_sed)/config.h \ - $(PATH_kmk_sed)/regex.h + $(kmk_sed_0_OUTDIR)/config.h \ + $(kmk_sed_0_OUTDIR)/regex.h kmk_sed_CLEAN = $(kmk_sed_DEPS) kmk_sed_INCS = \ - $(PATH_kmk_sed) \ + $(kmk_sed_0_OUTDIR) \ . \ lib \ intl kmk_sed_DEFS = \ HAVE_CONFIG_H +ifdef KBUILD_SOLARIS_10 + kmk_sed_CFLAGS += -std=gnu99 +endif kmk_sed_SOURCES = \ sed/sed.c \ lib/regex.c \ @@ -66,10 +69,17 @@ kmk_sed_SOURCES.freebsd = \ lib/strverscmp.c \ lib/obstack.c \ lib/getline.c -kmk_sed_SOURCES.solaris = \ +kmk_sed_SOURCES.openbsd = \ lib/strverscmp.c \ lib/obstack.c \ lib/getline.c +kmk_sed_SOURCES.solaris = \ + lib/strverscmp.c \ + lib/obstack.c +ifdef KBUILD_SOLARIS_10 +kmk_sed_SOURCES.solaris += \ + lib/getline.c +endif kmk_sed_SOURCES.win = \ lib/strverscmp.c \ lib/obstack.c \ @@ -82,14 +92,14 @@ include $(FILE_KBUILD_SUB_FOOTER) # # Use checked in config.h instead of running ./configure for it. # -kmk_sed_config.h.$(KBUILD_TARGET) := $(kmk_sed_PATH)/config.h.$(KBUILD_TARGET) +kmk_sed_config.h.$(KBUILD_TARGET) := $(kmk_sed_DEFPATH)/config.h.$(KBUILD_TARGET) -$(PATH_kmk_sed)/config.h: $(kmk_sed_config.h.$(KBUILD_TARGET)) | $(call DIRDEP,$(PATH_kmk_sed)) +$(kmk_sed_0_OUTDIR)/config.h: $(kmk_sed_config.h.$(KBUILD_TARGET)) | $(call DIRDEP,$(kmk_sed_0_OUTDIR)) $(CP) -f $^ $@ # # Use the regex lib shipped with sed and not anything installed on the system. # -$(PATH_kmk_sed)/regex.h: $(kmk_sed_PATH)/lib/regex_.h | $(call DIRDEP,$(PATH_kmk_sed)) +$(kmk_sed_0_OUTDIR)/regex.h: $(kmk_sed_DEFPATH)/lib/regex_.h | $(call DIRDEP,$(kmk_sed_0_OUTDIR)) $(CP) -f $^ $@ diff --git a/src/sed/sed/sed.c b/src/sed/sed/sed.c index a11c4eb..575d6ad 100644 --- a/src/sed/sed/sed.c +++ b/src/sed/sed/sed.c @@ -115,6 +115,10 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\ edit files in place (makes backup if extension supplied)\n")); fprintf(out, _(" -l N, --line-length=N\n\ specify the desired line-wrap length for the `l' command\n")); +#ifndef CONFIG_WITHOUT_O_LANG_C + fprintf(out, _(" --lang_c\n\ + specify C locale\n")); +#endif fprintf(out, _(" --posix\n\ disable all GNU extensions.\n")); #ifndef CONFIG_WITHOUT_O_OPT @@ -176,6 +180,9 @@ main(argc, argv) {"file", 1, NULL, 'f'}, {"in-place", 2, NULL, 'i'}, {"line-length", 1, NULL, 'l'}, +#ifndef CONFIG_WITHOUT_O_LANG_C + {"lang_c", 0, NULL, 'L'}, +#endif {"quiet", 0, NULL, 'n'}, {"posix", 0, NULL, 'p'}, {"silent", 0, NULL, 'n'}, @@ -289,30 +296,41 @@ main(argc, argv) lcmd_out_line_len = ATOI(optarg); break; +#ifndef CONFIG_WITHOUT_O_LANG_C + case 'L': + setlocale (LC_ALL, "C"); + initialize_mbcs (); +# if ENABLE_NLS + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); +# endif + break; +#endif + #ifndef CONFIG_WITHOUT_O_OPT - case 'o': - sed_stdout = ck_fopen (optarg, "w", true /* fail on error */); - break; + case 'o': + sed_stdout = ck_fopen (optarg, "w", true /* fail on error */); + break; - case 300: - sed_stdout = ck_fopen (optarg, "wb", true /* fail on error */); - break; + case 300: + sed_stdout = ck_fopen (optarg, "wb", true /* fail on error */); + break; - case 301: - sed_stdout = ck_fopen (optarg, "wt", true /* fail on error */); - break; + case 301: + sed_stdout = ck_fopen (optarg, "wt", true /* fail on error */); + break; - case 302: - sed_stdout = ck_fopen (optarg, "a", true /* fail on error */); - break; + case 302: + sed_stdout = ck_fopen (optarg, "a", true /* fail on error */); + break; - case 303: - sed_stdout = ck_fopen (optarg, "ab", true /* fail on error */); - break; + case 303: + sed_stdout = ck_fopen (optarg, "ab", true /* fail on error */); + break; - case 304: - sed_stdout = ck_fopen (optarg, "at", true /* fail on error */); - break; + case 304: + sed_stdout = ck_fopen (optarg, "at", true /* fail on error */); + break; #endif case 'p': diff --git a/tests/Config.kmk b/tests/Config.kmk index 8950add..e56d524 100644 --- a/tests/Config.kmk +++ b/tests/Config.kmk @@ -1,10 +1,10 @@ -# $Id: Config.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Config.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Tests - Configuration. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/tests/Makefile.kmk b/tests/Makefile.kmk index 3f36970..d36a5ed 100644 --- a/tests/Makefile.kmk +++ b/tests/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2420 2010-10-17 00:33:38Z bird $ ## @file # Tests - Top Level Makefile. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # @@ -32,4 +32,7 @@ SUBDIRS = \ inherit-bld \ inherit-misc \ +SUBDIRS.os2 = \ + os2-impdef + include $(FILE_KBUILD_FOOTER) diff --git a/tests/dummy.c b/tests/dummy.c index 4f14fb6..535f0a2 100644 --- a/tests/dummy.c +++ b/tests/dummy.c @@ -1,10 +1,10 @@ -/* $Id: dummy.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: dummy.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Tests - Dummy test program. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/tests/dummy_defined_X.c b/tests/dummy_defined_X.c index bf3c6ac..7f2415c 100644 --- a/tests/dummy_defined_X.c +++ b/tests/dummy_defined_X.c @@ -1,10 +1,10 @@ -/* $Id: dummy_defined_X.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: dummy_defined_X.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Tests - Dummy test program checking that X == 42, possibly doing this via y. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/tests/dummy_defined_Y.c b/tests/dummy_defined_Y.c index da73d80..5e6b6e5 100644 --- a/tests/dummy_defined_Y.c +++ b/tests/dummy_defined_Y.c @@ -1,10 +1,10 @@ -/* $Id: dummy_defined_Y.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: dummy_defined_Y.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Tests - Dummy test program checking that Y == 42. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/tests/hello.c b/tests/hello.c index d38152a..1785b95 100644 --- a/tests/hello.c +++ b/tests/hello.c @@ -1,10 +1,10 @@ -/* $Id: hello.c 2243 2009-01-10 02:24:02Z bird $ */ +/* $Id: hello.c 2413 2010-09-11 17:43:04Z bird $ */ /** @file * Tests - Hello world test program. */ /* - * Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> + * Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> * * This file is part of kBuild. * diff --git a/tests/inherit-bld/Config.kmk b/tests/inherit-bld/Config.kmk index 3df0f23..baa3e28 100644 --- a/tests/inherit-bld/Config.kmk +++ b/tests/inherit-bld/Config.kmk @@ -1,4 +1,4 @@ -# $Id: Config.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Config.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Tests - Build Type Inheritance. # @@ -6,7 +6,7 @@ # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/tests/inherit-bld/Makefile.kmk b/tests/inherit-bld/Makefile.kmk index 3b5fd3a..919f5c2 100644 --- a/tests/inherit-bld/Makefile.kmk +++ b/tests/inherit-bld/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $
+# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $
## @file
# Test - Build Type Inheritance.
#
#
-# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
+# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
#
# This file is part of kBuild.
#
diff --git a/tests/inherit-misc/Makefile.kmk b/tests/inherit-misc/Makefile.kmk index a37448a..e83e503 100644 --- a/tests/inherit-misc/Makefile.kmk +++ b/tests/inherit-misc/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Test - Misc Inheritance. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/tests/inherit-misc/sdk51a-xz.kmk b/tests/inherit-misc/sdk51a-xz.kmk index 1d816cb..ea3430e 100644 --- a/tests/inherit-misc/sdk51a-xz.kmk +++ b/tests/inherit-misc/sdk51a-xz.kmk @@ -1,10 +1,10 @@ -# $Id: sdk51a-xz.kmk 2243 2009-01-10 02:24:02Z bird $ +# $Id: sdk51a-xz.kmk 2413 2010-09-11 17:43:04Z bird $ ## @file # Test - Misc Inheritance Issues. # # -# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net> +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> # # This file is part of kBuild. # diff --git a/tests/inherit-target/Makefile.kmk b/tests/inherit-target/Makefile.kmk index 766202a..6691cf1 100644 --- a/tests/inherit-target/Makefile.kmk +++ b/tests/inherit-target/Makefile.kmk @@ -1,10 +1,10 @@ -# $Id: Makefile.kmk 2243 2009-01-10 02:24:02Z bird $
+# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $
## @file
# Test - Target Inheritance.
#
#
-# Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
+# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
#
# This file is part of kBuild.
#
diff --git a/tests/os2-implib/Makefile.kmk b/tests/os2-implib/Makefile.kmk new file mode 100644 index 0000000..ec43222 --- /dev/null +++ b/tests/os2-implib/Makefile.kmk @@ -0,0 +1,38 @@ +# $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# Tests - OS/2 import library. +# + +# +# Copyright (c) 2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# kBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# + + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk +ifeq ($(KBUILD_HOST),os2) + +LIBRARIES = os2-implib-1 +os2-implib-1_TOOL = GCC3OMF +os2-implib-1_SOURCES = os2-implib.def + +endif +include $(FILE_KBUILD_FOOTER) + diff --git a/tests/os2-implib/os2-implib.def b/tests/os2-implib/os2-implib.def new file mode 100644 index 0000000..f3b6a90 --- /dev/null +++ b/tests/os2-implib/os2-implib.def @@ -0,0 +1,30 @@ +; $Id: Makefile.kmk 2413 2010-09-11 17:43:04Z bird $ +;; @file +; Tests - OS/2 import library definitions. +; + +; +; Copyright (c) 2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +; +; This file is part of kBuild. +; +; kBuild is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; +; kBuild is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with kBuild; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +; + +LIBRARY os2dll +EXPORTS + SomeFunction1 + SomeFunction2 + |