# $Id: Makefile.kmk 2304 2009-03-01 07:48:14Z bird $ ## @file # Sub-makefile for kash. # # # Copyright (c) 2005-2009 knut st. osmundsen # # This file is part of kBuild. # # kBuild is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # kBuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with kBuild. If not, see # # SUB_DEPTH = ../.. include $(KBUILD_PATH)/subheader.kmk # # The program. # PROGRAMS += kash kash_TEMPLATE = BIN kash_ASTOOL = YASM kash_DEFS = lint SHELL SMALL kash_DEFS += SH_FORKED_MODE kash_DEFS.debug = DEBUG=2 kash_DEFS.linux = BSD kash_DEFS.solaris = BSD ## @todo bring over PC_SLASHES? kash_DEFS.win = \ BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS YY_NO_UNISTD_H SH_DEAL_WITH_CRLF kash_DEFS.os2 = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME \ EXEC_HASH_BANG_SCRIPT PC_OS2_LIBPATHS PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS kash_DEFS.darwin = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kash_DEFS.dragonfly = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kash_DEFS.freebsd = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kash_INCS = $(PATH_kash) . # (the last is because of error.h) kash_ASFLAGS.win = -g cv8 kash_ASFLAGS.win.x86 = -f win32 kash_ASFLAGS.win.amd64 = -f win64 if "$(USER)" == "bird" && "$(KBUILD_TARGET)" != "win" kash_CFLAGS += -std=gnu99 endif kash_CFLAGS.win = -GS- kash_SOURCES = \ main.c \ alias.c \ cd.c \ error.c \ eval.c \ exec.c \ expand.c \ histedit.c \ input.c \ jobs.c \ mail.c \ memalloc.c \ mystring.c \ options.c \ output.c \ parser.c \ redir.c \ show.c \ syntax.c \ trap.c \ var.c \ miscbltin.c \ bltin/echo.c \ bltin/kill.c \ bltin/test.c \ \ $(PATH_kash)/arith.c \ $(PATH_kash)/arith_lex.c \ $(PATH_kash)/builtins.c \ $(PATH_kash)/init.c \ $(PATH_kash)/nodes.c \ \ setmode.c \ shinstance.c \ shheap.c \ shthread.c \ shfile.c kash_SOURCES.linux = \ sys_signame.c \ strlcpy.c kash_SOURCES.win = \ sys_signame.c \ strlcpy.c \ shfork-win.c \ shforkA-win.asm kash_SOURCES.solaris = \ sys_signame.c \ strlcpy.c kash_INTERMEDIATES = \ $(PATH_kash)/arith.h \ $(PATH_kash)/builtins.h \ $(PATH_kash)/nodes.h \ $(PATH_kash)/token.h kash_CLEAN = \ $(kash_INTERMEDIATES) \ $(PATH_kash)/arith.c \ $(PATH_kash)/arith_lex.c \ $(PATH_kash)/builtins.c \ $(PATH_kash)/init.c \ $(PATH_kash)/nodes.c ## ## The manual page. ## #INSTALLS += kash.man #kash.man_TEMPLATE = usr.bin.man #kash.man_SOURCES = sh.1=>kash.1 if1of ($(KBUILD_TARGET), win) # # Use the pregenerated code. # kash_INTERMEDIATES := kash_INCS += generated kash_SOURCES := $(patsubst $(PATH_kash)/%,generated/%,$(kash_SOURCES)) else # # ATTENTION! ATTENTION! ATTENTION! # # Older ash versions has trouble with some of these scripts, great. # Kudos to the NetBSD guys for this clever move. ;) # # So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea. # BOOTSTRAP_SHELL ?= $(SHELL) ifndef YACC YACC := $(firstword $(which byacc) $(which yacc) yacc) endif $$(PATH_kash)/arith.h + $$(PATH_kash)/arith.c: arith.y | $$(dir $$@) $(YACC) -ld $^ $(MV) -f y.tab.c $(PATH_kash)/arith.c $(MV) -f y.tab.h $(PATH_kash)/arith.h $$(PATH_kash)/arith_lex.c: $$(kash_DEFPATH)/arith_lex.l | $$(dir $$@) flex -8 -o$@ $^ # 8-bit lex scanner for arithmetic $$(PATH_kash)/builtins.h + $$(PATH_kash)/builtins.c: \ $$(kash_DEFPATH)/mkbuiltins \ $$(kash_DEFPATH)/shell.h \ $$(kash_DEFPATH)/builtins.def \ | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(dir $@) [ -f $(PATH_kash)/builtins.h ] $$(PATH_kash)/nodes.h + $$(PATH_kash)/nodes.c: \ $$(kash_DEFPATH)/mknodes.sh \ $$(kash_DEFPATH)/nodetypes \ $$(kash_DEFPATH)/nodes.c.pat \ | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(dir $@) [ -f $(dir $@)/nodes.h ] $$(PATH_kash)/token.h: $$(kash_DEFPATH)/mktokens | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(MV) token.h $@ $$(PATH_kash)/init.c: \ $$(kash_DEFPATH)/mkinit.sh \ $$(abspathex $$(filter-out $$(PATH_kash)/%,$$(kash_SOURCES)), $$(kash_DEFPATH)) \ | $$(dir $$@) $(BOOTSTRAP_SHELL) $+ $(MV) init.c $@ endif # Include the sub-makefile. include $(PATH_SUB_CURRENT)/tests/Makefile.kmk include $(FILE_KBUILD_SUB_FOOTER)