1 # $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $
3 # Sub-makefile for kmk_ash.
7 # Copyright (c) 2005-2008 knut st. osmundsen <bird-kBuild-spam@anduin.net>
9 # This file is part of kBuild.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 include $(KBUILD_PATH
)/subheader.kmk
33 kmk_ash_TEMPLATE
= BIN
34 kmk_ash_DEFS
= lint SHELL SMALL KMK
35 kmk_ash_DEFS.linux
= BSD
36 kmk_ash_DEFS.solaris
= BSD
38 BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
40 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME \
41 EXEC_HASH_BANG_SCRIPT PC_OS2_LIBPATHS PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
42 kmk_ash_DEFS.darwin
= \
43 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
44 kmk_ash_DEFS.dragonfly
= \
45 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
46 kmk_ash_DEFS.freebsd
= \
47 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
48 kmk_ash_INCS
= $(PATH_kmk_ash
) .
# (the last is because of error.h)
49 kmk_ash_CFLAGS.win
= -I.
## @todo kBuild bug?
50 kmk_ash_INCS.win
= win
77 $(PATH_kmk_ash
)/arith.c \
78 $(PATH_kmk_ash
)/builtins.c \
79 $(PATH_kmk_ash
)/init.c \
80 $(PATH_kmk_ash
)/nodes.c
81 kmk_ash_SOURCES.linux
= \
85 kmk_ash_SOURCES.win
= \
92 kmk_ash_SOURCES.solaris
= \
97 kmk_ash_INTERMEDIATES
= \
98 $(PATH_kmk_ash
)/arith.h \
99 $(PATH_kmk_ash
)/builtins.h \
100 $(PATH_kmk_ash
)/nodes.h \
101 $(PATH_kmk_ash
)/token.h
103 $(kmk_ash_INTERMEDIATES
) \
104 $(PATH_kmk_ash
)/arith.c \
105 $(PATH_kmk_ash
)/arith_lex.c \
106 $(PATH_kmk_ash
)/builtins.c \
107 $(PATH_kmk_ash
)/init.c \
108 $(PATH_kmk_ash
)/nodes.c
110 kmk_ash.man_TEMPLATE
= usr.bin.man
111 kmk_ash.man_SOURCES
= \
113 #ash.man_SYMLINKS = \
116 if1of
($(KBUILD_TARGET
), win nt
)
118 # Use the pregenerated code.
121 kmk_ash_SOURCES
+= $(PATH_kmk_ash
)/arith_lex.c
123 include $(FILE_KBUILD_SUB_FOOTER
)
125 define def_copy_generated
126 $(PATH_kmk_ash
)/$(src
): generated
/$(src
)
131 $(foreach src
, arith.h arith.c arith_lex.c builtins.h builtins.c nodes.h nodes.c token.h init.c
,\
132 $(eval
$(def_copy_generated
)))
137 # Generate the code on the fly.
140 ifeq (1,2) #disabled for now.
141 kmk_ash_USES
= lex #yacc
142 kmk_ash_SOURCES
+= arith_lex.l
143 kmk_ash_LEXTOOL
= FLEX
144 kmk_ash_LEXFLAGS
= -8
146 kmk_ash_SOURCES
+= $(PATH_kmk_ash
)/arith_lex.c
149 include $(FILE_KBUILD_SUB_FOOTER
)
152 # ATTENTION! ATTENTION! ATTENTION!
154 # Older ash versions has trouble with some of these scripts, great.
155 # Kudos to the NetBSD guys for this clever move. ;)
157 # So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea.
159 BOOTSTRAP_SHELL ?
= $(SHELL
)
161 YACC
:= $(firstword $(which byacc
) $(which
yacc) yacc)
164 $(PATH_kmk_ash
)/arith.h
+ $(PATH_kmk_ash
)/arith.c
: $(kmk_ash_PATH
)/arith.y |
$(call DIRDEP
,$(PATH_kmk_ash
))
166 $(MV
) -f y.tab.c
$(PATH_kmk_ash
)/arith.c
167 $(MV
) -f y.tab.h
$(PATH_kmk_ash
)/arith.h
169 ifndef kmk_ash_LEXTOOL
170 $(PATH_kmk_ash
)/arith_lex.c
: $(kmk_ash_PATH
)/arith_lex.l |
$(call DIRDEP
,$(PATH_kmk_ash
))
171 flex
-8 -o
$@
$^
# 8-bit lex scanner for arithmetic
174 $(PATH_kmk_ash
)/builtins.h
+ $(PATH_kmk_ash
)/builtins.c
: \
175 $(kmk_ash_PATH
)/mkbuiltins \
176 $(kmk_ash_PATH
)/shell.h \
177 $(kmk_ash_PATH
)/builtins.def \
178 |
$(call DIRDEP
,$(PATH_kmk_ash
))
179 $(BOOTSTRAP_SHELL
) $+ $(dir $@
)
180 [ -f
$(PATH_kmk_ash
)/builtins.h
]
182 $(PATH_kmk_ash
)/nodes.h
+ $(PATH_kmk_ash
)/nodes.c
: \
183 $(kmk_ash_PATH
)/mknodes.sh \
184 $(kmk_ash_PATH
)/nodetypes \
185 $(kmk_ash_PATH
)/nodes.c.pat \
186 |
$(call DIRDEP
,$(PATH_kmk_ash
))
187 $(BOOTSTRAP_SHELL
) $+ $(dir $@
)
188 [ -f
$(dir $@
)/nodes.h
]
190 $(PATH_kmk_ash
)/token.h
: $(kmk_ash_PATH
)/mktokens |
$(call DIRDEP
,$(PATH_kmk_ash
))
191 $(BOOTSTRAP_SHELL
) $+
194 $(PATH_kmk_ash
)/init.c
: \
195 $(kmk_ash_PATH
)/mkinit.sh \
196 $(abspathex
$(filter-out $(PATH_kmk_ash
)/%,$(kmk_ash_SOURCES
)), $(kmk_ash_PATH
)) \
197 |
$(call DIRDEP
,$(PATH_kmk_ash
))
198 $(BOOTSTRAP_SHELL
) $+
201 endif # generate on the fly