Teach kbuild to pull files from BK repository
PATCH 2/3 Teach kbuild to pull files from BK repository
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1505 -> 1.1506
# scripts/kconfig/lkc.h 1.5 -> 1.6
# Makefile 1.440 -> 1.441
# scripts/kconfig/zconf.l 1.7 -> 1.8
# scripts/kconfig/lex.zconf.c_shipped 1.7 -> 1.8
# scripts/kconfig/Makefile 1.11 -> 1.12
# (new) -> 1.1 scripts/depkconfig # (new) -> 1.1 scripts/kconfig/listkconfigs.c
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/12/04 [email protected] 1.1506
# Teach the kbuild system how to retrieve the Kconfig files from
# the repository. This involves modifying the kconfig lexer/parser # to give us a list of sourced Kconfig files so that we can tell # make about the dependencies. Then is just a matter of makeing sure # that make will extract those files before they are needed in the # build process. # -------------------------------------------- # diff -Nru a/Makefile b/Makefile --- a/Makefile Thu Dec 4 00:24:45 2003 +++ b/Makefile Thu Dec 4 00:24:45 2003 @@ -308,7 +308,7 @@ scripts/docproc scripts/split-include : scripts ;
.PHONY: scripts scripts/fixdep
-scripts:
+scripts: kbuild_files
$(Q)$(MAKE) $(build)=scripts
scripts/fixdep:
@@ -329,6 +329,7 @@
config-targets := 0
mixed-targets := 0 dot-config := 1 +config-type :=
ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
@@ -338,6 +339,7 @@
ifneq ($(filter config %config,$(MAKECMDGOALS)),)
config-targets := 1
+ config-type := $(filter config %config,$(MAKECMDGOALS))
ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
mixed-targets := 1
endif
@@ -357,9 +359,7 @@
# *config targets only - make sure prerequisites are updated, and descend
# in scripts/kconfig to make the *config target
-%config: scripts/fixdep FORCE
- $(Q)$(MAKE) $(build)=scripts/kconfig $@
-config : scripts/fixdep FORCE
+$(config-type) : scripts/fixdep FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
else
@@ -941,6 +941,10 @@
# Rules to automatically check files out of the repository during build # ===========================================================================
+# Don't need these if doing an out-of-tree build
+#
+ifeq ($(KBUILD_SRC),)
+
# Command to use to perform actual pull of a file from the repository GET = get
export GET
@@ -958,11 +962,35 @@
kbuild_base_files += scripts/Makefile.repo scripts/mkversion kbuild_base_files += scripts/getfiles scripts/mkcompile_h
-# This rule will ensure these files exist, or are pulled from the repository -.get_kbuild_files.d: $(kbuild_base_files)
+# These rules will ensure these files exist, or are pulled from the repository +.PHONY: kbuild_files
+kbuild_files: $(kbuild_base_files) ;
+
+.get_kbuild_files.d: kbuild_files
$(Q)touch .get_kbuild_files.d
-include .get_kbuild_files.d
+
+# These targets do not require the Kconfig files. Everything else does. +nokconfig_targets := help clean mrproper distclean
+
+scripts/kconfig/listkconfigs: scripts FORCE
+ $(Q)$(MAKE) $(build)=scripts/kconfig $@
+
+ifeq ($(filter $(nokconfig_targets),$(MAKECMDGOALS)),)
+
+quiet_cmd_kconfig_checkout_dep = GENDEP $< +cmd_kconfig_checkout_dep = $(srctree)/scripts/depkconfig $< $@ +
+.checkout_Kconfig.d: scripts/depkconfig +.checkout_Kconfig.d: scripts/kconfig/listkconfigs +.checkout_Kconfig.d: arch/$(ARCH)/Kconfig
+ $(call cmd,kconfig_checkout_dep)
+
+-include .checkout_Kconfig.d
+
+endif # filter on nokconfig_targtes
+endif # ifeq ($(KBUILD_SRC),)
include $(srctree)/scripts/Makefile.repo
scripts/depkconfig new file +58 -0
@@ -0,0 +1,58 @@ +#!/bin/bash +# +# Script to convert the output of listkconfig to a form make will understand. +# The output from this script is in the form of a Makefile fragment, and +# makes the output file depend on every Kconfig file seen. +# +# Copyright (C) 2003 David Dillow <[email protected]> +# +# Released under the GNU GPL, see COPYING for details +# + +usage() { + echo "usage: depkconfig <starting Kconfig> <output file>\n" 1>&2 + echo -e "\tconvert sourced Kconfig files from starting file into" 1>&2 + echo -e "\tmake dependency rules in output file" 1>&2 + exit 2 +} + +mark_precious() { + precious="$precious $1" +} + +add_kconfig() { + kconfigs="$kconfigs $1" +} + +[[ $# -eq 2 ]] || usage + +in=$1 +out=$2 + +if [[ ! -e $in ]]; then + echo "depkconfig: $in does not exist!" 1>&2 + exit 1 +fi + +kconfigs="" +precious="" + +mark_precious $in +add_kconfig $in + +for file in `scripts/kconfig/listkconfigs $in | grep ^KDEP | cut -f2- -d' '`; +do + mark_precious $file + add_kconfig $file +done + +cat /dev/null > $out +for file in $kconfigs; do + echo "$out: $file" >> $out +done + +[[ $precious ]] && echo -n ".PRECIOUS:" >> $out +for file in $precious; do + echo -n " $file" >> $out +done +echo >> $out
scripts/kconfig/Makefile +15 -10
@@ -56,20 +56,24 @@ # =========================================================================== # Shared Makefile for the various kconfig executables: -# conf: Used for defconfig, oldconfig and related targets -# mconf: Used for the mconfig target. -# Utilizes the lxdialog package -# qconf: Used for the xconfig target -# Based on QT which needs to be installed to compile it -# gconf: Used for the gconfig target -# Based on GTK which needs to be installed to compile it +# conf: Used for defconfig, oldconfig and related targets +# mconf: Used for the mconfig target. +# Utilizes the lxdialog package +# qconf: Used for the xconfig target +# Based on QT which needs to be installed to compile it +# gconf: Used for the gconfig target +# Based on GTK which needs to be installed to compile it +# listkconfigs: Used to generate a list of Kconfigs so that make will +# pull them from the repository for us +# # object files used by all kconfig flavours libkconfig-objs := zconf.tab.o -host-progs := conf mconf qconf gconf -conf-objs := conf.o libkconfig.so -mconf-objs := mconf.o libkconfig.so +host-progs := conf mconf qconf gconf listkconfigs +conf-objs := conf.o libkconfig.so +mconf-objs := mconf.o libkconfig.so +listkconfigs-objs := listkconfigs.o libkconfig.so ifeq ($(MAKECMDGOALS),xconfig) qconf-target := 1
@@ -102,6 +106,7 @@ HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` $(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h +$(obj)/listkconfigs.o: $(obj)/zconf.tab.h $(obj)/qconf.o: $(obj)/.tmp_qtcheck
scripts/kconfig/lex.zconf.c_shipped +107 -7
491 lines not on this page · raw message
scripts/kconfig/listkconfigs.c new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2003 David Dillow <[email protected]> +* Released under the terms of the GNU GPL, see COPYING for details +*/ +#include <stdio.h> +#include <stdlib.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +int main (int argc,char **argv) +{ +if (argc !=2 ) { +fprintf (stderr,"usage: %s inputfile\n" , argv[0 ]); +exit (2 ); + } + +/* tell the zconf parser to just print the files we source */ + zconf_print_sources =1 ; +conf_parse (argv[1 ]); +exit (0 ); +}
scripts/kconfig/lkc.h +2 -0
@@ -34,6 +34,8 @@int zconf_lineno (void );char *zconf_curname (void ); +extern int zconf_print_sources; +/* confdata.c */ extern const char conf_def_filename[];extern char conf_filename[];
scripts/kconfig/zconf.l +23 -6
@@ -34,6 +34,8 @@ static void zconf_endhelp(void); static struct buffer *zconf_endfile(void); +int zconf_print_sources; + void new_string(void) { text = malloc(START_STRSIZE);
@@ -301,16 +303,31 @@ void zconf_nextfile(const char *name) { - struct file *file = file_lookup(name); - struct buffer *buf = malloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); + FILE *nextfile; + struct file *file; + struct buffer *buf; + + if(zconf_print_sources) + printf("KDEP %s\n", name); + + nextfile = zconf_fopen(name); + if (!nextfile) { + /* If we're just here to find filenames, it's not fatal + * for a file to be missing... + */ + if(zconf_print_sources) + return; - current_buf->state = YY_CURRENT_BUFFER; - yyin = zconf_fopen(name); - if (!yyin) { printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); exit(1); } + + file = file_lookup(name); + buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + yyin = nextfile; yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); buf->parent = current_buf; current_buf = buf;