diff --git a/buildtools/gen-pmdinfo-cfile.sh b/buildtools/gen-pmdinfo-cfile.sh
new file mode 100755
index 000000000..a042375a8
--- /dev/null
+++ b/buildtools/gen-pmdinfo-cfile.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+#   BSD LICENSE
+#
+#   Copyright(c) 2017 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+input=$1
+output=$2
+pmdinfogen=$3
+CFLAGS=$4
+build_root=$5
+
+tmp_o=${output%.c.pmd.o}.o
+tmp_c=${output%.o}.c
+
+set -x
+cc -Wfatal-errors $CFLAGS -I$build_root -include rte_config.h -c $input -o $tmp_o && \
+		$pmdinfogen $tmp_o $tmp_c && \
+		cc -c $tmp_c -o $output
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 92206f912..a08000be0 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -30,3 +30,5 @@
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 subdir('pmdinfogen')
+
+pmdinfo = find_program('gen-pmdinfo-cfile.sh')
diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build
index a6d0bf4e4..e1c3e17a9 100644
--- a/drivers/net/i40e/meson.build
+++ b/drivers/net/i40e/meson.build
@@ -47,21 +47,35 @@ sources = files(
 	'rte_pmd_i40e.c'
 	)
 
+deps = [rte_eal, rte_net,
+	rte_mbuf, rte_ether,
+	rte_mempool, rte_ring,
+	rte_hash, rte_kvargs]
+
 if arch_subdir == 'x86'
 	sources += files('i40e_rxtx_vec_sse.c')
 endif
 
-pmdinfogen_srcs = run_command('grep', '--files-with-matches', 'RTE_PMD_REGISTER_.*(.*)', sources).stdout().strip().split()
-message(pmdinfogen_srcs)
-
 install_headers('rte_pmd_i40e.h')
 
-i40e_lib = library('rte_pmd_i40e', sources,
+pmdinfogen_srcs = run_command('grep', '--files-with-matches',
+		'RTE_PMD_REGISTER_.*(.*)', sources).stdout().strip().split()
+objs = []
+foreach src: pmdinfogen_srcs
+	out_filename = '@0@.pmd.o'.format(src.split('/')[-1])
+	pmd_o_file = custom_target(out_filename,
+			command: [pmdinfo, '@INPUT@', '@OUTPUT@',
+			pmdinfogen.full_path(),
+			' '.join(dpdk_includes + i40e_cflags + ['-march=@0@'.format(machine)]),
+			meson.build_root()],
+			input: src, output: out_filename,
+			depends: pmdinfogen)
+	objs += pmd_o_file
+endforeach
+
+i40e_lib = library('rte_pmd_i40e', sources, objs,
 	include_directories: include_directories('base'),
-	dependencies: [rte_eal, rte_net,
-			rte_mbuf, rte_ether,
-			rte_mempool, rte_ring,
-			rte_hash, rte_kvargs],
+	dependencies: deps,
 	link_with: base_lib,
 	c_args: i40e_cflags,
 	install: true,
diff --git a/lib/librte_cmdline/meson.build b/lib/librte_cmdline/meson.build
index ceac0a429..0b909b77e 100644
--- a/lib/librte_cmdline/meson.build
+++ b/lib/librte_cmdline/meson.build
@@ -29,7 +29,7 @@
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-sources = [ 'cmdline.c',
+sources = files('cmdline.c',
 	'cmdline_cirbuf.c',
 	'cmdline_parse.c',
 	'cmdline_parse_etheraddr.c',
@@ -39,9 +39,9 @@ sources = [ 'cmdline.c',
 	'cmdline_parse_string.c',
 	'cmdline_rdline.c',
 	'cmdline_socket.c',
-	'cmdline_vt100.c']
+	'cmdline_vt100.c')
 
-install_headers('cmdline.h',
+headers = ['cmdline.h',
 	'cmdline_parse.h',
 	'cmdline_parse_num.h',
 	'cmdline_parse_ipaddr.h',
@@ -51,13 +51,12 @@ install_headers('cmdline.h',
 	'cmdline_vt100.h',
 	'cmdline_socket.h',
 	'cmdline_cirbuf.h',
-	'cmdline_parse_portlist.h')
+	'cmdline_parse_portlist.h']
 
-cmdline_lib = library('rte_cmdline', sources, dependencies: rte_eal,
+install_headers(headers)
+
+lib = library('rte_cmdline', sources, dependencies: rte_eal,
 		install: true)
-rte_cmdline = declare_dependency(link_with: cmdline_lib,
+rte_cmdline = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += cmdline_lib
-
-dpdk_conf.set('RTE_LIBRTE_CMDLINE', 1)
diff --git a/lib/librte_eal/common/include/arch/meson.build b/lib/librte_eal/common/include/arch/meson.build
index 863d7e4bb..0bf3ee94d 100644
--- a/lib/librte_eal/common/include/arch/meson.build
+++ b/lib/librte_eal/common/include/arch/meson.build
@@ -30,4 +30,5 @@
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 eal_inc += include_directories(arch_subdir)
+dpdk_includes += '-I@0@/@1@'.format(meson.current_source_dir(), arch_subdir)
 subdir(arch_subdir)
diff --git a/lib/librte_eal/common/include/meson.build b/lib/librte_eal/common/include/meson.build
index e92c4eb7c..6d61c8003 100644
--- a/lib/librte_eal/common/include/meson.build
+++ b/lib/librte_eal/common/include/meson.build
@@ -30,6 +30,7 @@
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 eal_inc += include_directories('.')
+dpdk_includes += '-I@0@'.format(meson.current_source_dir())
 
 common_headers = [
 	'rte_alarm.h',
diff --git a/lib/librte_eal/linuxapp/eal/meson.build b/lib/librte_eal/linuxapp/eal/meson.build
index 79fcff42f..f8547a8a4 100644
--- a/lib/librte_eal/linuxapp/eal/meson.build
+++ b/lib/librte_eal/linuxapp/eal/meson.build
@@ -30,6 +30,7 @@
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 eal_inc += include_directories('include')
+dpdk_includes += '-I@0@/include'.format(meson.current_source_dir())
 install_subdir('include/exec-env', install_dir: 'include')
 
 sources = ['eal_alarm.c',
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 219501c86..dec6baedd 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -31,6 +31,7 @@
 
 eal_inc = [global_inc]
 subdir('common')
+
 if host_machine.system() == 'linux'
 	dpdk_conf.set('RTE_EXEC_ENV_LINUXAPP', 1)
 	subdir('linuxapp')
diff --git a/lib/librte_ether/meson.build b/lib/librte_ether/meson.build
index 55eabd23a..e9ef496ad 100644
--- a/lib/librte_ether/meson.build
+++ b/lib/librte_ether/meson.build
@@ -40,10 +40,9 @@ install_headers('rte_ethdev.h',
 	'rte_flow.h',
 	'rte_flow_driver.h')
 
-ether_lib = library('rte_ether', sources,
+lib = library('rte_ether', sources,
 	dependencies: [rte_eal, rte_ring, rte_mempool, rte_net, rte_mbuf],
 	install: true)
-rte_ether = declare_dependency(link_with: ether_lib,
+rte_ether = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += ether_lib
diff --git a/lib/librte_hash/meson.build b/lib/librte_hash/meson.build
index 6d8270b51..48d0ecf80 100644
--- a/lib/librte_hash/meson.build
+++ b/lib/librte_hash/meson.build
@@ -45,10 +45,9 @@ headers = ['rte_cmp_arm64.h',
 
 install_headers(headers)
 
-hash_lib = library('rte_hash', sources,
+lib = library('rte_hash', sources,
 	dependencies: [rte_eal, rte_ring, rte_compat],
 	install: true)
-rte_hash = declare_dependency(link_with: hash_lib,
+rte_hash = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += hash_lib
diff --git a/lib/librte_kvargs/meson.build b/lib/librte_kvargs/meson.build
index 6cd5ab377..bc79d55e9 100644
--- a/lib/librte_kvargs/meson.build
+++ b/lib/librte_kvargs/meson.build
@@ -34,10 +34,9 @@ sources = ['rte_kvargs.c']
 
 install_headers('rte_kvargs.h')
 
-kvargs_lib = library('rte_kvargs', sources,
+lib = library('rte_kvargs', sources,
 	dependencies: rte_eal,
 	install: true)
-rte_kvargs = declare_dependency(link_with: kvargs_lib,
+rte_kvargs = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += kvargs_lib
diff --git a/lib/librte_mbuf/meson.build b/lib/librte_mbuf/meson.build
index 7926e7236..0a302f464 100644
--- a/lib/librte_mbuf/meson.build
+++ b/lib/librte_mbuf/meson.build
@@ -33,10 +33,9 @@ sources = ['rte_mbuf.c', 'rte_mbuf_ptype.c']
 
 install_headers('rte_mbuf.h', 'rte_mbuf_ptype.h')
 
-mbuf_lib = library('rte_mbuf', sources,
+lib = library('rte_mbuf', sources,
 	dependencies: [rte_eal, rte_mempool, rte_ring],
 	install: true)
-rte_mbuf = declare_dependency(link_with: mbuf_lib,
+rte_mbuf = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += mbuf_lib
diff --git a/lib/librte_mempool/meson.build b/lib/librte_mempool/meson.build
index 6da2403cc..15c5e6695 100644
--- a/lib/librte_mempool/meson.build
+++ b/lib/librte_mempool/meson.build
@@ -34,10 +34,9 @@ sources = ['rte_mempool.c', 'rte_mempool_ops.c']
 
 install_headers('rte_mempool.h')
 
-mempool_lib = library('rte_mempool', sources,
+lib = library('rte_mempool', sources,
 	dependencies: [rte_eal, rte_ring],
 	install: true)
-rte_mempool = declare_dependency(link_with: mempool_lib,
+rte_mempool = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += mempool_lib
diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build
index 7c8e323f6..f4df1691f 100644
--- a/lib/librte_net/meson.build
+++ b/lib/librte_net/meson.build
@@ -43,10 +43,9 @@ install_headers('rte_ip.h',
 	'rte_net.h',
 	'rte_net_crc.h')
 
-net_lib = library('rte_net', sources,
+lib = library('rte_net', sources,
 	dependencies: [rte_eal, rte_mbuf, rte_ring, rte_mempool],
 	install: true)
-rte_net = declare_dependency(link_with: net_lib,
+rte_net = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += net_lib
diff --git a/lib/librte_ring/meson.build b/lib/librte_ring/meson.build
index 5832a7632..20e623e9d 100644
--- a/lib/librte_ring/meson.build
+++ b/lib/librte_ring/meson.build
@@ -34,10 +34,9 @@ sources = ['rte_ring.c']
 
 install_headers('rte_ring.h')
 
-ring_lib = library('rte_ring', sources,
+lib = library('rte_ring', sources,
 	dependencies: rte_eal,
 	install: true)
-rte_ring = declare_dependency(link_with: ring_lib,
+rte_ring = declare_dependency(link_with: lib,
 	include_directories: include_directories('.'))
 
-dpdk_libraries += ring_lib
diff --git a/lib/meson.build b/lib/meson.build
index 0ea608684..0af9eb706 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -29,13 +29,26 @@
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+# special case for eal, not a simple lib
 subdir('librte_eal')
-subdir('librte_ring')
-subdir('librte_mempool')
-subdir('librte_cmdline')
-subdir('librte_mbuf')
-subdir('librte_net')
-subdir('librte_ether')
-subdir('librte_compat')
-subdir('librte_hash')
-subdir('librte_kvargs')
+
+# process all libraries equally, as far as possible
+libs = ['ring', 'mempool', 'cmdline', 'mbuf', 'net', 'ether', 'compat', 'hash', 'kvargs']
+foreach l:libs
+
+	dpdk_conf.set('RTE_LIBRTE_@0@'.format(l.to_upper()),1)
+	subdir('librte_@0@'.format(l))
+	dpdk_libraries = [lib] + dpdk_libraries
+	dpdk_includes += '-I@0@/librte_@1@'.format(meson.current_source_dir(), l)
+
+endforeach
+
+#subdir('librte_ring')
+#subdir('librte_mempool')
+#subdir('librte_cmdline')
+#subdir('librte_mbuf')
+#subdir('librte_net')
+#subdir('librte_ether')
+#subdir('librte_compat')
+#subdir('librte_hash')
+#subdir('librte_kvargs')
diff --git a/meson.build b/meson.build
index 54bb4632e..a0ab08252 100644
--- a/meson.build
+++ b/meson.build
@@ -51,8 +51,11 @@ else
 endif
 
 # configure the build, and make sure configs here and in config folder are
-# able to be included in any file
+# able to be included in any file. We also store a global array of include dirs
+# for passing to pmdinfogen scripts
 global_inc = include_directories('.', 'config')
+dpdk_includes = ['-I@0@'.format(meson.current_source_dir()),
+		'-I@0@/config'.format(meson.current_source_dir())]
 subdir('config')
 
 # now build libs and drivers
@@ -71,16 +74,10 @@ if get_option('default_library') == 'static'
 	dpdk_libraries = dpdk_drivers + dpdk_libraries
 endif
 
-# the DPDK libs needs to be passed to the link command in reverse order
-dpdk_link_libs = []
-foreach lib: dpdk_libraries
-	dpdk_link_libs = [lib] + dpdk_link_libs
-endforeach
-
 pkg = import('pkgconfig')
 pkg.generate(name: meson.project_name(),
 	version: meson.project_version(),
-	libraries: dpdk_link_libs,
+	libraries: dpdk_libraries,
 	description: 'The Data Plane Development Kit (DPDK)',
 	extra_cflags: '-include "rte_config.h"'
 )
