使用 GCC 编译简单的 Mac App

只是编译一个简简单单的 Mac 窗口应用, 没什么实用价值 ┑( ̄Д  ̄)┍

#import <Cocoa/Cocoa.h>

int main()
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    // NSApplication* app = [NSApplication sharedApplication];

    //Create the main window
    NSRect rc = NSMakeRect(0, 0, 800, 600);
    NSUInteger uiStyle = NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask;
    NSBackingStoreType backingStoreStyle = NSBackingStoreBuffered;
    NSWindow* win = [[NSWindow alloc] initWithContentRect:rc styleMask:uiStyle backing:backingStoreStyle defer:NO];
    [win setTitle:@"测试字符串"];
    [win makeKeyAndOrderFront:win];
    [win makeMainWindow];

    //Start the event loop by calling NSApp run
    [NSApp run];
    [pool drain];
    return 0;
}

TARGET = hello

CFLAGS ?= -std=c99 -Wall -Wextra -pedantic -I./

TARGET_OS ?= $(OS)
ifeq ($(TARGET_OS),Windows_NT)
else ifeq ($(shell uname -s),Linux)
else ifeq ($(shell uname -s),Darwin)
	WEBVIEW_CFLAGS := -x objective-c
	WEBVIEW_LDFLAGS := -framework Cocoa -framework WebKit
endif

$(TARGET): main.m
	$(CC) $(CFLAGS) $(WEBVIEW_CFLAGS) main.m $(LDFLAGS) $(WEBVIEW_LDFLAGS) -o $@

clean:
	rm -f $(TARGET)

.PHONY: clean