--- a/src/include.am
+++ b/src/include.am
@@ -7,9 +7,9 @@ noinst_HEADERS=
 
 MEGACMD = mega-cmd mega-exec mega-cmd-server
 bin_PROGRAMS += $(MEGACMD)
-$(MEGACMD): $(top_builddir)/sdk/src/libmega.la
+$(MEGACMD):
 noinst_HEADERS += src/comunicationsmanager.h src/configurationmanager.h src/megacmd.h src/megacmdlogger.h src/megacmdsandbox.h src/megacmdutils.h src/megacmdcommonutils.h src/listeners.h src/megacmdexecuter.h src/megacmdversion.h src/megacmdplatform.h src/comunicationsmanagerportsockets.h
-megacmdcompletiondir = $(sysconfdir)/bash_completion.d/
+megacmdcompletiondir = $(datarootdir)/bash-completion/completions
 megacmdcompletion_DATA = src/client/megacmd_completion.sh
 megacmdscripts_bindir = $(bindir)
 
@@ -20,20 +20,21 @@ mega_cmd_server_SOURCES = src/megacmd.cp
 mega_cmddir=examples
 
 #CMDCLIENT
-noinst_HEADERS += src/megacmdcommonutils.h src/megacmdshell/megacmdshellcommunications.h src/megacmdshell/megacmdshell.h sdk/include/mega/thread.h
+noinst_HEADERS += src/megacmdcommonutils.h src/megacmdshell/megacmdshellcommunications.h src/megacmdshell/megacmdshell.h
 
 mega_exec_SOURCES = src/megacmdcommonutils.cpp src/client/megacmdclient.cpp src/megacmdshell/megacmdshellcommunications.cpp
 mega_execdir=examples
 #mega_exec_CXXFLAGS = -std=c++11 -DUSE_CPPTHREAD=1 -Iinclude/
 #mega_exec_CXXFLAGS = -Iinclude/
 mega_exec_CXXFLAGS = -Isdk/include/ $(LMEGAINC)
+mega_exec_LDADD = $(RL_LDFLAGS) $(RL_LIBS) $(TERMCAP_LDFLAGS) $(TERMCAP_LIBS) $(MEGA_LIBS)
 
 #CMDSHELL
-noinst_HEADERS += src/megacmdcommonutils.h src/megacmdshell/megacmdshellcommunications.h src/megacmdshell/megacmdshell.h sdk/include/mega/thread.h
+noinst_HEADERS += src/megacmdcommonutils.h src/megacmdshell/megacmdshellcommunications.h src/megacmdshell/megacmdshell.h
 mega_cmd_SOURCES = src/megacmdcommonutils.cpp src/megacmdshell/megacmdshellcommunications.cpp src/megacmdshell/megacmdshell.cpp 
 
 mega_cmd_CXXFLAGS = $(RL_CXXFLAGS) -Isdk/include/ $(LMEGAINC)
-mega_cmd_LDADD = $(RL_LDFLAGS) $(RL_LIBS) $(TERMCAP_LDFLAGS) $(TERMCAP_LIBS) 
+mega_cmd_LDADD = $(RL_LDFLAGS) $(RL_LIBS) $(TERMCAP_LDFLAGS) $(TERMCAP_LIBS) $(MEGA_LIBS)
 
 mega_cmd_server_CXXFLAGS = $(LMEGAINC)
 if USE_PCRE
@@ -41,9 +42,7 @@ mega_cmd_server_CXXFLAGS += -DUSE_PCRE=1
 endif
 
 if WIN32
-noinst_HEADERS += src/megacmdshell/megacmdshellcommunicationsnamedpipes.h sdk/include/mega/thread.h sdk/include/mega/thread/win32thread.h sdk/include/mega/logging.h
-mega_cmd_SOURCES += src/megacmdshell/megacmdshellcommunicationsnamedpipes.cpp sdk/src/thread/win32thread.cpp sdk/src/logging.cpp
-mega_exec_SOURCES += src/megacmdshell/megacmdshellcommunicationsnamedpipes.cpp sdk/src/thread/win32thread.cpp sdk/src/logging.cpp
+noinst_HEADERS += src/megacmdshell/megacmdshellcommunicationsnamedpipes.h
 mega_cmd_server_SOURCES += src/comunicationsmanagernamedpipes.cpp
 
 mega_cmd_server_CXXFLAGS += -D_WIN32=1 -Isdk/include/ -Isdk/include/mega/win32
@@ -56,12 +55,10 @@ mega_cmd_LDADD += $(LIBS_EXTRA)
 
 else
 
-mega_cmd_server_LDADD=$(PCRE_LIBS) $(top_builddir)/sdk/src/libmega.la
+mega_cmd_server_LDADD=$(PCRE_LIBS) $(MEGA_LIBS)
 
 mega_cmd_server_SOURCES += src/comunicationsmanagerfilesockets.cpp
-noinst_HEADERS += src/comunicationsmanagerfilesockets.h sdk/include/mega/thread/posixthread.h sdk/include/mega/logging.h
-mega_cmd_SOURCES += sdk/src/thread/posixthread.cpp sdk/src/logging.cpp
-mega_exec_SOURCES += sdk/src/thread/posixthread.cpp sdk/src/logging.cpp
+noinst_HEADERS += src/comunicationsmanagerfilesockets.h
 
 #mega_cmd_CXXFLAGS += -DUSE_PTHREAD=1
 #mega_exec_CXXFLAGS += -DUSE_PTHREAD=1
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,6 @@ DISTCLEANFILES=
 BUILT_SOURCES=
 noinst_PROGRAMS=
 
-SUBDIRS = sdk
 include src/include.am
 
 #EXTRA_DIST += autogen.sh
--- a/configure.ac
+++ b/configure.ac
@@ -18,9 +18,6 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-m4_include([sdk/m4/ax_check_compile_flag.m4])
-m4_include([sdk/m4/ax_check_link_flag.m4])
-m4_include([sdk/m4/ax_cxx_compile_stdcxx.m4])
 
 m4_define([megacmd_major_version], [$(cat src/megacmdversion.h | grep "define MEGACMD_MAJOR" | cut -d" " -f 3)])
 m4_define([megacmd_minor_version], [$(cat src/megacmdversion.h | grep "define MEGACMD_MINOR" | cut -d" " -f 3)])
@@ -37,20 +34,18 @@ m4_define([megacmd_lt_age], [0])
 
 AC_INIT([MEGAcmd], m4_esyscmd([ grep define < src/megacmdversion.h | awk '{print $3}' | awk 'BEGIN { RS = "" ; FS = "\n" } {printf $1"."$2"."$3}']), [https://github.com/meganz/megacmd])
 
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([1.11 foreign silent-rules])
 
 AC_PROG_CC
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT
 
-AC_CONFIG_SUBDIRS(sdk)
 
 
 # Define _GNU_SOURCE
 # AC_GNU_SOURCE
 AC_USE_SYSTEM_EXTENSIONS
 
-AM_INIT_AUTOMAKE([1.11 foreign silent-rules])
 AC_CONFIG_HEADERS([src/megacmdconfig.h]) #this avoids inline definitions of stuff already defined in sdk's config.h (e.g: -DPACKAGE_NAME)
 
 LT_INIT([shared disable-static win32-dll])
@@ -449,7 +444,8 @@ AM_CONDITIONAL([HAVE_PTHREAD], [test "${
 #This will simulate compilation of sdk and extract the includes defined for it. Thus we can
 # take care of the configuration done for the subproject withtout having to recheck here
 AC_OUTPUT
-LMEGAINC=$(cd sdk; for i in $(make -n 2>/dev/null | grep "\-I" | grep megaapi ); do echo $i; done | grep "\-I" | sort | uniq | awk '{printf $0" "}')
+PKG_CHECK_MODULES([MEGA],[libmega])
+LMEGAINC=${MEGA_CFLAGS}
 AC_SUBST(LMEGAINC)
 
 # Output
