SRCMODULES = zip.c unzip.c ioapi.c
ARMOBJMODULES = $(addprefix ./arm64/,$(SRCMODULES:.c=.o))
X86OBJMODULES = $(addprefix ./x86_64/,$(SRCMODULES:.c=.o))
HEADERS = $(wildcard ./include/*.h)

CC = clang
CFLAGS = -g

./arm64/%.o: %.c $(HEADERS)
	@:$(if $(value MACOS_VERSION),,$(error MACOS_VERSION is not defined))
	$(CC) -target arm64-apple-macos -mmacosx-version-min=$(MACOS_VERSION) \
		$(CFLAGS) -fmodule-file=./module/module.modulemap -I./include \
		-c $< -o ./$@

./x86_64/%.o: %.c $(HEADERS)
	@:$(if $(value MACOS_VERSION),,$(error MACOS_VERSION is not defined))
	@$(CC) -target x86_64-apple-macos -mmacosx-version-min=$(MACOS_VERSION) \
		$(CFLAGS) -fmodule-file=./module/module.modulemap -I./include \
		-c $< -o ./$@

all: $(ARMOBJMODULES) $(X86OBJMODULES)

default: $(OBJMODULES)

clean:
	rm -rf arm64 x86_64
	mkdir arm64 x86_64
