source: trunk/src/ash/Makefile.kmk@ 2422

Last change on this file since 2422 was 2422, checked in by bird, 15 years ago

OpenBSD hacks.

  • Property svn:eol-style set to native
File size: 4.4 KB
Line 
1# $Id: $
2## @file
3# Sub-makefile for kmk_ash.
4#
5
6#
7# Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@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
26SUB_DEPTH = ../..
27include $(KBUILD_PATH)/subheader.kmk
28
29#INSTALLS = ash.man
30
31PROGRAMS += kmk_ash
32kmk_ash_TEMPLATE = BIN
33kmk_ash_DEFS = lint SHELL SMALL KMK
34if "$(USER)" == "bird"
35kmk_ash_DEFS.debug = DEBUG=2
36endif
37kmk_ash_DEFS.linux = BSD
38kmk_ash_DEFS.solaris = BSD
39kmk_ash_DEFS.win = \
40 BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
41kmk_ash_DEFS.os2 = \
42 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME \
43 EXEC_HASH_BANG_SCRIPT PC_OS2_LIBPATHS PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
44kmk_ash_DEFS.darwin = \
45 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
46kmk_ash_DEFS.dragonfly = \
47 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
48kmk_ash_DEFS.freebsd = \
49 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
50kmk_ash_DEFS.openbsd = \
51 HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
52kmk_ash_INCS = $(PATH_kmk_ash) . # (the last is because of error.h)
53kmk_ash_CFLAGS.win = -I. ## @todo kBuild bug?
54kmk_ash_INCS.win = win
55kmk_ash_SOURCES = \
56 alias.c \
57 cd.c \
58 error.c \
59 eval.c \
60 exec.c \
61 expand.c \
62 histedit.c \
63 input.c \
64 jobs.c \
65 mail.c \
66 main.c \
67 memalloc.c \
68 miscbltin.c \
69 mystring.c \
70 options.c \
71 output.c \
72 parser.c \
73 redir.c \
74 show.c \
75 syntax.c \
76 trap.c \
77 var.c \
78 bltin/echo.c \
79 bltin/kill.c \
80 bltin/test.c \
81 $(PATH_kmk_ash)/builtins.c \
82 $(PATH_kmk_ash)/init.c \
83 $(PATH_kmk_ash)/nodes.c
84kmk_ash_SOURCES.linux = \
85 sys_signame.c \
86 strlcpy.c \
87 setmode.c
88kmk_ash_SOURCES.win = \
89 win/mscfakes.c \
90 win/err.c \
91 win/dirent.c \
92 sys_signame.c \
93 strlcpy.c \
94 setmode.c
95kmk_ash_SOURCES.solaris = \
96 sys_signame.c \
97 strlcpy.c \
98 setmode.c
99
100kmk_ash_INTERMEDIATES = \
101 $(PATH_kmk_ash)/builtins.h \
102 $(PATH_kmk_ash)/nodes.h \
103 $(PATH_kmk_ash)/token.h
104kmk_ash_CLEAN = \
105 $(kmk_ash_INTERMEDIATES) \
106 $(PATH_kmk_ash)/builtins.c \
107 $(PATH_kmk_ash)/init.c \
108 $(PATH_kmk_ash)/nodes.c
109
110kmk_ash.man_TEMPLATE = usr.bin.man
111kmk_ash.man_SOURCES = \
112 sh.1=>ash.1
113#ash.man_SYMLINKS = \
114# ash.1.gz=>sh.1
115
116if1of ($(KBUILD_TARGET), win nt)
117#
118# Use the pregenerated code.
119#
120kmk_ash_DEPS :=
121kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c
122
123include $(FILE_KBUILD_SUB_FOOTER)
124
125define def_copy_generated
126$(PATH_kmk_ash)/$(src): generated/$(src)
127 $$(RM) -f $$@
128 $$(CP) -f $$^ $$@
129endef
130
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)))
133
134
135else
136#
137# Generate the code on the fly.
138#
139
140USES += lex yacc
141kmk_ash_USES = lex yacc
142kmk_ash_LEXTOOL = FLEX
143kmk_ash_LEXFLAGS = -8
144#kmk_ash_YACCTOOL = BISON
145kmk_ash_YACCTOOL = YACC
146kmk_ash_YACCFLAGS = -ld
147kmk_ash_SOURCES += \
148 arith.y \
149 arith_lex.l
150
151
152include $(FILE_KBUILD_SUB_FOOTER)
153
154#
155# ATTENTION! ATTENTION! ATTENTION!
156#
157# Older ash versions has trouble with some of these scripts, great.
158# Kudos to the NetBSD guys for this clever move. ;)
159#
160# So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea.
161#
162BOOTSTRAP_SHELL ?= $(SHELL)
163
164$(PATH_kmk_ash)/builtins.h + $(PATH_kmk_ash)/builtins.c: \
165 $(kmk_ash_PATH)/mkbuiltins \
166 $(kmk_ash_PATH)/shell.h \
167 $(kmk_ash_PATH)/builtins.def \
168 | $(call DIRDEP,$(PATH_kmk_ash))
169 $(BOOTSTRAP_SHELL) $+ $(dir $@)
170 [ -f $(PATH_kmk_ash)/builtins.h ]
171
172$(PATH_kmk_ash)/nodes.h + $(PATH_kmk_ash)/nodes.c: \
173 $(kmk_ash_PATH)/mknodes.sh \
174 $(kmk_ash_PATH)/nodetypes \
175 $(kmk_ash_PATH)/nodes.c.pat \
176 | $(call DIRDEP,$(PATH_kmk_ash))
177 $(BOOTSTRAP_SHELL) $+ $(dir $@)
178 [ -f $(dir $@)/nodes.h ]
179
180$(PATH_kmk_ash)/token.h: $(kmk_ash_PATH)/mktokens | $(call DIRDEP,$(PATH_kmk_ash))
181 $(BOOTSTRAP_SHELL) $+
182 $(MV) token.h $@
183
184$(PATH_kmk_ash)/init.c: \
185 $(kmk_ash_PATH)/mkinit.sh \
186 $(abspathex $(filter-out $(PATH_kmk_ash)/%,$(kmk_ash_SOURCES)), $(kmk_ash_PATH)) \
187 | $(call DIRDEP,$(PATH_kmk_ash))
188 $(BOOTSTRAP_SHELL) $+
189 $(MV) init.c $@
190
191endif # generate on the fly
192
Note: See TracBrowser for help on using the repository browser.