11use std:: env;
22
3+ fn print_pcsclite_error_message ( target_os : & str ) {
4+ if target_os == "linux" {
5+ eprintln ! (
6+ "If you are using Debian (or a derivative), try:
7+
8+ $ sudo apt install pkgconf libpcsclite-dev
9+ "
10+ ) ;
11+ eprintln ! (
12+ "If you are using Arch (or a derivative), try:
13+
14+ $ sudo pacman -S pkgconf pcsclite
15+ "
16+ ) ;
17+ eprintln ! (
18+ "If you are using Fedora (or a derivative), try:
19+
20+ $ sudo dnf install pkgconf pcsc-lite-devel
21+ "
22+ ) ;
23+ }
24+ }
25+
326fn main ( ) {
427 let target_os = env:: var ( "CARGO_CFG_TARGET_OS" )
528 . expect ( r#"The CARGO_CFG_TARGET_OS environment is not set in the build script."# ) ;
@@ -25,17 +48,16 @@ fn main() {
2548 env:: var( "PCSC_LIB_NAME" ) . unwrap_or_else( |_| "pcsclite" . to_string( ) )
2649 ) ;
2750 } else {
28- pkg_config:: Config :: new ( )
29- . atleast_version ( "1" )
30- . probe ( "libpcsclite" )
31- . unwrap_or_else ( |_| {
32- panic ! (
33- r#"Could not find a PCSC library.
34- For the target OS `{}`, I tried to use pkg-config to find libpcsclite.
35- Do you have pkg-config and libpcsclite configured for this target?"# ,
36- target_os
37- )
38- } ) ;
51+ if let Err ( err) = pkg_config:: Config :: new ( ) . atleast_version ( "1" ) . probe ( "libpcsclite" ) {
52+ eprintln ! ( "Could not find a PCSC library." ) ;
53+ eprintln ! (
54+ "For the target OS `{}`, I tried to use pkg-config to find libpcsclite." ,
55+ target_os
56+ ) ;
57+ eprintln ! ( "The error given is: {}" , err) ;
58+ print_pcsclite_error_message ( & target_os) ;
59+ std:: process:: exit ( 1 ) ;
60+ }
3961 }
4062 }
4163 } ;
0 commit comments