# $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $ ## @file # Sub-makefile for kmk_ash. # # # Copyright (c) 2005-2008 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 2 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # SUB_DEPTH = ../.. include $(KBUILD_PATH)/subheader.kmk #INSTALLS = ash.man PROGRAMS += kmk_ash kmk_ash_TEMPLATE = BIN kmk_ash_DEFS = lint SHELL SMALL KMK if "$(USER)" == "bird" kmk_ash_DEFS.debug = DEBUG=2 endif kmk_ash_DEFS.linux = BSD kmk_ash_DEFS.solaris = BSD kmk_ash_DEFS.win = \ BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES kmk_ash_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 PC_SLASHES kmk_ash_DEFS.darwin = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kmk_ash_DEFS.dragonfly = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kmk_ash_DEFS.freebsd = \ HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME kmk_ash_INCS = $(PATH_kmk_ash) . # (the last is because of error.h) kmk_ash_CFLAGS.win = -I. ## @todo kBuild bug? kmk_ash_INCS.win = win kmk_ash_SOURCES = \ alias.c \ cd.c \ error.c \ eval.c \ exec.c \ expand.c \ histedit.c \ input.c \ jobs.c \ mail.c \ main.c \ memalloc.c \ miscbltin.c \ mystring.c \ options.c \ output.c \ parser.c \ redir.c \ show.c \ syntax.c \ trap.c \ var.c \ bltin/echo.c \ bltin/kill.c \ bltin/test.c \ $(PATH_kmk_ash)/arith.c \ $(PATH_kmk_ash)/builtins.c \ $(PATH_kmk_ash)/init.c \ $(PATH_kmk_ash)/nodes.c kmk_ash_SOURCES.linux = \ sys_signame.c \ strlcpy.c \ setmode.c kmk_ash_SOURCES.win = \ win/mscfakes.c \ win/err.c \ win/dirent.c \ sys_signame.c \ strlcpy.c \ setmode.c kmk_ash_SOURCES.solaris = \ sys_signame.c \ strlcpy.c \ setmode.c kmk_ash_INTERMEDIATES = \ $(PATH_kmk_ash)/arith.h \ $(PATH_kmk_ash)/builtins.h \ $(PATH_kmk_ash)/nodes.h \ $(PATH_kmk_ash)/token.h kmk_ash_CLEAN = \ $(kmk_ash_INTERMEDIATES) \ $(PATH_kmk_ash)/arith.c \ $(PATH_kmk_ash)/arith_lex.c \ $(PATH_kmk_ash)/builtins.c \ $(PATH_kmk_ash)/init.c \ $(PATH_kmk_ash)/nodes.c kmk_ash.man_TEMPLATE = usr.bin.man kmk_ash.man_SOURCES = \ sh.1=>ash.1 #ash.man_SYMLINKS = \ # ash.1.gz=>sh.1 if1of ($(KBUILD_TARGET), win nt) # # Use the pregenerated code. # kmk_ash_DEPS := kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c include $(FILE_KBUILD_SUB_FOOTER) define def_copy_generated $(PATH_kmk_ash)/$(src): generated/$(src) $$(RM) -f $$@ $$(CP) -f $$^ $$@ endef $(foreach src, arith.h arith.c arith_lex.c builtins.h builtins.c nodes.h nodes.c token.h init.c,\ $(eval $(def_copy_generated))) else # # Generate the code on the fly. # ifeq (1,2) #disabled for now. kmk_ash_USES = lex #yacc kmk_ash_SOURCES += arith_lex.l kmk_ash_LEXTOOL = FLEX kmk_ash_LEXFLAGS = -8 else kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c endif include $(FILE_KBUILD_SUB_FOOTER) # # 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_kmk_ash)/arith.h + $(PATH_kmk_ash)/arith.c: $(kmk_ash_PATH)/arith.y | $(call DIRDEP,$(PATH_kmk_ash)) $(YACC) -ld $^ $(MV) -f y.tab.c $(PATH_kmk_ash)/arith.c $(MV) -f y.tab.h $(PATH_kmk_ash)/arith.h ifndef kmk_ash_LEXTOOL $(PATH_kmk_ash)/arith_lex.c: $(kmk_ash_PATH)/arith_lex.l | $(call DIRDEP,$(PATH_kmk_ash)) flex -8 -o$@ $^ # 8-bit lex scanner for arithmetic endif $(PATH_kmk_ash)/builtins.h + $(PATH_kmk_ash)/builtins.c: \ $(kmk_ash_PATH)/mkbuiltins \ $(kmk_ash_PATH)/shell.h \ $(kmk_ash_PATH)/builtins.def \ | $(call DIRDEP,$(PATH_kmk_ash)) $(BOOTSTRAP_SHELL) $+ $(dir $@) [ -f $(PATH_kmk_ash)/builtins.h ] $(PATH_kmk_ash)/nodes.h + $(PATH_kmk_ash)/nodes.c: \ $(kmk_ash_PATH)/mknodes.sh \ $(kmk_ash_PATH)/nodetypes \ $(kmk_ash_PATH)/nodes.c.pat \ | $(call DIRDEP,$(PATH_kmk_ash)) $(BOOTSTRAP_SHELL) $+ $(dir $@) [ -f $(dir $@)/nodes.h ] $(PATH_kmk_ash)/token.h: $(kmk_ash_PATH)/mktokens | $(call DIRDEP,$(PATH_kmk_ash)) $(BOOTSTRAP_SHELL) $+ $(MV) token.h $@ $(PATH_kmk_ash)/init.c: \ $(kmk_ash_PATH)/mkinit.sh \ $(abspathex $(filter-out $(PATH_kmk_ash)/%,$(kmk_ash_SOURCES)), $(kmk_ash_PATH)) \ | $(call DIRDEP,$(PATH_kmk_ash)) $(BOOTSTRAP_SHELL) $+ $(MV) init.c $@ endif # generate on the fly