Opened 21 months ago

Closed 7 months ago

#4879 closed defect (fixed)

Fix macOS Monterey compile issues

Reported by: ohmza Owned by:
Priority: critical Component: General
Severity: high Keywords:
Cc: Sensitive: no

Description (last modified by ohmza)

Three files on source code need to be changed in order to make oscam being able to be compiled on macOS Monterey.

First, on Makefile

Change:

ifeq ($(uname_S),Darwin)
	DEFAULT_LIBUSB_FLAGS = -I/opt/local/include
	DEFAULT_LIBUSB_LIB = -L/opt/local/lib -lusb-1.0
	DEFAULT_PCSC_FLAGS = -isysroot $(OSX_SDK)
	DEFAULT_PCSC_LIB = -isysroot $(OSX_SDK) -framework IOKit -framework CoreFoundation -framework PCSC
else

To:

ifeq ($(uname_S),Darwin)
        FIX_OPENSSL_FLAGS_DIR := $(shell ln -sf /usr/local/opt/openssl@1.1/include/openssl /usr/local/include)
        FIX_OPENSSL_LIB_DIR := $(shell ln -sf /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib /usr/local/lib)
        FIX_OPENSSL_LIBCRYPTO_DIR := $(shell ln -sf /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib /usr/local/lib)
        DEFAULT_LIBCRYPTO_LIB = -L/usr/local/opt/openssl@1.1/lib -lcrypto
        DEFAULT_SSL_LIB = -L/usr/local/opt/openssl@1.1/lib -lssl
	DEFAULT_LIBUSB_FLAGS = -I/usr/local/opt/libusb/include
	DEFAULT_LIBUSB_LIB = -L/usr/local/opt/libusb/lib -lusb-1.0 -framework IOKit -framework CoreFoundation -framework Security
	DEFAULT_PCSC_FLAGS = -I/usr/local/opt/pcsc-lite/include/PCSC
	DEFAULT_PCSC_LIB = -L/usr/local/opt/pcsc-lite/lib -framework IOKit -framework CoreFoundation -framework PCSC
else

Second, on globals.h

Change:

#include <sys/sysmacros.h>

To:

#if !defined(__APPLE__)
#include <sys/sysmacros.h>
#endif

Lastly, on csctapi/ifd_pcsc.c

Change:

#if defined(__CYGWIN__)
#define __reserved
#define __nullnullterminated
#include <specstrings.h>
#include <WinSCard.h>
#else
#include <PCSC/pcsclite.h>
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#if !defined(__APPLE__)
#include <PCSC/reader.h>
#endif
#endif

To:

#if defined(__CYGWIN__)
#define __reserved
#define __nullnullterminated
#include <specstrings.h>
#include <WinSCard.h>
#endif

#if !defined(__CYGWIN__)
#if !defined(__APPLE__)
#include <PCSC/pcsclite.h>
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#include <PCSC/reader.h>
#endif
#endif

#if defined(__APPLE__)
#include "pcsclite.h"
#include "winscard.h"
#include "wintypes.h"
#include "reader.h"
#endif

With all of the above changes, you should be able to compile oscam on macOS Monterey with a single command below:

make USE_PCSC=1 USE_LIBUSB=1

Change History (8)

comment:1 by ohmza, 21 months ago

Description: modified (diff)

Fix broken CYGWIN compilation due to previous fix.

Last edited 21 months ago by ohmza (previous) (diff)

in reply to:  1 comment:2 by ohmza, 21 months ago

In case of the compilation resulted in errors about libusb, pcsc-lite or openssl. Try to run

brew install libusb pcsc-lite openssl@1.1 first and then re-run make USE_PCSC=1 USE_LIBUSB=1 to compile the oscam again.

Last edited 21 months ago by ohmza (previous) (diff)

comment:3 by ohmza, 21 months ago

Description: modified (diff)

Fix broken smartreader due to previous fix.

Last edited 21 months ago by ohmza (previous) (diff)

comment:4 by ohmza, 21 months ago

Description: modified (diff)

Preliminary fix for openssl compilation error issues.

Last edited 21 months ago by ohmza (previous) (diff)

comment:5 by ohmza, 21 months ago

Description: modified (diff)

More complete (still incomplete!!!) fix for openssl compilation errors issues.

Note: Because macOS ships LibreSSL instead of openssl, the openssl headers are not in /usr/local/include/ path which lead to a compilation error. I am currently working on a permanent fix, however in a meantime I can provide a workaround that can fix this issue, as described below.

  1. Run the command brew install openssl@1.1
  2. Run the command

sudo cp -R /usr/local/opt/openssl@1.1/include/openssl /usr/local/include/openssl

  1. Run the command make USE_PCSC=1 USE_LIBUSB=1 to compile oscam again.
Version 1, edited 21 months ago by ohmza (previous) (next) (diff)

comment:6 by ohmza, 21 months ago

Description: modified (diff)

Completed fix for openssl compilation errors issues.

Last edited 21 months ago by ohmza (previous) (diff)

comment:7 by ohmza, 7 months ago

Description: modified (diff)
Summary: Fix macOS Monterey compilation issuesFix macOS Monterey compile issues

Add reader header for pcsc

Last edited 7 months ago by ohmza (previous) (diff)

comment:8 by Bust3D, 7 months ago

Resolution: fixed
Status: newclosed

Committed and tested with Changeset 11725.

Note: See TracTickets for help on using tickets.