Linux-kernel mailing list archive 2000-02,: [PATCH] Small cleanup to main Makefile

# [PATCH] Small cleanup to main Makefile

Brian Gerst (bgerst@quark.vpplus.com)
Wed, 12 Jan 2000 20:14:30 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Gaurav Yadav: "Regarding slab.c"
- Previous message: Brian Gerst: "Re: [PATCH] Replacing __SMP__ by CONFIG_SMP globally in linux-2.3.39."

This is a multi-part message in MIME format.
--------------6E4539C780D3C9A9B3C1DAA0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This patch:
- Moves the complexity of creating the version.h and compile.h from the
main Makefile into a pair of shell scripts.
- Makes these header files protected from multiple includes.
- Cleans up some ugliness in init/version.c

Please test this patch before I send it to Linus.

    --

    						Brian Gerst
    --------------6E4539C780D3C9A9B3C1DAA0
    Content-Type: text/plain; charset=us-ascii;
     name="version.h.diff"
    Content-Transfer-Encoding: 7bit
    Content-Disposition: inline;
     filename="version.h.diff"

    diff -urN linux-2.3.39/Makefile linux-2.3.39-kv/Makefile
    --- linux-2.3.39/Makefile	Wed Jan 12 18:52:48 2000
    +++ linux-2.3.39-kv/Makefile	Wed Jan 12 19:09:07 2000
    @@ -303,36 +303,11 @@
     $(TOPDIR)/include/linux/version.h: include/linux/version.h
     $(TOPDIR)/include/linux/compile.h: include/linux/compile.h

    -newversion:
    -	@if [ ! -f .version ]; then \
    -		echo 1 > .version; \
    -	else \
    -		expr 0`cat .version` + 1 > .version; \
    -	fi
    +include/linux/compile.h: $(CONFIGURATION) include/linux/version.h scripts/mkcompile.h.sh
    +	$(CONFIG_SHELL) scripts/mkcompile.h.sh > $@

    -include/linux/compile.h: $(CONFIGURATION) include/linux/version.h newversion
    -	@echo -n \#define UTS_VERSION \"\#`cat .version` > .ver
    -	@if [ -n "$(CONFIG_SMP)" ] ; then echo -n " SMP" >> .ver; fi
    -	@if [ -f .name ]; then  echo -n \-`cat .name` >> .ver; fi
    -	@echo ' '`date`'"' >> .ver
    -	@echo \#define LINUX_COMPILE_TIME \"`date +%T`\" >> .ver
    -	@echo \#define LINUX_COMPILE_BY \"`whoami`\" >> .ver
    -	@echo \#define LINUX_COMPILE_HOST \"`hostname`\" >> .ver
    -	@if [ -x /bin/dnsdomainname ]; then \
    -	   echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"; \
    -	 elif [ -x /bin/domainname ]; then \
    -	   echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"; \
    -	 else \
    -	   echo \#define LINUX_COMPILE_DOMAIN ; \
    -	 fi >> .ver
    -	@echo \#define LINUX_COMPILER \"`$(CC) $(CFLAGS) -v 2>&1 | tail -1`\" >> .ver
    -	@mv -f .ver $@
    -
    -include/linux/version.h: ./Makefile
    -	@echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" > .ver
    -	@echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver
    -	@echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver
    -	@mv -f .ver $@
    +include/linux/version.h: ./Makefile scripts/mkversion.h.sh
    +	$(CONFIG_SHELL) scripts/mkversion.h.sh > $@

     init/version.o: init/version.c include/linux/compile.h include/config/MARKER
     	$(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c
    diff -urN linux-2.3.39/init/version.c linux-2.3.39-kv/init/version.c
    --- linux-2.3.39/init/version.c	Mon Jan  5 04:41:01 1998
    +++ linux-2.3.39-kv/init/version.c	Wed Jan 12 18:54:31 2000
    @@ -11,10 +11,7 @@
     #include <linux/version.h>
     #include <linux/compile.h>

    -#define version(a) Version_ ## a
    -#define version_string(a) version(a)
    -
    -int version_string(LINUX_VERSION_CODE) = 0;
    +int LINUX_VERSION_SYMBOL = 0;

     struct new_utsname system_utsname = {
     	UTS_SYSNAME, UTS_NODENAME, UTS_RELEASE, UTS_VERSION,
    diff -urN linux-2.3.39/scripts/mkcompile.h.sh linux-2.3.39-kv/scripts/mkcompile.h.sh
    --- linux-2.3.39/scripts/mkcompile.h.sh	Wed Dec 31 19:00:00 1969
    +++ linux-2.3.39-kv/scripts/mkcompile.h.sh	Wed Jan 12 18:54:31 2000
    @@ -0,0 +1,45 @@
    +#!/bin/bash
    +
    +if [ -f .version ]; then
    +	version=$[`cat .version` + 1]
    +else
    +	version=1
    +fi
    +echo $version > .version
    +
    +uts_version="#$version"
    +if [ "$CONFIG_SMP" = "y" ]; then
    +	uts_version="$uts_version SMP"
    +fi
    +if [ -f .name ]; then
    +	uts_version="$uts_version-`cat .name`"
    +fi
    +uts_version="$uts_version `date`"
    +
    +time=`date +%T`
    +user=`whoami`
    +host=`hostname`
    +
    +if [ -x /bin/dnsdomainname ]; then
    +	domain=`dnsdomainname`
    +elif [ -x /bin/domainname ]; then
    +	domain=`dommainname`
    +else
    +	domain=
    +fi
    +
    +compiler="`$CC $CFLAGS -v 2>&1 | tail -1`"
    +
    +cat << EOF
    +/* Automatically created by mkcompile.h.sh */
    +#ifndef __LINUX_COMPILE_H
    +
    +#define UTS_VERSION "$uts_version"
    +#define LINUX_COMPILE_TIME "$time"
    +#define LINUX_COMPILE_BY "$user"
    +#define LINUX_COMPILE_HOST "$host"
    +#define LINUX_COMPILE_DOMAIN "$domain"
    +#define LINUX_COMPILER "$compiler"
    +
    +#endif /* __LINUX_COMPILE_H */
    +EOF
    diff -urN linux-2.3.39/scripts/mkversion.h.sh linux-2.3.39-kv/scripts/mkversion.h.sh
    --- linux-2.3.39/scripts/mkversion.h.sh	Wed Dec 31 19:00:00 1969
    +++ linux-2.3.39-kv/scripts/mkversion.h.sh	Wed Jan 12 19:08:34 2000
    @@ -0,0 +1,16 @@
    +#!/bin/bash
    +
    +version_code=$[$VERSION * 65536 + $PATCHLEVEL * 256 + $SUBLEVEL]
    +
    +cat << EOF
    +/* Automatically created by mkversion.h.sh */
    +#ifndef __LINUX_VERSION_H
    +
    +#define UTS_RELEASE "$KERNELRELEASE"
    +#define LINUX_VERSION_CODE $version_code
    +#define LINUX_VERSION_SYMBOL Version_$version_code
    +
    +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
    +
    +#endif /* __LINUX_VERSION_H */
    +EOF

    --------------6E4539C780D3C9A9B3C1DAA0--

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

- Next message: Gaurav Yadav: "Regarding slab.c"
- Previous message: Brian Gerst: "Re: [PATCH] Replacing __SMP__ by CONFIG_SMP globally in linux-2.3.39."