blob: 3652375dd9f4b493d637b2f6c20d18394eb79bc9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
CC:=clang
RUSTC:=rustc
AR:=llvm-ar
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 -fsanitize=safe-stack -fcf-protection=full
endif
INCLUDES=-Iinc/
OBJECTS=obj/salloc.c.o obj/arena.c.o obj/resarr.c.o obj/sstring.c.o
.PHONY: all
all: build/lib/libspicy.so build/lib/static/libspicy.a includes
.PHONY: includes
includes:
@if [ ! -d "build/include/libspicy" ]; then mkdir -p build/include/libspicy; fi
@cp -v inc/*.h build/include/libspicy/
.PHONY: release
release: all build/rel/libspicy.so build/dbg/libspicy.so.debug
build/rel/%: build/lib/%
@if [ ! -d "build/rel" ]; then mkdir -p build/rel; fi
strip -s -o $@ $<
build/dbg/%.debug: build/lib/%
@if [ ! -d "build/dbg" ]; then mkdir -p build/dbg; fi
strip --only-keep-debug -o $@ $<
build/lib/%.so: $(OBJECTS)
@if [ ! -d "build/lib" ]; then mkdir -p build/lib; fi
$(CC) -g -shared $(CFLAGS) $(LDFLAGS) -o $@ $^
build/lib/static/%.a: $(OBJECTS)
@if [ ! -d "build/lib/static" ]; then mkdir -p build/lib/static; fi
$(AR) rcs $@ $^
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
@rm -rf build
|