CC = swiftc
FLAGS = -g
#-O
#TARGET = 
MACOS_VERSION = 13.0

FILES = main.swift

EXEC = cmdbar_updater

FRAMEWORKS = -framework AppKit

./arm64/$(EXEC): $(FILES)
	$(CC) -target arm64-apple-macos$(MACOS_VERSION) $(FLAGS) $^ \
		$(FRAMEWORKS) -o $@

./x86_64/$(EXEC): $(FILES)
	$(CC) -target x86_64-apple-macos$(MACOS_VERSION) $(FLAGS) $^ \
		$(FRAMEWORKS) -o $@

$(EXEC): ./arm64/$(EXEC) ./x86_64/$(EXEC)
	lipo -create -output $(EXEC) $^ && \
	codesign -s ${APPLE_DEVELOPER_ID_APPLICATION} -f --timestamp \
	    -o runtime $(EXEC)

all: $(EXEC)

clean:
	rm -rf arm64 x86_64 $(EXEC)
	mkdir arm64 x86_64
