From 4ecac1b2645afc8079aad4067a1aa0e8a96eab12 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Micha=C5=82=20Januszewski?= <spock@gentoo.org>
Date: Tue, 16 Feb 2010 23:30:18 +0100
Subject: [PATCH] Make it possible to build fbcondecor_helper against glibc.

---
 configure.ac     |   34 ++++++++++++++++++++++++++++++++++
 libs/Makefile.am |    2 ++
 src/Makefile.am  |   34 +++++++++++++++++++++++++++++++++-
 3 files changed, 69 insertions(+), 1 deletions(-)

diff --git configure.ac configure.ac
index 63b1ff6..8db1498 100644
--- configure.ac
+++ configure.ac
@@ -76,6 +76,23 @@ AC_ARG_ENABLE([klibc-shared],
 )
 AM_CONDITIONAL([CONFIG_KLIBC_SHARED], [test "x${config_klibc_shared}" = "xyes"])
 
+AC_ARG_ENABLE([static-binaries],
+  AC_HELP_STRING([--disable-static-binaries], [do not build any statically linked binaries]),
+  [
+    AS_CASE(["${enableval}"],
+      [yes], [config_static_binaries="yes"],
+      [no],  [config_static_binaries="no"],
+             [AC_MSG_ERROR([bad value '${enableval}' for --disable-static-binaries])]
+    )
+  ],
+  [config_static_binaries="yes"]
+)
+AM_CONDITIONAL([CONFIG_STATIC_BINARIES], [test "x${config_static_binaries}" = "xyes"])
+AS_IF(
+  [test "x${config_static_binaries}" = "xyes"],
+  [AC_DEFINE([CONFIG_STATIC_BINARIES], [1], [Define to 1 to disable building of statically linked binaries.])]
+)
+
 AC_ARG_ENABLE([deprecated],
   AC_HELP_STRING([--enable-deprecated], [include support for deprecated features]),
   [
@@ -333,6 +350,23 @@ AC_ARG_WITH([themedir],
 )
 AC_SUBST([themedir])
 
+AC_ARG_WITH([klibc],
+  AC_HELP_STRING([--without-klibc], [link the kernel helper against glibc instead of klibc]),
+  [
+    AS_CASE(["${withval}"],
+      [yes], [config_klibc="yes"],
+      [no],  [config_klibc="no"],
+             [AC_MSG_ERROR([bad value ${withval} for --with-klibc])]
+    )
+  ],
+  [config_klibc="yes"]
+)
+AM_CONDITIONAL([CONFIG_KLIBC], [test "x${config_klibc}" = "xyes"])
+AS_IF(
+  [test "x${config_klibc}" = "xyes"],
+  [AC_DEFINE([CONFIG_KLIBC], [1], [use klibc])]
+)
+
 M_CFLFAGS=
 M_LIBS=
 AC_CHECK_HEADER(
diff --git libs/Makefile.am b/core/libs/Makefile.am
index 6675ec1..d070b29 100644
--- libs/Makefile.am
+++ libs/Makefile.am
@@ -24,6 +24,7 @@ mostlyclean-local: \
 
 noinst_LIBRARIES =
 
+if CONFIG_KLIBC
 if CONFIG_HELPER
 noinst_LIBRARIES += libjpeg.a
 if CONFIG_PNG
@@ -33,6 +34,7 @@ if CONFIG_TTF_KERNEL
 noinst_LIBRARIES += libfreetype.a
 endif
 endif
+endif
 
 libjpeg_a_SOURCES =
 libpng_a_SOURCES =
diff --git src/Makefile.am b/core/src/Makefile.am
index fa6919d..7570b5e 100644
--- src/Makefile.am
+++ src/Makefile.am
@@ -167,7 +167,6 @@ sbin_PROGRAMS += fbcondecor_ctl
 endif
 sbin_PROGRAMS += fbsplashd
 bin_PROGRAMS  += splash_util
-eexecsbin_PROGRAMS += fbsplashctl
 
 fbcondecor_ctl_SOURCES      = fbcon_decor_ctl.c fbcon_decor.h ../include/console_decor.h ../include/fbcondecor.h common.h fbsplash.h
 fbcondecor_ctl_CPPFLAGS     = $(AM_CPPFLAGS) -DTARGET_UTIL $(libfbsplashrender_la_CFLAGS)
@@ -185,6 +184,9 @@ splash_util_CPPFLAGS        = $(AM_CPPFLAGS) -DTARGET_UTIL $(libfbsplashrender_l
 splash_util_LDFLAGS         = $(AM_LDFLAGS)
 splash_util_LDADD           = libfbsplashrender.la libfbsplash.la
 
+if CONFIG_STATIC_BINARIES
+eexecsbin_PROGRAMS += fbsplashctl
+
 fbsplashctl_SOURCES         = $(fbsplashd_SOURCES) $(splash_util_SOURCES) fbsplashctl.c
 fbsplashctl_CFLAGS          = $(AM_CFLAGS) $(PTHREAD_STATIC_CFLAGS) $(RT_CFLAGS) $(libfbsplashrender_la_CFLAGS) -DUNIFIED_BUILD
 fbsplashctl_CPPFLAGS        = $(fbsplashd_CPPFLAGS) $(splash_util_CPPFLAGS)
@@ -210,6 +212,7 @@ uninstall-hook:
 if CONFIG_FBCON_DECOR
 	rm -f $(DESTDIR)$(eexecsbindir)/fbcondecor_ctl.static$(EXEEXT)
 endif
+endif
 
 ################################################################################
 # Kernel
@@ -219,6 +222,7 @@ if CONFIG_HELPER
 eexecsbin_PROGRAMS  += fbcondecor_helper
 endif
 
+if CONFIG_KLIBC
 fbcondecor_helper_SOURCES = \
 	kernel.c \
 	libfbsplash.c \
@@ -236,10 +240,12 @@ fbcondecor_helper_SOURCES = \
 	common.h \
 	render.h \
 	fbsplash.h
+
 fbcondecor_helper_CPPFLAGS  = -DWITH_ERRLIST -DTARGET_KERNEL -DTT_CONFIG_OPTION_BYTECODE_INTERPRETER
 fbcondecor_helper_CFLAGS    = -Os -w -ffunction-sections -fdata-sections -I.@am__isrc@
 fbcondecor_helper_LDFLAGS   = 
 fbcondecor_helper_LDADD     = 
+
 fbcondecor_helper_CFLAGS   += -I$(abs_top_builddir)/libs/libjpeg -I$(LIBJPEG_SOURCE)
 fbcondecor_helper_LDADD    += $(top_builddir)/libs/libjpeg.a
 if CONFIG_PNG
@@ -280,3 +286,29 @@ fbcondecor_helper-%.o: %.c
 	@$(call infmsg,CC,$@)
 	$(Q)$(MKDIR_P) $(@D)
 	$(Q)$(KLCC) $(fbcondecor_helper_CPPFLAGS) $(fbcondecor_helper_CFLAGS) $(INCLUDES) -c $< -o $@
+else
+fbcondecor_helper_SOURCES = \
+	kernel.c \
+	libfbsplash.c \
+	libfbsplashrender.c \
+	fbcon_decor.c \
+	common.c \
+	parse.c \
+	list.c \
+	render.c \
+	image.c \
+	effects.c \
+	fbcon_decor.h \
+	../include/console_decor.h \
+	../include/fbcondecor.h \
+	common.h \
+	render.h \
+	fbsplash.h
+if CONFIG_TTF_KERNEL
+fbcondecor_helper_SOURCES  += ttf.c ttf.h
+endif
+fbcondecor_helper_CPPFLAGS = $(AM_CPPFLAGS) -DTARGET_KERNEL
+fbcondecor_helper_CFLAGS   = $(AM_CFLAGS) $(libfbsplashrender_la_CFLAGS)
+fbcondecor_helper_LDFLAGS  = $(AM_LDFLAGS)
+fbcondecor_helper_LDADD    = $(libfbsplashrender_la_LIBADD)
+endif
-- 
1.6.5.GIT