cleanup
This commit is contained in:
@@ -19,6 +19,7 @@ LD := ld
|
|||||||
BEAR := bear
|
BEAR := bear
|
||||||
TOUCH := touch
|
TOUCH := touch
|
||||||
RM := rm
|
RM := rm
|
||||||
|
MKDIR := mkdir -p
|
||||||
RMDIR := rmdir
|
RMDIR := rmdir
|
||||||
|
|
||||||
SRCDIR := ./src
|
SRCDIR := ./src
|
||||||
@@ -27,6 +28,7 @@ OBJDIR := ./obj
|
|||||||
LIBDIR := ./lib
|
LIBDIR := ./lib
|
||||||
BINDIR := ./bin
|
BINDIR := ./bin
|
||||||
DEPDIR := ./dep
|
DEPDIR := ./dep
|
||||||
|
TESTDIR := ./test
|
||||||
|
|
||||||
SRC := $(wildcard $(SRCDIR)/*.c) # brlib sources
|
SRC := $(wildcard $(SRCDIR)/*.c) # brlib sources
|
||||||
SRC_FN := $(notdir $(SRC)) # source basename
|
SRC_FN := $(notdir $(SRC)) # source basename
|
||||||
@@ -39,17 +41,23 @@ DLIB := $(addsuffix .so, $(LIBDIR)/lib$(LIB)) # dynamic lib
|
|||||||
DEP_FN := $(SRC_FN) $(LIBSRC_FN)
|
DEP_FN := $(SRC_FN) $(LIBSRC_FN)
|
||||||
DEP := $(addprefix $(DEPDIR)/,$(DEP_FN:.c=.d))
|
DEP := $(addprefix $(DEPDIR)/,$(DEP_FN:.c=.d))
|
||||||
|
|
||||||
##################################### emacs projectile/ccls
|
TESTSRC := $(wildcard $(TESTDIR)/*.c)
|
||||||
|
TEST_FN := $(notdir $(TESTSRC))
|
||||||
|
BIN := $(addprefix $(BINDIR)/,$(TEST_FN:.c=))
|
||||||
|
|
||||||
|
##################################### emacs projectile/ccls dirs & files
|
||||||
PRJROOT := .projectile
|
PRJROOT := .projectile
|
||||||
|
EMACSLSP := .dir-locals.el
|
||||||
|
|
||||||
CCLSROOT := .ccls-root
|
CCLSROOT := .ccls-root
|
||||||
|
CCLSFILE := .ccls
|
||||||
CCLSCMDS := compile_commands.json
|
CCLSCMDS := compile_commands.json
|
||||||
|
|
||||||
##################################### pre-processor flags
|
##################################### pre-processor flags
|
||||||
CPPFLAGS := -I$(INCDIR)
|
CPPFLAGS := -I$(INCDIR)
|
||||||
#CPPFLAGS += -DDEBUG # global
|
#CPPFLAGS += -DDEBUG # global
|
||||||
CPPFLAGS += -DDEBUG_DEBUG # enable log() functions
|
|
||||||
#CPPFLAGS += -DDEBUG_DEBUG_C # log() funcs debug
|
#CPPFLAGS += -DDEBUG_DEBUG_C # log() funcs debug
|
||||||
PPFLAGS += -DDEBUG_DEBUG # activate logs funcs
|
CPPFLAGS += -DDEBUG_DEBUG # activate logs funcs
|
||||||
CPPFLAGS += -DDEBUG_POOL # mem pools
|
CPPFLAGS += -DDEBUG_POOL # mem pools
|
||||||
|
|
||||||
# remove extraneous spaces (due to spaces before comments)
|
# remove extraneous spaces (due to spaces before comments)
|
||||||
@@ -78,16 +86,20 @@ LDFLAGS := -L$(LIBDIR)
|
|||||||
DEPFLAGS = -MMD -MP -MF $(DEPDIR)/$*.d
|
DEPFLAGS = -MMD -MP -MF $(DEPDIR)/$*.d
|
||||||
|
|
||||||
##################################### General targets
|
##################################### General targets
|
||||||
.PHONY: all compile clean cleanall
|
.PHONY: all compile clean cleanall cleanallall
|
||||||
|
|
||||||
all: libs
|
all: libs
|
||||||
|
|
||||||
compile: objs
|
compile: objs
|
||||||
|
|
||||||
|
test: testbins
|
||||||
|
|
||||||
clean: cleandep cleanobj cleanlib cleanbin
|
clean: cleandep cleanobj cleanlib cleanbin
|
||||||
|
|
||||||
cleanall: clean cleandepdir cleanobjdir cleanlibdir cleanbindir
|
cleanall: clean cleandepdir cleanobjdir cleanlibdir cleanbindir
|
||||||
|
|
||||||
|
cleanallall: cleanall cleanemacs
|
||||||
|
|
||||||
# setup emacs projectile/ccls
|
# setup emacs projectile/ccls
|
||||||
emacs: emacs-setup
|
emacs: emacs-setup
|
||||||
# update compile-commands.json
|
# update compile-commands.json
|
||||||
@@ -141,7 +153,7 @@ alldirs: $(ALLDIRS)
|
|||||||
# a will be built if (1) older than a, or (2) does not exist. Here only (2).
|
# a will be built if (1) older than a, or (2) does not exist. Here only (2).
|
||||||
$(ALLDIRS): $@
|
$(ALLDIRS): $@
|
||||||
@echo creating $@ directory.
|
@echo creating $@ directory.
|
||||||
@mkdir -p $@
|
@$(MKDIR) $@
|
||||||
|
|
||||||
##################################### Dependencies files
|
##################################### Dependencies files
|
||||||
.PHONY: cleandep cleandepdir
|
.PHONY: cleandep cleandepdir
|
||||||
@@ -188,17 +200,18 @@ cleanlibdir:
|
|||||||
#$(DLIB): CFLAGS += -fPIC
|
#$(DLIB): CFLAGS += -fPIC
|
||||||
$(DLIB): LDFLAGS += -shared
|
$(DLIB): LDFLAGS += -shared
|
||||||
$(DLIB): $(OBJ) | $(LIBDIR)
|
$(DLIB): $(OBJ) | $(LIBDIR)
|
||||||
@echo "building $@ shared library ($?)."
|
@echo "building shared library ($@)."
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) $? -o $@
|
$(CC) $(CFLAGS) $(LDFLAGS) $? -o $@
|
||||||
|
|
||||||
$(SLIB): $(OBJ) | $(LIBDIR)
|
$(SLIB): $(OBJ) | $(LIBDIR)
|
||||||
@echo "building $@ static library ($?)."
|
@echo "building static library ($@)."
|
||||||
$(AR) $(ARFLAGS) $@ $? > /dev/null
|
$(AR) $(ARFLAGS) $@ $? > /dev/null
|
||||||
|
|
||||||
##################################### brchess binaries
|
##################################### tests
|
||||||
.PHONY: targets cleanbin cleanbindir
|
.PHONY: testbins cleanbin cleanbindir
|
||||||
|
|
||||||
targets: $(TARGET)
|
testbins: $(BIN)
|
||||||
|
echo $^
|
||||||
|
|
||||||
cleanbin:
|
cleanbin:
|
||||||
$(call rmfiles,$(TARGET),binary)
|
$(call rmfiles,$(TARGET),binary)
|
||||||
@@ -215,21 +228,15 @@ cleanbindir:
|
|||||||
@echo generating $@
|
@echo generating $@
|
||||||
@$(CC) -S -fverbose-asm $(CPPFLAGS) $(CFLAGS) $< -o $@
|
@$(CC) -S -fverbose-asm $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
##################################### LSP (ccls)
|
##################################### Emacs
|
||||||
.PHONY: emacs-setup
|
.PHONY: emacs-setup cleanemacs
|
||||||
|
|
||||||
PRJROOT := .projectile
|
emacs-setup: $(PRJROOT) $(EMACSLSP)
|
||||||
CCLSROOT := .ccls-root
|
|
||||||
CCLSFILE := .ccls
|
|
||||||
CCLSCMDS := compile_commands.json
|
|
||||||
|
|
||||||
emacs-setup: $(PRJROOT) $(CCLSROOT) $(CCLSCMDS)
|
cleanemacs:
|
||||||
|
$(call rmfiles, $(PRJROOT) $(EMACSLSP), Emacs);
|
||||||
|
|
||||||
#$(CCLSFILE):
|
$(PRJROOT) $(EMACSLSP):
|
||||||
# @echo "creating CCLS's $@ project root file."
|
|
||||||
# echo '%compile_commands.json' > $@
|
|
||||||
|
|
||||||
$(CCLSROOT) $(PRJROOT):
|
|
||||||
@if [[ $(@) = $(PRJROOT) ]] ; \
|
@if [[ $(@) = $(PRJROOT) ]] ; \
|
||||||
then \
|
then \
|
||||||
echo "creating Emacs's projectile root file." ; \
|
echo "creating Emacs's projectile root file." ; \
|
||||||
@@ -238,6 +245,16 @@ $(CCLSROOT) $(PRJROOT):
|
|||||||
fi
|
fi
|
||||||
@$(TOUCH) $@
|
@$(TOUCH) $@
|
||||||
|
|
||||||
|
##################################### LSP (ccls)
|
||||||
|
.PHONY: cleanccls
|
||||||
|
|
||||||
|
cleanccls:
|
||||||
|
$(call rmfiles, $(CCLSROOT), ccls);
|
||||||
|
|
||||||
|
$(CCLSROOT):
|
||||||
|
echo "creating ccls root file."
|
||||||
|
@$(TOUCH) $@
|
||||||
|
|
||||||
# generate compile_commands.json.
|
# generate compile_commands.json.
|
||||||
# TODO: add includes and Makefile dependencies.
|
# TODO: add includes and Makefile dependencies.
|
||||||
# also, if cclsfile is newer than sources, no need to clean objects file
|
# also, if cclsfile is newer than sources, no need to clean objects file
|
||||||
|
Reference in New Issue
Block a user