You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
SRC = $(wildcard src/*.c)
|
|
|
|
INCLUDE = include
|
|
|
|
|
|
|
|
CFLAGS?= -O3 -flto -fgraphite
|
|
|
|
CFLAGS+= -Wall $(addprefix -I,$(INCLUDE)) --std=gnu11 -pedantic
|
|
|
|
|
|
|
|
LDFLAGS?= -O3 -flto
|
|
|
|
|
|
|
|
OBJ:= obj
|
|
|
|
|
|
|
|
STATIC = $(addprefix $(OBJ)/static/,$(SRC:.c=.o))
|
|
|
|
SHARED = $(addprefix $(OBJ)/shared/,$(SRC:.c=.o))
|
|
|
|
|
|
|
|
BUILD = librc
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: dirs $(BUILD)
|
|
|
|
|
|
|
|
dirs:
|
|
|
|
@mkdir -p obj/{shared,static}/src
|
|
|
|
|
|
|
|
obj/static/%.o: %.c
|
|
|
|
$(CC) -c $< $(CFLAGS) -o $@
|
|
|
|
|
|
|
|
obj/shared/%.o: %.c
|
|
|
|
$(CC) -fPIC -c $< $(CFLAGS) -o $@
|
|
|
|
|
|
|
|
$(BUILD).a: $(STATIC)
|
|
|
|
ar rcs $@ $^
|
|
|
|
|
|
|
|
$(BUILD).so: $(SHARED)
|
|
|
|
$(CC) -shared $^ $(CFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
strip $@
|
|
|
|
|
|
|
|
$(BUILD): $(BUILD).a $(BUILD).so
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(BUILD).{a,so}
|
|
|
|
rm -rf obj
|