Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Benes <mbenes@suse.cz>2017-04-19 14:02:27 +0200
committerMiroslav Benes <mbenes@suse.cz>2017-04-19 14:02:27 +0200
commit1af6c29e961ed1567e3556fb2cf4c86431b4bc72 (patch)
tree86f7abcea56ad0fb8054c3640087218dd738be1e
parentbdc7598481a77e34f914cd70ab1215289c524b67 (diff)
Create Makefile automatically
Introduce scripts/create-makefile.sh script to automatically create a makefile. The scripts is called from tar-up.sh or could be called manually. Signed-off-by: Miroslav Benes <mbenes@suse.cz>
-rw-r--r--Makefile11
-rwxr-xr-xscripts/create-makefile.sh25
-rwxr-xr-xscripts/tar-up.sh4
3 files changed, 28 insertions, 12 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index a08b0bd..0000000
--- a/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-KDIR ?= /lib/modules/`uname -r`/build
-
-obj-m := kgraft-patch-@@RPMRELEASE@@.o
-
-kgraft-patch-@@RPMRELEASE@@-y := kgr_patch_main.o uname_patch/kgr_patch_uname.o
-
-default:
- $(MAKE) -C $(KDIR) M=$(PWD) modules
-
-clean:
- $(MAKE) -C $(KDIR) M=$(PWD) clean
diff --git a/scripts/create-makefile.sh b/scripts/create-makefile.sh
new file mode 100755
index 0000000..778e5ee
--- /dev/null
+++ b/scripts/create-makefile.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Automatically generate a Makefile
+# $1 is output directory
+
+if [ -e "$1/Makefile" ]; then
+ echo "Makefile already exists."
+ exit 0
+fi
+
+objects=$(find . -type f -name "*.c" | sed "s/^\.\/\(.*\)\.c$/\1.o/" | tr '\n' ' ')
+
+cat << EOF > $1/Makefile
+KDIR ?= /lib/modules/\`uname -r\`/build
+
+obj-m := kgraft-patch-@@RPMRELEASE@@.o
+
+kgraft-patch-@@RPMRELEASE@@-y := $objects
+
+default:
+ \$(MAKE) -C \$(KDIR) M=\$(PWD) modules
+
+clean:
+ \$(MAKE) -C \$(KDIR) M=\$(PWD) clean
+EOF
diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh
index 0b48420..9bdbd45 100755
--- a/scripts/tar-up.sh
+++ b/scripts/tar-up.sh
@@ -73,11 +73,13 @@ done
source $(dirname $0)/release-version.sh
install -m 644 kgr_patch_main.c $build_dir
-install -m 644 Makefile $build_dir
install -m 644 rpm/kgraft-patch.spec $build_dir/kgraft-patch-"$RELEASE".spec
install -m 644 rpm/config.sh $build_dir/config.sh
install -m 644 compat.h $build_dir
+# create new Makefile in $build_dir
+scripts/create-makefile.sh $build_dir
+
# timestamp
tsfile=source-timestamp
ts=$(git show --pretty=format:%ct HEAD | head -n 1)