From f02932abbb29ccfc5f4ea4c540bc8d6a46cba1de Mon Sep 17 00:00:00 2001 From: Ren Kararou Date: Fri, 31 Jan 2025 13:20:50 -0600 Subject: add rust build integration --- makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index 9eb0e07..3c456a1 100644 --- a/makefile +++ b/makefile @@ -1,18 +1,20 @@ CC:=clang +RUSTC:=rustc AR:=llvm-ar -CFLAGS:=-march=native -O3 -funroll-loops -Wall -Wextra -Werror -fPIC +CFLAGS:=-march=native -O3 -funroll-loops -Wall -Wextra -Werror -fPIC -fstack-protector-all LDFLAGS:=-flto=thin +RSFLAGS:=--edition 2021 --crate-name libspicy -Copt-level=3 -Cpanic=abort --deny warnings ifeq ($(shell uname),SunOS) CC = gcc CFLAGS += -std=gnu11 else -CFLAGS += -std=c11 +CFLAGS += -std=c11 -fsanitize=safe-stack -fcf-protection=[full] endif INCLUDES=-Iinc/ -OBJECTS=obj/salloc.o obj/arena.o obj/resarr.o +OBJECTS=obj/salloc.c.o obj/arena.c.o obj/resarr.c.o .PHONY: all all: build/lib/libspicy.so build/lib/static/libspicy.a includes @@ -41,10 +43,14 @@ build/lib/static/%.a: $(OBJECTS) @if [ ! -d "build/lib/static" ]; then mkdir -p build/lib/static; fi $(AR) rcs $@ $^ -obj/%.o: src/%.c inc/%.h +obj/%.c.o: src/%.c inc/%.h @if [ ! -d "obj" ]; then mkdir -p obj; fi $(CC) -g -c $(INCLUDES) $(CFLAGS) -o $@ $< +obj/%.rs.o: src/%.rs inc/%.h + @if [ ! -d "obj" ]; then mkdir -p obj; fi + $(RUSTC) -g --emit obj --crate-type lib $(RSFLAGS) -o $@ $< + .PHONY: clean clean: @rm -rf obj -- cgit 1.4.1-2-gfad0