2023-06-19 21:39:56 +03:00
|
|
|
STATIC_LIB ?= libqments.a
|
|
|
|
SHARED_LIB ?= libqments.so
|
2023-06-15 01:44:02 +03:00
|
|
|
|
|
|
|
BD ?= build
|
|
|
|
SRC_DIRS ?= src
|
|
|
|
INCLUDE_DIRS ?= include
|
|
|
|
|
2023-06-19 21:39:56 +03:00
|
|
|
SBD ?= $(BD)/shared
|
|
|
|
|
2023-06-15 01:44:02 +03:00
|
|
|
SRC_FILES := $(shell find $(SRC_DIRS) -name *.c)
|
|
|
|
OBJ_FILES := $(patsubst %.c,$(BD)/%.o,$(SRC_FILES))
|
|
|
|
|
2023-06-19 21:39:56 +03:00
|
|
|
OBJ_FILES := $(patsubst %.c,$(BD)/%.o,$(SRC_FILES))
|
|
|
|
SHARED_OBJ_FILES := $(patsubst %.c,$(SBD)/%.o,$(SRC_FILES))
|
|
|
|
|
|
|
|
shared: $(SBD)/$(SHARED_LIB)
|
|
|
|
static: $(BD)/$(STATIC_LIB)
|
|
|
|
|
|
|
|
$(SBD)/$(SHARED_LIB): $(SHARED_OBJ_FILES)
|
|
|
|
$(CC) $(CFLAGS) -shared -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive
|
|
|
|
|
|
|
|
$(BD)/$(STATIC_LIB): $(OBJ_FILES)
|
2023-06-15 01:44:02 +03:00
|
|
|
mkdir -p $(@D)
|
|
|
|
ar rcs $@ $(OBJ_FILES)
|
|
|
|
|
2023-06-19 21:39:56 +03:00
|
|
|
$(SBD)/%.o: %.c
|
|
|
|
mkdir -p $(@D)
|
|
|
|
$(CC) $(CFLAGS) -fPIC -c $< -o $@ -I $(INCLUDE_DIRS)
|
|
|
|
|
2023-06-15 01:44:02 +03:00
|
|
|
$(BD)/%.o: %.c
|
|
|
|
mkdir -p $(@D)
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(INCLUDE_DIRS)
|
|
|
|
|
2023-06-19 21:39:56 +03:00
|
|
|
all: shared static
|
2023-06-15 01:44:02 +03:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rfI $(BD)/
|
|
|
|
|
2023-06-19 21:39:56 +03:00
|
|
|
.PHONY: all clean shared static
|