| 1 | # $Id: Makefile.kmk 2314 2009-03-02 01:31:03Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # Sub-makefile for kash.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@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 3 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, see <http://www.gnu.org/licenses/>
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 |
|
|---|
| 26 | SUB_DEPTH = ../..
|
|---|
| 27 | include $(KBUILD_PATH)/subheader.kmk
|
|---|
| 28 |
|
|---|
| 29 | #
|
|---|
| 30 | # The program.
|
|---|
| 31 | #
|
|---|
| 32 | PROGRAMS += kash
|
|---|
| 33 | kash_TEMPLATE = BIN
|
|---|
| 34 | kash_ASTOOL = YASM
|
|---|
| 35 | kash_DEFS = lint SHELL SMALL
|
|---|
| 36 | kash_DEFS += SH_FORKED_MODE
|
|---|
| 37 | kash_DEFS.debug = DEBUG=2
|
|---|
| 38 | kash_DEFS.linux = BSD
|
|---|
| 39 | kash_DEFS.solaris = BSD
|
|---|
| 40 | ## @todo bring over PC_SLASHES?
|
|---|
| 41 | kash_DEFS.win = \
|
|---|
| 42 | BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS YY_NO_UNISTD_H SH_DEAL_WITH_CRLF
|
|---|
| 43 | kash_DEFS.os2 = \
|
|---|
| 44 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME \
|
|---|
| 45 | EXEC_HASH_BANG_SCRIPT PC_OS2_LIBPATHS PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS
|
|---|
| 46 | kash_DEFS.darwin = \
|
|---|
| 47 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
|---|
| 48 | kash_DEFS.dragonfly = \
|
|---|
| 49 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
|---|
| 50 | kash_DEFS.freebsd = \
|
|---|
| 51 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
|---|
| 52 | kash_INCS = $(PATH_kash) . # (the last is because of error.h)
|
|---|
| 53 | kash_ASFLAGS.win = -g cv8
|
|---|
| 54 | kash_ASFLAGS.win.x86 = -f win32
|
|---|
| 55 | kash_ASFLAGS.win.amd64 = -f win64
|
|---|
| 56 | if "$(USER)" == "bird" && "$(KBUILD_TARGET)" != "win"
|
|---|
| 57 | kash_CFLAGS += -std=gnu99
|
|---|
| 58 | endif
|
|---|
| 59 | kash_CFLAGS.win.amd64 = -GS-
|
|---|
| 60 | kash_SOURCES = \
|
|---|
| 61 | main.c \
|
|---|
| 62 | alias.c \
|
|---|
| 63 | cd.c \
|
|---|
| 64 | error.c \
|
|---|
| 65 | eval.c \
|
|---|
| 66 | exec.c \
|
|---|
| 67 | expand.c \
|
|---|
| 68 | histedit.c \
|
|---|
| 69 | input.c \
|
|---|
| 70 | jobs.c \
|
|---|
| 71 | mail.c \
|
|---|
| 72 | memalloc.c \
|
|---|
| 73 | mystring.c \
|
|---|
| 74 | options.c \
|
|---|
| 75 | output.c \
|
|---|
| 76 | parser.c \
|
|---|
| 77 | redir.c \
|
|---|
| 78 | show.c \
|
|---|
| 79 | syntax.c \
|
|---|
| 80 | trap.c \
|
|---|
| 81 | var.c \
|
|---|
| 82 | miscbltin.c \
|
|---|
| 83 | bltin/echo.c \
|
|---|
| 84 | bltin/kill.c \
|
|---|
| 85 | bltin/test.c \
|
|---|
| 86 | \
|
|---|
| 87 | $(PATH_kash)/arith.c \
|
|---|
| 88 | $(PATH_kash)/arith_lex.c \
|
|---|
| 89 | $(PATH_kash)/builtins.c \
|
|---|
| 90 | $(PATH_kash)/init.c \
|
|---|
| 91 | $(PATH_kash)/nodes.c \
|
|---|
| 92 | \
|
|---|
| 93 | setmode.c \
|
|---|
| 94 | shinstance.c \
|
|---|
| 95 | shheap.c \
|
|---|
| 96 | shthread.c \
|
|---|
| 97 | shfile.c
|
|---|
| 98 | kash_SOURCES.linux = \
|
|---|
| 99 | sys_signame.c \
|
|---|
| 100 | strlcpy.c
|
|---|
| 101 | kash_SOURCES.win = \
|
|---|
| 102 | sys_signame.c \
|
|---|
| 103 | strlcpy.c \
|
|---|
| 104 | shfork-win.c \
|
|---|
| 105 | shforkA-win.asm
|
|---|
| 106 | kash_SOURCES.solaris = \
|
|---|
| 107 | sys_signame.c \
|
|---|
| 108 | strlcpy.c
|
|---|
| 109 |
|
|---|
| 110 | kash_INTERMEDIATES = \
|
|---|
| 111 | $(PATH_kash)/arith.h \
|
|---|
| 112 | $(PATH_kash)/builtins.h \
|
|---|
| 113 | $(PATH_kash)/nodes.h \
|
|---|
| 114 | $(PATH_kash)/token.h
|
|---|
| 115 | kash_CLEAN = \
|
|---|
| 116 | $(kash_INTERMEDIATES) \
|
|---|
| 117 | $(PATH_kash)/arith.c \
|
|---|
| 118 | $(PATH_kash)/arith_lex.c \
|
|---|
| 119 | $(PATH_kash)/builtins.c \
|
|---|
| 120 | $(PATH_kash)/init.c \
|
|---|
| 121 | $(PATH_kash)/nodes.c
|
|---|
| 122 |
|
|---|
| 123 | ##
|
|---|
| 124 | ## The manual page.
|
|---|
| 125 | ##
|
|---|
| 126 | #INSTALLS += kash.man
|
|---|
| 127 | #kash.man_TEMPLATE = usr.bin.man
|
|---|
| 128 | #kash.man_SOURCES = sh.1=>kash.1
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 | if1of ($(KBUILD_TARGET), win)
|
|---|
| 132 |
|
|---|
| 133 | #
|
|---|
| 134 | # Use the pregenerated code.
|
|---|
| 135 | #
|
|---|
| 136 | kash_INTERMEDIATES :=
|
|---|
| 137 | kash_INCS += generated
|
|---|
| 138 | kash_SOURCES := $(patsubst $(PATH_kash)/%,generated/%,$(kash_SOURCES))
|
|---|
| 139 |
|
|---|
| 140 | else
|
|---|
| 141 |
|
|---|
| 142 | #
|
|---|
| 143 | # ATTENTION! ATTENTION! ATTENTION!
|
|---|
| 144 | #
|
|---|
| 145 | # Older ash versions has trouble with some of these scripts, great.
|
|---|
| 146 | # Kudos to the NetBSD guys for this clever move. ;)
|
|---|
| 147 | #
|
|---|
| 148 | # So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea.
|
|---|
| 149 | #
|
|---|
| 150 | BOOTSTRAP_SHELL ?= $(SHELL)
|
|---|
| 151 | ifndef YACC
|
|---|
| 152 | YACC := $(firstword $(which byacc) $(which yacc) yacc)
|
|---|
| 153 | endif
|
|---|
| 154 |
|
|---|
| 155 | $$(PATH_kash)/arith.h + $$(PATH_kash)/arith.c: arith.y | $$(dir $$@)
|
|---|
| 156 | $(YACC) -ld $^
|
|---|
| 157 | $(MV) -f y.tab.c $(PATH_kash)/arith.c
|
|---|
| 158 | $(MV) -f y.tab.h $(PATH_kash)/arith.h
|
|---|
| 159 |
|
|---|
| 160 | $$(PATH_kash)/arith_lex.c: $$(kash_DEFPATH)/arith_lex.l | $$(dir $$@)
|
|---|
| 161 | flex -8 -o$@ $^ # 8-bit lex scanner for arithmetic
|
|---|
| 162 |
|
|---|
| 163 | $$(PATH_kash)/builtins.h + $$(PATH_kash)/builtins.c: \
|
|---|
| 164 | $$(kash_DEFPATH)/mkbuiltins \
|
|---|
| 165 | $$(kash_DEFPATH)/shell.h \
|
|---|
| 166 | $$(kash_DEFPATH)/builtins.def \
|
|---|
| 167 | | $$(dir $$@)
|
|---|
| 168 | $(BOOTSTRAP_SHELL) $+ $(dir $@)
|
|---|
| 169 | [ -f $(PATH_kash)/builtins.h ]
|
|---|
| 170 |
|
|---|
| 171 | $$(PATH_kash)/nodes.h + $$(PATH_kash)/nodes.c: \
|
|---|
| 172 | $$(kash_DEFPATH)/mknodes.sh \
|
|---|
| 173 | $$(kash_DEFPATH)/nodetypes \
|
|---|
| 174 | $$(kash_DEFPATH)/nodes.c.pat \
|
|---|
| 175 | | $$(dir $$@)
|
|---|
| 176 | $(BOOTSTRAP_SHELL) $+ $(dir $@)
|
|---|
| 177 | [ -f $(dir $@)/nodes.h ]
|
|---|
| 178 |
|
|---|
| 179 | $$(PATH_kash)/token.h: $$(kash_DEFPATH)/mktokens | $$(dir $$@)
|
|---|
| 180 | $(BOOTSTRAP_SHELL) $+
|
|---|
| 181 | $(MV) token.h $@
|
|---|
| 182 |
|
|---|
| 183 | $$(PATH_kash)/init.c: \
|
|---|
| 184 | $$(kash_DEFPATH)/mkinit.sh \
|
|---|
| 185 | $$(abspathex $$(filter-out $$(PATH_kash)/%,$$(kash_SOURCES)), $$(kash_DEFPATH)) \
|
|---|
| 186 | | $$(dir $$@)
|
|---|
| 187 | $(BOOTSTRAP_SHELL) $+
|
|---|
| 188 | $(MV) init.c $@
|
|---|
| 189 |
|
|---|
| 190 | endif
|
|---|
| 191 |
|
|---|
| 192 | # Include the sub-makefile.
|
|---|
| 193 | include $(PATH_SUB_CURRENT)/tests/Makefile.kmk
|
|---|
| 194 |
|
|---|
| 195 | include $(FILE_KBUILD_SUB_FOOTER)
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|