ADD: added project makefiles with menuconfig support

This commit is contained in:
Dominik Meyer 2014-02-08 21:44:12 +01:00
parent 5cbcbdd04f
commit faae844176
61 changed files with 23973 additions and 50 deletions

View File

@ -1,50 +1,17 @@
include .config
#location of Makefiles
MAKEFILES_PATH=/home/dmeyer/Programmieren/Makefiles/
#which FPGA are we synthesizing for ?
FPGA=xc5vlx110t-3-ff1136
#NR of the FPGA in jtag chain
DEVICE_NR=5
SD= NGC/
#which is the TOP Module of the project ?
TOP=SOC
UCF=UCF/ML505.ucf
#is this a partial reconfiguration project
RECONFIGURATION=0
#modelsim vcom Flags
FLAGS = -O0 -rangecheck -check_synthesis +acc=full
#xilinx license server
XILINX_LICENSE=2100@192.168.1.5
#path to Xilinx tools
XILINX_PATH=/opt/tools/Xilinx/14.1/ISE_DS/ISE/bin/lin64/
#modelsim license server
MODELSIM_LICENSE=1718@192.168.1.5
#path to modelsim tools
MODELSIM_PATH=/opt/tools/Modelsim/modeltech/linux_x86_64
-include .config
MAKEFILES_PATH=$(CURDIR)/Makefiles/
include Makefile.modules
include $(MAKEFILES_PATH)/Makefile
# additional parameters for xilinx tools
XILINX_XST=
XILINX_NGDBUILD=
XILINX_MAP=
XILINX_PAR=
XILINX_BITGEN=
ifeq ($(BOARD_TARGET), spartan3e)
UCF=UCF/spartan3e.ucf
endif
# xst file parameters
define XST_PARAMS
-opt_mode Speed
-opt_level 1
-power NO
-iuc NO
-netlist_hierarchy as_optimized
-rtlview Yes
@ -57,9 +24,6 @@ define XST_PARAMS
-case maintain
-slice_utilization_ratio 100
-bram_utilization_ratio 100
-dsp_utilization_ratio 100
-lc off
-reduce_control_sets off
-fsm_extract YES
-fsm_encoding Auto
-safe_implementation Yes
@ -72,7 +36,6 @@ define XST_PARAMS
-auto_bram_packing NO
-resource_sharing YES
-async_to_sync NO
-use_dsp48 auto
-iobuf YES
-keep_hierarchy NO
-max_fanout 100000
@ -83,8 +46,5 @@ define XST_PARAMS
endef
export XST_PARAMS
%/blockRAM.o: %/blockRAM.vhd
@export LM_LICENSE_FILE=$(MODELSIM_LICENSE);$(MODELSIM_PATH)/vcom -ignorevitalerrors -permissive -work work $< | grep -E 'Compiling|Error:|Warning:'
@touch $@
include $(MAKEFILES_PATH)/Makefile
test:
@echo $(BOARD_TARGET)

View File

@ -1,4 +1,11 @@
VHDL_PKG += src/cpupkg.vhd
VHDL_TB += src/TBRechner.vhd
VHDL_SRC += src/RegFile.vhd src/CPU.vhd src/MemInterface.vhd src/FetchDecode.vhd src/ALU.vhd src/RAM.vhd
VHDL_SRC += src/SOC.vhd src/ControlUnit.vhd src/MMIO_Uart.vhd src/clkDivider.vhd src/ClkEnable.vhd src/MemoryMapper.vhd
VHDL_SRC += src/ControlUnit.vhd src/MMIO_Uart.vhd src/clkDivider.vhd src/ClkEnable.vhd src/MemoryMapper.vhd
VHDL_SRC += src/SOC.vhd
ifeq ($(BOARD_TARGET), spartan3e)
VHDL_SRC += src/top_spartan3e.vhd
else
VHDL_SRC += src/top_generic.vhd
endif

94
Makefiles/Kconfig Normal file
View File

@ -0,0 +1,94 @@
#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.txt.
#
mainmenu "System configuration for Simple Processor Core"
comment "General project settings"
config EVAL_BOARD
bool "use evaluation board"
default y
config MAKEFILES_PATH
string
option env="MAKEFILES_PATH"
source "$MAKEFILES_PATH/Kconfig.boards"
config FPGA_TYPE
string "fpga type"
depends on !EVAL_BOARD
config IMPACT_TARGET
string "impact tool jtag chain target number"
depends on !EVAL_BOARD
config NGC_LOOKUP
string ".ngc files lookup directories"
default "./"
config XILINX_VERBOSE_OUTPUT
bool "verbose output for Xilinx tools"
menu "tool invokation parameters (flags)"
comment "Xilinx tools"
config XILINX_XST_FLAGS
string "xst flags"
default ""
config XILINX_NGDBUILD_FLAGS
string "ngdbuild flags"
default ""
config XILINX_MAP_FLAGS
string "map flags"
default ""
config XILINX_PAR_FLAGS
string "par flags"
default ""
config XILINX_BITGEN_FLAGS
string "bitgen flags"
default ""
endmenu
menu "General tool options"
comment "General System"
config SYSTEM_64
bool "Is System 64bit ?"
default y
comment "Xilinx tools"
config XILINX_INSTALL_DIR
string "Xilinx installation directory"
default "/opt/Xilinx"
config XILINX_VERSION
string "Xilinx version to use"
config XILINX_SERVER
string "Xilinx license server"
default "2100@192.168.1.5"
comment "Modelsim"
config MODELSIM_INSTALL_DIR
string "Modelsim installation directory"
default "/opt/modeltech/linux"
config MODELSIM_SERVER
string "Modelsim license server"
default "1718@192.168.1.5"
endmenu
# the followin will call the project specific Kconfig file
source Kconfig

16
Makefiles/Kconfig.boards Normal file
View File

@ -0,0 +1,16 @@
choice
prompt "board type"
default BOARD_ML505
depends on EVAL_BOARD
config BOARD_ML505
bool "ML505"
config BOARD_SPARTAN3E500
bool "Spartan3e(500)"
endchoice

128
Makefiles/Makefile Normal file
View File

@ -0,0 +1,128 @@
#main makefile for the Simple Processor Core Makefile scripts
#written 2014 by Dominik Meyer <dmeyer@federationhq.de>
#License: GPLv2
#
-include .config
include $(MAKEFILES_PATH)/Makefile.boards
export MAKEFILES_PATH
# impact device number for jtag chain
ifndef DEVICE_NR
DEVICE_NR=$(subst ", , $(CONFIG_IMPACT_TARGET))
#")
endif
TOP=top
ifndef UCF
UCF=$(subst ", , $(CONFIG_UCF_NAME))
endif
ifndef SD
SD=$(subst ", , $(CONFIG_NGC_LOOKUP))
endif
ifndef XILINX_XST
XILINX_XST=$(subst ", ,$(CONFIG_XILINX_XST_FLAGS))
#")
endif
ifndef XILINX_NGDBUILD
XILINX_NGDBUILD=$(subst ", , $(XILINX_NGDBUILD_FLAGS))
#")
endif
ifndef XILINX_MAP
XILINX_MAP=$(subst ", , $(CONFIG_XILINX_MAP_FLAGS))
#")
endif
ifndef XILINX_PAR
XILINX_PAR=$(subst ", ,$(CONFIG_XILINX_PAR_FLAGS))
#")
endif
ifndef XILINX_BITGEN
XILINX_BITGEN=$(subst ", ,$(CONFIG_XILINX_BITGEN_FLAGS))
#")
endif
ifndef FLAGS
FLAGS=$(subst ", ,$(CONFIG_MODELSIM_VCOM_FLAGS))
#")
endif
XILINX_LICENSE=$(CONFIG_XILINX_SERVER)
#path to Xilinx tools
XILINX_INSTALL_DIR=$(subst ",,$(CONFIG_XILINX_INSTALL_DIR))
XILINX_VERSION=$(subst ",,$(CONFIG_XILINX_VERSION))
ifndef XILINX_PATH
ifeq ($(CONFIG_SYSTEM_64),y)
XILINX_PATH=$(XILINX_INSTALL_DIR)/$(XILINX_VERSION)/ISE_DS/ISE/bin/lin64/
else
XILINX_PATH=$(XILINX_INSTALL_DIR)/$(XILINX_VERSION)/ISE_DS/ISE/bin/lin/
endif
endif
#modelsim license server
MODELSIM_LICENSE=$(CONFIG_MODELSIM_SERVER)
#path to modelsim tools
ifndef MODELSIM_PATH
MODELSIM_PATH=$(CONFIG_MODELSIM_INSTALL_DIR)
endif
ifndef VERBOSE_OUTPUT
ifdef CONFIG_XILINX_VERBOSE_OUTPUT
VERBOSE_OUTPUT=1
else
VERBOSE_OUTPUT=0
endif
endif
.PHONY: clean all real_clean
all:
real_clean:
git clean -x -f
clean: kconfig_clean
-@rm -rf Make.sources ${CLEAN_FILES} $(OBJ)
Make.sources: Makefile.files Makefile.modules
@clear
@echo "****************************************************************************************"
@echo "**** XILINX Synthesis, Map, Place, Route and Modelsim Makefile Version " $(VERSION)
@echo "****"
@echo "**** written 2012 by Dominik Meyer <dmeyer@hsu-hh.de>"
@echo "**** Marcel Eckert <eckert@hsu-hh.de>"
@echo "****"
@echo "**** Creating Make.sources ****"
@make -s -f $(MAKEFILES_PATH)Makefile.gensources TOPDIR=$(CURDIR) MAKEFILES_PATH=$(MAKEFILES_PATH) BOARD_TARGET=$(BOARD_TARGET) FPGA_FAMILY=$(FPGA_FAMILY) Make.sources
@echo "**** Make.sources created"
impact.script:
@echo "setMode -bs" > $@
@echo "setCable -p auto" >> $@
@echo "identify" >> $@
@$(foreach d,$(DEVICE_NR),echo "AssignFile -p ${d} -file flash.bit" >> $@ ;)
@$(foreach d,$(DEVICE_NR),echo "program -p ${d}" >> $@ ;)
@echo "quit" >> $@
program: impact.script
echo "**** Programming FPGA ****"
[ -n "$(BIT)" ] || ( echo "**** Please give Bitfile on commandline with BIT=<FILE>" && exit 1)
cp $(BIT) flash.bit
$(XILINX_PATH)/impact -batch impact.script 1>/dev/null
rm impact.script
include $(MAKEFILES_PATH)/Makefile.configure
include $(MAKEFILES_PATH)/Makefile.synth
include $(MAKEFILES_PATH)/Makefile.Modelsim
include $(MAKEFILES_PATH)/Makefile.isim

View File

@ -0,0 +1,28 @@
OBJ += $(foreach i,$(VHDL_PKG),$(patsubst %.vhd,%.o,$i))
OBJ += $(foreach i,$(VHDL_SRC),$(patsubst %.vhd,%.o,$i))
OBJ += $(foreach i,$(VHDL_TB),$(patsubst %.vhd,%.o,$i))
OBJ_DIRS := $(dir $(OBJ))
CLEAN_FILES+=$(OBJ) work
.PHONY: modelsim modelsim_clean
simulate:
export LM_LICENSE_FILE=$(MODELSIM_LICENSE);$(MODELSIM_PATH)/vsim -novopt $(TB)
work:
@export LM_LICENSE_FILE=$(MODELSIM_LICENSE);$(MODELSIM_PATH)/vlib work
modelsim_compile: work $(OBJ)
modelsim_clean:
@echo "**** Cleaning up Modelsim Files"
-@rm -rf work 2>/dev/null
-@rm $(OBJ) 2>/dev/null
%.o : %.vhd
@export LM_LICENSE_FILE=$(MODELSIM_LICENSE);$(MODELSIM_PATH)/vcom $(FLAGS) -work work $< | tee m.log | grep -E 'Compiling|Error:|Warning:'
@grep -q Error m.log; if [ "$$?" -eq "1" ]; then touch $@; fi; rm m.log

58
Makefiles/Makefile.boards Normal file
View File

@ -0,0 +1,58 @@
ifdef CONFIG_EVAL_BOARD
# Board Name Mapping
BOARDTYPE-$(CONFIG_BOARD_NEXYS3) := nexys3
BOARDTYPE-$(CONFIG_BOARD_ML505) := ml505
BOARDTYPE-$(CONFIG_BOARD_ML605) := ml605
BOARDTYPE-$(CONFIG_BOARD_VC707) := vc707
BOARDTYPE-$(CONFIG_BOARD_SPARTAN3E500) := spartan3e
BOARDTYPE-$(CONFIG_BOARD_SUZAKU_V) := suzakuv
BOARDTYPE-$(CONFIG_BOARD_SUZAKU_S) := suzakus
BOARDTYPE-$(CONFIG_BOARD_SUZAKU_S1200) := suzakus1200
BOARDTYPE-$(BOARD_GR_XC3S_1500) := grxc3s1500
BOARD_TARGET = $(BOARDTYPE-y)
# FPGA type mapping
FPGATYPE-$(CONFIG_BOARD_NEXYS3) := xc6slx16-csg324
FPGATYPE-$(CONFIG_BOARD_ML505) := xc5vlx110t-3ff1136
FPGATYPE-$(CONFIG_BOARD_ML605) := XC6VLX240T-1ff1156
FPGATYPE-$(CONFIG_BOARD_VC707) := xc7vx485T-2-ffg1761
FPGATYPE-$(CONFIG_BOARD_SPARTAN3E500) := xc3s500e-4fg320
FPGATYPE-$(CONFIG_BOARD_SUZAKU_V) := xc4vfx12-10sf363
FPGATYPE-$(CONFIG_BOARD_SUZAKU_S) := xc3s400-4ft256
FPGATYPE-$(CONFIG_BOARD_SUZAKU_S1200) := xc3s1200E-4fg320
FPGATYPE-$(CONFIG_BOARD_GR_XC3S_1500) := xc3s1500-4fg456
FPGA = $(FPGATYPE-y)
# FPGA family mapping
FPGAFAMILY-$(CONFIG_BOARD_NEXYS3) := spartan6
FPGAFAMILY-$(CONFIG_BOARD_ML505) := virtex5
FPGAFAMILY-$(CONFIG_BOARD_ML605) := virtex6
FPGAFAMILY-$(CONFIG_BOARD_VC707) := virtex7
FPGAFAMILY-$(CONFIG_BOARD_SPARTAN3E500) := spartan3e
FPGAFAMILY-$(CONFIG_BOARD_SUZAKU_V) := virtex4
FPGAFAMILY-$(CONFIG_BOARD_SUZAKU_S) := spartan3
FPGAFAMILY-$(CONFIG_BOARD_SUZAKU_S1200) := spartan3e
FPGAFAMILY-$(CONFIG_BOARD_GR_XC3S_1500) := spartan3
FPGA_FAMILY = $(FPGAFAMILY-y)
# Impact target device id
IMPACT_TARGET-$(CONFIG_BOARD_NEXYS3) := 1
IMPACT_TARGET-$(CONFIG_BOARD_ML505) := 5
IMPACT_TARGET-$(CONFIG_BOARD_ML605) := 2
IMPACT_TARGET-$(CONFIG_BOARD_VC707) := 1
IMPACT_TARGET-$(CONFIG_BOARD_SPARTAN3E500):= 1
IMPACT_TARGET-$(CONFIG_BOARD_SUZAKU_V) := 1
IMPACT_TARGET-$(CONFIG_BOARD_SUZAKU_S) := 1
IMPACT_TARGET-$(CONFIG_BOARD_SUZAKU_S1200) := 1
IMPACT_TARGET-$(CONFIG_BOARD_GR_XC3S_1500) := 3
DEVICE_NR = $(IMPACT_TARGET-y)
endif # CONFIG_EVAL_BOARD

View File

@ -0,0 +1,41 @@
#
# Makefile for using kernel config scripts for xilinx configuration
#
# written by Marcel Eckert <marcel.eckert@hsu-hh.de>
#
# License: GPLv2
#
KCONFIG_SUBDIR := kconfig/
.config:
$(MAKEFILES_PATH)$(KCONFIG_SUBDIR)conf $(MAKEFILES_PATH)Kconfig
.PHONY: kconfig_clean
kconfig_clean:
$(MAKE) -i -s --directory=$(MAKEFILES_PATH)$(KCONFIG_SUBDIR) clean
.PHONY: config
config: $(MAKEFILES_PATH)$(KCONFIG_SUBDIR)conf Kconfig
$(MAKEFILES_PATH)$(KCONFIG_SUBDIR)conf $(MAKEFILES_PATH)Kconfig
.PHONY: menuconfig
menuconfig: $(MAKEFILES_PATH)$(KCONFIG_SUBDIR)mconf Kconfig
$(MAKEFILES_PATH)$(KCONFIG_SUBDIR)mconf $(MAKEFILES_PATH)Kconfig
## recursive make calls to kconfig subdir for building the executables
$(MAKEFILES_PATH)$(KCONFIG_SUBDIR)conf:
$(MAKE) --directory=$(MAKEFILES_PATH)$(KCONFIG_SUBDIR) $(@F)
$(MAKEFILES_PATH)$(KCONFIG_SUBDIR)mconf:
$(MAKE) --directory=$(MAKEFILES_PATH)$(KCONFIG_SUBDIR) $(@F)
# rule to create an empty Kconfig file in project directory if none exist
Kconfig:
@echo "**** Creating empty Kconfig file for project"
@touch Kconfig

View File

@ -0,0 +1,35 @@
# include a .config file if existing
-include .config
#check for includes
MF=${shell if [ -e Makefile.files ]; then echo 1; else echo 0; fi}
MM=${shell if [ -e Makefile.modules ]; then echo 1; else echo 0; fi}
MC=${shell if [ -e Makefile.PR ]; then echo 1; else echo 0; fi}
MODULE=$(CURDIR)
.PHONY : clean
ifeq ($(MF),1)
include Makefile.files
endif
ifeq ($(MM),1)
include Makefile.modules
endif
Make.sources:
@echo "**** Creating Make.sources for $(CURDIR)"
$(foreach f,$(Modules), (cd $f; make -f $(MAKEFILES_PATH)/Makefile.gensources MAKEFILES_PATH=$(MAKEFILES_PATH) $(SUBMAKE) SUBMAKE=$(SUBMAKE) TOPDIR=${TOPDIR} BOARD_TARGET=$(BOARD_TARGET) FPGA_FAMILY=$(FPGA_FAMILY) );)
$(foreach f,$(Modules), cat $f/Make.sources >> $@;)
$(foreach f,$(VHDL_SRC), echo VHDL_SRC +=$(MODULE)/$f >> $@;)
$(foreach f,$(VERILOG_SRC), echo $f | grep -c '^/' >/dev/null; if [ $$? -eq 0 ]; then echo VERILOG_SRC +=$f >> $@; else echo VERILOG_SRC +=$(MODULE)/$f >> $@; fi;)
$(foreach f,$(VHDL_PKG), echo VHDL_PKG +=$(MODULE)/$f >> $@;)
$(foreach f,$(VHDL_TB), echo VHDL_TB +=$(MODULE)/$f >> $@;)
clean:
@$(foreach f,$(Modules), (cd $f; make -f $(MAKEFILES_PATH)/Makefile.gensources clean);)
@$(foreach f,$(RM_TUPEL), (src=`echo $f | sed 's/(//' | sed 's/)//' | awk -F',' '{print $$4}'`; cd $$src; make -f $(MAKEFILES_PATH)/Makefile.gensources clean );)
-@rm Make.sources

17
Makefiles/Makefile.isim Normal file
View File

@ -0,0 +1,17 @@
CLEAN_FILES+=isim.prj
CLEAN_FILES+=isim.exe
CLEAN_FILES+=fuse.xmsgs fuseRelaunch.cmd isim
isim.prj: $(VHDL_SRC) $(VHDL_PKG) $(VERILOG_SRC)
@sleep 1
@echo "**** Creating Xilinx Project file $@****"
@if [ -e $@ ]; then rm $@; fi
@$(foreach f,$(VHDL_PKG),echo "vhdl work $f" >> $@ ;)
@$(foreach f,$(VHDL_TB),echo "vhdl work $f" >> $@ ;)
@$(foreach f,$(VHDL_SRC),echo "vhdl work $f" >> $@ ;)
@$(foreach f,$(VERILOG_SRC),echo "verilog work $f" >> $@ ;)
isim.exe: isim.prj
@export XILINXD_LICENSE_FILE=$(XILINX_LICENSE);$(XILINX_PATH)/fuse -prj isim.prj -o isim.exe $(TB)

46
Makefiles/Makefile.synth Normal file
View File

@ -0,0 +1,46 @@
include Make.sources
CLEAN_FILES+=*.ucf *.ngc *.prj *.xst xst.log *.lso *.xrpt *.srp _xmsgs xst __ngo *.ngd *.bld xlnx_auto*
CLEAN_FILES+=.config.old _impact* *.log *.bit *.bgn *.drc *.ngr *.pad *.par *.pcf *.ptwx *.unroutes
CLEAN_FILES+=*.xpi *.map *.mrp *.ngm *.csv *.txt *.xml *.xwbt *.html
%.prj: $(VHDL_SRC) $(VHDL_PKG) $(VERILOG_SRC)
@sleep 1
@echo "**** Creating Xilinx Project file $@****"
@if [ -e $@ ]; then rm $@; fi
@$(foreach f,$(VHDL_PKG),echo "vhdl work $f" >> $@ ;)
@$(foreach f,$(VHDL_SRC),echo "vhdl work $f" >> $@ ;)
@$(foreach f,$(VERILOG_SRC),echo "verilog work $f" >> $@ ;)
%.xst: %.prj
@echo "**** Creating XST file ($@) ****"
@echo run > $@
@echo -ifn $(subst .xst,,$(@F)).prj >>$@
@echo -ifmt mixed >>$@
@echo -ofn $(subst .xst,,$(@F)) >>$@
@echo -ofmt NGC >>$@
@echo -p ${FPGA} >>$@
@echo -top ${TOP} >>$@
@echo "$$XST_PARAMS" >>$@
%.ngc: %.xst %.prj
@echo "**** Running XST ($@)****"
@export XILINXD_LICENSE_FILE=$(XILINX_LICENSE);cd $(dir $<); $(XILINX_PATH)/xst -ifn $(<F) $(XILINX_XST) >xst.log;if [ $$? -ne 0 ]; then grep ERROR xst.log; exit 1; else grep "Minimum period" xst.log; fi
%.ngd: %.ngc $(UCF)
@echo "**** Running NGDBUILD ****"
@export XILINXD_LICENSE_FILE=$(XILINX_LICENSE);$(XILINX_PATH)/ngdbuild $(XILINX_NGDBUILD) -aul -sd ${SD} -dd __ngo -uc $(UCF) -p ${FPGA} $< $@ > ngdbuild.log
%.bgn %.bit %.drc: %.ncd %_map.ncd
@echo "**** Creating Bitfile $@****"
@export XILINXD_LICENSE_FILE=$(XILINX_LICENSE); $(XILINX_PATH)/bitgen $(XILINX_BITGEN) -w $< >bitgen.log
%.ncd %.pad %_pad.csv %_pad.txt %.par %.xpi: %_map.ncd %.pcf
@echo "**** Place components and Routing Signals ****"
@export XILINXD_LICENSE_FILE=$(XILINX_LICENSE); $(XILINX_PATH)/par $(XILINX_PAR) -w $< $@ $*.pcf > place.log
%_map.mrp %_map.ncd %_map.ngm %.pcf: %.ngd
@echo "**** Mapping components ****"
@export XILINXD_LICENSE_FILE=$(XILINX_LICENSE);$(XILINX_PATH)/map $(XILINX_MAP) -w -p ${FPGA} -pr b -c 100 -o $*_map.ncd $< $*.pcf >map.log

View File

@ -0,0 +1 @@
cmd_scripts/kconfig/conf := gcc -o scripts/kconfig/conf scripts/kconfig/conf.o scripts/kconfig/zconf.tab.o

View File

@ -0,0 +1,69 @@
cmd_scripts/kconfig/conf.o := gcc -Wp,-MD,scripts/kconfig/.conf.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -DCURSES_LOC="<ncurses.h>" -DLOCALE -c -o scripts/kconfig/conf.o scripts/kconfig/conf.c
source_scripts/kconfig/conf.o := scripts/kconfig/conf.c
deps_scripts/kconfig/conf.o := \
$(wildcard include/config/.h) \
$(wildcard include/config/allconfig.h) \
$(wildcard include/config/nosilentupdate.h) \
/usr/include/locale.h \
/usr/include/features.h \
/usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h \
/usr/include/i386-linux-gnu/bits/locale.h \
/usr/include/xlocale.h \
/usr/include/ctype.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h \
/usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/stdio.h \
/usr/include/libio.h \
/usr/include/_G_config.h \
/usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h \
/usr/include/stdlib.h \
/usr/include/i386-linux-gnu/bits/waitflags.h \
/usr/include/i386-linux-gnu/bits/waitstatus.h \
/usr/include/i386-linux-gnu/sys/types.h \
/usr/include/time.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/alloca.h \
/usr/include/i386-linux-gnu/bits/stdlib.h \
/usr/include/string.h \
/usr/include/i386-linux-gnu/bits/string.h \
/usr/include/i386-linux-gnu/bits/string2.h \
/usr/include/i386-linux-gnu/bits/string3.h \
/usr/include/unistd.h \
/usr/include/i386-linux-gnu/bits/posix_opt.h \
/usr/include/i386-linux-gnu/bits/environments.h \
/usr/include/i386-linux-gnu/bits/confname.h \
/usr/include/getopt.h \
/usr/include/i386-linux-gnu/bits/unistd.h \
/usr/include/i386-linux-gnu/sys/stat.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/sys/time.h \
scripts/kconfig/lkc.h \
$(wildcard include/config/list.h) \
scripts/kconfig/expr.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdbool.h \
/usr/include/libintl.h \
scripts/kconfig/lkc_proto.h \
scripts/kconfig/conf.o: $(deps_scripts/kconfig/conf.o)
$(deps_scripts/kconfig/conf.o):

23
Makefiles/kconfig/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
#
# Generated files
#
config*
*.lex.c
*.tab.c
*.tab.h
zconf.hash.c
*.moc
lkc_defs.h
gconf.glade.h
*.pot
*.mo
#
# configuration programs
#
conf
mconf
nconf
qconf
gconf
kxgettext

View File

@ -0,0 +1,98 @@
cmd_scripts/kconfig/zconf.tab.o := gcc -Wp,-MD,scripts/kconfig/.zconf.tab.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -DCURSES_LOC="<ncurses.h>" -DLOCALE -Iscripts/kconfig -c -o scripts/kconfig/zconf.tab.o scripts/kconfig/zconf.tab.c
source_scripts/kconfig/zconf.tab.o := scripts/kconfig/zconf.tab.c
deps_scripts/kconfig/zconf.tab.o := \
/usr/include/ctype.h \
/usr/include/features.h \
/usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h \
/usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/xlocale.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/stdio.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h \
/usr/include/libio.h \
/usr/include/_G_config.h \
/usr/include/wchar.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h \
/usr/include/stdlib.h \
/usr/include/i386-linux-gnu/bits/waitflags.h \
/usr/include/i386-linux-gnu/bits/waitstatus.h \
/usr/include/i386-linux-gnu/sys/types.h \
/usr/include/time.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/alloca.h \
/usr/include/i386-linux-gnu/bits/stdlib.h \
/usr/include/string.h \
/usr/include/i386-linux-gnu/bits/string.h \
/usr/include/i386-linux-gnu/bits/string2.h \
/usr/include/i386-linux-gnu/bits/string3.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdbool.h \
scripts/kconfig/lkc.h \
$(wildcard include/config/.h) \
$(wildcard include/config/list.h) \
scripts/kconfig/expr.h \
/usr/include/libintl.h \
/usr/include/locale.h \
/usr/include/i386-linux-gnu/bits/locale.h \
scripts/kconfig/lkc_proto.h \
scripts/kconfig/zconf.hash.c \
scripts/kconfig/zconf.lex.c \
/usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h \
/usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h \
/usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed/limits.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed/syslimits.h \
/usr/include/limits.h \
/usr/include/i386-linux-gnu/bits/posix1_lim.h \
/usr/include/i386-linux-gnu/bits/local_lim.h \
/usr/include/linux/limits.h \
/usr/include/i386-linux-gnu/bits/posix2_lim.h \
/usr/include/unistd.h \
/usr/include/i386-linux-gnu/bits/posix_opt.h \
/usr/include/i386-linux-gnu/bits/environments.h \
/usr/include/i386-linux-gnu/bits/confname.h \
/usr/include/getopt.h \
/usr/include/i386-linux-gnu/bits/unistd.h \
scripts/kconfig/util.c \
scripts/kconfig/confdata.c \
$(wildcard include/config/config.h) \
$(wildcard include/config/autoconfig.h) \
$(wildcard include/config/overwriteconfig.h) \
$(wildcard include/config/autoheader.h) \
$(wildcard include/config/tristate.h) \
/usr/include/i386-linux-gnu/sys/stat.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h \
scripts/kconfig/expr.c \
scripts/kconfig/symbol.c \
/usr/include/regex.h \
/usr/include/i386-linux-gnu/gnu/option-groups.h \
/usr/include/i386-linux-gnu/sys/utsname.h \
/usr/include/i386-linux-gnu/bits/utsname.h \
scripts/kconfig/menu.c \
scripts/kconfig/zconf.tab.o: $(deps_scripts/kconfig/zconf.tab.o)
$(deps_scripts/kconfig/zconf.tab.o):

View File

@ -0,0 +1,33 @@
lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o $(lxdialog)
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o
qconf-cxxobjs := qconf.o
qconf-objs := zconf.tab.o
gconf-objs := gconf.o zconf.tab.o
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
clean-files += mconf qconf gconf nconf
clean-files += config.pot linux.pot
HOSTCC := gcc
.PHONY: clean
clean:
-rm -r *.o
-rm conf mconf nconf qconf gconf
mconf: $(mconf-objs)
$(HOSTCC) $? -o $@ -lncurses
conf: $(conf-objs)
$(HOSTCC) $? -o $@
%.o: %.c
$(HOSTCC) -c $? -o $@

View File

@ -0,0 +1,308 @@
# ===========================================================================
# Kernel configuration targets
# These targets are used from top-level makefile
PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
localmodconfig localyesconfig
ifdef KBUILD_KCONFIG
Kconfig := $(KBUILD_KCONFIG)
else
Kconfig := Kconfig
endif
xconfig: $(obj)/qconf
$< $(Kconfig)
gconfig: $(obj)/gconf
$< $(Kconfig)
menuconfig: $(obj)/mconf
$< $(Kconfig)
config: $(obj)/conf
$< --oldaskconfig $(Kconfig)
nconfig: $(obj)/nconf
$< $(Kconfig)
oldconfig: $(obj)/conf
$< --$@ $(Kconfig)
silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/generated
$< --$@ $(Kconfig)
localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
$(Q)mkdir -p include/generated
$(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
$(Q)if [ -f .config ]; then \
cmp -s .tmp.config .config || \
(mv -f .config .config.old.1; \
mv -f .tmp.config .config; \
$(obj)/conf --silentoldconfig $(Kconfig); \
mv -f .config.old.1 .config.old) \
else \
mv -f .tmp.config .config; \
$(obj)/conf --silentoldconfig $(Kconfig); \
fi
$(Q)rm -f .tmp.config
# Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
# The symlink is used to repair a deficiency in arch/um
update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
$(Q)echo " GEN config"
$(Q)xgettext --default-domain=linux \
--add-comments --keyword=_ --keyword=N_ \
--from-code=UTF-8 \
--files-from=$(srctree)/scripts/kconfig/POTFILES.in \
--directory=$(srctree) --directory=$(objtree) \
--output $(obj)/config.pot
$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
$(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
$(srctree)/arch/*/um/Kconfig`; \
do \
echo " GEN $$i"; \
$(obj)/kxgettext $$i \
>> $(obj)/config.pot; \
done )
$(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
--output $(obj)/linux.pot
$(Q)rm -f $(obj)/config.pot
PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf
$< --$@ $(Kconfig)
PHONY += listnewconfig oldnoconfig savedefconfig defconfig
listnewconfig oldnoconfig: $(obj)/conf
$< --$@ $(Kconfig)
savedefconfig: $(obj)/conf
$< --$@=defconfig $(Kconfig)
defconfig: $(obj)/conf
ifeq ($(KBUILD_DEFCONFIG),)
$< --defconfig $(Kconfig)
else
@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif
%_defconfig: $(obj)/conf
$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
# Help text used by make help
help:
@echo ' config - Update current config utilising a line-oriented program'
@echo ' nconfig - Update current config utilising a ncurses menu based program'
@echo ' menuconfig - Update current config utilising a menu based program'
@echo ' xconfig - Update current config utilising a QT based front-end'
@echo ' gconfig - Update current config utilising a GTK based front-end'
@echo ' oldconfig - Update current config utilising a provided .config as base'
@echo ' localmodconfig - Update current config disabling modules not loaded'
@echo ' localyesconfig - Update current config converting local mods to core'
@echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
@echo ' defconfig - New config with default from ARCH supplied defconfig'
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
@echo ' allnoconfig - New config where all options are answered with no'
@echo ' allyesconfig - New config where all options are accepted with yes'
@echo ' allmodconfig - New config selecting modules when possible'
@echo ' alldefconfig - New config with all symbols set to default'
@echo ' randconfig - New config with random answer to all options'
@echo ' listnewconfig - List new options'
@echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)'
# lxdialog stuff
check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
-DLOCALE
# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
# nconf: Used for the nconfig target.
# Utilizes ncurses
# mconf: Used for the menuconfig 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
# object files used by all kconfig flavours
lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o $(lxdialog)
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o
qconf-cxxobjs := qconf.o
qconf-objs := zconf.tab.o
gconf-objs := gconf.o zconf.tab.o
hostprogs-y := conf
ifeq ($(MAKECMDGOALS),nconfig)
hostprogs-y += nconf
endif
ifeq ($(MAKECMDGOALS),menuconfig)
hostprogs-y += mconf
endif
ifeq ($(MAKECMDGOALS),update-po-config)
hostprogs-y += kxgettext
endif
ifeq ($(MAKECMDGOALS),xconfig)
qconf-target := 1
endif
ifeq ($(MAKECMDGOALS),gconfig)
gconf-target := 1
endif
ifeq ($(qconf-target),1)
hostprogs-y += qconf
endif
ifeq ($(gconf-target),1)
hostprogs-y += gconf
endif
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
clean-files += mconf qconf gconf nconf
clean-files += config.pot linux.pot
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
PHONY += $(obj)/dochecklxdialog
$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
always := dochecklxdialog
# Add environment specific flags
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
# generated files seem to need this to find local include files
HOSTCFLAGS_zconf.lex.o := -I$(src)
HOSTCFLAGS_zconf.tab.o := -I$(src)
LEX_PREFIX_zconf := zconf
YACC_PREFIX_zconf := zconf
HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
-Wno-missing-prototypes
HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses
$(obj)/qconf.o: $(obj)/.tmp_qtcheck
ifeq ($(qconf-target),1)
$(obj)/.tmp_qtcheck: $(src)/Makefile
-include $(obj)/.tmp_qtcheck
# QT needs some extra effort...
$(obj)/.tmp_qtcheck:
@set -e; echo " CHECK qt"; dir=""; pkg=""; \
if ! pkg-config --exists QtCore 2> /dev/null; then \
echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
pkg-config --exists qt 2> /dev/null && pkg=qt; \
pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
if [ -n "$$pkg" ]; then \
cflags="\$$(shell pkg-config $$pkg --cflags)"; \
libs="\$$(shell pkg-config $$pkg --libs)"; \
moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
dir="$$(pkg-config $$pkg --variable=prefix)"; \
else \
for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
done; \
if [ -z "$$dir" ]; then \
echo "*"; \
echo "* Unable to find any QT installation. Please make sure that"; \
echo "* the QT4 or QT3 development package is correctly installed and"; \
echo "* either qmake can be found or install pkg-config or set"; \
echo "* the QTDIR environment variable to the correct location."; \
echo "*"; \
false; \
fi; \
libpath=$$dir/lib; lib=qt; osdir=""; \
$(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
test -f $$libpath/libqt-mt.so && lib=qt-mt; \
cflags="-I$$dir/include"; \
libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
moc="$$dir/bin/moc"; \
fi; \
if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
echo "*"; \
echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
echo "*"; \
moc="/usr/bin/moc"; \
fi; \
else \
cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \
moc="$$binpath/bin/moc"; \
fi; \
echo "KC_QT_CFLAGS=$$cflags" > $@; \
echo "KC_QT_LIBS=$$libs" >> $@; \
echo "KC_QT_MOC=$$moc" >> $@
endif
$(obj)/gconf.o: $(obj)/.tmp_gtkcheck
ifeq ($(gconf-target),1)
-include $(obj)/.tmp_gtkcheck
# GTK needs some extra effort, too...
$(obj)/.tmp_gtkcheck:
@if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
touch $@; \
else \
echo "*"; \
echo "* GTK+ is present but version >= 2.0.0 is required."; \
echo "*"; \
false; \
fi \
else \
echo "*"; \
echo "* Unable to find the GTK+ installation. Please make sure that"; \
echo "* the GTK+ 2.0 development package is correctly installed..."; \
echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
echo "*"; \
false; \
fi
endif
$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
$(obj)/qconf.o: $(obj)/qconf.moc
$(obj)/%.moc: $(src)/%.h
$(KC_QT_MOC) -i $< -o $@
# Extract gconf menu items for I18N support
$(obj)/gconf.glade.h: $(obj)/gconf.glade
$(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
$(obj)/gconf.glade

View File

@ -0,0 +1,12 @@
scripts/kconfig/lxdialog/checklist.c
scripts/kconfig/lxdialog/inputbox.c
scripts/kconfig/lxdialog/menubox.c
scripts/kconfig/lxdialog/textbox.c
scripts/kconfig/lxdialog/util.c
scripts/kconfig/lxdialog/yesno.c
scripts/kconfig/mconf.c
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
scripts/kconfig/gconf.c
scripts/kconfig/gconf.glade.h
scripts/kconfig/qconf.cc

14
Makefiles/kconfig/check.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
# Needed for systems without gettext
$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
#include <libintl.h>
int main()
{
gettext("");
return 0;
}
EOF
if [ ! "$?" -eq "0" ]; then
echo -DKBUILD_NO_NLS;
fi

684
Makefiles/kconfig/conf.c Normal file
View File

@ -0,0 +1,684 @@
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#include <locale.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "lkc.h"
static void conf(struct menu *menu);
static void check_conf(struct menu *menu);
static void xfgets(char *str, int size, FILE *in);
enum input_mode {
oldaskconfig,
silentoldconfig,
oldconfig,
allnoconfig,
allyesconfig,
allmodconfig,
alldefconfig,
randconfig,
defconfig,
savedefconfig,
listnewconfig,
oldnoconfig,
} input_mode = oldaskconfig;
static int indent = 1;
static int valid_stdin = 1;
static int sync_kconfig;
static int conf_cnt;
static char line[128];
static struct menu *rootEntry;
static void print_help(struct menu *menu)
{
struct gstr help = str_new();
menu_get_ext_help(menu, &help);
printf("\n%s\n", str_get(&help));
str_free(&help);
}
static void strip(char *str)
{
char *p = str;
int l;
while ((isspace(*p)))
p++;
l = strlen(p);
if (p != str)
memmove(str, p, l + 1);
if (!l)
return;
p = str + l - 1;
while ((isspace(*p)))
*p-- = 0;
}
static void check_stdin(void)
{
if (!valid_stdin) {
printf(_("aborted!\n\n"));
printf(_("Console input/output is redirected. "));
printf(_("Run 'make oldconfig' to update configuration.\n\n"));
exit(1);
}
}
static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
if (!sym_has_value(sym))
printf(_("(NEW) "));
line[0] = '\n';
line[1] = 0;
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return 0;
}
switch (input_mode) {
case oldconfig:
case silentoldconfig:
if (sym_has_value(sym)) {
printf("%s\n", def);
return 0;
}
check_stdin();
/* fall through */
case oldaskconfig:
fflush(stdout);
xfgets(line, 128, stdin);
return 1;
default:
break;
}
switch (type) {
case S_INT:
case S_HEX:
case S_STRING:
printf("%s\n", def);
return 1;
default:
;
}
printf("%s", line);
return 1;
}
static int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
const char *def;
while (1) {
printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
printf("(%s) ", sym->name);
def = sym_get_string_value(sym);
if (sym_get_string_value(sym))
printf("[%s] ", def);
if (!conf_askvalue(sym, def))
return 0;
switch (line[0]) {
case '\n':
break;
case '?':
/* print help */
if (line[1] == '\n') {
print_help(menu);
def = NULL;
break;
}
/* fall through */
default:
line[strlen(line)-1] = 0;
def = line;
}
if (def && sym_set_string_value(sym, def))
return 0;
}
}
static int conf_sym(struct menu *menu)
{
struct symbol *sym = menu->sym;
tristate oldval, newval;
while (1) {
printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
if (sym->name)
printf("(%s) ", sym->name);
putchar('[');
oldval = sym_get_tristate_value(sym);
switch (oldval) {
case no:
putchar('N');
break;
case mod:
putchar('M');
break;
case yes:
putchar('Y');
break;
}
if (oldval != no && sym_tristate_within_range(sym, no))
printf("/n");
if (oldval != mod && sym_tristate_within_range(sym, mod))
printf("/m");
if (oldval != yes && sym_tristate_within_range(sym, yes))
printf("/y");
if (menu_has_help(menu))
printf("/?");
printf("] ");
if (!conf_askvalue(sym, sym_get_string_value(sym)))
return 0;
strip(line);
switch (line[0]) {
case 'n':
case 'N':
newval = no;
if (!line[1] || !strcmp(&line[1], "o"))
break;
continue;
case 'm':
case 'M':
newval = mod;
if (!line[1])
break;
continue;
case 'y':
case 'Y':
newval = yes;
if (!line[1] || !strcmp(&line[1], "es"))
break;
continue;
case 0:
newval = oldval;
break;
case '?':
goto help;
default:
continue;
}
if (sym_set_tristate_value(sym, newval))
return 0;
help:
print_help(menu);
}
}
static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
bool is_new;
sym = menu->sym;
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
sym_calc_value(sym);
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
return 0;
case yes:
break;
}
} else {
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
return 0;
case yes:
break;
}
}
while (1) {
int cnt, def;
printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
line[0] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
if (!child->sym) {
printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
continue;
}
cnt++;
if (child->sym == def_sym) {
def = cnt;
printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
printf(" %d. %s", cnt, _(menu_get_prompt(child)));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
printf(_(" (NEW)"));
printf("\n");
}
printf(_("%*schoice"), indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
}
printf("[1-%d", cnt);
if (menu_has_help(menu))
printf("?");
printf("]: ");
switch (input_mode) {
case oldconfig:
case silentoldconfig:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
/* fall through */
case oldaskconfig:
fflush(stdout);
xfgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
print_help(menu);
continue;
}
if (!line[0])
cnt = def;
else if (isdigit(line[0]))
cnt = atoi(line);
else
continue;
break;
default:
break;
}
conf_childs:
for (child = menu->list; child; child = child->next) {
if (!child->sym || !menu_is_visible(child))
continue;
if (!--cnt)
break;
}
if (!child)
continue;
if (line[0] && line[strlen(line) - 1] == '?') {
print_help(child);
continue;
}
sym_set_choice_value(sym, child->sym);
for (child = child->list; child; child = child->next) {
indent += 2;
conf(child);
indent -= 2;
}
return 1;
}
}
static void conf(struct menu *menu)
{
struct symbol *sym;
struct property *prop;
struct menu *child;
if (!menu_is_visible(menu))
return;
sym = menu->sym;
prop = menu->prompt;
if (prop) {
const char *prompt;
switch (prop->type) {
case P_MENU:
if ((input_mode == silentoldconfig ||
input_mode == listnewconfig ||
input_mode == oldnoconfig) &&
rootEntry != menu) {
check_conf(menu);
return;
}
/* fall through */
case P_COMMENT:
prompt = menu_get_prompt(menu);
if (prompt)
printf("%*c\n