| 1 | # $Id: YASM.kmk 2891 2016-09-08 03:02:58Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # kBuild Tool Config - YASM 0.4.0 or later.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2006-2014 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
|
|---|
| 8 | #
|
|---|
| 9 | # This file is part of kBuild.
|
|---|
| 10 | #
|
|---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
|---|
| 12 | # it under the terms of the GNU General Public License as published by
|
|---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
|---|
| 14 | # (at your option) any later version.
|
|---|
| 15 | #
|
|---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
|---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | # GNU General Public License for more details.
|
|---|
| 20 | #
|
|---|
| 21 | # You should have received a copy of the GNU General Public License
|
|---|
| 22 | # along with kBuild; if not, write to the Free Software
|
|---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 24 | #
|
|---|
| 25 | #
|
|---|
| 26 | # As a special exception you are granted permission to include this file, via
|
|---|
| 27 | # the kmk include directive, as you wish without this in itself causing the
|
|---|
| 28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
|---|
| 29 | # This exception does not however invalidate any other reasons why the makefile,
|
|---|
| 30 | # program, whatever should not be covered the GPL.
|
|---|
| 31 | #
|
|---|
| 32 | #
|
|---|
| 33 |
|
|---|
| 34 | TOOL_YASM := YASM v0.4.0+
|
|---|
| 35 |
|
|---|
| 36 | # Tool Specific Properties
|
|---|
| 37 | ifndef PATH_TOOL_YASM
|
|---|
| 38 | PATH_TOOL_YASM := $(sort $(wildcard $(KBUILD_DEVTOOLS_HST)/yasm/v*.*))
|
|---|
| 39 | ifneq ($(PATH_TOOL_YASM),)
|
|---|
| 40 | PATH_TOOL_YASM := $(call lastword,$(PATH_TOOL_YASM))
|
|---|
| 41 | endif
|
|---|
| 42 | else
|
|---|
| 43 | # Resolve any fancy stuff once and for all.
|
|---|
| 44 | PATH_TOOL_YASM := $(PATH_TOOL_YASM)
|
|---|
| 45 | endif
|
|---|
| 46 | ifneq ($(PATH_TOOL_YASM),)
|
|---|
| 47 | TOOL_YASM_AS ?= $(PATH_TOOL_YASM)/yasm$(HOSTSUFF_EXE)
|
|---|
| 48 | else
|
|---|
| 49 | TOOL_YASM_AS ?= yasm$(HOSTSUFF_EXE)
|
|---|
| 50 | endif
|
|---|
| 51 |
|
|---|
| 52 | # kSubmit
|
|---|
| 53 | ifdef TOOL_YASM_USE_KSUBMIT
|
|---|
| 54 | ifeq ($(KBUILD_HOST),win)
|
|---|
| 55 | TOOL_YASM_KSUBMIT ?= kmk_builtin_kSubmit --
|
|---|
| 56 | endif
|
|---|
| 57 | endif
|
|---|
| 58 |
|
|---|
| 59 | # General Properties used by kBuild
|
|---|
| 60 | TOOL_YASM_ASFLAGS ?=
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | ## Compile Assembly source.
|
|---|
| 64 | # @param $(target) Normalized main target name.
|
|---|
| 65 | # @param $(source) Source filename (relative).
|
|---|
| 66 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 67 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 68 | # @param $(flags) Flags.
|
|---|
| 69 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 70 | # @param $(incs) Includes. No -I or something.
|
|---|
| 71 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 72 | # @param $(deps) Other dependencies.
|
|---|
| 73 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 74 | # @param $(objsuff) Object suffix.
|
|---|
| 75 | #
|
|---|
| 76 | TOOL_YASM_COMPILE_AS_OUTPUT = $(outbase).lst
|
|---|
| 77 | TOOL_YASM_COMPILE_AS_OUTPUT_MAYBE = $(obj).map
|
|---|
| 78 | TOOL_YASM_COMPILE_AS_DEPEND =
|
|---|
| 79 | TOOL_YASM_COMPILE_AS_DEPORD =
|
|---|
| 80 | define TOOL_YASM_COMPILE_AS_CMDS
|
|---|
| 81 | ifdef TOOL_YASM_KSUBMIT # yasm 1.3.0 w/ patches.
|
|---|
| 82 | $(QUIET)$(TOOL_YASM_KSUBMIT) $(TOOL_YASM_AS)\
|
|---|
| 83 | $(patsubst --mapfile%,--mapfile=$(obj).map,$(flags))\
|
|---|
| 84 | $(addsuffix /,$(addprefix -I, $(incs))) $(addprefix -D, $(defs))\
|
|---|
| 85 | -l $(outbase).lst\
|
|---|
| 86 | -o $(obj)\
|
|---|
| 87 | -MD="$(dep)" -MP --makedep-dos2unix-slash\
|
|---|
| 88 | $(abspath $(source))
|
|---|
| 89 | else
|
|---|
| 90 | $(QUIET)$(TOOL_YASM_AS)\
|
|---|
| 91 | $(patsubst --mapfile%,--mapfile=$(obj).map,$(flags))\
|
|---|
| 92 | $(addsuffix /,$(addprefix -I, $(incs))) $(addprefix -D, $(defs))\
|
|---|
| 93 | -l $(outbase).lst\
|
|---|
| 94 | -o $(obj)\
|
|---|
| 95 | $(abspath $(source))
|
|---|
| 96 | $(QUIET)$(REDIRECT) -wo $(dep) -- $(TOOL_YASM_AS) -DKBUILD_GENERATING_MAKEFILE_DEPENDENCIES\
|
|---|
| 97 | $(patsubst --mapfile%,--mapfile=$(obj).map,$(flags))\
|
|---|
| 98 | $(addsuffix /,$(addprefix -I, $(incs))) $(addprefix -D, $(defs))\
|
|---|
| 99 | -o $(obj) \
|
|---|
| 100 | $(abspath $(source)) \
|
|---|
| 101 | -M
|
|---|
| 102 | if1of ($(KBUILD_HOST), win nt os2)
|
|---|
| 103 | $(QUIET)$(SED) -e 's/\\\(.\)/\/\1/g' --output "$(dep).tmp" "$(dep)"
|
|---|
| 104 | else
|
|---|
| 105 | $(QUIET)$(CP) -f -- "$(dep)" "$(dep).tmp"
|
|---|
| 106 | endif
|
|---|
| 107 | $(QUIET)$(APPEND) -n "$(dep).tmp" "" ""
|
|---|
| 108 | $(QUIET)$(SED) $(if $(intersects $(KBUILD_HOST), win nt os2), -e 's/\\\(.\)/\/\1/g',)\
|
|---|
| 109 | -e 's/^[^ ]*: / /'\
|
|---|
| 110 | -e 's/ *\\$$(DOLLAR)//'\
|
|---|
| 111 | -e 's/^ *//'\
|
|---|
| 112 | -e 's/ */\n/g'\
|
|---|
| 113 | -e 's/ *\([^ \n][^ \n]*\)/\1:\n/g'\
|
|---|
| 114 | --append "$(dep).tmp"\
|
|---|
| 115 | "$(dep)"
|
|---|
| 116 | $(QUIET)$(MV) -f -- "$(dep).tmp" "$(dep)"
|
|---|
| 117 | endif
|
|---|
| 118 | endef
|
|---|
| 119 |
|
|---|