Skip to content

Instantly share code, notes, and snippets.

@codestation
Created May 2, 2013 05:00
Show Gist options
  • Save codestation/5500223 to your computer and use it in GitHub Desktop.
Save codestation/5500223 to your computer and use it in GitHub Desktop.
diff --git a/configure.ac b/configure.ac
index b32e159..5e95a4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,8 +18,10 @@ AC_PROG_INSTALL
# Checks for libraries.
AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([libpthread not found])])
-AC_CHECK_LIB([xml2], [xmlReadMemory], [], [AC_MSG_ERROR([libxml2 not found])])
PKG_CHECK_MODULES(MTP, libmtp, found_libmtp=yes, found_libmtp=no)
+PKG_CHECK_MODULES(XML, libxml-2.0)
+AC_SUBST(XML_CFLAGS)
+AC_SUBST(XML_LIBS)
AC_SUBST(MTP_CFLAGS)
AC_SUBST(MTP_LIBS)
AC_SUBST(MTP_STATIC_LIBS)
@@ -32,6 +34,13 @@ fi
# Checks for header files.
AC_CHECK_HEADERS([errno.h fcntl.h limits.h stdlib.h string.h sys/statvfs.h unistd.h], [], [AC_MSG_ERROR([Cannot find required header.])])
+case $host_os in
+ linux*)
+ OS_CFLAGS="-D_XOPEN_SOURCE=600 -D__USE_XOPEN"
+esac
+
+AC_SUBST(OS_CFLAGS)
+
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_OFF_T
diff --git a/libvitamtp.pc.in b/libvitamtp.pc.in
index b604adc..99eb64b 100644
--- a/libvitamtp.pc.in
+++ b/libvitamtp.pc.in
@@ -8,6 +8,5 @@ Media transfer with PlayStation Vita
Version: @VERSION@
Libs: -L${libdir} -lvitamtp
Libs.private: @LIBS@
-Requires.private: libmtp >= 1.1.2
Cflags: -I${includedir}/libusb-1.0
diff --git a/src/Makefile.am b/src/Makefile.am
index a9320e3..1f3f385 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,17 +3,17 @@ include_HEADERS=vitamtp.h
# static library for linking
noinst_LIBRARIES=libvitamtp.a
libvitamtp_a_SOURCES=device.c vitamtp.c vitacma.c xmlparsing.c
-libvitamtp_a_CFLAGS=$(MTP_CFLAGS) -std=c99
+libvitamtp_a_CFLAGS=$(MTP_CFLAGS) $(XML_CFLAGS) $(OS_CFLAGS) -std=c99
# shared library for installing
lib_LTLIBRARIES=libvitamtp.la
libvitamtp_la_SOURCES=device.c vitamtp.c vitacma.c xmlparsing.c
-libvitamtp_la_LIBADD=$(LIBS) $(MTP_LIBS)
-libvitamtp_la_CFLAGS=$(MTP_CFLAGS) -std=c99
+libvitamtp_la_LIBADD=$(LIBS) $(MTP_LIBS) $(XML_LIBS)
+libvitamtp_la_CFLAGS=$(MTP_CFLAGS) $(XML_CFLAGS) $(OS_CFLAGS) -std=c99
# opencma program
bin_PROGRAMS=opencma
opencma_SOURCES=opencma.c database.c utilities.c
-opencma_CFLAGS=$(MTP_CFLAGS) -std=c99
-opencma_LDADD=libvitamtp.a $(MTP_STATIC_LIBS) $(LIBS)
+opencma_CFLAGS=$(MTP_CFLAGS) $(XML_CFLAGS) $(OS_CFLAGS) -std=c99
+opencma_LDADD=libvitamtp.a $(MTP_STATIC_LIBS) $(LIBS) $(XML_LIBS)
opencma_LDFLAGS=-static-libtool-libs
diff --git a/src/opencma.c b/src/opencma.c
index dc2e726..a566e96 100644
--- a/src/opencma.c
+++ b/src/opencma.c
@@ -20,6 +20,7 @@
#include <assert.h>
#include <limits.h>
+#include <fcntl.h>
#include <pthread.h>
#include <semaphore.h>
#include <signal.h>
diff --git a/src/utilities.c b/src/utilities.c
index 1f328c3..8f4ddb6 100644
--- a/src/utilities.c
+++ b/src/utilities.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
+#include <sys/select.h>
#include <unistd.h>
#include "opencma.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment