All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11 12:49 Igor Zhbanov
  0 siblings, 0 replies; 2+ messages in thread
From: Igor Zhbanov @ 2012-07-11 12:49 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2948 bytes --]

It was impossible to build PowerTOP for ARM with a cross-compiler
because PowerTOP uses internal csstoh utility that converts
powertop.css to powertoh.h for inclusion in *.cpp source files.

When you use the cross-compiler (without making complicated rules
in the Makefile) this utility will be compiled for ARM platform too.
And you cannot run it on x86 build host.

To solve this issue I have rewritten it in a shell script.
---
 .gitignore      |    1 -
 src/Makefile.am |    7 ++-----
 src/csstoh.sh   |   44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 6 deletions(-)
 create mode 100644 src/csstoh.sh

diff --git a/.gitignore b/.gitignore
index 5534072..35f0df6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,7 +39,6 @@ po/*.gmo
 po/stamp-po
 src/powertop
 src/css.h
-src/csstoh
 src/Makefile.in
 src/.deps/
 src/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index c77b2aa..15e5feb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,6 @@
 AUTOMAKE_OPTIONS = subdir-objects
 ACLOCAL_AMFLAGS = -I ../m4 
 
-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c 
-
 sbin_PROGRAMS = powertop
 nodist_powertop_SOURCES = css.h
 
@@ -44,6 +41,6 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(PCIUTILS_LIBS) $(LIBNL_LIBS) $(LIBZ_LIBS)
 
 BUILT_SOURCES = css.h
 CLEANFILES = css.h
-css.h: csstoh powertop.css
-	./csstoh powertop.css css.h
+css.h: powertop.css
+	$(SHELL) ./csstoh.sh powertop.css css.h
 
diff --git a/src/csstoh.sh b/src/csstoh.sh
new file mode 100644
index 0000000..cc9ad3f
--- /dev/null
+++ b/src/csstoh.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+#
+# Written by Igor Zhbanov <i.zhbanov(a)samsung.com>
+
+if [ $# -lt 2 ]; then
+	echo "Usage: csstoh.sh cssfile header.h"
+	exit 1
+fi
+
+if [ ! -r $1 ]; then
+	echo "Can't find file $1"
+	exit 1
+fi
+
+if ! echo -n >$2; then
+	echo "Can't open file $2 for writing."
+	exit 1
+fi
+
+echo "#ifndef __INCLUDE_GUARD_CCS_H" >> $2
+echo "#define __INCLUDE_GUARD_CCS_H" >> $2
+echo >> $2
+echo "const char css[] = " >> $2
+
+sed -r 's/^(.*)$/\t\"\1\\n\"/' $1 >> $2
+
+echo ";" >> $2
+echo "#endif" >> $2
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Powertop] [PATCH] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11 16:26 Kok, Auke-jan H
  0 siblings, 0 replies; 2+ messages in thread
From: Kok, Auke-jan H @ 2012-07-11 16:26 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

On Wed, Jul 11, 2012 at 12:49 PM, Igor Zhbanov <i.zhbanov(a)samsung.com> wrote:
> It was impossible to build PowerTOP for ARM with a cross-compiler
> because PowerTOP uses internal csstoh utility that converts
> powertop.css to powertoh.h for inclusion in *.cpp source files.
>
> When you use the cross-compiler (without making complicated rules
> in the Makefile) this utility will be compiled for ARM platform too.
> And you cannot run it on x86 build host.
>
> To solve this issue I have rewritten it in a shell script.

So, while this approach is correct, it's a clear case where basically
autotools is not used properly and should be able to solve the problem
for you, and this tool cuold remain a binary program.

In this case it's probably not worth it, since the program is so
small, but I'd like for everyone to realize that there is a lot of
support in autotools for using HOSTCC and building _noinst programs
etc. - autotools has excellent crosscompilation support.

Auke

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-11 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11 12:49 [Powertop] [PATCH] csstoh shell-script for cross-compiling PowerTOP Igor Zhbanov
2012-07-11 16:26 Kok, Auke-jan H

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.