#!/bin/bash
modules_dir=`pwd`
-# kernel_dir="/home/kain/dev/inperfa/kernel/redwood/linux-3.4-exynos"
-kernel_dir="/home/kain/dev/inperfa/tizen/da/emulator-kernel"
-# cross_compile=arm-none-linux-gnueabi-
-# arch=arm
-arch=i386
+
+if [ "$#" -lt 2 ] ; then
+ echo "Usage: $0 <kernel dir> <arch (arm/i386)> [<cross compile>]"
+ exit 1
+fi
+
+kernel_dir=$1
+arch=$2
+cross_compile=$3
if [ ${arch} = "arm" ] ; then
link_name="arm"
buffer_dir=${modules_dir}/buffer
writer_dir=${modules_dir}/writer
-driver_new_dir=${modules_dir}/driver_new
+driver_dir=${modules_dir}/driver
kprobe_dir=${modules_dir}/kprobe
kprobe_arch_dir=${kprobe_dir}/arch
ksyms_dir=${modules_dir}/ksyms
ks_features_dir=${modules_dir}/ks_features
sampler_dir=${modules_dir}/sampler
parser_dir=${modules_dir}/parser
-
-driver_dir=${modules_dir}/driver
-common_dir=${modules_dir}/../common
+energy_dir=${modules_dir}/energy
install_dir="/opt/swap/sdk"
-rm ${kprobe_arch_dir}/asm
+rm -f ${kprobe_arch_dir}/asm
ln -s asm-${link_name} ${kprobe_arch_dir}/asm
-rm ${uprobe_arch_dir}/asm
+rm -f ${uprobe_arch_dir}/asm
ln -s asm-${link_name} ${uprobe_arch_dir}/asm
buffer_module_name=swap_buffer.ko
writer_module_name=swap_writer.ko
writer_inc=${modules_inc}
-make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${writer_dir} modules || exit 1
+make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${writer_dir} \
+ extra_cflags="-I${modules_dir}" modules || exit 1
-driver_new_module_name=swap_driver_new.ko
-make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${driver_new_dir} \
+driver_module_name=swap_driver.ko
+make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${driver_dir} \
extra_cflags="-I${modules_dir}" modules || exit 1
kprobe_module_name=swap_kprobe.ko
uprobe_module_name=swap_uprobe.ko
make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${uprobe_dir} \
- extra_cflags="-I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir}" \
+ extra_cflags="-I${modules_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir}" \
modules || exit 1
us_manager_module_name=swap_us_manager.ko
make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${us_manager_dir} \
- extra_cflags="-I${modules_dir} -I${us_manager_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir} -I${driver_dir} -I${common_dir} -I${ksyms_dir}" \
+ extra_cflags="-I${modules_dir} -I${us_manager_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir} -I${driver_dir} -I${ksyms_dir}" \
modules || exit 1
ks_features_module_name=swap_ks_features.ko
make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${parser_dir} \
extra_cflags="-I${modules_dir}" modules || exit 1
+energy_module_name=swap_energy.ko
+make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${energy_dir} \
+ extra_cflags="-I${modules_dir} -I${kprobe_dir} -I${kprobe_arch_dir}" modules || exit 1
+
modules=\
"${buffer_dir}/${buffer_module_name} \
${writer_dir}/${writer_module_name} \
-${driver_new_dir}/${driver_new_module_name} \
+${driver_dir}/${driver_module_name} \
${kprobe_dir}/${kprobe_module_name} \
${ks_manager_dir}/${ks_manager_module_name} \
${uprobe_dir}/${uprobe_module_name} \
${us_manager_dir}/${us_manager_module_name} \
${ks_features_dir}/${ks_features_module_name} \
${sampler_dir}/${sampler_module_name} \
-${parser_dir}/${parser_module_name}"
+${parser_dir}/${parser_module_name} \
+${energy_dir}/${energy_module_name}"
-for m in ${modules} ; do
- sdb -e push $m ${install_dir}
-done
+# for m in ${modules} ; do
+# sdb -e push $m ${install_dir}
+# done