[PATCH] Cleanup to main Makefile

From: Brian Gerst (bgerst@quark.vpplus.com)
Date: Sat Jan 15 2000 - 15:51:20 EST


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

This patch applies to 2.3.40-pre3.

-- 

Brian Gerst

diff -urN linux-2.3.40p3/Makefile linux-bg/Makefile --- linux-2.3.40p3/Makefile Sat Jan 15 11:47:42 2000 +++ linux-bg/Makefile Sat Jan 15 12:56:52 2000 @@ -307,42 +307,15 @@ $(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 scripts/mkversion_h.sh + $(CONFIG_SHELL) scripts/mkversion_h.sh > $@ -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 $@ +init/version.o: include/config/MARKER include/linux/compile.h -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 - -init/main.o: init/main.c include/config/MARKER - $(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $< +init/main.o: include/config/MARKER fs lib mm ipc kernel drivers net: dummy $(MAKE) $(subst $@, _dir_$@, $@) diff -urN linux-2.3.40p3/init/version.c linux-bg/init/version.c --- linux-2.3.40p3/init/version.c Mon Jan 5 04:41:01 1998 +++ linux-bg/init/version.c Sat Jan 15 12:41:34 2000 @@ -6,15 +6,12 @@ * May be freely distributed as part of Linux. */ -#include <linux/uts.h> -#include <linux/utsname.h> #include <linux/version.h> #include <linux/compile.h> +#include <linux/uts.h> +#include <linux/utsname.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.40p3/scripts/mkcompile_h.sh linux-bg/scripts/mkcompile_h.sh --- linux-2.3.40p3/scripts/mkcompile_h.sh Wed Dec 31 19:00:00 1969 +++ linux-bg/scripts/mkcompile_h.sh Sat Jan 15 12:36:05 2000 @@ -0,0 +1,46 @@ +#!/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 UTS_MACHINE "$ARCH" +#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.40p3/scripts/mkversion_h.sh linux-bg/scripts/mkversion_h.sh --- linux-2.3.40p3/scripts/mkversion_h.sh Wed Dec 31 19:00:00 1969 +++ linux-bg/scripts/mkversion_h.sh Sat Jan 15 12:18:07 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

- 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/



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:13 EST