Linux Audio

Check our new training course

Loading...
v6.2
 1#!/bin/sh
 2# SPDX-License-Identifier: GPL-2.0-only
 3
 4# Script to update include/generated/autoksyms.h and dependency files
 5#
 6# Copyright:	(C) 2016  Linaro Limited
 7# Created by:	Nicolas Pitre, January 2016
 8#
 9
10# Update the include/generated/autoksyms.h file.
 
 
 
 
 
11#
12# For each symbol being added or removed, the corresponding dependency
13# file's timestamp is updated to force a rebuild of the affected source
14# file. All arguments passed to this script are assumed to be a command
15# to be exec'd to trigger a rebuild of those files.
16
17set -e
18
19cur_ksyms_file="include/generated/autoksyms.h"
20new_ksyms_file="include/generated/autoksyms.h.tmpnew"
21
22info() {
23	if [ "$quiet" != "silent_" ]; then
24		printf "  %-7s %s\n" "$1" "$2"
25	fi
26}
27
28info "CHK" "$cur_ksyms_file"
29
30# Use "make V=1" to debug this script.
31case "$KBUILD_VERBOSE" in
32*1*)
33	set -x
34	;;
35esac
36
37# Generate a new symbol list file
38$CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh --modorder "$new_ksyms_file"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40# Extract changes between old and new list and touch corresponding
41# dependency files.
42changed=$(
43count=0
44sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u |
45sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' |
46while read sympath; do
47	if [ -z "$sympath" ]; then continue; fi
48	depfile="include/ksym/${sympath}"
49	mkdir -p "$(dirname "$depfile")"
50	touch "$depfile"
51	# Filesystems with coarse time precision may create timestamps
52	# equal to the one from a file that was very recently built and that
53	# needs to be rebuild. Let's guard against that by making sure our
54	# dep files are always newer than the first file we created here.
55	while [ ! "$depfile" -nt "$new_ksyms_file" ]; do
56		touch "$depfile"
57	done
58	echo $((count += 1))
59done | tail -1 )
60changed=${changed:-0}
61
62if [ $changed -gt 0 ]; then
63	# Replace the old list with tne new one
64	old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true)
65	new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true)
66	info "KSYMS" "symbols: before=$old, after=$new, changed=$changed"
67	info "UPD" "$cur_ksyms_file"
68	mv -f "$new_ksyms_file" "$cur_ksyms_file"
69	# Then trigger a rebuild of affected source files
70	exec $@
71else
72	rm -f "$new_ksyms_file"
73fi
v4.10.11
  1#!/bin/sh
 
  2
  3# Script to create/update include/generated/autoksyms.h and dependency files
  4#
  5# Copyright:	(C) 2016  Linaro Limited
  6# Created by:	Nicolas Pitre, January 2016
  7#
  8# This program is free software; you can redistribute it and/or modify
  9# it under the terms of the GNU General Public License version 2 as
 10# published by the Free Software Foundation.
 11
 12# Create/update the include/generated/autoksyms.h file from the list
 13# of all module's needed symbols as recorded on the third line of
 14# .tmp_versions/*.mod files.
 15#
 16# For each symbol being added or removed, the corresponding dependency
 17# file's timestamp is updated to force a rebuild of the affected source
 18# file. All arguments passed to this script are assumed to be a command
 19# to be exec'd to trigger a rebuild of those files.
 20
 21set -e
 22
 23cur_ksyms_file="include/generated/autoksyms.h"
 24new_ksyms_file="include/generated/autoksyms.h.tmpnew"
 25
 26info() {
 27	if [ "$quiet" != "silent_" ]; then
 28		printf "  %-7s %s\n" "$1" "$2"
 29	fi
 30}
 31
 32info "CHK" "$cur_ksyms_file"
 33
 34# Use "make V=1" to debug this script.
 35case "$KBUILD_VERBOSE" in
 36*1*)
 37	set -x
 38	;;
 39esac
 40
 41# We need access to CONFIG_ symbols
 42case "${KCONFIG_CONFIG}" in
 43*/*)
 44	. "${KCONFIG_CONFIG}"
 45	;;
 46*)
 47	# Force using a file from the current directory
 48	. "./${KCONFIG_CONFIG}"
 49esac
 50
 51# In case it doesn't exist yet...
 52if [ -e "$cur_ksyms_file" ]; then touch "$cur_ksyms_file"; fi
 53
 54# Generate a new ksym list file with symbols needed by the current
 55# set of modules.
 56cat > "$new_ksyms_file" << EOT
 57/*
 58 * Automatically generated file; DO NOT EDIT.
 59 */
 60
 61EOT
 62[ "$(ls -A "$MODVERDIR")" ] &&
 63sed -ns -e '3{s/ /\n/g;/^$/!p;}' "$MODVERDIR"/*.mod | sort -u |
 64while read sym; do
 65	if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then
 66		sym="${sym#_}"
 67	fi
 68	echo "#define __KSYM_${sym} 1"
 69done >> "$new_ksyms_file"
 70
 71# Special case for modversions (see modpost.c)
 72if [ -n "$CONFIG_MODVERSIONS" ]; then
 73	echo "#define __KSYM_module_layout 1" >> "$new_ksyms_file"
 74fi
 75
 76# Extract changes between old and new list and touch corresponding
 77# dependency files.
 78changed=$(
 79count=0
 80sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u |
 81sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" |
 82while read sympath; do
 83	if [ -z "$sympath" ]; then continue; fi
 84	depfile="include/config/ksym/${sympath}.h"
 85	mkdir -p "$(dirname "$depfile")"
 86	touch "$depfile"
 
 
 
 
 
 
 
 87	echo $((count += 1))
 88done | tail -1 )
 89changed=${changed:-0}
 90
 91if [ $changed -gt 0 ]; then
 92	# Replace the old list with tne new one
 93	old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true)
 94	new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true)
 95	info "KSYMS" "symbols: before=$old, after=$new, changed=$changed"
 96	info "UPD" "$cur_ksyms_file"
 97	mv -f "$new_ksyms_file" "$cur_ksyms_file"
 98	# Then trigger a rebuild of affected source files
 99	exec $@
100else
101	rm -f "$new_ksyms_file"
102fi