2006-06-18 14:58:39 +04:00
# ==========================================================================
# Installing headers
#
# header-y files will be installed verbatim
# unifdef-y are the files where unifdef will be run before installing files
# objhdr-y are generated files that will be installed verbatim
#
# ==========================================================================
2006-07-23 22:47:50 +04:00
UNIFDEF := scripts/unifdef -U__KERNEL__
2006-06-18 14:58:39 +04:00
# Eliminate the contents of (and inclusions of) compiler.h
HDRSED := sed -e "s/ inline / __inline__ /g" \
-e "s/[[:space:]]__user[[:space:]]\+/ /g" \
-e "s/(__user[[:space:]]\+/ (/g" \
-e "s/[[:space:]]__force[[:space:]]\+/ /g" \
-e "s/(__force[[:space:]]\+/ (/g" \
-e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \
-e "s/(__iomem[[:space:]]\+/ (/g" \
-e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \
-e " s/[[:space:]]__attribute_const__ $$ // " \
-e "/^\#include <linux\/compiler.h>/d"
_dst := $( if $( dst) ,$( dst) ,$( obj) )
i f e q ( , $( patsubst include /asm /%,,$ ( obj ) /) )
# For producing the generated stuff in include/asm for biarch builds, include
# both sets of Kbuild files; we'll generate anything which is mentioned in
# _either_ arch, and recurse into subdirectories which are mentioned in either
# arch. Since some directories may exist in one but not the other, we must
2006-09-25 01:15:14 +04:00
# use $(wildcard...).
2006-06-18 14:58:39 +04:00
GENASM := 1
archasm := $( subst include/asm,asm-$( ARCH) ,$( obj) )
altarchasm := $( subst include/asm,asm-$( ALTARCH) ,$( obj) )
2006-09-25 01:15:14 +04:00
KBUILDFILES := $( wildcard $( srctree) /include/$( archasm) /Kbuild $( srctree) /include/$( altarchasm) /Kbuild)
2006-06-18 14:58:39 +04:00
e l s e
2006-09-25 01:15:14 +04:00
KBUILDFILES := $( srctree) /$( obj) /Kbuild
2006-06-18 14:58:39 +04:00
e n d i f
2006-09-25 01:15:14 +04:00
i n c l u d e $( KBUILDFILES )
i n c l u d e s c r i p t s / K b u i l d . i n c l u d e
2006-06-18 14:58:39 +04:00
# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
# override $(_dst) so that we install to include/asm directly.
2006-09-25 01:15:14 +04:00
# Unless $(BIASMDIR) is set, in which case we're probably doing
# a 'headers_install_all' build and we should keep the -$(ARCH)
# in the directory name.
i f e q ( $( obj ) $( ALTARCH ) , i n c l u d e / a s m - $( ARCH ) $( BIASMDIR ) )
2006-06-18 14:58:39 +04:00
_dst := include/asm
e n d i f
header-y := $( sort $( header-y) )
unifdef-y := $( sort $( unifdef-y) )
subdir-y := $( patsubst %/,%,$( filter %/, $( header-y) ) )
header-y := $( filter-out %/, $( header-y) )
header-y := $( filter-out $( unifdef-y) ,$( header-y) )
2006-09-25 01:15:14 +04:00
# stamp files for header checks
check-y := $( patsubst %,.check.%,$( header-y) $( unifdef-y) $( objhdr-y) )
# Work out what needs to be removed
oldheaders := $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /%,%,$( wildcard $( INSTALL_HDR_PATH) /$( _dst) /*.h) )
unwanted := $( filter-out $( header-y) $( unifdef-y) $( objhdr-y) ,$( oldheaders) )
oldcheckstamps := $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /%,%,$( wildcard $( INSTALL_HDR_PATH) /$( _dst) /.check.*.h) )
unwanted += $( filter-out $( check-y) ,$( oldcheckstamps) )
# Prefix them all with full paths to $(INSTALL_HDR_PATH)
header-y := $( patsubst %,$( INSTALL_HDR_PATH) /$( _dst) /%,$( header-y) )
unifdef-y := $( patsubst %,$( INSTALL_HDR_PATH) /$( _dst) /%,$( unifdef-y) )
objhdr-y := $( patsubst %,$( INSTALL_HDR_PATH) /$( _dst) /%,$( objhdr-y) )
check-y := $( patsubst %,$( INSTALL_HDR_PATH) /$( _dst) /%,$( check-y) )
2006-06-18 14:58:39 +04:00
i f d e f A L T A R C H
i f e q ( $( obj ) , i n c l u d e / a s m - $( ARCH ) )
altarch-y := altarch-dir
e n d i f
e n d i f
# Make the definitions visible for recursive make invocations
export ALTARCH
export ARCHDEF
export ALTARCHDEF
2006-09-25 01:15:14 +04:00
quiet_cmd_o_hdr_install = INSTALL $( patsubst $( INSTALL_HDR_PATH) /%,%,$@ )
cmd_o_hdr_install = cp $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /%,$( objtree) /$( obj) /%,$@ ) \
$( INSTALL_HDR_PATH) /$( _dst)
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
quiet_cmd_headers_install = INSTALL $( patsubst $( INSTALL_HDR_PATH) /%,%,$@ )
cmd_headers_install = $( HDRSED) $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /%,$( srctree) /$( obj) /%,$@ ) \
> $@
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
quiet_cmd_unifdef = UNIFDEF $( patsubst $( INSTALL_HDR_PATH) /%,%,$@ )
cmd_unifdef = $( UNIFDEF) $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /%,$( srctree) /$( obj) /%,$@ ) \
| $( HDRSED) > $@ || :
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
quiet_cmd_check = CHECK $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /.check.%,$( _dst) /%,$@ )
2006-10-04 13:15:20 +04:00
cmd_check = $( CONFIG_SHELL) $( srctree) /scripts/hdrcheck.sh \
2006-09-25 01:15:14 +04:00
$( INSTALL_HDR_PATH) /include $( subst /.check.,/,$@ ) $@
quiet_cmd_remove = REMOVE $( _dst) /$@
cmd_remove = rm -f $( INSTALL_HDR_PATH) /$( _dst) /$@
2006-06-18 15:02:10 +04:00
2006-09-25 01:15:14 +04:00
quiet_cmd_mkdir = MKDIR $( patsubst $( INSTALL_HDR_PATH) /%,%,$@ )
cmd_mkdir = mkdir -p $@
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
quiet_cmd_gen = GEN $( patsubst $( INSTALL_HDR_PATH) /%,%,$@ )
2006-06-18 14:58:39 +04:00
cmd_gen = \
2006-09-25 01:15:14 +04:00
FNAME = $( patsubst $( INSTALL_HDR_PATH) /$( _dst) /%,%,$@ ) \
2007-01-31 01:35:55 +03:00
STUBDEF = __ASM_STUB_` echo $$ FNAME | tr a-z.- A-Z__` ; \
2006-06-18 14:58:39 +04:00
( e c h o "/* File autogenerated by 'make headers_install' */" ; \
e c h o "\#ifndef $$STUBDEF" ; \
e c h o "\#define $$STUBDEF" ; \
e c h o "\# if $(ARCHDEF)" ; \
2006-09-25 01:15:14 +04:00
i f [ - r $( subst /$ ( _dst ) /,/include /$ ( archasm ) /,$ @) ] ; t h e n \
echo " \# include < $( archasm) / $$ FNAME> " ; \
2006-06-18 14:58:39 +04:00
e l s e \
2006-09-25 01:15:14 +04:00
echo " \# error $( archasm) / $$ FNAME does not exist in " \
2006-06-18 14:58:39 +04:00
" the $( ARCH) architecture " ; \
f i ; \
e c h o "\# elif $(ALTARCHDEF)" ; \
2006-09-25 01:15:14 +04:00
i f [ - r $( subst /$ ( _dst ) /,/include /$ ( altarchasm ) /,$ @) ] ; t h e n \
echo " \# include < $( altarchasm) / $$ FNAME> " ; \
2006-06-18 14:58:39 +04:00
e l s e \
2006-09-25 01:15:14 +04:00
echo " \# error $( altarchasm) / $$ FNAME does not exist in " \
2006-06-18 14:58:39 +04:00
" the $( ALTARCH) architecture " ; \
f i ; \
e c h o "\# else" ; \
e c h o "\# warning This machine appears to be" \
" neither $( ARCH) nor $( ALTARCH) . " ; \
e c h o "\# endif" ; \
e c h o "\#endif /* $$STUBDEF */" ; \
2006-09-25 01:15:14 +04:00
) > $@
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
.PHONY : __headersinst __headerscheck
2006-06-18 14:58:39 +04:00
2006-06-18 15:02:10 +04:00
i f d e f H D R C H E C K
2006-09-25 01:15:14 +04:00
__headerscheck : $( subdir -y ) $( check -y )
@true
$(check-y) : $( INSTALL_HDR_PATH ) /$( _dst ) /.check .%.h : $( INSTALL_HDR_PATH ) /$( _dst ) /%.h
2006-06-18 15:02:10 +04:00
$( call cmd,check)
2006-09-25 01:15:14 +04:00
# Other dependencies for $(check-y)
- i n c l u d e / d e v / n u l l $( check -y )
# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
.PHONY : $( check -y )
2006-06-18 15:02:10 +04:00
e l s e
2006-06-18 14:58:39 +04:00
# Rules for installing headers
2006-09-25 01:15:14 +04:00
__headersinst : $( subdir -y ) $( header -y ) $( unifdef -y ) $( altarch -y ) $( objhdr -y )
@true
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y) : | $( INSTALL_HDR_PATH ) /$( _dst ) $( unwanted )
2006-06-18 14:58:39 +04:00
2006-09-25 01:15:14 +04:00
$(INSTALL_HDR_PATH)/$(_dst) :
2006-06-18 14:58:39 +04:00
$( call cmd,mkdir)
2006-09-25 01:15:14 +04:00
.PHONY : $( unwanted )
$(unwanted) :
$( call cmd,remove)
2006-06-18 14:58:39 +04:00
i f d e f G E N A S M
2006-09-25 01:15:14 +04:00
$(objhdr-y) $(header-y) $(unifdef-y) : $( KBUILDFILES )
2006-06-18 14:58:39 +04:00
$( call cmd,gen)
e l s e
2006-10-17 11:10:02 +04:00
$(objhdr-y) : $( INSTALL_HDR_PATH ) /$( _dst ) /%.h : $( objtree ) /$( obj ) /%.h $( KBUILDFILES )
2006-06-18 14:58:39 +04:00
$( call cmd,o_hdr_install)
2006-09-25 01:15:14 +04:00
$(header-y) : $( INSTALL_HDR_PATH ) /$( _dst ) /%.h : $( srctree ) /$( obj ) /%.h $( KBUILDFILES )
2006-06-18 14:58:39 +04:00
$( call cmd,headers_install)
2006-09-25 01:15:14 +04:00
$(unifdef-y) : $( INSTALL_HDR_PATH ) /$( _dst ) /%.h : $( srctree ) /$( obj ) /%.h $( KBUILDFILES )
2006-06-18 14:58:39 +04:00
$( call cmd,unifdef)
e n d i f
2006-06-18 15:02:10 +04:00
e n d i f
2006-06-18 14:58:39 +04:00
hdrinst := -rR -f $( srctree) /scripts/Makefile.headersinst obj
.PHONY : altarch -dir
2006-09-16 23:15:45 +04:00
# All the files in the normal arch dir must be created first, since we test
# for their existence.
altarch-dir : $( subdir -y ) $( header -y ) $( unifdef -y ) $( objhdr -y )
2006-06-18 14:58:39 +04:00
$( Q) $( MAKE) $( hdrinst) = include/asm-$( ALTARCH) dst = include/asm-$( ALTARCH)
2006-09-25 01:15:14 +04:00
$( Q) $( MAKE) $( hdrinst) = include/asm dst = include/asm$( BIASMDIR)
2006-06-18 14:58:39 +04:00
# Recursion
2006-09-25 01:15:14 +04:00
.PHONY : $( subdir -y )
2006-06-18 14:58:39 +04:00
$(subdir-y) :
$( Q) $( MAKE) $( hdrinst) = $( obj) /$@ dst = $( _dst) /$@ rel = ../$( rel)