From 8f2e60cef7dd10c03859a30aa089fae935bf8333 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 26 Jul 2000 23:07:52 +0000 Subject: [PATCH] merge modbuild-0.0.2 changes --- Makefile | 147 +---------- Makefile.modbuild | 136 +++++++++++ arch/Makefile.noarch | 3 + scripts/Configure | 46 +--- scripts/check_kernel | 2 +- scripts/config.in | 3 +- scripts/dep.linux | 60 +++++ scripts/dep.rtai | 16 ++ scripts/dep.rtlinux | 14 ++ scripts/mkdep.c | 567 +++++++++++++++++++++++++++++++++++++++++++ scripts/preconfigure | 7 + 11 files changed, 817 insertions(+), 184 deletions(-) create mode 100644 Makefile.modbuild create mode 100644 arch/Makefile.noarch create mode 100755 scripts/dep.linux create mode 100755 scripts/dep.rtai create mode 100755 scripts/dep.rtlinux create mode 100644 scripts/mkdep.c create mode 100755 scripts/preconfigure diff --git a/Makefile b/Makefile index 46249f1c..50e2b181 100644 --- a/Makefile +++ b/Makefile @@ -1,145 +1,12 @@ +VERSION = 0 +PATCHLEVEL = 7 +SUBLEVEL = 48 +EXTRAVERSION = -# Makefile for comedi - -VERS1 = 0 -VERS2 = 7 -VERS3 = 47 - -INSTALLDIR=/usr - -ifndef LINUXDIR -LINUXDIR = /usr/src/linux -endif - -# define the following if you want to compile using RTL -# headers that aren't in the default location -#RTLDIR = /d/ds/cvs/rtlinux - -# define the following if you want to compile using RTAI -# headers that aren't in the default location -#RTAIDIR = /home/ds/cvs/rtai - -# define the following if you want to compile using PCMCIA -# headers -#PCMCIADIR = /d/ds/stuff/pcmcia-cs-3.1.15 - -TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) - -.EXPORT_ALL_VARIABLES: - -CFLAGS = -Wall -O2 -Wstrict-prototypes -CFLAGS += -D__KERNEL__ -I $(LINUXDIR)/include -I $(TOPDIR)/include -I . -CFLAGS += -D__MODBUILD__ - -CONFIG_SHELL := sh - -include $(LINUXDIR)/.config -ifdef PCMCIADIR -CONFIG_PCMCIA=y -endif - -ifeq (.config,$(wildcard .config)) -include .config -include .uts_version -all2: modules comedi_config -else -all2: config -endif - -ifeq ($(CONFIG_SMP),y) -CFLAGS += -D__SMP__ -endif - -ifeq ($(CONFIG_COMEDI_RTL),y) -ifdef RTLDIR -CFLAGS += -I $(RTLDIR)/include -else -CFLAGS += -I /usr/include/rtlinux -endif -CFLAGS += -D__RTL__ -endif - -ifeq ($(CONFIG_COMEDI_RTAI),y) -ifdef RTAIDIR -CFLAGS += -I $(RTAIDIR)/include -else -CFLAGS += -I /usr/include/rtai -endif -endif - -ifdef PCMCIADIR -CFLAGS += -I $(PCMCIADIR)/include -endif +PROJECT = COMEDI +project = comedi SUBDIRS := comedi -DOCFILES= README INSTALL drivers `find doc -type f` - -comedi_config: dummy - $(MAKE) -C comedi_config - -config: dummy - scripts/Configure - -install: dummy -ifeq (/lib/modules/${UTS_VERSION},$(wildcard /lib/modules/${UTS_VERSION})) - install -d /lib/modules/${UTS_VERSION}/misc - install modules/*.o /lib/modules/${UTS_VERSION}/misc - /sbin/depmod -a ${UTS_VERSION} -else - # *** - # *** Could not install comedi.o into /lib/modules/${UTS_VERSION}/misc - # *** Please install by hand. - # *** -endif -# install -m 755 comedi_config/comedi_config ${INSTALLDIR}/sbin -# install -d ${INSTALLDIR}/include -# (cd include;install -m 644 comedi.h ${INSTALLDIR}/include) -# install man/comedi.7 ${INSTALLDIR}/man/man7 -# install man/comedi_config.8 ${INSTALLDIR}/man/man8 -# install -d ${INSTALLDIR}/doc/comedi -# install ${DOCFILES} ${INSTALLDIR}/doc/comedi - -lpr: dummy - find . -name '*.[chs]'|xargs enscript -2r -pit.ps - -dev: dummy - -rm /dev/comedi* - /bin/mknod /dev/comedi0 c 98 0 - /bin/mknod /dev/comedi1 c 98 1 - /bin/mknod /dev/comedi2 c 98 2 - /bin/mknod /dev/comedi3 c 98 3 - chown root.root /dev/comedi* - chmod 666 /dev/comedi* - - -MODFLAGS += -DMODULE -ifeq ($(CONFIG_MODVERSIONS),y) -MODFLAGS += -DMODVERSIONS -include $(LINUXDIR)/include/linux/modversions.h -endif - - -modules: $(patsubst %, _mod_%, $(SUBDIRS)) - -$(patsubst %, _mod_%, $(SUBDIRS)) : dummy - -mkdir modules - $(MAKE) -C $(patsubst _mod_%, %, $@) CFLAGS="$(CFLAGS) $(MODFLAGS)" MAKING_MODULES=1 modules - -clean: - rm -f core `find . -name '*.[oas]'` - rm -f core `find . -name '.*.flags' -print` - rm -f comedi/range.h comedi/mk_range comedi/range.def - rm -f comedi_config/comedi_config - -distclean: clean - rm -f .depend `find . -name .depend -print` - rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ - -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ - -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS - -rm -rf modules - rm -f .config .uts_version include/config.h - -include $(TOPDIR)/Rules.make - +include ./Makefile.modbuild -dummy: diff --git a/Makefile.modbuild b/Makefile.modbuild new file mode 100644 index 00000000..8f472c63 --- /dev/null +++ b/Makefile.modbuild @@ -0,0 +1,136 @@ + +-include .sourcedirs + +# Makefile for modbuild + +# define the following if you want to compile using PCMCIA +# headers +# PCMCIADIR = /home/ds/stuff/pcmcia-cs-3.1.15 + +ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) + +.EXPORT_ALL_VARIABLES: +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) +TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) + +HPATH = $(TOPDIR)/include +FINDHPATH = $(HPATH)/$(project) + +HOSTCC =gcc +HOSTCFLAGS =-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer + +CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer +# use '-fno-strict-aliasing', but only if the compiler can take it +CFLAGS += $(shell if $(CC) -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-fno-strict-aliasing"; fi) +#CFLAGS += -include $(TOPDIR)/include/modbuild/config.h +CFLAGS += -D__KERNEL__ -I $(TOPDIR)/include -I $(LINUXDIR)/include -I . +CFLAGS += -D__MODBUILD__ + +CONFIG_SHELL := sh + +PROJECTRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +-include $(LINUXDIR)/.config +ifdef PCMCIADIR +CONFIG_PCMCIA=m +endif + +ifeq (.config,$(wildcard .config)) +include .config +include .uts_version +ifeq (.depend,$(wildcard .depend)) +include .depend +all2: modules +else +all2: depend +endif +else +all2: config +endif + +ifeq ($(CONFIG_SMP),y) +CFLAGS += -D__SMP__ +endif + +ifdef PCMCIADIR +CFLAGS += -I $(PCMCIADIR)/include +endif + + +-include arch/$(ARCH)/Makefile +-include arch/Makefile.noarch + +config: dummy + scripts/Configure + +install: dummy + mkdir -p ${MOD_INSTALL_PATH}/lib/modules/${UTS_VERSION}/misc + install -d ${MOD_INSTALL_PATH}/lib/modules/${UTS_VERSION}/misc + install modules/*.o ${MOD_INSTALL_PATH}/lib/modules/${UTS_VERSION}/misc + #/sbin/depmod -a ${UTS_VERSION} + + +MODFLAGS += -DMODULE +ifeq ($(CONFIG_MODVERSIONS),y) +MODFLAGS += -DMODVERSIONS -include $(LINUXDIR)/include/linux/modversions.h +endif + + +modules: $(patsubst %, _mod_%, $(SUBDIRS)) + +$(patsubst %, _mod_%, $(SUBDIRS)) : dummy + -mkdir modules + $(MAKE) -C $(patsubst _mod_%, %, $@) CFLAGS="$(CFLAGS) $(MODFLAGS)" MAKING_MODULES=1 modules + +dep-files: scripts/mkdep archdep include/$(project)/version.h new-genksyms +# scripts/mkdep init/*.c >.depend + echo >.depend + scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend +# set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep ;done +# let this be made through the fastdep rule in Rules.make + $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" + +include/$(project)/version.h: ./Makefile + @echo \#define $(PROJECT)_RELEASE \"$(PROJECTRELEASE)\" > .ver + @echo \#define $(PROJECT)_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver + @echo '#define $(PROJECT)_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver + @mv -f .ver $@ + + +MODVERFILE := + +new-genksyms: + +depend dep: dep-files $(MODVERFILE) + +clean: + rm -f core `find . -name '*.[oas]'` + rm -f core `find . -name '.*.flags' -print` + +distclean: clean + rm -f .depend `find . -name .depend -print` + rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS + -rm -rf modules + rm -f .config .uts_version include/modbuild/config.h .config.old + rm -f scripts/mkdep + rm -f .sourcedirs + +include $(TOPDIR)/Rules.make + + +dummy: + +# +# This generates dependencies for the .h files. +# + +scripts/mkdep: scripts/mkdep.c + $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c + +scripts/split-include: scripts/split-include.c + $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c + diff --git a/arch/Makefile.noarch b/arch/Makefile.noarch new file mode 100644 index 00000000..fd4d3959 --- /dev/null +++ b/arch/Makefile.noarch @@ -0,0 +1,3 @@ + +archdep: + diff --git a/scripts/Configure b/scripts/Configure index c1dae68c..0c9e6ca1 100755 --- a/scripts/Configure +++ b/scripts/Configure @@ -3,43 +3,7 @@ # This script was hacked from the one used to configure the linux kernel. # -# -# check running kernel vs. /usr/src/linux and warn if necessary -# -read dummy dummy dummy2 <$LINUXDIR/include/linux/version.h -UTS_VERSION=`echo $dummy2|sed 's/"//g'` - -echo UTS_VERSION=$UTS_VERSION >.uts_version - -. $LINUXDIR/.config - -if [ "$CONFIG_MODULES" = "n" ] -then - cat < $CONFIG_H echo " * Automatically generated C config: don't edit" >> $CONFIG_H echo " */" >> $CONFIG_H -echo '#define COMEDI_VERSION "'$VERS1.$VERS2.$VERS3\" >> $CONFIG_H -echo '#define COMEDI_VERSION_CODE ('0x1000*$VERS1+0x100*$VERS2+$VERS3')' >> $CONFIG_H +echo '#define '${PROJECT}'_VERSION "'$VERS1.$VERS2.$VERS3\" >> $CONFIG_H +echo '#define '${PROJECT}'_VERSION_CODE ('0x1000*$VERS1+0x100*$VERS2+$VERS3')' >> $CONFIG_H DEFAULT="" if [ "$1" = "-d" ] ; then @@ -468,10 +432,10 @@ if [ -f .config ]; then mv .config .config.old fi mv .tmpconfig .config -mv .tmpconfig.h include/config.h +mv .tmpconfig.h include/modbuild/config.h echo -echo "Makefiles for comedi should now be configured. Run 'make' to compile," +echo "Makefiles for ${project} should now be configured. Run 'make' to compile," echo "and then 'make install' to install." echo diff --git a/scripts/check_kernel b/scripts/check_kernel index ebaffe07..72ed648d 100755 --- a/scripts/check_kernel +++ b/scripts/check_kernel @@ -2,7 +2,7 @@ -if [ $(grep -c "$(uname -r)" ${LINUXDIR}/version.h) != 0 ] +if [ $(grep -c "$(uname -r)" /usr/include/linux/version.h) != 0 ] then echo <.sourcedirs + +. $LINUXDIR/.config + +# +# check for a bad situation +# +if [ "$CONFIG_MODULES" = "n" ] +then + cat <.uts_version + +if [ "$(uname -r)" != "$UTS_VERSION" ] +then + cat <>.sourcedirs + if [ -d $RTAIDIR/include/rtai ];then + (cd include;rm -f rtai;ln -s $RTAIDIR/include/rtai rtai) + else + (cd include;rm -f rtai;ln -s $RTAIDIR/include rtai) + fi +fi + diff --git a/scripts/dep.rtlinux b/scripts/dep.rtlinux new file mode 100755 index 00000000..7c544f94 --- /dev/null +++ b/scripts/dep.rtlinux @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ "$CONFIG_RTL" != "" ];then + echo You appear to be running an RTL-patched kernel + + echo -n "Enter location of RTL source tree [/usr/src/rtl]: " + read RTLDIR + : ${RTLDIR:=/usr/src/rtl} + echo RTLDIR=$RTLDIR >>.sourcedirs + (cd include;rm -f rtlinux;ln -s $RTLDIR/include rtlinux) +fi + + + diff --git a/scripts/mkdep.c b/scripts/mkdep.c new file mode 100644 index 00000000..cb62dce5 --- /dev/null +++ b/scripts/mkdep.c @@ -0,0 +1,567 @@ +/* + * Originally by Linus Torvalds. + * Smart CONFIG_* processing by Werner Almesberger, Michael Chastain. + * + * Usage: mkdep file ... + * + * Read source files and output makefile dependency lines for them. + * I make simple dependency lines for #include <*.h> and #include "*.h". + * I also find instances of CONFIG_FOO and generate dependencies + * like include/config/foo.h. + * + * 1 August 1999, Michael Elizabeth Chastain, + * - Keith Owens reported a bug in smart config processing. There used + * to be an optimization for "#define CONFIG_FOO ... #ifdef CONFIG_FOO", + * so that the file would not depend on CONFIG_FOO because the file defines + * this symbol itself. But this optimization is bogus! Consider this code: + * "#if 0 \n #define CONFIG_FOO \n #endif ... #ifdef CONFIG_FOO". Here + * the definition is inactivated, but I still used it. It turns out this + * actually happens a few times in the kernel source. The simple way to + * fix this problem is to remove this particular optimization. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + + +char __depname[512] = "\n\t@touch "; +#define depname (__depname+9) +int hasdep; + +struct path_struct { + int len; + char buffer[256-sizeof(int)]; +} path_array[2] = { + { 0, "" }, + { 0, "" } +}; + + + +/* + * This records all the configuration options seen. + * In perl this would be a hash, but here it's a long string + * of values separated by newlines. This is simple and + * extremely fast. + */ +char * str_config = NULL; +int size_config = 0; +int len_config = 0; + + + +/* + * Grow the configuration string to a desired length. + * Usually the first growth is plenty. + */ +void grow_config(int len) +{ + if (str_config == NULL) { + len_config = 0; + size_config = 4096; + str_config = malloc(4096); + if (str_config == NULL) + { perror("malloc"); exit(1); } + } + + while (len_config + len > size_config) { + str_config = realloc(str_config, size_config *= 2); + if (str_config == NULL) + { perror("malloc config"); exit(1); } + } +} + + + +/* + * Lookup a value in the configuration string. + */ +int is_defined_config(const char * name, int len) +{ + const char * pconfig; + const char * plast = str_config + len_config - len; + for ( pconfig = str_config + 1; pconfig < plast; pconfig++ ) { + if (pconfig[ -1] == '\n' + && pconfig[len] == '\n' + && !memcmp(pconfig, name, len)) + return 1; + } + return 0; +} + + + +/* + * Add a new value to the configuration string. + */ +void define_config(const char * name, int len) +{ + grow_config(len + 1); + + memcpy(str_config+len_config, name, len); + len_config += len; + str_config[len_config++] = '\n'; +} + + + +/* + * Clear the set of configuration strings. + */ +void clear_config(void) +{ + len_config = 0; + define_config("", 0); +} + + + +/* + * This records all the precious .h filenames. No need for a hash, + * it's a long string of values enclosed in tab and newline. + */ +char * str_precious = NULL; +int size_precious = 0; +int len_precious = 0; + + + +/* + * Grow the precious string to a desired length. + * Usually the first growth is plenty. + */ +void grow_precious(int len) +{ + if (str_precious == NULL) { + len_precious = 0; + size_precious = 4096; + str_precious = malloc(4096); + if (str_precious == NULL) + { perror("malloc precious"); exit(1); } + } + + while (len_precious + len > size_precious) { + str_precious = realloc(str_precious, size_precious *= 2); + if (str_precious == NULL) + { perror("malloc"); exit(1); } + } +} + + + +/* + * Add a new value to the precious string. + */ +void define_precious(const char * filename) +{ + int len = strlen(filename); + grow_precious(len + 4); + *(str_precious+len_precious++) = '\t'; + memcpy(str_precious+len_precious, filename, len); + len_precious += len; + memcpy(str_precious+len_precious, " \\\n", 3); + len_precious += 3; +} + + + +/* + * Handle an #include line. + */ +void handle_include(int type, const char * name, int len) +{ + struct path_struct *path = path_array+type; + + if (len == 14 && !memcmp(name, "linux/config.h", len)) + return; + + if (len >= 7 && !memcmp(name, "config/", 7)) + define_config(name+7, len-7-2); + + memcpy(path->buffer+path->len, name, len); + path->buffer[path->len+len] = '\0'; + if (access(path->buffer, F_OK) != 0) + return; + + if (!hasdep) { + hasdep = 1; + printf("%s:", depname); + } + printf(" \\\n %s", path->buffer); +} + + + +/* + * Record the use of a CONFIG_* word. + */ +void use_config(const char * name, int len) +{ + char *pc; + int i; + + pc = path_array[0].buffer + path_array[0].len; + memcpy(pc, "config/", 7); + pc += 7; + + for (i = 0; i < len; i++) { + char c = name[i]; + if (isupper(c)) c = tolower(c); + if (c == '_') c = '/'; + pc[i] = c; + } + pc[len] = '\0'; + + if (is_defined_config(pc, len)) + return; + + define_config(pc, len); + + if (!hasdep) { + hasdep = 1; + printf("%s: ", depname); + } + printf(" \\\n $(wildcard %s.h)", path_array[0].buffer); +} + + + +/* + * Macros for stunningly fast map-based character access. + * __buf is a register which holds the current word of the input. + * Thus, there is one memory access per sizeof(unsigned long) characters. + */ + +#if defined(__alpha__) || defined(__i386__) || defined(__ia64__) || defined(__MIPSEL__) \ + || defined(__arm__) +#define LE_MACHINE +#endif + +#ifdef LE_MACHINE +#define next_byte(x) (x >>= 8) +#define current ((unsigned char) __buf) +#else +#define next_byte(x) (x <<= 8) +#define current (__buf >> 8*(sizeof(unsigned long)-1)) +#endif + +#define GETNEXT { \ + next_byte(__buf); \ + if ((unsigned long) next % sizeof(unsigned long) == 0) { \ + if (next >= end) \ + break; \ + __buf = * (unsigned long *) next; \ + } \ + next++; \ +} + +/* + * State machine macros. + */ +#define CASE(c,label) if (current == c) goto label +#define NOTCASE(c,label) if (current != c) goto label + +/* + * Yet another state machine speedup. + */ +#define MAX2(a,b) ((a)>(b)?(a):(b)) +#define MIN2(a,b) ((a)<(b)?(a):(b)) +#define MAX6(a,b,c,d,e,f) (MAX2(a,MAX2(b,MAX2(c,MAX2(d,MAX2(e,f)))))) +#define MIN6(a,b,c,d,e,f) (MIN2(a,MIN2(b,MIN2(c,MIN2(d,MIN2(e,f)))))) + + + +/* + * The state machine looks for (approximately) these Perl regular expressions: + * + * m|\/\*.*?\*\/| + * m|'.*?'| + * m|".*?"| + * m|#\s*include\s*"(.*?)"| + * m|#\s*include\s*<(.*?>"| + * m|#\s*(?define|undef)\s*CONFIG_(\w*)| + * m|(?!\w)CONFIG_| + * m|__SMP__| + * + * About 98% of the CPU time is spent here, and most of that is in + * the 'start' paragraph. Because the current characters are + * in a register, the start loop usually eats 4 or 8 characters + * per memory read. The MAX6 and MIN6 tests dispose of most + * input characters with 1 or 2 comparisons. + */ +void state_machine(const char * map, const char * end) +{ + const char * next = map; + const char * map_dot; + unsigned long __buf = 0; + + for (;;) { +start: + GETNEXT +__start: + if (current > MAX6('/','\'','"','#','C','_')) goto start; + if (current < MIN6('/','\'','"','#','C','_')) goto start; + CASE('/', slash); + CASE('\'', squote); + CASE('"', dquote); + CASE('#', pound); + CASE('C', cee); + CASE('_', underscore); + goto start; + +/* / */ +slash: + GETNEXT + NOTCASE('*', __start); +slash_star_dot_star: + GETNEXT +__slash_star_dot_star: + NOTCASE('*', slash_star_dot_star); + GETNEXT + NOTCASE('/', __slash_star_dot_star); + goto start; + +/* '.*?' */ +squote: + GETNEXT + CASE('\'', start); + NOTCASE('\\', squote); + GETNEXT + goto squote; + +/* ".*?" */ +dquote: + GETNEXT + CASE('"', start); + NOTCASE('\\', dquote); + GETNEXT + goto dquote; + +/* #\s* */ +pound: + GETNEXT + CASE(' ', pound); + CASE('\t', pound); + CASE('i', pound_i); + CASE('d', pound_d); + CASE('u', pound_u); + goto __start; + +/* #\s*i */ +pound_i: + GETNEXT NOTCASE('n', __start); + GETNEXT NOTCASE('c', __start); + GETNEXT NOTCASE('l', __start); + GETNEXT NOTCASE('u', __start); + GETNEXT NOTCASE('d', __start); + GETNEXT NOTCASE('e', __start); + goto pound_include; + +/* #\s*include\s* */ +pound_include: + GETNEXT + CASE(' ', pound_include); + CASE('\t', pound_include); + map_dot = next; + CASE('"', pound_include_dquote); + CASE('<', pound_include_langle); + goto __start; + +/* #\s*include\s*"(.*)" */ +pound_include_dquote: + GETNEXT + CASE('\n', start); + NOTCASE('"', pound_include_dquote); + handle_include(1, map_dot, next - map_dot - 1); + goto start; + +/* #\s*include\s*<(.*)> */ +pound_include_langle: + GETNEXT + CASE('\n', start); + NOTCASE('>', pound_include_langle); + handle_include(0, map_dot, next - map_dot - 1); + goto start; + +/* #\s*d */ +pound_d: + GETNEXT NOTCASE('e', __start); + GETNEXT NOTCASE('f', __start); + GETNEXT NOTCASE('i', __start); + GETNEXT NOTCASE('n', __start); + GETNEXT NOTCASE('e', __start); + goto pound_define_undef; + +/* #\s*u */ +pound_u: + GETNEXT NOTCASE('n', __start); + GETNEXT NOTCASE('d', __start); + GETNEXT NOTCASE('e', __start); + GETNEXT NOTCASE('f', __start); + goto pound_define_undef; + +/* + * #\s*(define|undef)\s*CONFIG_(\w*) + * + * this does not define the word, because it could be inside another + * conditional (#if 0). But I do parse the word so that this instance + * does not count as a use. -- mec + */ +pound_define_undef: + GETNEXT + CASE(' ', pound_define_undef); + CASE('\t', pound_define_undef); + + NOTCASE('C', __start); + GETNEXT NOTCASE('O', __start); + GETNEXT NOTCASE('N', __start); + GETNEXT NOTCASE('F', __start); + GETNEXT NOTCASE('I', __start); + GETNEXT NOTCASE('G', __start); + GETNEXT NOTCASE('_', __start); + + map_dot = next; +pound_define_undef_CONFIG_word: + GETNEXT + if (isalnum(current) || current == '_') + goto pound_define_undef_CONFIG_word; + goto __start; + +/* \= map+2 && (isalnum(next[-2]) || next[-2] == '_')) + goto start; + GETNEXT NOTCASE('O', __start); + GETNEXT NOTCASE('N', __start); + GETNEXT NOTCASE('F', __start); + GETNEXT NOTCASE('I', __start); + GETNEXT NOTCASE('G', __start); + GETNEXT NOTCASE('_', __start); + + map_dot = next; +cee_CONFIG_word: + GETNEXT + if (isalnum(current) || current == '_') + goto cee_CONFIG_word; + use_config(map_dot, next - map_dot - 1); + goto __start; + +/* __SMP__ */ +underscore: + GETNEXT NOTCASE('_', __start); + GETNEXT NOTCASE('S', __start); + GETNEXT NOTCASE('M', __start); + GETNEXT NOTCASE('P', __start); + GETNEXT NOTCASE('_', __start); + GETNEXT NOTCASE('_', __start); + use_config("SMP", 3); + goto __start; + + } +} + + + +/* + * Generate dependencies for one file. + */ +void do_depend(const char * filename, const char * command) +{ + int mapsize; + int pagesizem1 = getpagesize()-1; + int fd; + struct stat st; + char * map; + + fd = open(filename, O_RDONLY); + if (fd < 0) { + perror(filename); + return; + } + + fstat(fd, &st); + if (st.st_size == 0) { + fprintf(stderr,"%s is empty\n",filename); + close(fd); + return; + } + + mapsize = st.st_size; + mapsize = (mapsize+pagesizem1) & ~pagesizem1; + map = mmap(NULL, mapsize, PROT_READ, MAP_PRIVATE, fd, 0); + if ((long) map == -1) { + perror("mkdep: mmap"); + close(fd); + return; + } + if ((unsigned long) map % sizeof(unsigned long) != 0) + { + fprintf(stderr, "do_depend: map not aligned\n"); + exit(1); + } + + hasdep = 0; + clear_config(); + state_machine(map, map+st.st_size); + if (hasdep) { + puts(command); + if (*command) + define_precious(filename); + } + + munmap(map, mapsize); + close(fd); +} + + + +/* + * Generate dependencies for all files. + */ +int main(int argc, char **argv) +{ + int len; + char *hpath; + + hpath = getenv("HPATH"); + if (!hpath) { + fputs("mkdep: HPATH not set in environment. " + "Don't bypass the top level Makefile.\n", stderr); + return 1; + } + len = strlen(hpath); + memcpy(path_array[0].buffer, hpath, len); + if (len && hpath[len-1] != '/') + path_array[0].buffer[len++] = '/'; + path_array[0].buffer[len] = '\0'; + path_array[0].len = len; + + while (--argc > 0) { + const char * filename = *++argv; + const char * command = __depname; + len = strlen(filename); + memcpy(depname, filename, len+1); + if (len > 2 && filename[len-2] == '.') { + if (filename[len-1] == 'c' || filename[len-1] == 'S') { + depname[len-1] = 'o'; + command = ""; + } + } + do_depend(filename, command); + } + if (len_precious) { + *(str_precious+len_precious) = '\0'; + printf(".PRECIOUS:%s\n", str_precious); + } + return 0; +} diff --git a/scripts/preconfigure b/scripts/preconfigure new file mode 100755 index 00000000..1ff65438 --- /dev/null +++ b/scripts/preconfigure @@ -0,0 +1,7 @@ +#!/bin/sh + +scripts/dep.linux + +scripts/dep.rtai +scripts/dep.rtlinux + -- 2.26.2