I ran a simple configure/compile with your patch installed, which worked fine. I then tried: ./configure --with-ns CFLAGS=-DMAC_OS_X_VERSION_MIN_REQUIRED=1060 -DMAC_OS_X_VERSION_MAX_ALLOWED=101200 -g -O3 and ran into a few errors, which should be fixed with the attached patch applied on top of yours. I've written notes on some of the changed parts below. --- a/src/macfont.h +++ b/src/macfont.h @@ -45,12 +45,12 @@ struct mac_glyph_layout CGGlyph glyph_id; }; -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080 +#if !defined (MAC_OS_X_VERSION_10_8) We have to define these constants when compiling on macOS < 10.8, since they're used by macfont.m and only available on 10.8+. -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 && defined (MAC_OS_X_VERSION_10_7) kCTFontTraitColorGlyphs = kCTFontColorGlyphsTrait #else kCTFontTraitColorGlyphs = (1 << 13) kCTFontColorGlyphsTrait is only defined on macOS 10.7+. --- a/src/macfont.m +++ b/src/macfont.m @@ -2875,7 +2875,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no @selector(backingScaleFactor)]) #endif CGContextSetLineWidth (context, synthetic_bold_factor * font_size - * [[FRAME_NS_VIEW(f) window] backingScaleFactor]); + * [(EmacsWindow *) [FRAME_NS_VIEW(f) window] backingScaleFactor]); Compiler needs a cast to EmacsWindow * here. I add the backing scale factor to the interface declaration of EmacsWindow here in nsterm.h: @@ -470,6 +499,10 @@ @interface EmacsWindow : NSWindow { NSPoint grabOffset; } +#if !defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 +- (NSRect)convertRectToScreen:(NSRect)rect; +@property(readonly) CGFloat backingScaleFactor; +#endif @end Next, in nsfns.m: --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1592,7 +1592,7 @@ Frames are listed from topmost (first) to bottommost (last). */) } #ifdef NS_IMPL_COCOA -#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 +#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 && defined (MAC_OS_X_VERSION_10_9) #define MODAL_OK_RESPONSE NSModalResponseOK #endif #endif NSModelResponseOK is only defined on macOS 10.9+. The next ifndef clause takes care of the right define on macOS below 10.9. Next, in src/nsterm.h: +#define NSAppKitVersionNumber10_7 1138 New define, since it's referenced verbatim in nsterm.m:7017: #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7) #endif New scroll styles in 10.7+: +enum { + NSScrollerStyleLegacy = 0, + NSScrollerStyleOverlay = 1 +}; +typedef NSInteger NSScrollerStyle; Add-on to the class declaration of NSScroller (not sure if this is the right way to do it). Otherwise the compiler errors out on compiling the 10.7+ call to scrollerWidthForControlSize: +@interface NSScroller(NSObject) ++ (CGFloat)scrollerWidthForControlSize:(NSControlSize)controlSize scrollerStyle:(NSScrollerStyle)scrollerStyle; +@end Forward declarations for functions used by macfont.m (declared as weak imports since they won't all be available unless we're on 10.8+): +void CTFontDrawGlyphs(CTFontRef font, const CGGlyph *glyphs, const CGPoint *positions, size_t count, CGContextRef context) __attribute__((weak_import)); +#endif + +#if !defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 +extern CFArrayRef CTFontCopyDefaultCascadeListForLanguages(CTFontRef font, CFArrayRef languagePrefList) __attribute__((weak_import)); The compiler issued no complaints here, but the linker would not link temacs unless the symbols were listed as permitted to be undefined, using this in src/Makefile: ## System-specific LDFLAGS. LD_SWITCH_SYSTEM= -Wl,-U,_CTFontCopyDefaultCascadeListForLanguages -Wl,-U,_CTFontDrawGlyphs I'm not sure where to integrate this in the source tree (and if we can conditionalize it based on what version of macOS we're building for). If they look okay, could you please integrate these changes into your patch? Thanks a lot for your help on this. On 02/08/2017 00:03, Alan Third wrote: > On Tue, Aug 01, 2017 at 05:38:03PM +0200, Anders Lindgren wrote: >> It's always a good idea to enable warnings when undefined preprocessor >> symbols are used. In gcc this is -Wundef and I gess it's the same in clang. > Unfortunately this produces an absolute ton of spurious warnings which > scroll off my terminal buffer. I think I’ve caught all the important > ones now, though. > > I’ve attached my latest go with this. I’ve removed the > MAC_OS_X_VERSION_10_XX macros with their numbers, as we can use the > existence of the macros to tell what platform we’re compiling on. Eg. > > #if !defined (MAC_OS_X_VERSION_10_7) \ > && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 > > I’ve also used the NSAppKitVersionNumber macros in a few places to do > runtime version detection. I’m not sure this is reliable. There are > two methods of finding the OS version definitively, which we can use > if we need to. > > I’ve got rid of the HAS_NATIVE_FS macro and tried to replace it with > other checks where required. It compiles on 10.12, but I’m not at all > convinced it will compile on 10.6. > > New 10.7 variables that need to be available on 10.6 when we’re > compiling for 10.7+ have been added near the bottom of nsterm.h. > > Overall it looks quite different in places, but the functionality > hasn’t really changed.