[klibc] EXTRA_KLIBCCFLAGS and dash
Sam Ravnborg
sam at ravnborg.org
Sat Jul 8 16:03:34 PDT 2006
On Sat, Jul 08, 2006 at 02:56:10PM -0700, H. Peter Anvin wrote:
> I think the dash Kbuild file
> needs some cleaning up.
First attempt - not ready for merging yet...
Sam
usr/dash/Kbuild | 105 ++++++++++++++++----------------------------------------
1 file changed, 30 insertions(+), 75 deletions(-)
diff --git a/usr/dash/Kbuild b/usr/dash/Kbuild
index 8e5184e..f046867 100644
--- a/usr/dash/Kbuild
+++ b/usr/dash/Kbuild
@@ -2,62 +2,38 @@ #
# Kbuild file for dash
#
-COMMON_CFLAGS :=
-COMMON_CPPFLAGS := \
- -DBSD=1 -DSMALL -DSHELL \
- -DGLOB_BROKEN -DFNMATCH_BROKEN -DIFS_BROKEN \
- -DJOBS=0
-
-CFLAGS := $(COMMON_CFLAGS)
-CPPFLAGS := $(COMMON_CPPFLAGS)
-CFLAGS_FOR_BUILD := $(COMMON_CFLAGS)
-CPPFLAGS_FOR_BUILD := $(COMMON_CPPFLAGS)
-
-DEFS := -DHAVE_CONFIG_H
-DEFAULT_INCLUDES := \
- -I$(srctree)/$(src) -I$(objtree)/$(obj) \
- -include $(srctree)/$(src)/config.h
-
-EXTRA_KLIBCCFLAGS := $(DEFS) $(DEFAULT_INCLUDES) $(CPPFLAGS) $(CFLAGS)
-HOST_EXTRACFLAGS := $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
-
-SRCS := alias.c arith_yylex.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 parser.c redir.c show.c trap.c output.c \
- bltin/printf.c system.c bltin/test.c var.c
-
-OBJ1 := builtins.o init.o nodes.o syntax.o
-OBJ2 := alias.o arith.o arith_yylex.o cd.o \
- error.o eval.o exec.o expand.o \
- histedit.o input.o jobs.o \
- mail.o main.o memalloc.o \
- miscbltin.o mystring.o options.o \
- parser.o redir.o show.o trap.o \
- output.o bltin/printf.o system.o \
- bltin/test.o var.o
-
-OBJS := $(OBJ1) $(OBJ2)
-
-HELPERS := mkinit mksyntax mknodes mksignames
-BUILT_SOURCES := arith.h builtins.h nodes.h syntax.h token.h
-CLEANFILES := \
- $(BUILT_SOURCES) $(patsubst %.o,%.c,$(OBJ1)) \
- arith.c $(HELPERS) builtins.def
+config-cppflags := -DBSD=1 -DSMALL -DJOBS=0 -DHAVE_CONFIG_H -DSHELL
+config-cppflags += -DGLOB_BROKEN -DFNMATCH_BROKEN -DIFS_BROKEN
-static-y := sh
+EXTRA_KLIBCCFLAGS := -I$(srctree)/$(src) -I$(objtree)/$(obj)
+EXTRA_KLIBCCFLAGS += -include $(srctree)/$(src)/config.h
+EXTRA_KLIBCCFLAGS += $(config-cppflags)
+
+HOST_EXTRACFLAGS := $(config-cppflags)
+
+init-o-files := alias.o arith_yylex.o cd.o error.o eval.o exec.o expand.o \
+ histedit.o input.o jobs.o mail.o main.o memalloc.o miscbltin.o \
+ mystring.o options.o parser.o redir.o show.o trap.o output.o \
+ bltin/printf.o system.o bltin/test.o var.o
+
+gen-o-files := builtins.o init.o nodes.o syntax.o
-sh-y := $(OBJS)
+sh-y := $(init-o-files) $(gen-o-files) arith.o
+
+hostprogs-y := mkinit mksyntax mknodes mksignames
+gen-h-files := arith.h builtins.h nodes.h syntax.h token.h
+
+static-y := sh
# The shared binary
shared-y := sh.shared
sh.shared-y := $(sh-y)
-hostprogs-y := $(HELPERS)
-
# For cleaning
-targets := sh sh.g sh.shared sh.shared.g $(CLEANFILES)
+targets := sh sh.g sh.shared sh.shared.g $(gen-o-files) $(gen-h-files)
-$(addprefix $(obj)/, $(OBJS)): $(addprefix $(obj)/, $(BUILT_SOURCES))
+# explicit dependency for all generated files
+$(addprefix $(obj)/, $(sh-y)): $(addprefix $(obj)/, $(gen-h-files))
# Generate token.h
quiet_cmd_mktokens = GEN $@
@@ -96,10 +72,9 @@ quiet_cmd_mknodes = GEN $@
$(obj)/nodes.c: $(obj)/mknodes $(src)/nodetypes $(src)/nodes.c.pat
$(call cmd,mknodes)
-quiet_cmd_mknodes_h = DUMMY $@
- cmd_mknodes_h = :
+# side effect..
$(obj)/nodes.h: $(obj)/nodes.c
- $(call cmd,mknodes_h)
+ $(Q):
quiet_cmd_mksyntax = GEN $@
cmd_mksyntax = cd $(obj) && ./mksyntax
@@ -114,34 +89,14 @@ # Prefer bison, but BSD yacc should work
YACC ?= bison
quiet_cmd_yacc = YACC $@
- cmd_yacc = $(YACC) -d -o $@ $<
+ cmd_yacc = $(YACC) -d -o $(@:.h=.c) $<
-$(obj)/%.c %(obj)/%.h: $(src)/%.y
+$(obj)/arith.h: $(src)/arith.y
$(call cmd,yacc)
-$(obj)/arith.c $(obj)/arith.h: $(src)/arith.y
+# side effect..
+$(obj)/arith.c: $(obj)/arith.h
+ $(Q):
# Targets to install
install-y := sh.shared
-
-# Dependencies on generated files. This really should be automated.
-$(obj)/arith_yylex.o: $(obj)/arith.h
-$(obj)/builtins.o: $(obj)/builtins.h
-$(obj)/cd.o: $(obj)/nodes.h
-$(obj)/eval.o: $(obj)/nodes.h $(obj)/syntax.h $(obj)/builtins.h
-$(obj)/exec.o: $(obj)/nodes.h $(obj)/builtins.h $(obj)/syntax.h
-$(obj)/expand.o: $(obj)/nodes.h $(obj)/syntax.h
-$(obj)/input.o: $(obj)/syntax.h
-$(obj)/jobs.o: $(obj)/nodes.h $(obj)/syntax.h
-$(obj)/mail.o: $(obj)/nodes.h
-$(obj)/main.o: $(obj)/nodes.h
-$(obj)/mystring.o: $(obj)/syntax.h
-$(obj)/nodes.o: $(obj)/nodes.h
-$(obj)/options.o: $(obj)/nodes.h
-$(obj)/output.o: $(obj)/syntax.h
-$(obj)/parser.o: $(obj)/nodes.h $(obj)/syntax.h $(obj)/builtins.h $(obj)/token.h
-$(obj)/redir.o: $(obj)/nodes.h
-$(obj)/show.o: $(obj)/nodes.h
-$(obj)/syntax.o: $(obj)/syntax.h
-$(obj)/trap.o: $(obj)/nodes.h $(obj)/syntax.h
-$(obj)/var.o: $(obj)/nodes.h $(obj)/syntax.h
More information about the klibc
mailing list