Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[libusbg] Clean-up configuration and make libusbg module compile
configure.ac is cleaned up and now also can selectivly use libusbg
or libkmod. Also linker flags are now shown after the configure run.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Dec 12, 2014
1 parent 03d6300 commit de3c9ff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
17 changes: 11 additions & 6 deletions configure.ac
Expand Up @@ -32,7 +32,7 @@ AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug],[Enable debug @<:@default
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])

AC_ARG_ENABLE([nokia], AS_HELP_STRING([--enable-nokia], [Enable Nokia extra's @<:@default=false@:>@]),
AC_ARG_ENABLE([nokia], AS_HELP_STRING([--enable-nokia], [Enable Nokia extras @<:@default=false@:>@]),
[case "${enableval}" in
yes) nokia=true ; CFLAGS="-DNOKIA -DN900 $CFLAGS" ;;
no) nokia=false ;;
Expand All @@ -48,7 +48,7 @@ AC_ARG_ENABLE([meegodevlock], AS_HELP_STRING([--enable-meegodevlock], [Enable Me
esac],[meegodevlock=false])
AM_CONDITIONAL([MEEGOLOCK], [test x$meegodevlock = xtrue])

AC_ARG_ENABLE([n900], AS_HELP_STRING([--enable-n900], [Enable N900 extra's @<:@default=false@:>@]),
AC_ARG_ENABLE([n900], AS_HELP_STRING([--enable-n900], [Enable N900 extras @<:@default=false@:>@]),
[case "${enableval}" in
yes) n900=true ; CFLAGS="-DN900 $CFLAGS" ;;
no) n900=false ;;
Expand Down Expand Up @@ -106,24 +106,29 @@ AM_CONDITIONAL([OFONO], [test x$ofono = xtrue])

AC_ARG_ENABLE([libusbg], AS_HELP_STRING([--enable-libusbg], [Enable the use of libusbg to use the USB gadgetfs @<:@default=false@:>@]),
[case "${enableval}" in
yes) libusbg=true ; CFLAGS="-DLIBUSBG $CFLAGS" ;;
yes) libusbg=true ; PKG_CHECK_MODULES([LIBUSBG], [libusbg]); CFLAGS="-DLIBUSBG $CFLAGS" ;;
no) libusbg=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-libusbg]) ;;
esac],[libusbg=false])
AM_CONDITIONAL([LIBUSBG], [test x$libusbg = xtrue])

if test "x$libusbg" = xfalse ; then
PKG_CHECK_MODULES([KMOD], [libkmod])
fi

PKG_CHECK_MODULES([USB_MODED], [
glib-2.0 >= 2.24.0
dbus-1 >= 1.2.1
dbus-glib-1 >= 0.78
gobject-2.0 >= 2.16.6
gio-2.0
libudev
libkmod
])

AC_SUBST(USB_MODED_LIBS)
AC_SUBST(USB_MODED_CFLAGS)
AC_SUBST(LIBUSBG_LIBS)
AC_SUBST(KMOD_LIBS)

AC_CONFIG_FILES([
Makefile
Expand All @@ -137,8 +142,8 @@ echo "
== $PACKAGE_NAME $VERSION ==

Compiler: ${CC}
CFLAGS: ${CFLAGS}
LDFLAGS: ${LDFLAGS}
CFLAGS: ${CFLAGS} ${USB_MODED_CFLAGS}
LDFLAGS: ${LDFLAGS} ${USB_MODED_LIBS} ${LIBUSBG_LIBS} ${KMOD_LIBS}

Debug enabled: ${debug}
"
Expand Down
17 changes: 14 additions & 3 deletions src/Makefile.am
Expand Up @@ -8,7 +8,9 @@ usb_moded_LDFLAGS = \
-Wl,--as-needed

usb_moded_LDADD = \
$(USB_MODED_LIBS)
$(USB_MODED_LIBS) \
$(LIBUSBG_LIBS) \
$(KMOD_LIBS)

usb_moded_SOURCES = \
usb_moded.c \
Expand All @@ -34,10 +36,17 @@ usb_moded_SOURCES = \
usb_moded-dyn-config.h \
usb_moded-udev.c \
usb_moded-trigger.c \
usb_moded-modules.c \
usb_moded-android.h \
usb_moded-android.c

if LIBUSBG
usb_moded_SOURCES += \
usb_moded-modules-libusbg.c
else
usb_moded_SOURCES += \
usb_moded-modules.c
endif

if MEEGOLOCK
usb_moded_SOURCES += \
usb_moded-devicelock.h \
Expand Down Expand Up @@ -74,7 +83,9 @@ usb_moded_util_LDFLAGS = \
-Wl,--as-needed

usb_moded_util_LDADD = \
$(USB_MODED_LIBS)
$(USB_MODED_LIBS) \
$(LIBUSBG_LIBS) \
$(KMOD_LIBS)

usb_moded_util_SOURCES = \
usb_moded-util.c
19 changes: 18 additions & 1 deletion src/usb_moded-modules-libusbg.c
Expand Up @@ -27,7 +27,7 @@

#include <glib.h>

#include <libkmod.h>
#include <usbg/usbg.h>

#include "usb_moded.h"
#include "usb_moded-modules.h"
Expand All @@ -38,6 +38,21 @@
#include "usb_moded-config.h"
#include "usb_moded-modesetting.h"

/* module context init and cleanup functions */
void usb_moded_module_ctx_init(void)
{
usbg_state *s;
int usbg_ret;

usbg_ret = usbg_init("/sys/kernel/config", &s);
if (usbg_ret != USBG_SUCCESS)
fprintf(stderr, "Error on USB gadget init\n");

}

void usb_moded_module_ctx_cleanup(void)
{
}

/** load module
*
Expand All @@ -48,6 +63,7 @@
*/
int usb_moded_load_module(const char *module)
{
return (0);
}

/** unload module
Expand All @@ -59,6 +75,7 @@ int usb_moded_load_module(const char *module)
*/
int usb_moded_unload_module(const char *module)
{
return (0);
}

/** Check which state a module is in
Expand Down

0 comments on commit de3c9ff

Please sign in to comment.