scsi: aic7xxx: fix firmware build with O=path
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 19 Jul 2017 01:58:34 +0000 (18:58 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 25 Jul 2017 02:06:36 +0000 (22:06 -0400)
Building firmware with O=path was apparently broken in aic7 for ever.
Message of the previous commit to the Makefile (from 2008) mentions this
unfortunate state of affairs already.  Fix this, mostly to make
randconfig builds more reliable.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/aic7xxx/Makefile
drivers/scsi/aic7xxx/aicasm/Makefile

index 741d81861d17f777e8fd814edd469004e0491040..07b60a780c06b8b2be234e1a5f4ea97403f1c54f 100644 (file)
@@ -55,9 +55,9 @@ aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) := \
 
 ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
 $(obj)/aic7xxx_seq.h: $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm
-       $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \
+       $(obj)/aicasm/aicasm -I$(srctree)/$(src) -r $(obj)/aic7xxx_reg.h \
                              $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \
-                             $(src)/aic7xxx.seq
+                             $(srctree)/$(src)/aic7xxx.seq
 
 $(aic7xxx-gen-y): $(obj)/aic7xxx_seq.h
 else
@@ -72,14 +72,14 @@ aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) := \
 
 ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
 $(obj)/aic79xx_seq.h: $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm
-       $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \
+       $(obj)/aicasm/aicasm -I$(srctree)/$(src) -r $(obj)/aic79xx_reg.h \
                              $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \
-                             $(src)/aic79xx.seq
+                             $(srctree)/$(src)/aic79xx.seq
 
 $(aic79xx-gen-y): $(obj)/aic79xx_seq.h
 else
 $(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped
 endif
 
-$(obj)/aicasm/aicasm: $(src)/aicasm/*.[chyl]
-       $(MAKE) -C $(src)/aicasm
+$(obj)/aicasm/aicasm: $(srctree)/$(src)/aicasm/*.[chyl]
+       $(MAKE) -C $(srctree)/$(src)/aicasm OUTDIR=$(shell pwd)/$(obj)/aicasm/
index b98c5c1056c380a10dddaa0c6b4a3e6c5d50796c..45e2d49c1fff5e5f2c6f0c11b8e5e6874a45f514 100644 (file)
@@ -1,19 +1,21 @@
 PROG=  aicasm
 
+OUTDIR ?= ./
+
 .SUFFIXES= .l .y .c .h
 
 CSRCS= aicasm.c aicasm_symbol.c
 YSRCS= aicasm_gram.y aicasm_macro_gram.y
 LSRCS= aicasm_scan.l aicasm_macro_scan.l
 
-GENHDRS=       aicdb.h $(YSRCS:.y=.h)
-GENSRCS=       $(YSRCS:.y=.c) $(LSRCS:.l=.c)
+GENHDRS=       $(addprefix ${OUTDIR}/,aicdb.h $(YSRCS:.y=.h))
+GENSRCS=       $(addprefix ${OUTDIR}/,$(YSRCS:.y=.c) $(LSRCS:.l=.c))
 
 SRCS=  ${CSRCS} ${GENSRCS}
 LIBS=  -ldb
 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
-AICASM_CFLAGS:= -I/usr/include -I.
+AICASM_CFLAGS:= -I/usr/include -I. -I$(OUTDIR)
 LEX= flex
 YACC= bison
 YFLAGS= -d
@@ -32,22 +34,25 @@ YFLAGS+= -t -v
 LFLAGS= -d
 endif
 
-$(PROG):  ${GENHDRS} $(SRCS)
-       $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) $(LIBS)
+$(PROG):  $(OUTDIR) ${GENHDRS} $(SRCS)
+       $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(OUTDIR)/$(PROG) $(LIBS)
+
+$(OUTDIR):
+       mkdir -p $(OUTDIR)
 
-aicdb.h:
+$(OUTDIR)/aicdb.h:
        @if [ -e "/usr/include/db4/db_185.h" ]; then            \
-               echo "#include <db4/db_185.h>" > aicdb.h;       \
+               echo "#include <db4/db_185.h>" > $@;    \
         elif [ -e "/usr/include/db3/db_185.h" ]; then          \
-               echo "#include <db3/db_185.h>" > aicdb.h;       \
+               echo "#include <db3/db_185.h>" > $@;    \
         elif [ -e "/usr/include/db2/db_185.h" ]; then          \
-               echo "#include <db2/db_185.h>" > aicdb.h;       \
+               echo "#include <db2/db_185.h>" > $@;    \
         elif [ -e "/usr/include/db1/db_185.h" ]; then          \
-               echo "#include <db1/db_185.h>" > aicdb.h;       \
+               echo "#include <db1/db_185.h>" > $@;    \
         elif [ -e "/usr/include/db/db_185.h" ]; then           \
-               echo "#include <db/db_185.h>" > aicdb.h;        \
+               echo "#include <db/db_185.h>" > $@;     \
         elif [ -e "/usr/include/db_185.h" ]; then              \
-               echo "#include <db_185.h>" > aicdb.h;           \
+               echo "#include <db_185.h>" > $@;                \
         else                                                   \
                echo "*** Install db development libraries";    \
         fi
@@ -58,23 +63,23 @@ clean:
 # Create a dependency chain in generated files
 # to avoid concurrent invocations of the single
 # rule that builds them all.
-aicasm_gram.c: aicasm_gram.h
-aicasm_gram.c aicasm_gram.h: aicasm_gram.y
+$(OUTDIR)/aicasm_gram.c: $(OUTDIR)/aicasm_gram.h
+$(OUTDIR)/aicasm_gram.c $(OUTDIR)/aicasm_gram.h: aicasm_gram.y
        $(YACC) $(YFLAGS) -b $(<:.y=) $<
-       mv $(<:.y=).tab.c $(<:.y=.c)
-       mv $(<:.y=).tab.h $(<:.y=.h)
+       mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
+       mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
 
 # Create a dependency chain in generated files
 # to avoid concurrent invocations of the single
 # rule that builds them all.
-aicasm_macro_gram.c: aicasm_macro_gram.h
-aicasm_macro_gram.c aicasm_macro_gram.h: aicasm_macro_gram.y
+$(OUTDIR)/aicasm_macro_gram.c: $(OUTDIR)/aicasm_macro_gram.h
+$(OUTDIR)/aicasm_macro_gram.c $(OUTDIR)/aicasm_macro_gram.h: aicasm_macro_gram.y
        $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
-       mv $(<:.y=).tab.c $(<:.y=.c)
-       mv $(<:.y=).tab.h $(<:.y=.h)
+       mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
+       mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
 
-aicasm_scan.c: aicasm_scan.l
-       $(LEX) $(LFLAGS) -o$@ $<
+$(OUTDIR)/aicasm_scan.c: aicasm_scan.l
+       $(LEX) $(LFLAGS) -o $@ $<
 
-aicasm_macro_scan.c: aicasm_macro_scan.l
-       $(LEX) $(LFLAGS) -Pmm -o$@ $<
+$(OUTDIR)/aicasm_macro_scan.c: aicasm_macro_scan.l
+       $(LEX) $(LFLAGS) -Pmm -o $@ $<