kmkbuiltin/expr.c: file revision 1.17 from OpenBSD
[kbuild-mirror.git] / src / ash / Makefile.kmk
blob1f81566471a0c419c00df222218cae306dba5685
1 # $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $
2 ## @file
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
27 SUB_DEPTH = ../..
28 include $(KBUILD_PATH)/subheader.kmk
30 #INSTALLS = ash.man
32 PROGRAMS += kmk_ash
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
37 kmk_ash_DEFS.win = \
38 BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
39 kmk_ash_DEFS.os2 = \
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
51 kmk_ash_SOURCES = \
52 alias.c \
53 cd.c \
54 error.c \
55 eval.c \
56 exec.c \
57 expand.c \
58 histedit.c \
59 input.c \
60 jobs.c \
61 mail.c \
62 main.c \
63 memalloc.c \
64 miscbltin.c \
65 mystring.c \
66 options.c \
67 output.c \
68 parser.c \
69 redir.c \
70 show.c \
71 syntax.c \
72 trap.c \
73 var.c \
74 bltin/echo.c \
75 bltin/kill.c \
76 bltin/test.c \
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 = \
82 sys_signame.c \
83 strlcpy.c \
84 setmode.c
85 kmk_ash_SOURCES.win = \
86 win/mscfakes.c \
87 win/err.c \
88 win/dirent.c \
89 sys_signame.c \
90 strlcpy.c \
91 setmode.c
92 kmk_ash_SOURCES.solaris = \
93 sys_signame.c \
94 strlcpy.c \
95 setmode.c
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
102 kmk_ash_CLEAN = \
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 = \
112 sh.1=>ash.1
113 #ash.man_SYMLINKS = \
114 # ash.1.gz=>sh.1
116 if1of ($(KBUILD_TARGET), win nt)
118 # Use the pregenerated code.
120 kmk_ash_DEPS :=
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)
127 $$(RM) -f $$@
128 $$(CP) -f $$^ $$@
129 endef
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)))
135 else
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
145 else
146 kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c
147 endif
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)
160 ifndef YACC
161 YACC := $(firstword $(which byacc) $(which yacc) yacc)
162 endif
164 $(PATH_kmk_ash)/arith.h + $(PATH_kmk_ash)/arith.c: $(kmk_ash_PATH)/arith.y | $(call DIRDEP,$(PATH_kmk_ash))
165 $(YACC) -ld $^
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
172 endif
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) $+
192 $(MV) token.h $@
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) $+
199 $(MV) init.c $@
201 endif # generate on the fly