2022-06-28 07:04:22 +00:00
|
|
|
|
|
|
|
CC=clang
|
|
|
|
SRC_DIR := src
|
|
|
|
OBJ_DIR := bin
|
2022-07-06 02:31:15 +00:00
|
|
|
IFLAGS := -Iinc -Isrc/win -Iunicope/inc
|
2022-06-28 07:04:22 +00:00
|
|
|
|
2022-06-28 11:49:30 +00:00
|
|
|
# Detect target operating system
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
PLATFORM := win
|
|
|
|
else
|
|
|
|
PLATFORM := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
|
|
|
|
PLATFORM := $(shell sh -c 'echo $(PLATFORM) | tr A-Z a-z')
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),Unknown)
|
|
|
|
echo Unknown platform
|
|
|
|
exit 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
# If we're compiling under windows we'll link to these libraries
|
|
|
|
ifeq ($(PLATFORM),win)
|
2022-06-28 12:57:14 +00:00
|
|
|
LIBS := -lDbghelp -lkernel32 -luser32 -lshell32
|
|
|
|
MKDIR_P_FLAG :=
|
|
|
|
NUL_FILE := NUL
|
|
|
|
else
|
|
|
|
LIBS := -lrt -lpthread -ldl
|
|
|
|
MKDIR_P_FLAG := '-p'
|
|
|
|
NUL_FILE := /dev/null
|
2022-06-28 11:49:30 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Compiler flags
|
|
|
|
ifeq ($(CC), clang)
|
2022-06-28 12:57:14 +00:00
|
|
|
CFLAGS=$(GNUFLAGS) -Wall -msse2 -mfma $(IFLAGS)
|
2022-06-28 11:49:30 +00:00
|
|
|
else
|
|
|
|
echo BAD CC
|
|
|
|
exit 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Figure out what we want to compile at the end
|
2022-06-28 12:57:14 +00:00
|
|
|
SRC_FILES := \
|
|
|
|
$(wildcard $(SRC_DIR)/code/*.c) \
|
|
|
|
$(wildcard $(SRC_DIR)/code/**/*.c) \
|
|
|
|
$(wildcard $(SRC_DIR)/$(PLATFORM)/*.c) \
|
|
|
|
$(wildcard $(SRC_DIR)/$(PLATFORM)/**/*.c)
|
2022-06-28 11:49:30 +00:00
|
|
|
OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.obj,$(SRC_FILES))
|
2022-06-28 07:04:22 +00:00
|
|
|
|
|
|
|
$(OBJ_DIR)/%.obj: $(SRC_DIR)/%.c
|
2022-06-28 12:57:14 +00:00
|
|
|
@-mkdir $(MKDIR_P_FLAG) "$(dir $@)" 2> $(NUL_FILE)
|
2022-06-28 07:04:22 +00:00
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
2022-07-06 02:31:15 +00:00
|
|
|
ciabatta.lib: $(OBJ_FILES) unicope/unicope.lib
|
2022-06-28 11:49:30 +00:00
|
|
|
llvm-ar rc $@ $^
|
|
|
|
|
2022-07-06 02:31:15 +00:00
|
|
|
unicope/unicope.lib:
|
2022-07-15 17:44:15 +00:00
|
|
|
unicope\bake
|
2022-07-06 02:31:15 +00:00
|
|
|
|
|
|
|
|
2022-06-28 11:49:30 +00:00
|
|
|
test: ciabatta.lib
|
2022-06-28 12:57:14 +00:00
|
|
|
clang -g test/test_$(test).c ciabatta.lib -std=c11 $(LIBS) -nostdlib -Iinc
|
2022-06-28 11:49:30 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rd/s/q bin || true
|
|
|
|
rm -Rf bin || true
|
2022-06-28 12:57:14 +00:00
|
|
|
rm -f ciabatta.lib || true
|
|
|
|
del ciabatta.lib || true
|
2022-06-28 11:49:30 +00:00
|
|
|
|
|
|
|
.PHONY: ciabatta.lib test
|