This repository has been archived on 2024-05-26. You can view files and clone it, but cannot push or open issues or pull requests.
trixy/example/main/Makefile

36 lines
847 B
Makefile
Raw Normal View History

BIN_NAME := ./target/plugin.so
BUILD_DIR := ./target/c_build/
SRC := $(wildcard c/*.c)
OBJ := $(SRC:.c=.o)
DEP := $(OBJ:.o=.d)
LIBS :=
ALL_CFLAGS := -O3 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS)
ALL_LDFLAGS := $(addprefix -l,$(LIBS)) -L $(LD_LIBRARY_PATH) $(CFLAGS) $(LDFLAGS)
$(BIN_NAME): $(OBJ)
gcc $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) -shared -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS)
$(OBJ): $(SRC)
mkdir --parents $(BUILD_DIR)
$(CC) -c -fPIC $< -o $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) $(ALL_CFLAGS)
.PHONY : clean options
options:
@echo "CC = $(CC)"
@echo "CFLAGS = $(ALL_CFLAGS)"
@echo "LDFLAGS = $(ALL_LDFLAGS)"
@echo "SRC = $(SRC)"
@echo "OBJ = $(OBJ)"
@echo "DEP = $(DEP)"
@echo ""
clean :
rm $(BIN_NAME) $(OBJ) $(DEP)
rm -r $(BUILD_DIR)