Comedi works with several PCMCIA cards, and the driver modules can
be loaded and unloaded upon insertion and removal of the card.
-Copy the files in etc/pcmcia/ to /etc/pcmcia and restart card
-services. The pcmcia script provided is very simple -- it only
+The necessary configuration files are in the Comedilib source
+package. Copy the files in etc/pcmcia/ to /etc/pcmcia and restart
+card services. The pcmcia script provided is very simple -- it only
uses /dev/comedi0 for devices, which is a limitation if you have
other Comedi devices in your system.
--include .sourcedirs
+-include .buildvars
-# 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; \
HOSTCC =gcc
HOSTCFLAGS =-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
-CROSS_COMPILE =
-
#
# Include the make variables (CC, etc...)
#
CONFIG_SHELL TOPDIR HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS MODFLAGS PERL
-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__
-ifdef RTLDIR
-CFLAGS += -I $(RTLDIR)/include -I $(RTLDIR)/include/posix -I $(RTLDIR)/include/compat -D__RT__
-endif
-ifdef RTAIDIR
-CFLAGS += -I $(TOPDIR)/include/rtai
-endif
-CFLAGS += -nostdinc -I $(shell $(CC) -print-search-dirs|grep ^install:|sed 's/^install: //')include
+MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
+export MODLIB
+
+export FLAT_MODULES
-CONFIG_SHELL := sh
+CFLAGS := -I $(TOPDIR)/include $(CFLAGS)
+
+CFLAGS += -nostdinc -I $(shell $(CC) -print-search-dirs|grep ^install:|sed 's/^install: //')include
PROJECTRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
-include $(LINUXDIR)/.config
-ifdef PCMCIADIR
-CONFIG_PCMCIA=m
-CFLAGS += -I $(PCMCIADIR)/include
-endif
ifeq (.config,$(wildcard .config))
include .config
-include .uts_version
ifeq (.depend,$(wildcard .depend))
include .depend
-all2: modules
+all: modules
else
-all2: depend modules
+all: depend modules
endif
else
-all2: config
+all: config
endif
-ifeq ($(CONFIG_SMP),y)
-CFLAGS += -D__SMP__
-endif
-
--include arch/$(ARCH)/Makefile
--include arch/Makefile.noarch
-
oldconfig: dummy
- $(CONFIG_SHELL) scripts/Configure -d
+ $(CONFIG_SHELL) ./configure --old
config: dummy
- $(CONFIG_SHELL) scripts/Configure
-
-MODULES = $(wildcard modules/*.o)
-MODULES_PCMCIA = $(filter %_cs.o, $(MODULES))
-MODULES_MISC = $(filter-out %_cs.o, $(MODULES))
-
-install: dummy
- mkdir -p ${INSTALL_MOD_PATH}/lib/modules/${UTS_VERSION}/misc
- install -d ${INSTALL_MOD_PATH}/lib/modules/${UTS_VERSION}/misc
- install ${MODULES_MISC} ${INSTALL_MOD_PATH}/lib/modules/${UTS_VERSION}/misc
-ifneq ($(MODULES_PCMCIA),)
- mkdir -p ${INSTALL_MOD_PATH}/lib/modules/${UTS_VERSION}/pcmcia
- install ${MODULES_PCMCIA} ${INSTALL_MOD_PATH}/lib/modules/${UTS_VERSION}/pcmcia
-endif
-ifeq (${INSTALL_MOD_PATH},)
- /sbin/depmod -a ${UTS_VERSION}
-else
- echo 'depmod -a not run'
-endif
+ $(CONFIG_SHELL) ./configure
+
+modules_install: $(patsubst %, _modinst_%, $(SUBDIRS))
+
+_modinst_%:
+ $(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install
ifeq ($(CONFIG_MODVERSIONS),y)
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/modbuild/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/modbuild/version.h: ./Makefile
- @echo \#define $(PROJECT)_RELEASE \"$(PROJECTRELEASE)\" > .ver
+include/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 $@
+depend: dep-files
+
+dep-files: scripts/mkdep include/version.h new-genksyms
+# scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend
+# let this be made through the fastdep rule in Rules.make
+ $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)"
-MODVERFILE :=
new-genksyms:
-depend dep: dep-files $(MODVERFILE)
-
clean:
rm -f core `find . -name '*.[oas]'`
rm -f core `find . -name '.*.flags' -print`
-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 .config.old
+ rm -f .config .config.old
+ rm -f include/config.h include/version.h
rm -f scripts/mkdep
- rm -f .sourcedirs
- rm -f include/modbuild/*.h
- rm -f include/rtai include/rtlinux
+ rm -f .buildvars
include $(TOPDIR)/Rules.make
Questions about Comedi should be sent to the Comedi mailing list,
<comedi@stm.lbl.gov>. Mailing the maintainer directly is always
acceptable, but since the mailing list is archived and questions
-are often answered more quickly by other, the mailing list is
+are often answered more quickly by others, the mailing list is
preferred.
To subscribe to ans unsubscribe from the mailing list, go to
-http://stm.lbl.gov/cgi-bin/mailman/listinfo/comedi. Alternatively,
+http://stm.lbl.gov/cgi-bin/mailman/listinfo/comedi. Alternatively,
you can send "subscribe comedi" to <comedi-request@stm.lbl.gov>
Traffic on the list is light, and mainly questions/answers about
comedi installation, bugs, and programming. General questions
access to the Comedi and Comedilib repositories are found at
http://oss.lineo.com/cvs_anon.html.
-Comedi may be freely distibuted and modified in accordance with the
+Comedi may be freely distributed and modified in accordance with the
GNU General Public License.
The person behind all this misspelled humor is David Schleef
+#
+# This file is derived from linux-2.4.16/Rules.make
+#
+
#
# This file contains rules which are shared between multiple Makefiles.
#
#
# Special variables which should not be exported
#
-unexport EXTRA_ASFLAGS
+unexport EXTRA_AFLAGS
unexport EXTRA_CFLAGS
unexport EXTRA_LDFLAGS
unexport EXTRA_ARFLAGS
unexport ALL_SUB_DIRS
unexport MOD_SUB_DIRS
unexport O_TARGET
-unexport O_OBJS
-unexport L_OBJS
-unexport M_OBJS
-# intermediate objects that form part of a module
-unexport MI_OBJS
unexport ALL_MOBJS
-# objects that export symbol tables
-unexport OX_OBJS
-unexport LX_OBJS
-unexport MX_OBJS
-unexport MIX_OBJS
-unexport SYMTAB_OBJS
-unexport MOD_LIST_NAME
+unexport obj-y
+unexport obj-m
+unexport obj-n
+unexport obj-
+unexport export-objs
+unexport subdir-y
+unexport subdir-m
+unexport subdir-n
+unexport subdir-
#
# Get things started.
first_rule: sub_dirs
$(MAKE) all_targets
+both-m := $(filter $(mod-subdirs), $(subdir-y))
+SUB_DIRS := $(subdir-y)
+MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m))
+ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-))
+
+
#
# Common rules
#
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
%.i: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -E $< > $@
+ $(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
) > $(dir $@)/.$(notdir $@).flags
%.o: %.s
- $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $<
+ $(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
+
+# Old makefiles define their own rules for compiling .S files,
+# but these standard rules are available for any Makefile that
+# wants to use them. Our plan is to incrementally convert all
+# the Makefiles to these standard rules. -- rmk, mec
+ifdef USE_STANDARD_AS_RULE
+%.s: %.S
+ $(CPP) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
+
+%.o: %.S
+ $(CC) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
+
+endif
+
+%.lst: %.c
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
+ $(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
#
#
#
# Rule to compile a set of .o files into one .o file
#
ifdef O_TARGET
-ALL_O = $(OX_OBJS) $(O_OBJS)
-$(O_TARGET): $(ALL_O)
+$(O_TARGET): $(obj-y)
rm -f $@
-ifneq "$(strip $(ALL_O))" ""
- $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O)
-else
+ ifneq "$(strip $(obj-y))" ""
+ $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
+ else
$(AR) rcs $@
-endif
+ endif
@ ( \
- echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(ALL_O))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(ALL_O))))' ; \
+ echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
# Rule to compile a set of .o files into one .a file
#
ifdef L_TARGET
-$(L_TARGET): $(LX_OBJS) $(L_OBJS)
+$(L_TARGET): $(obj-y)
rm -f $@
- $(AR) $(EXTRA_ARFLAGS) rcs $@ $(LX_OBJS) $(L_OBJS)
+ $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
@ ( \
- echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(LX_OBJS) $(L_OBJS))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(LX_OBJS) $$(L_OBJS))))' ; \
+ echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
endif
+
#
# This make dependencies quickly
#
fastdep: dummy
- $(TOPDIR)/scripts/mkdep $(wildcard *.[chS] local.h.master) > .depend
+ $(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- $(wildcard *.[chS]) > .depend
ifdef ALL_SUB_DIRS
$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
endif
#
# A rule to make subdirectories
#
-sub_dirs: dummy $(patsubst %,_subdir_%,$(SUB_DIRS))
+subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
+sub_dirs: dummy $(subdir-list)
ifdef SUB_DIRS
-$(patsubst %,_subdir_%,$(SUB_DIRS)) : dummy
+$(subdir-list) : dummy
$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif
#
# A rule to make modules
#
-ALL_MOBJS = $(MX_OBJS) $(M_OBJS)
+ALL_MOBJS = $(filter-out $(obj-y), $(obj-m))
ifneq "$(strip $(ALL_MOBJS))" ""
-PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
+MOD_DESTDIR := $(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
endif
-ifdef MOD_SUB_DIRS
-$(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS)) : dummy
+unexport MOD_DIRS
+MOD_DIRS := $(MOD_SUB_DIRS) $(MOD_IN_SUB_DIRS)
+ifneq "$(strip $(MOD_DIRS))" ""
+.PHONY: $(patsubst %,_modsubdir_%,$(MOD_DIRS))
+$(patsubst %,_modsubdir_%,$(MOD_DIRS)) : dummy
$(MAKE) -C $(patsubst _modsubdir_%,%,$@) modules
-endif
-ifdef MOD_IN_SUB_DIRS
-$(patsubst %,_modinsubdir_%,$(MOD_IN_SUB_DIRS)) : dummy
- $(MAKE) -C $(patsubst _modinsubdir_%,%,$@) modules
+.PHONY: $(patsubst %,_modinst_%,$(MOD_DIRS))
+$(patsubst %,_modinst_%,$(MOD_DIRS)) : dummy
+ $(MAKE) -C $(patsubst _modinst_%,%,$@) modules_install
endif
-modules: $(ALL_MOBJS) $(MIX_OBJS) $(MI_OBJS) dummy \
- $(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS)) \
- $(patsubst %,_modinsubdir_%,$(MOD_IN_SUB_DIRS))
-ifneq "$(strip $(MOD_LIST_NAME))" ""
- rm -f $$TOPDIR/modules/$(MOD_LIST_NAME)
-ifdef MOD_SUB_DIRS
- for i in $(MOD_SUB_DIRS); do \
- echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done
-endif
+.PHONY: modules
+modules: $(ALL_MOBJS) dummy \
+ $(patsubst %,_modsubdir_%,$(MOD_DIRS))
+
+.PHONY: _modinst__
+_modinst__: dummy
ifneq "$(strip $(ALL_MOBJS))" ""
- echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
-endif
-ifneq "$(strip $(MOD_TO_LIST))" ""
- echo $(MOD_TO_LIST) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
-endif
+ifeq "$(FLAT_MODULES)" "yes"
+ mkdir -p $(MODLIB)/misc/
+ cp $(ALL_MOBJS) $(MODLIB)/misc/
+else
+ mkdir -p $(MODLIB)/$(project)/$(MOD_DESTDIR)
+ cp $(ALL_MOBJS) $(MODLIB)/$(project)/$(MOD_DESTDIR)$(MOD_TARGET)
endif
-ifneq "$(strip $(ALL_MOBJS))" ""
- echo $(PDWN)
- cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
- ln -sf ../$(PDWN)/$$i $$i; done
endif
+.PHONY: modules_install
+modules_install: _modinst__ \
+ $(patsubst %,_modinst_%,$(MOD_DIRS))
+
#
# A rule to do nothing
#
#
# This sets version suffixes on exported symbols
-# Uses SYMTAB_OBJS
# Separate the object into "normal" objects and "exporting" objects
# Exporting objects are: all objects that define symbol tables
#
ifdef CONFIG_MODULES
-SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS) $(MIX_OBJS)
+multi-used := $(filter $(list-multi), $(obj-y) $(obj-m))
+multi-objs := $(foreach m, $(multi-used), $($(basename $(m))-objs))
+active-objs := $(sort $(multi-objs) $(obj-y) $(obj-m))
ifdef CONFIG_MODVERSIONS
-ifneq "$(strip $(SYMTAB_OBJS))" ""
+ifneq "$(strip $(export-objs))" ""
-MODINCL = $(LINUXDIR)/include/linux/modules
+MODINCL = $(TOPDIR)/include/linux/modules
# The -w option (enable warnings) for genksyms will return here in 2.1
# So where has it gone?
$(MODINCL)/%.ver: %.c
@if [ ! -r $(MODINCL)/$*.stamp -o $(MODINCL)/$*.stamp -ot $< ]; then \
- echo '$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
+ echo '$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E -D__GENKSYMS__ $<'; \
echo '| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
- $(CC) $(CFLAGS) -E -D__GENKSYMS__ $< \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E -D__GENKSYMS__ $< \
| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp; \
if [ -r $@ ] && cmp -s $@ $@.tmp; then echo $@ is unchanged; rm -f $@.tmp; \
else echo mv $@.tmp $@; mv -f $@.tmp $@; fi; \
fi; touch $(MODINCL)/$*.stamp
-$(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(LINUXDIR)/include/linux/autoconf.h
-
-#$(LINUXDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
-# @echo updating $(LINUXDIR)/include/linux/modversions.h
-# @(echo "#ifndef _LINUX_MODVERSIONS_H";\
-# echo "#define _LINUX_MODVERSIONS_H"; \
-# echo "#include <linux/modsetver.h>"; \
-# cd $(LINUXDIR)/include/linux/modules; \
-# for f in *.ver; do \
-# if [ -f $$f ]; then echo "#include <linux/modules/$${f}>"; fi; \
-# done; \
-# echo "#endif"; \
-# ) > $@
-
-dep fastdep: $(LINUXDIR)/include/linux/modversions.h
-
-endif # SYMTAB_OBJS
-
-$(M_OBJS): $(LINUXDIR)/include/linux/modversions.h
-ifdef MAKING_MODULES
-$(O_OBJS) $(L_OBJS): $(LINUXDIR)/include/linux/modversions.h
-endif
+$(addprefix $(MODINCL)/,$(export-objs:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h
+
+# updates .ver files but not modversions.h
+fastdep: $(addprefix $(MODINCL)/,$(export-objs:.o=.ver))
+
+# updates .ver files and modversions.h like before (is this needed?)
+dep: fastdep update-modverfile
+
+endif # export-objs
+
+# update modversions.h, but only if it would change
+update-modverfile:
+ @(echo "#ifndef _LINUX_MODVERSIONS_H";\
+ echo "#define _LINUX_MODVERSIONS_H"; \
+ echo "#include <linux/modsetver.h>"; \
+ cd $(TOPDIR)/include/linux/modules; \
+ for f in *.ver; do \
+ if [ -f $$f ]; then echo "#include <linux/modules/$${f}>"; fi; \
+ done; \
+ echo "#endif"; \
+ ) > $(TOPDIR)/include/linux/modversions.h.tmp
+ @if [ -r $(TOPDIR)/include/linux/modversions.h ] && cmp -s $(TOPDIR)/include/linux/modversions.h $(TOPDIR)/include/linux/modversions.h.tmp; then \
+ echo $(TOPDIR)/include/linux/modversions.h was not updated; \
+ rm -f $(TOPDIR)/include/linux/modversions.h.tmp; \
+ else \
+ echo $(TOPDIR)/include/linux/modversions.h was updated; \
+ mv -f $(TOPDIR)/include/linux/modversions.h.tmp $(TOPDIR)/include/linux/modversions.h; \
+ fi
+
+$(active-objs): $(TOPDIR)/include/linux/modversions.h
else
-$(LINUXDIR)/include/linux/modversions.h:
+$(TOPDIR)/include/linux/modversions.h:
@echo "#include <linux/modsetver.h>" > $@
endif # CONFIG_MODVERSIONS
-ifneq "$(strip $(SYMTAB_OBJS))" ""
-$(SYMTAB_OBJS): $(LINUXDIR)/include/linux/modversions.h $(SYMTAB_OBJS:.o=.c)
+ifneq "$(strip $(export-objs))" ""
+$(export-objs): $(export-objs:.o=.c) $(TOPDIR)/include/linux/modversions.h
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
FILES_FLAGS_CHANGED := $(strip \
$(filter-out $(FILES_FLAGS_UP_TO_DATE), \
- $(O_TARGET) $(O_OBJS) $(OX_OBJS) \
- $(L_TARGET) $(L_OBJS) $(LX_OBJS) \
- $(M_OBJS) $(MX_OBJS) \
- $(MI_OBJS) $(MIX_OBJS) \
+ $(O_TARGET) $(L_TARGET) $(active-objs) \
))
# A kludge: .S files don't get flag dependencies (yet),
-# because that will involve changing a lot of Makefiles.
+# because that will involve changing a lot of Makefiles. Also
+# suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
+# This allows handling of assembly files that get translated into
+# multiple object files (see arch/ia64/lib/idiv.S, for example).
FILES_FLAGS_CHANGED := $(strip \
- $(filter-out $(patsubst %.S, %.o, $(wildcard *.S)), \
+ $(filter-out $(patsubst %.S, %.o, $(wildcard *.S) $(IGNORE_FLAGS_OBJS)), \
$(FILES_FLAGS_CHANGED)))
ifneq ($(FILES_FLAGS_CHANGED),)
--- /dev/null
+#!/bin/sh
+
+
+topdir=${PWD}
+
+interactive=y
+
+while [ "$1" != "" ];do
+ case $1 in
+ --linuxdir)
+ shift
+ export LINUXDIR=$1
+ ;;
+ --rtaidir)
+ shift
+ export RTAIDIR=$1
+ ;;
+ --rtldir)
+ shift
+ export RTLDIR=$1
+ ;;
+ --reconf*)
+ old=-d
+ interactive=n
+ ;;
+ --non-interactive)
+ interactive=n
+ ;;
+ esac
+ shift
+done
+
+. scripts/dep.linux
+. scripts/dep.rtai
+. scripts/dep.rtlinux
+
+
+scripts/Configure ${old}
+
+
+scripts/generate_makefile comedi/Makefile.in >comedi/Makefile
+scripts/generate_makefile comedi/drivers/Makefile.in >comedi/drivers/Makefile
+scripts/generate_makefile comedi/kcomedilib/Makefile.in >comedi/kcomedilib/Makefile
+
+
+cat <<EOF
+
+Makefiles for Comedi are now be configured.
+Run 'make' to compile, and then 'make install' to install.
+
+If Comedi has never been installed on your system,
+also run 'make dev' to create the device nodes '/dev/comedi*'.
+
+EOF
+
# 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
# - Improve the exit message (Jeff Ronne).
-. scripts/preconfigure
+. ${LINUXDIR}/.config
#
# Make sure we're really running bash.
fi
mv .tmpconfig .config
#mv .tmpconfig.h include/linux/autoconf.h
-mv .tmpconfig.h include/modbuild/config.h
-
-echo
-echo "Makefiles for ${project} should now be configured."
-echo "Run 'make dep ; make' to compile, and then 'make install' to install."
-echo
-echo "If ${project} has never been installed on your system,"
-echo "then run 'make dev' to build the device nodes '/dev/comedi*'."
-echo
+mv .tmpconfig.h include/config.h
exit 0
#!/bin/sh
default=${LINUXDIR:=/usr/src/linux}
-echo -n "Enter location of Linux source tree [$default]: "
-read LINUXDIR
+if [ "${interactive}" = "y" ];then
+ echo -n "Enter location of Linux source tree [$default]: "
+ read LINUXDIR
+fi
: ${LINUXDIR:=$default}
if [ ! -f "$LINUXDIR/.config" ];then
fi
echo using LINUXDIR=$LINUXDIR
-echo LINUXDIR=$LINUXDIR >.sourcedirs
+
+export LINUXDIR
. $LINUXDIR/.config
#
UTS_VERSION=$(grep UTS_RELEASE ${LINUXDIR}/include/linux/version.h| \
sed 's/[^"]*"\(.*\)\{1\}"/\1/')
-echo UTS_VERSION=$UTS_VERSION >.uts_version
echo "Kernel source version is ${UTS_VERSION}"
EOF
fi
+topdir=${PWD}
+
+cd ${topdir}/scripts/linux_flags
+make LINUXDIR=${LINUXDIR} &>/dev/null
+cd ${topdir}
+mv scripts/linux_flags/flags .buildvars
+
+
+if [ "$(echo ${UTS_VERSION} | grep '^2.[45]')" != "" ];then
+ echo "FLAT_MODULES := no" >>.buildvars
+else
+ echo "FLAT_MODULES := yes" >>.buildvars
+fi
+
: ${PCMCIADIR:=$default}
if [ -r $PCMCIADIR ]; then
- echo PCMCIADIR=$PCMCIADIR >>.sourcedirs
echo using PCMCIADIR=$PCMCIADIR
else
echo not configuring PCMCIA support
if [ "$CONFIG_RTHAL" != "" ];then
echo You appear to be running an RTAI-patched kernel
- if [ "$RTAIDIR" = "" ]
+ default=${RTAIDIR:=/usr/src/rtai}
+ if [ "${interactive}" = "y" ]
then
- echo -n "Enter location of RTAI source tree [/usr/src/rtai]: "
+ echo -n "Enter location of RTAI source tree [${default}]: "
read RTAIDIR
- : ${RTAIDIR:=/usr/src/rtai}
fi
- echo RTAIDIR=$RTAIDIR >>.sourcedirs
- (cd include;rm -f rtai;ln -s $RTAIDIR/include rtai)
+ : ${RTAIDIR:=${default}}
+ echo RTAIDIR=$RTAIDIR >>.buildvars
+ echo CFLAGS += -I $RTAIDIR/include >>.buildvars
+ export RTAIDIR
fi
echo You appear to be running an RTL-patched kernel
default=${RTLDIR:=/usr/src/rtl}
- echo -n "Enter location of RTL source tree [$default]: "
- read RTLDIR
+ if [ "${interactive}" = "y" ];then
+ echo -n "Enter location of RTL source tree [$default]: "
+ read RTLDIR
+ fi
: ${RTLDIR:=$default}
- echo RTLDIR=$RTLDIR >>.sourcedirs
-# (cd include;rm -f rtlinux;ln -s $RTLDIR/include rtlinux)
+ echo RTLDIR=$RTLDIR >>.buildvars
+ echo CFLAGS += -I $RTLDIR/include -I $RTLDIR/include/compat -D__RT__ >>.buildvars
+ export RTLDIR
fi
--- /dev/null
+#!/usr/bin/perl -w
+
+
+open(IN, "$ARGV[0]");
+
+print "# This Makefile is autogenerated. Edit Makefile.in instead.\n";
+while($_=<IN>){
+ if(m/select\(([\w_]+) ([\w_.]+)\)/){
+ print "obj-\$($1) += $2\n";
+ }elsif(m/expsyms\(([\w_. ]+)\)/){
+ print "export-objs += $1\n";
+ }elsif(m/objlink\(([\w_.]+) ([\w_. ]+)\)/){
+ push @later,"$1: $2\n";
+ push @later,"\t\$(LD) -r -o \$@ $2\n";
+ }elsif(m/link_subdirs\(([\w_.]+)\)/){
+ print "subdir-m += $1\n";
+ }elsif(m/^$/){
+ }elsif(m/^#/){
+ }else{
+ print "ack! $_";
+ }
+}
+
+#print "\n";
+#print "M_OBJS := \$(sort \$(filter-out \$(export-objs), \$(obj-m)))\n";
+#print "MX_OBJS := \$(sort \$(filter \$(export-objs), \$(obj-m)))\n";
+#print "SUB_DIRS := \$(subdirs-m)\n";
+#print "ALL_SUB_DIRS := \$(SUB_DIRS)\n";
+#print "MOD_SUB_DIRS := \$(SUB_DIRS)\n";
+print "\n";
+print "include \$(TOPDIR)/Rules.make\n";
+print "\n";
+print @later;
+
* Originally by Linus Torvalds.
* Smart CONFIG_* processing by Werner Almesberger, Michael Chastain.
*
- * Usage: mkdep file ...
+ * Usage: mkdep cflags -- file ...
*
* Read source files and output makefile dependency lines for them.
* I make simple dependency lines for #include <*.h> and #include "*.h".
* 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.
+ *
+ * 2.3.99-pre1, Andrew Morton <andrewm@uow.edu.au>
+ * - Changed so that 'filename.o' depends upon 'filename.[cS]'. This is so that
+ * missing source files are noticed, rather than silently ignored.
+ *
+ * 2.4.2-pre3, Keith Owens <kaos@ocs.com.au>
+ * - Accept cflags followed by '--' followed by filenames. mkdep extracts -I
+ * options from cflags and looks in the specified directories as well as the
+ * defaults. Only -I is supported, no attempt is made to handle -idirafter,
+ * -isystem, -I- etc.
*/
#include <ctype.h>
#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct path_struct {
int len;
- char buffer[256-sizeof(int)];
-} path_array[2] = {
- { 0, "" },
- { 0, "" }
+ char *buffer;
};
+struct path_struct *path_array;
+int paths;
+/* Current input file */
+static const char *g_filename;
/*
* This records all the configuration options seen.
int size_config = 0;
int len_config = 0;
-
+static void
+do_depname(void)
+{
+ if (!hasdep) {
+ hasdep = 1;
+ printf("%s:", depname);
+ if (g_filename)
+ printf(" %s", g_filename);
+ }
+}
/*
* Grow the configuration string to a desired length.
*/
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) {
+ if (size_config == 0)
+ size_config = 2048;
str_config = realloc(str_config, size_config *= 2);
if (str_config == NULL)
{ perror("malloc config"); exit(1); }
*/
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) {
+ if (size_precious == 0)
+ size_precious = 2048;
str_precious = realloc(str_precious, size_precious *= 2);
if (str_precious == NULL)
{ perror("malloc"); exit(1); }
/*
* Handle an #include line.
*/
-void handle_include(int type, const char * name, int len)
+void handle_include(int start, const char * name, int len)
{
- struct path_struct *path = path_array+type;
+ struct path_struct *path;
+ int i;
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;
+ for (i = start, path = path_array+start; i < paths; ++i, ++path) {
+ memcpy(path->buffer+path->len, name, len);
+ path->buffer[path->len+len] = '\0';
+ if (access(path->buffer, F_OK) == 0) {
+ do_depname();
+ printf(" \\\n %s", path->buffer);
+ return;
+ }
+ }
- if (!hasdep) {
- hasdep = 1;
- printf("%s:", depname);
+}
+
+
+
+/*
+ * Add a path to the list of include paths.
+ */
+void add_path(const char * name)
+{
+ struct path_struct *path;
+ char resolved_path[PATH_MAX+1];
+ const char *name2;
+
+ if (strcmp(name, ".")) {
+ name2 = realpath(name, resolved_path);
+ if (!name2) {
+ fprintf(stderr, "realpath(%s) failed, %m\n", name);
+ exit(1);
+ }
+ }
+ else {
+ name2 = "";
+ }
+
+ path_array = realloc(path_array, (++paths)*sizeof(*path_array));
+ if (!path_array) {
+ fprintf(stderr, "cannot expand path_arry\n");
+ exit(1);
+ }
+
+ path = path_array+paths-1;
+ path->len = strlen(name2);
+ path->buffer = malloc(path->len+1+256+1);
+ if (!path->buffer) {
+ fprintf(stderr, "cannot allocate path buffer\n");
+ exit(1);
+ }
+ strcpy(path->buffer, name2);
+ if (path->len && *(path->buffer+path->len-1) != '/') {
+ *(path->buffer+path->len) = '/';
+ *(path->buffer+(++(path->len))) = '\0';
}
- printf(" \\\n %s", path->buffer);
}
char *pc;
int i;
- pc = path_array[0].buffer + path_array[0].len;
+ pc = path_array[paths-1].buffer + path_array[paths-1].len;
memcpy(pc, "config/", 7);
pc += 7;
define_config(pc, len);
- if (!hasdep) {
- hasdep = 1;
- printf("%s: ", depname);
- }
- printf(" \\\n $(wildcard %s.h)", path_array[0].buffer);
+ do_depname();
+ printf(" \\\n $(wildcard %s.h)", path_array[paths-1].buffer);
}
* Thus, there is one memory access per sizeof(unsigned long) characters.
*/
-#if defined(__alpha__) || defined(__i386__) || defined(__ia64__) || defined(__MIPSEL__) \
+#if defined(__alpha__) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__) || defined(__MIPSEL__) \
|| defined(__arm__)
#define LE_MACHINE
#endif
*/
#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))))))
+#define MAX5(a,b,c,d,e) (MAX2(a,MAX2(b,MAX2(c,MAX2(d,e)))))
+#define MIN5(a,b,c,d,e) (MIN2(a,MIN2(b,MIN2(c,MIN2(d,e)))))
* The state machine looks for (approximately) these Perl regular expressions:
*
* m|\/\*.*?\*\/|
+ * 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
+ * per memory read. The MAX5 and MIN5 tests dispose of most
* input characters with 1 or 2 comparisons.
*/
void state_machine(const char * map, const char * end)
start:
GETNEXT
__start:
- if (current > MAX6('/','\'','"','#','C','_')) goto start;
- if (current < MIN6('/','\'','"','#','C','_')) goto start;
+ if (current > MAX5('/','\'','"','#','C')) goto start;
+ if (current < MIN5('/','\'','"','#','C')) goto start;
CASE('/', slash);
CASE('\'', squote);
CASE('"', dquote);
CASE('#', pound);
CASE('C', cee);
- CASE('_', underscore);
goto start;
+/* // */
+slash_slash:
+ GETNEXT
+ CASE('\n', start);
+ NOTCASE('\\', slash_slash);
+ GETNEXT
+ goto slash_slash;
+
/* / */
slash:
GETNEXT
+ CASE('/', slash_slash);
NOTCASE('*', __start);
slash_star_dot_star:
GETNEXT
GETNEXT
CASE('\n', start);
NOTCASE('"', pound_include_dquote);
- handle_include(1, map_dot, next - map_dot - 1);
+ handle_include(0, map_dot, next - map_dot - 1);
goto start;
/* #\s*include\s*<(.*)> */
GETNEXT
CASE('\n', start);
NOTCASE('>', pound_include_langle);
- handle_include(0, map_dot, next - map_dot - 1);
+ handle_include(1, map_dot, next - map_dot - 1);
goto start;
/* #\s*d */
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;
-
}
}
int main(int argc, char **argv)
{
int len;
- char *hpath;
+ const char *hpath;
hpath = getenv("HPATH");
if (!hpath) {
"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;
+
+ add_path("."); /* for #include "..." */
+
+ while (++argv, --argc > 0) {
+ if (strncmp(*argv, "-I", 2) == 0) {
+ if (*((*argv)+2)) {
+ add_path((*argv)+2);
+ }
+ else {
+ ++argv;
+ --argc;
+ add_path(*argv);
+ }
+ }
+ else if (strcmp(*argv, "--") == 0) {
+ break;
+ }
+ }
+
+ add_path(hpath); /* must be last entry, for config files */
while (--argc > 0) {
const char * filename = *++argv;
const char * command = __depname;
+ g_filename = 0;
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';
+ g_filename = filename;
command = "";
}
}