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