Sam Ravnborg
2005-Jul-31 11:46 UTC
[klibc] Shared versus static linked executables - and strip
I'm still pondering with kbuild and klibc. Next in line was to get ipconfig support in the kernel (build wise). A little challenge that is bigger than anticipated was to create a shared executable. This required a far bigger rewrite of Kbuild.klibc than originally planned. The good part is that I now managed to treat linking of objects with single and multiple .o files almost the same. I've introduced a new syntax: static-y := foo shared-y := bar The old user-progs is gone and dead. Well almost before it was alive anyway. I expect to have this part ready in a few days (delayed by work-work). But then I wonder about the strip and install part. The way stripped targets are handled are different from gzip and ipconfig. In the gzip case a gzip.stripped is made. In the ipconfig case a ipconfig.g is made that is unstripped. So far my preferred approach is that is one wants a stripped target they can do it using: $(obj)/target: $(obj)/target-unstripped $(call cmd,strip) The stripped target is only usefull when we install the executable (create the fs or what it is used for). So using the --strip option to install would do the trick. But so far I do not see how to use the install target in the kernel. I foresee that whan one selects the gzip executable in the kernel, then it would added to the initramfs automatically, in a stripped version. I just do not see how this is going to work for now. Ideas are welcome! I will not bore you with a half-done patch for now. But I like you to reply on your thought about stripped targets, install and shared versus static linked targets. Sam
Sam Ravnborg
2005-Jul-31 15:00 UTC
[klibc] kbuild: Included kinit, nfsmount and ipconfig in kernel build
The kinit (and the rest) are build both as static and shared linked executables. To support this in a clean way the support in Kbuild.klibc was reworked considerably. Now to tell when you want a static linked executables use: static-y := binary Likewise for shared executables use: shared-y := binary To test things out a Kbuild file was created for kinit, ipconfig and nfsmount. Things worked out pretty well and the syntax is kept nice and readable. Due to the fact that kinit uses ipconfig and nfsmount they were in the kernel placed as subdirectories for kinit. This is the only sane way to express the dependencies when doing recursive build like in the kernel. With the current scheme a .o file is created for ipconfig and nfsmount. If we are better served with a ar file then this is easy to fix. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- commit 6ec5f2d923dc945d942a36ed7875733678644712 tree 71e225a468135f4162e143a08b38da15cfe8b7f8 parent e7daa9d72c3c7ea2cf23ff34bf601989ced7c6e1 author Sam Ravnborg <sam@mars.(none)> Mon, 01 Aug 2005 00:01:34 +0200 committer Sam Ravnborg <sam@mars.(none)> Mon, 01 Aug 2005 00:01:34 +0200 cp-to-kernel.sh | 18 +++++++ gzip/Kbuild | 4 +- ipconfig/Kbuild | 35 +++++++++++++ kinit/Kbuild | 27 ++++++++++ nfsmount/Kbuild | 28 +++++++++++ scripts/Kbuild.klibc | 132 ++++++++++++++++++++++++++++---------------------- usr/Kbuild | 3 + 7 files changed, 187 insertions(+), 60 deletions(-) diff --git a/cp-to-kernel.sh b/cp-to-kernel.sh --- a/cp-to-kernel.sh +++ b/cp-to-kernel.sh @@ -38,6 +38,24 @@ if [ ! -d $kernel/usr/gzip ]; then fi cp -R gzip/* $kernel/usr/gzip +echo "Copying kinit" +if [ ! -d $kernel/usr/kinit ]; then + mkdir -p $kernel/usr/kinit +fi +cp -R kinit/* $kernel/usr/kinit + +echo "Copying ipconfig" +if [ ! -d $kernel/usr/kinit/ipconfig ]; then + mkdir -p $kernel/usr/kinit/ipconfig +fi +cp -R ipconfig/* $kernel/usr/kinit/ipconfig + +echo "Copying nfsmount" +if [ ! -d $kernel/usr/kinit/nfsmount ]; then + mkdir -p $kernel/usr/kinit/nfsmount +fi +cp -R nfsmount/* $kernel/usr/kinit/nfsmount + echo "Copying kbuild files" cp scripts/Kbuild.klibc $kernel/scripts # Newer kernel versions have Kbuild.include, so do not overwrite it diff --git a/gzip/Kbuild b/gzip/Kbuild --- a/gzip/Kbuild +++ b/gzip/Kbuild @@ -3,8 +3,8 @@ # # The gzip executable -user-progs := gzip -gzip-y := gzip.o util.o unzip.o inflate.o +static-y := gzip +gzip-y := gzip.o util.o unzip.o inflate.o # Additional targets always := gunzip zcat gzip.stripped diff --git a/ipconfig/Kbuild b/ipconfig/Kbuild new file mode 100644 --- /dev/null +++ b/ipconfig/Kbuild @@ -0,0 +1,35 @@ +# +# Kbuild file for ipconfig +# + +static-y := static/ipconfig +shared-y := shared/ipconfig + +# common .o files +objs := main.o netdev.o packet.o +# dhcp +objs += dhcp_proto.o +# bootp +objs += bootp_proto.o + + +# TODO - do we want a stripped version +# TODO - do we want the static.g + shared.g directories? + + +# Create built-in.o with all object files (used by kinit) +obj-y := $(objs) + +# .o files used to built executables +static/ipconfig-y := $(objs) +shared/ipconfig-y := $(objs) + +ifeq (a,b) +# TODO - can we replace this with built-in.o? +$(LIB): $(OBJS) + $(AR) cru $(LIB) $(OBJS) + +install: all + $(INSTALL_EXEC) shared/* $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)bin + +endif diff --git a/kinit/Kbuild b/kinit/Kbuild new file mode 100644 --- /dev/null +++ b/kinit/Kbuild @@ -0,0 +1,27 @@ +# +# Kbuild file for kinit +# + +static-y := kinit +kinit-y := kinit.o do_mounts.o nfsroot.o getintfile.o initrd.o +kinit-y += open.o readfile.o + +kinit-y += ipconfig/ +kinit-y += nfsmount/ + + +# kinit.c include ipconfig header file +USERCFLAGS_kinit.o := -I$(src)/ipconfig +# So do nfsroot +USERCFLAGS_nfsroot.o := -I$(src)/ipconfig -I$(src)/nfsmount + + +# TODO - stripped image + +ifeq (a,b) + +# This should perhaps be a shared binary? +install: all + $(INSTALL_EXEC) $(PROGS) $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)bin + +endif diff --git a/nfsmount/Kbuild b/nfsmount/Kbuild new file mode 100644 --- /dev/null +++ b/nfsmount/Kbuild @@ -0,0 +1,28 @@ +# +# kbuild file for nfsmount +# + +static-y := static/nfsmount +#FIXME - build is broken static-y := dummypmap +shared-y := shared/nfsmount + +objs := main.o mount.o portmap.o dummypmap.o sunrpc.o + +# Create built-in.o with all .o files (used by kinit) +obj-y := $(objs) + +# .o files used for executables +static/nfsmount-y := $(objs) +shared/nfsmount-y := $(objs) + +# dummypmap uses a single .o file (rename src file?) +dummypmap-y := dummypmap_test.o + +# TODO - do we want a stripped version +# TODO - do we want the static.g + shared.g directories? + +ifeq (a,b) + +install: all + $(INSTALL_EXEC) shared/* $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)bin +endif diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -6,17 +6,35 @@ # # Kbuild: # -# user-progs := cat +# static-y := cat +# # This will compile a file named cat.c -> the executable 'cat' +# # The executable will be linked statically +# +# shared-y := cats +# # This will compile a file named cats.c -> the executable 'cats' +# # The executable will be linked shared # -# This will compile a file named cat.c -> the executable 'cat' -# # If the user space program consist of more files do the following: # Kbuild: # -# user-progs := ipconfig +# static-y := ipconfig # ipconfig-y := main.o netdev.c +# So ipconfig will be linked statically using the two .o files +# specified with ipconfig-y. +# +# To set directory wide CFLAGS use: +# EXTRA_USERCFLAGS := -DDEBUG +# To set directory wide AFLAGS use: +# EXTRA_USERAFLAGS := -DDEBUG +# +# To set target specific CFLAGS (for .c files) use +# USERCFLAGS-main.o := -DDEBUG=3 +# To set target specific AFLAGS (for .s files) use +# USERAFLAGS-main.o := -DDEBUG=3 src := $(obj) +# Preset target and make sure it is a ':=' variable +targets : .phony: __build __build: @@ -55,8 +73,10 @@ USERSTRIPFLAGS := --strip-all -R .comme USERLIBGCC := $(shell $(USERCC) --print-libgcc) USERSHAREDFLAGS := $(SHAREDFLAGS) -USERCRT0 := $(KLIBSRC)/arch/$(ARCH)/crt0.o -USERLIBC := $(KLIBSRC)/libc.a +USERCRT0 := $(KLIBOBJ)/arch/$(ARCH)/crt0.o +USERLIBC := $(KLIBOBJ)/libc.a +USERCRTSHARED := $(KLIBOBJ)/interp.o +USERLIBCSHARED := $(KLIBOBJ)/libc.so # # This indicates the location of the final version of the shared library. @@ -79,21 +99,23 @@ objectify = $(foreach o,$(1),$(if $(filt include $(obj)/Kbuild ##### -# user-progs := handling - -# user-progs based on a single .c file (with same name) -user-single := $(foreach p, $(user-progs), $(if $($(p)-y),,$(p))) - +# static-y + shared-y handling +user-progs := $(static-y) $(shared-y) +# user-progs based on a single .o file (with same name + .o) +user-objs := $(foreach p, $(user-progs), $(if $($(p)-y),,$(p))) +user-objs := $(addsuffix .o, $(user-objs)) # user-progs which is based on several .o files -user-multi := $(foreach p, $(user-progs), $(if $($(p)-y),$(p))) +user-multi := $(foreach p, $(user-progs), $(if $($(p)-y),$(p))) # objects used for user-progs with more then one .o file -user-multi-objs := $(foreach p, $(user-multi), $($(p)-y)) +user-objs += $(foreach p, $(user-multi), $($(p)-y)) # objects build in this dir -user-real-objs := $(patsubst %/,,$(user-multi-objs)) -# Directories we need to visit before user-multi-obs are up-to-date -user-dirs := $(patsubst %/,%,$(filter %/, $(user-multi-objs))) +user-real-objs := $(patsubst %/,,$(user-objs)) +# Directories we need to visit before user-objs are up-to-date +user-dirs := $(patsubst %/,%,$(filter %/, $(user-objs))) # replace all dir/ with dir/built-in.o -user-multi-objs := $(patsubst %/, %/built-in.o, $(user-multi-objs)) +user-objs := $(patsubst %/, %/built-in.o, $(user-objs)) + +targets += $(static-y) $(shared-y) # $(output-dirs) are a list of directories that contain object files output-dirs := $(dir $(user-dirs)) @@ -102,14 +124,14 @@ output-dirs += $(foreach f, $(hostprogs- output-dirs := $(strip $(sort $(filter-out ./,$(output-dirs)))) # prefix so we get full dir -user-progs := $(addprefix $(obj)/,$(user-progs)) -user-single := $(addprefix $(obj)/,$(user-single)) -user-multi := $(addprefix $(obj)/,$(user-multi)) -user-multi-objs := $(addprefix $(obj)/,$(user-multi-objs)) +static-y := $(addprefix $(obj)/,$(static-y)) +shared-y := $(addprefix $(obj)/,$(shared-y)) +user-objs := $(addprefix $(obj)/,$(user-objs)) user-real-objs := $(addprefix $(obj)/,$(user-real-objs)) output-dirs := $(addprefix $(obj)/,$(output-dirs)) user-dirs := $(addprefix $(obj)/,$(user-dirs)) subdir-y := $(addprefix $(obj)/,$(subdir-y)) +obj-y := $(addprefix $(obj)/,$(obj-y)) always := $(addprefix $(obj)/,$(always)) targets := $(addprefix $(obj)/,$(targets)) @@ -120,14 +142,12 @@ _useraflags = $(USERAFLAGS) $(EXTRA_U usercflags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(_usercflags) useraflags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(_useraflags) -ifneq ($(KBUILD_SRC),) # Create output directory if not already present _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) # Create directories for object files if directory does not exist # Needed when obj-y := dir/file.o syntax is used _dummy := $(foreach d,$(output-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) -endif # Do we have to make a built-in.o in this dir? ifneq ($(strip $(obj-y) $(obj-n) $(obj-)),) @@ -195,45 +215,44 @@ ifdef user-progs # Compile userspace programs for the target # ========================================================================== -__build : $(user-dirs) $(user-progs) +__build : $(user-dirs) $(static-y) $(shared-y) # Descend if needed $(sort $(addsuffix /built-in.o,$(user-dirs))): $(user-dirs) ; -# link program that has only a single .o file -quiet_cmd_user-ld-single = USERLD $@ - cmd_user-ld-single = $(USERLD) $(USERLDFLAGS) -o $@ \ - $(USERCRT0) $< \ - $(filter-out FORCE,$^) \ - $(USERLIBC) $(USERLIBGCC) \ - $(USERLIBGCC); \ - $(USERSTRIP) $(USERSTRIPFLAGS) $@ - -$(user-single): %: %.o $(USERCRT0) $(USERLIBC) FORCE - $(call if_changed,user-ld-single) - -targets += $(user-single) $(user-single:=.o) - -# link programs that consist of more than one .o file -multi-deps = $($(subst $(obj)/,,$@-y)) -link-multi-deps = $(addprefix $(obj)/, \ - $(patsubst %/, %/built-in.o, $(multi-deps))) - -quiet_cmd_user-ld-multi = USERLD $@ - cmd_user-ld-multi = $(USERLD) $(USERLDFLAGS) -o $@ \ - $(USERCRT0) \ - $(link-multi-deps) \ - $(USERLIBC) $(USERLIBGCC) \ - $(USERLIBGCC); \ - $(USERSTRIP) $(USERSTRIPFLAGS) $@ - -$(user-multi): $(user-multi-objs) FORCE - $(call if_changed,user-ld-multi) - -targets += $(user-multi) $(user-real-objs) +# Define dependencies for link of progs +# For the simple program: +# file.o => file +# A program with multiple objects +# filea.o, fileb.o => file +# A program with .o files in another dir +# dir/built-in.o filea.o => file + +stripobj = $(subst $(obj)/,,$@) +addbuiltin = $(addprefix $(obj)/, $(patsubst %/, %/built-in.o, $(1))) +link-deps = $(if $($(stripobj)-y), $(call addbuiltin, $($(stripobj)-y)), $@.o) + +quiet_cmd_ld-static = USERLD $@ + cmd_ld-static = $(USERLD) $(USERLDFLAGS) -o $@ \ + $(USERCRT0) \ + $(link-deps) \ + $(USERLIBC) $(USERLIBGCC) + +$(static-y): $(user-objs) FORCE + $(call if_changed,ld-static) + +quiet_cmd_ld-shared = USERLD $@ + cmd_ld-shared = $(USERLD) $(USERLDFLAGS) -o $@ \ + -e main $(USERCRTSHARED) \ + $(link-deps) \ + $(USERLIBCSHARED) $(USERLIBGCC) + +$(shared-y): $(user-objs) FORCE + $(call if_changed,ld-shared) + +targets += $(user-real-objs) endif - # Compile programs on the host # ========================================================================== ifdef hostprogs-y @@ -277,7 +296,6 @@ quiet_cmd_strip = STRIP $@ # may be building above, using $(if_changed{,_dep}). As an # optimization, we don't need to read them if the target does not # exist, we will rebuild anyway in that case. - targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) diff --git a/usr/Kbuild b/usr/Kbuild --- a/usr/Kbuild +++ b/usr/Kbuild @@ -5,6 +5,7 @@ # klibc definitions - to be moved to top-level Makefile later export KLIBSRC := $(srctree)/$(src)/klibc export KLIBINC := $(srctree)/$(src)/include +export KLIBOBJ := $(objtree)/$(obj)/klibc obj-y := initramfs_data.o always := klibc/libc.a @@ -18,7 +19,7 @@ subdir- := klibc $(obj)/klibc/libc.a: FORCE $(Q)$(MAKE) -rR -f $(srctree)/scripts/Kbuild.klibc obj=$(obj)/klibc -initramfs-y += gzip +initramfs-y += gzip kinit initramfs-y := $(addprefix $(obj)/,$(initramfs-y)) .PHONY: $(initramfs-y)
Executables that consist of objects from a subdirectory were previously linked to a built-in.o file. Convert this to use archives. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- commit c8da2e7a7d748918be96965829fcf8249d87be04 tree 86d07333ac9f85f8d60dca69eab06664c96ec743 parent 6ec5f2d923dc945d942a36ed7875733678644712 author Sam Ravnborg <sam@mars.(none)> Mon, 01 Aug 2005 00:43:51 +0200 committer Sam Ravnborg <sam@mars.(none)> Mon, 01 Aug 2005 00:43:51 +0200 scripts/Kbuild.klibc | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -112,8 +112,8 @@ user-objs += $(foreach p, $(user-multi), user-real-objs := $(patsubst %/,,$(user-objs)) # Directories we need to visit before user-objs are up-to-date user-dirs := $(patsubst %/,%,$(filter %/, $(user-objs))) -# replace all dir/ with dir/built-in.o -user-objs := $(patsubst %/, %/built-in.o, $(user-objs)) +# replace all dir/ with dir/lib.a +user-objs := $(patsubst %/, %/lib.a, $(user-objs)) targets += $(static-y) $(shared-y) @@ -149,12 +149,12 @@ _dummy := $(shell [ -d $(obj) ] || mkdir # Needed when obj-y := dir/file.o syntax is used _dummy := $(foreach d,$(output-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) -# Do we have to make a built-in.o in this dir? +# Do we have to make a lib.a in this dir? ifneq ($(strip $(obj-y) $(obj-n) $(obj-)),) -builtin-target := $(obj)/built-in.o +lib-target := $(obj)/lib.a endif -__build: $(subdir-y) $(builtin-target) $(always) +__build: $(subdir-y) $(lib-target) $(always) @: # Compile C sources (.c) @@ -198,17 +198,17 @@ targets += $(real-objs-y) # # Rule to compile a set of .o files into one .o file # -ifdef builtin-target +ifdef lib-target quiet_cmd_link_o_target = LD $@ -# If the list of objects to link is empty, just create an empty built-in.o +# If the list of objects to link is empty, just create an empty lib.a cmd_link_o_target = $(if $(strip $(obj-y)),\ - $(USERLD) $(USERLDFLAGS) -r -o $@ $(filter $(obj-y), $^),\ - rm -f $@; $(AR) rcs $@) + rm -f $@; $(USERAR) cru $@ $(filter $(obj-y), $^),\ + rm -f $@; $(USERAR) crs $@) -$(builtin-target): $(obj-y) FORCE +$(lib-target): $(obj-y) FORCE $(call if_changed,link_o_target) -targets += $(builtin-target) -endif # builtin-target +targets += $(lib-target) +endif # lib-target ifdef user-progs @@ -218,7 +218,7 @@ ifdef user-progs __build : $(user-dirs) $(static-y) $(shared-y) # Descend if needed -$(sort $(addsuffix /built-in.o,$(user-dirs))): $(user-dirs) ; +$(sort $(addsuffix /lib.a,$(user-dirs))): $(user-dirs) ; # Define dependencies for link of progs # For the simple program: @@ -226,11 +226,11 @@ $(sort $(addsuffix /built-in.o,$(user-di # A program with multiple objects # filea.o, fileb.o => file # A program with .o files in another dir -# dir/built-in.o filea.o => file +# dir/lib.a filea.o => file -stripobj = $(subst $(obj)/,,$@) -addbuiltin = $(addprefix $(obj)/, $(patsubst %/, %/built-in.o, $(1))) -link-deps = $(if $($(stripobj)-y), $(call addbuiltin, $($(stripobj)-y)), $@.o) +stripobj = $(subst $(obj)/,,$@) +addliba = $(addprefix $(obj)/, $(patsubst %/, %/lib.a, $(1))) +link-deps = $(if $($(stripobj)-y), $(call addliba, $($(stripobj)-y)), $@.o) quiet_cmd_ld-static = USERLD $@ cmd_ld-static = $(USERLD) $(USERLDFLAGS) -o $@ \
When we changed from built-in.o to lib.a it makes less sense to use the obj- syntax. So switch it over to lib- Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- commit 1b8f997e4838bb3f152d0f54067d64cc52dbb209 tree 87746c7965fe930458f0a2485dad3d72f9c791cd parent c8da2e7a7d748918be96965829fcf8249d87be04 author Sam Ravnborg <sam@mars.(none)> Mon, 01 Aug 2005 16:38:32 +0200 committer Sam Ravnborg <sam@mars.(none)> Mon, 01 Aug 2005 16:38:32 +0200 ipconfig/Kbuild | 2 +- nfsmount/Kbuild | 2 +- scripts/Kbuild.klibc | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ipconfig/Kbuild b/ipconfig/Kbuild --- a/ipconfig/Kbuild +++ b/ipconfig/Kbuild @@ -18,7 +18,7 @@ objs += bootp_proto.o # Create built-in.o with all object files (used by kinit) -obj-y := $(objs) +lib-y := $(objs) # .o files used to built executables static/ipconfig-y := $(objs) diff --git a/nfsmount/Kbuild b/nfsmount/Kbuild --- a/nfsmount/Kbuild +++ b/nfsmount/Kbuild @@ -9,7 +9,7 @@ shared-y := shared/nfsmount objs := main.o mount.o portmap.o dummypmap.o sunrpc.o # Create built-in.o with all .o files (used by kinit) -obj-y := $(objs) +lib-y := $(objs) # .o files used for executables static/nfsmount-y := $(objs) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -131,7 +131,7 @@ user-real-objs := $(addprefix $(obj)/,$ output-dirs := $(addprefix $(obj)/,$(output-dirs)) user-dirs := $(addprefix $(obj)/,$(user-dirs)) subdir-y := $(addprefix $(obj)/,$(subdir-y)) -obj-y := $(addprefix $(obj)/,$(obj-y)) +lib-y := $(addprefix $(obj)/,$(lib-y)) always := $(addprefix $(obj)/,$(always)) targets := $(addprefix $(obj)/,$(targets)) @@ -146,11 +146,11 @@ useraflags = -Wp,-MD,$(depfile) $(NO _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) # Create directories for object files if directory does not exist -# Needed when obj-y := dir/file.o syntax is used +# Needed when lib-y := dir/file.o syntax is used _dummy := $(foreach d,$(output-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) # Do we have to make a lib.a in this dir? -ifneq ($(strip $(obj-y) $(obj-n) $(obj-)),) +ifneq ($(strip $(lib-y) $(lib-n) $(lib-)),) lib-target := $(obj)/lib.a endif @@ -201,11 +201,11 @@ targets += $(real-objs-y) ifdef lib-target quiet_cmd_link_o_target = LD $@ # If the list of objects to link is empty, just create an empty lib.a -cmd_link_o_target = $(if $(strip $(obj-y)),\ - rm -f $@; $(USERAR) cru $@ $(filter $(obj-y), $^),\ +cmd_link_o_target = $(if $(strip $(lib-y)),\ + rm -f $@; $(USERAR) cru $@ $(filter $(lib-y), $^),\ rm -f $@; $(USERAR) crs $@) -$(lib-target): $(obj-y) FORCE +$(lib-target): $(lib-y) FORCE $(call if_changed,link_o_target) targets += $(lib-target) endif # lib-target
Just a short heads up. With the latest patches posted I beleive that all of klibc is now buildable in kernel context. The full repository is available at rsync://rsync.kernel.org/pub/scm/linux/kernel/git/sam/klibc-kbuild.git To copy the source to a kernel use: sh cp-to-kernel path/to/kernel Then to build klibc simply type 'make'. For now klibc and executables are build unconditionally - something I beleive we may decide different. But here I need some input what you want. The major TODO items: - fix make clean so we clean out klibc user program files too. - kbuildtify syslinux - or do we really want that? - kbuildtify klibc, ripping out what is no longer needed from the old Make system The last items is starting to look like a rather trivial task now that all the relevant parts has a working Kbuild file. Only 'issue' is that directory structure has to change a bit. ipconfig + nfsmount has to move under kinit. hpa & others - what do you see as needed before potential -mm inclusion? Sam
Sam Ravnborg
2005-Aug-07 01:39 UTC
[klibc] kbuild: install of kinit, ipconfig and nfsmount
kbuild: install of kinit, ipconfig and nfsmount When they moved we now have the possibility to install them, so do it. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- commit 423986135aac6073aff2e1b8efd01f3dadf3fe77 tree c211f30e7f91cdfe02cf44c2a56bf9774620d8f2 parent 50b7344b545588cbc413081ed19c625ffaa6a5ef author Sam Ravnborg <sam@mars.(none)> Sun, 07 Aug 2005 10:39:22 +0200 committer Sam Ravnborg <sam@mars.(none)> Sun, 07 Aug 2005 10:39:22 +0200 usr/kinit/Kbuild | 8 ++------ usr/kinit/ipconfig/Kbuild | 11 ++--------- usr/kinit/nfsmount/Kbuild | 7 ++----- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild --- a/usr/kinit/Kbuild +++ b/usr/kinit/Kbuild @@ -22,10 +22,6 @@ KLIBCCFLAGS_nfsroot.o := -I$(srctree)/$( targets := $(static-y) $(shared-y) subdir- := ipconfig nfsmount -ifeq (a,b) -# This should perhaps be a shared binary? -install: all - $(INSTALL_EXEC) $(PROGS) $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)bin - -endif +# install binary +install-y := kinit diff --git a/usr/kinit/ipconfig/Kbuild b/usr/kinit/ipconfig/Kbuild --- a/usr/kinit/ipconfig/Kbuild +++ b/usr/kinit/ipconfig/Kbuild @@ -27,12 +27,5 @@ shared/ipconfig-y := $(objs) # Cleaning clean-dirs := static shared -ifeq (a,b) -# TODO - can we replace this with built-in.o? -$(LIB): $(OBJS) - $(AR) cru $(LIB) $(OBJS) - -install: all - $(INSTALL_EXEC) shared/* $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)bin - -endif +# install binary +install-y := $(shared-y) diff --git a/usr/kinit/nfsmount/Kbuild b/usr/kinit/nfsmount/Kbuild --- a/usr/kinit/nfsmount/Kbuild +++ b/usr/kinit/nfsmount/Kbuild @@ -23,8 +23,5 @@ dummypmap-y := dummypmap_test.o clean-dirs := static shared -ifeq (a,b) - -install: all - $(INSTALL_EXEC) shared/* $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)bin -endif +# Install binary +install-y := $(shared-y)