meson: link flashrom binary against static libflashrom

TEST: meson build && ninja -C build
      Read chip successfully with ch341a_spi programmer

Change-Id: Ic522610f59e00299ebfa1bd29482ff92120ec52b
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/64030
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72335
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/meson.build b/meson.build
index 42661df..252bd01 100644
--- a/meson.build
+++ b/meson.build
@@ -403,7 +403,7 @@
 
 mapfile = 'libflashrom.map'
 vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
-flashrom = library(
+libflashrom = both_libraries(
   'flashrom',
   sources : [
     srcs,
@@ -433,7 +433,7 @@
 
 pkgg = import('pkgconfig')
 pkgg.generate(
-  libraries : flashrom,
+  libraries : libflashrom,
   version : version,
   name : 'flashrom',
   filebase : 'flashrom',
@@ -450,31 +450,18 @@
   install_dir: join_paths(get_option('mandir'), 'man8'),
 )
 
-flashrom_dep = declare_dependency(
-  link_with : flashrom,
-  include_directories : include_dir,
-  dependencies : deps
-)
-
-# we can't just link_with libflashrom as we require all the internal symbols...
 executable(
   'flashrom',
-  sources : [
-    srcs,
+  files(
     'cli_classic.c',
     'cli_common.c',
     'cli_output.c',
-    'flashrom.c',
-  ],
+  ),
+  c_args : cargs,
   include_directories : include_dir,
-  dependencies : [
-    deps,
-  ],
-  c_args : [
-    cargs,
-  ],
   install : true,
-  install_dir : get_option('sbindir')
+  install_dir : get_option('sbindir'),
+  link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
 )
 
 subdir('util')