1 ###############################################################################
4 # @brief Builds up Lynx driver.
6 # @author Yury GEORGIEVSKIY, CERN.
9 # Don't use this makefile directly!
10 # It should be included through Makefile.drvr _ONLY_
12 # @date Created on 13/01/2009
13 ###############################################################################
15 include ../$(ROOTDIR)/makefiles/Makefile.base
16 include ../$(ROOTDIR)/makefiles/Kbuild.lynx
17 include ../$(ROOTDIR)/makefiles/Kbuild.include
19 ADDCFLAGS += $(STDFLAGS) -DCPU=\"$(CPU)\"
20 ADDINCLUDES = $(KERN_INCLUDES)
22 # Driver source directory
23 #+ This name is defined _only_ if user in not alredy define it
26 # What will be finally created
27 DRIVER = $(OBJDIR)/$(DRIVER_NAME).ko
29 # Extremely simplified Quiet/Verbose
31 ifeq ("$(origin V)", "command line")
40 $(DRIVER): CC = $(KERN_CC)
46 $(DRIVER): CC = $(QCC); $(KERN_CC)
47 QLD = @echo 'LD [M] $@'
48 QCC = @echo 'CC [M] $@'
53 # We need to re-define OUTPUT_OPTION to compile the drivers...
54 # Note, that normally, it should be declared like this:
55 # OUTPUT_OPTION +=; mv $*.$(CPU).o $(OBJDIR)
56 # But it's NOT working this way, because $@ parameter is vanishing somehow
57 # from the definition of the OUTPUT_OPTION (-o $@).
58 # Because of this - it should be defined either like:
59 # OUTPUT_OPTION = $(OUTPUT_OPTION); mv $*.$(CPU).o $(OBJDIR)
60 # or like this (as it's done below):
61 # OUTPUT_OPTION +=$@; mv $*.$(CPU).o $(OBJDIR)
62 # It's working in this case.
63 $(DRIVER): OUTPUT_OPTION +=$(KFLAGS); mv $*.$(CPU).o $(OBJDIR)
65 # Get all *.c files from current dir. ,*.c will be sorted-out in Kbuild.include
66 DRVRSRCFILES += $(wildcard $(shell pwd)/*.c)
68 # Filter out driver objects
69 DRVROBJS = $(OBJFILES) $(EXTRA_DRVR_OBJS)
72 /acc/sys/$(CPU)/usr/include/ces \
78 /acc/sys/ppc4/sys/lynx.os
81 @echo -e "\nCompiling driver for $(KVER) Lynx kernel:\n"
82 @$(MAKE) CPU=$(CPU) __build
84 __build: $(OBJDIR) $(FINAL_DEST) $(DRIVER)
87 # This rule produce temporary driver archive file that contains unresolved
88 # symbols. They in turn will be used as an input files for 'nm' command.
89 # And after 'nm' command call, an import files (that holds all unresolved
90 # symbols) will be build.
91 $(DRIVER_NAME)Drvr.$(CPU).tmp: $(DRVROBJS)
93 $(Q)$(KERN_LD) -o $(OBJDIR)/$@ -berok -r $(addprefix $(OBJDIR)/, $(notdir $^))
96 # This rule will put only undefined symbols (those external to an object
97 # file) to the '*.import' file.
100 $(Q)$(NM) -u $(OBJDIR)/$< > $(OBJDIR)/$@
102 # This rules will create a driver shared object that imports an undefined
104 $(DRIVER): $(DRIVER_NAME)Drvr.$(CPU).import $(DRVROBJS)
106 $(Q)$(KERN_LD) -o $(subst .o,.ko,$@) -bM:SRE -bimport:$(addprefix $(OBJDIR)/, $(notdir $^))
107 $(Q)ln -sf ../$(DRVR_DIR)/$(OBJDIR)/$(DRIVER_NAME).ko ../$(FINAL_DEST)/$(DRIVER_NAME).$(KVER).ko
110 include ../$(ROOTDIR)/makefiles/deliver.mk
113 cleanloc clearloc:: abort
114 @ if [ -n "$(ISP)" ]; then \
118 find ./ -name '*~' | xargs rm -f