Yubico / yubico-piv-tool

Command line tool for the YubiKey PIV application
https://developers.yubico.com/yubico-piv-tool
BSD 2-Clause "Simplified" License
290 stars 97 forks source link

Build fails on Yosemite #28

Closed techdragon closed 9 years ago

techdragon commented 9 years ago
$ ./configure
checking for a BSD-compatible install... /opt/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /opt/local/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking whether clang understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of clang... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... x86_64-apple-darwin14.4.0
checking host system type... x86_64-apple-darwin14.4.0
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/local/bin/gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by clang... /opt/local/libexec/llvm-3.4/bin/ld
checking if the linker (/opt/local/libexec/llvm-3.4/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /opt/local/bin/nm
checking the name lister (/opt/local/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin14.4.0 file names to x86_64-apple-darwin14.4.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin14.4.0 file names to toolchain format... func_convert_file_noop
checking for /opt/local/libexec/llvm-3.4/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /opt/local/bin/nm output from clang object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking how to run the C preprocessor... clang -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if clang supports -fno-rtti -fno-exceptions... yes
checking for clang option to produce PIC... -fno-common -DPIC
checking if clang PIC flag -fno-common -DPIC works... yes
checking if clang static flag -static works... no
checking if clang supports -c -o file.o... yes
checking if clang supports -c -o file.o... (cached) yes
checking whether the clang linker (/opt/local/libexec/llvm-3.4/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin14.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /opt/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for OPENSSL... yes
checking if LD -Wl,--version-script works... no
checking for valgrind... no
checking whether self tests are run under valgrind... no
configure: Detected Mac: selecting macscard backend
configure: use --with-backend to override
configure: checking for PCSC with Mac linkage
checking PCSC/winscard.h usability... yes
checking PCSC/winscard.h presence... yes
checking for PCSC/winscard.h... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating lib/tests/Makefile
config.status: creating tool/Makefile
config.status: creating tool/tests/Makefile
config.status: creating lib/ykpiv-version.h
config.status: creating lib/ykpiv.pc
config.status: executing depfiles commands
config.status: executing libtool commands
configure: summary of build options:

  Version:          1.0.2
  Host type:        x86_64-apple-darwin14.4.0
  Install prefix:   /usr/local
  Compiler:         clang
  CFLAGS:           -g -O2
  CPPFLAGS:         
  Warnings:         
  Backend:          macscard
  PCSC
          CFLAGS:   
            LIBS:   
  Winscard
            LIBS:   
  Mac PCSC
            LIBS:   -Wl,-framework -Wl,PCSC
$ make
Making all in lib
Making all in .
  CC       ykpiv.lo
/usr/include/module.map:1:25: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module Darwin [system] [extern_c] {
                        ^
/usr/include/module.map:1561:21: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module os [system] [extern_c] {
                    ^
/usr/include/module.map:1577:26: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module libkern [system] [extern_c] {
                         ^
/usr/include/module.map:1602:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module ldap [system] [extern_c] {
                      ^
/usr/include/module.map:1635:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module krb5 [system] [extern_c] {
                      ^
/usr/include/module.map:1662:22: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module XPC [system] [extern_c] {
                     ^
ykpiv.c:145:53: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Wincompatible-pointer-types]
  rc = SCardListReaders(state->context, NULL, NULL, &num_readers);
                                                    ^~~~~~~~~~~~
/System/Library/Frameworks/PCSC.framework/Headers/winscard.h:111:67: note: passing argument to parameter 'pcchReaders' here
                                      char *mszReaders, uint32_t *pcchReaders);
                                                                  ^
ykpiv.c:158:59: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Wincompatible-pointer-types]
  rc = SCardListReaders(state->context, NULL, reader_buf, &num_readers);
                                                          ^~~~~~~~~~~~
/System/Library/Frameworks/PCSC.framework/Headers/winscard.h:111:67: note: passing argument to parameter 'pcchReaders' here
                                      char *mszReaders, uint32_t *pcchReaders);
                                                                  ^
ykpiv.c:193:40: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Wincompatible-pointer-types]
      SCARD_PROTOCOL_T1, &state->card, &active_protocol);
                                       ^~~~~~~~~~~~~~~~
/System/Library/Frameworks/PCSC.framework/Headers/winscard.h:67:67: note: passing argument to parameter 'pdwActiveProtocol' here
                                  LPSCARDHANDLE phCard, uint32_t *pdwActiveProtocol);
                                                                  ^
ykpiv.c:327:82: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Wincompatible-pointer-types]
  rc = SCardTransmit(state->card, SCARD_PCI_T1, apdu->raw, send_len, NULL, data, recv_len);
                                                                                 ^~~~~~~~
/System/Library/Frameworks/PCSC.framework/Headers/winscard.h:104:75: note: passing argument to parameter 'pcbRecvLength' here
                                   unsigned char *pbRecvBuffer, uint32_t *pcbRecvLength);
                                                                          ^
10 warnings generated.
  CC       version.lo
/usr/include/module.map:1:25: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module Darwin [system] [extern_c] {
                        ^
/usr/include/module.map:1561:21: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module os [system] [extern_c] {
                    ^
/usr/include/module.map:1577:26: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module libkern [system] [extern_c] {
                         ^
/usr/include/module.map:1602:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module ldap [system] [extern_c] {
                      ^
/usr/include/module.map:1635:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module krb5 [system] [extern_c] {
                      ^
/usr/include/module.map:1662:22: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module XPC [system] [extern_c] {
                     ^
6 warnings generated.
  CC       error.lo
/usr/include/module.map:1:25: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module Darwin [system] [extern_c] {
                        ^
/usr/include/module.map:1561:21: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module os [system] [extern_c] {
                    ^
/usr/include/module.map:1577:26: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module libkern [system] [extern_c] {
                         ^
/usr/include/module.map:1602:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module ldap [system] [extern_c] {
                      ^
/usr/include/module.map:1635:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module krb5 [system] [extern_c] {
                      ^
/usr/include/module.map:1662:22: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module XPC [system] [extern_c] {
                     ^
6 warnings generated.
  CCLD     libykpiv.la
Making all in tests
make[2]: Nothing to be done for `all'.
Making all in tool
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in .
  CC       util.lo
/usr/include/module.map:1:25: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module Darwin [system] [extern_c] {
                        ^
/usr/include/module.map:1561:21: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module os [system] [extern_c] {
                    ^
/usr/include/module.map:1577:26: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module libkern [system] [extern_c] {
                         ^
/usr/include/module.map:1602:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module ldap [system] [extern_c] {
                      ^
/usr/include/module.map:1635:23: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module krb5 [system] [extern_c] {
                      ^
/usr/include/module.map:1662:22: warning: unknown attribute 'extern_c' [-Wignored-attributes]
module XPC [system] [extern_c] {
                     ^
util.c:203:10: error: use of undeclared identifier 'slot__NULL'
    case slot__NULL:
         ^
6 warnings and 1 error generated.
make[3]: *** [util.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

The prebuilt version on the releases page works, but you provide no install instructions, only compile instructions, and since there are crypto libraries included in the zip, naively overwriting the versions of these files I already have in /usr/local/include/ /usr/local/lib/ etc, would be extremely foolish.

klali commented 9 years ago

Hello,

There's a homebrew package for yubico-piv-tool, no macports as far as I know.

I'd suggest you go with the source package (the tar.gz) from https://developers.yubico.com/yubico-piv-tool/Releases/ instead of compiling current master. The README lists the dependencies that should be necessary, the notable for ocmpiling from git being help2man and gengetopt (version 2.22.6) with this it should compile from source.

/klas

techdragon commented 9 years ago

So I've tried the release tar.gz and it has the same issues. gcc, and clang, both die when they try to compile this code.

util.c:203:10: error: use of undeclared identifier 'slot__NULL'
    case slot__NULL:
         ^

I'm not a C programer, and trying to google this is much less than helpful. But from what I can deduce, it appears that my system is not correctly generating cmdline.h. Something is wrong with how gengetopt is handling things. In the dpkg version of this repo, cmdline.h looks like this https://github.com/Yubico/yubico-piv-tool-dpkg/blob/master/tool/cmdline.h#L42 But my generated version lacks slot__NULL, in fact it appears to lack all the __NULL options that appear in the dpkg version of this file. I can only assume is that something else is wrong with the environment in which I am compiling the code, something that isn't being found by the configure scripts which causes gengetopt to work incorrectly.

Edit: I've confirmed this is the root cause of the behaviour. I'm able to successfully complete both make and make --install when I use the https://github.com/Yubico/yubico-piv-tool-dpkg repo. However I'm still not sure what the issue with gengetopt is. I did notice a minor version number difference, but it seems unusual that being 2 minor revisions behind the version of gengetopt that generated the files in the dpkg repo would be the cause.

klali commented 9 years ago

Yes, there is this difference between gengetopt 2.22.4 and 2.22.6 though if you download the release tarball from https://developers.yubico.com/yubico-piv-tool/Releases/ (not from github, the github releases are broken) you shouldn't need gengetopt at all.