From 07533554e67d04279131a3fb1af5cc84fa0584db Mon Sep 17 00:00:00 2001 From: zawz Date: Tue, 8 Jun 2021 16:38:25 +0200 Subject: [PATCH] =?UTF-8?q?=C3=83zcsf:=20fix=20makefiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zcsf/Makefile | 18 +++++++++++------- zcsf/Makefile_cpp | 22 ++++++++++++---------- zcsf/zcsf | 8 ++++---- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/zcsf/Makefile b/zcsf/Makefile index a4deed0..84b93b0 100644 --- a/zcsf/Makefile +++ b/zcsf/Makefile @@ -15,12 +15,14 @@ LDFLAGS = CC=gcc # compiler flags CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c18 -ifeq ($(DEBUG),true) +ifeq ($(DEBUG),true) # debugging flags CXXFLAGS += -g + RODIR = $(ODIR)/debug else # release flags CXXFLAGS += -O2 + RODIR = $(ODIR)/release endif ifeq ($(STATIC),true) # static links @@ -32,15 +34,17 @@ endif ## END CONFIG ## -$(shell mkdir -p $(ODIR)) +$(shell mkdir -p $(RODIR)) $(shell mkdir -p $(BINDIR)) -# automatically finds .h +# automatically find .h DEPS = $(shell find $(IDIR) -type f -regex '.*\.h') -# automatically finds .c and makes the corresponding .o rule -OBJ = $(shell find $(SRCDIR) -type f -regex '.*\.c' | sed 's|\.c|.o|g;s|^$(SRCDIR)/|$(ODIR)/|g') +# automatically find .c and make the corresponding .o rule +OBJ = $(shell find $(SRCDIR) -type f -regex '.*\.c' | sed 's|\.c|.o|g;s|^$(SRCDIR)/|$(RODIR)/|g') -$(ODIR)/%.o: $(SRCDIR)/%.c $(DEPS) +build: $(BINDIR)/$(NAME) + +$(RODIR)/%.o: $(SRCDIR)/%.c $(DEPS) $(CC) $(CXXFLAGS) -c -o $@ $< $(BINDIR)/$(NAME): $(OBJ) @@ -50,7 +54,7 @@ test: $(BINDIR)/$(NAME) $(BINDIR)/$(NAME) clean: - rm $(ODIR)/*.o + rm $(ODIR)/*/*.o clear: rm $(BINDIR)/$(NAME) diff --git a/zcsf/Makefile_cpp b/zcsf/Makefile_cpp index 1355f06..94568f5 100644 --- a/zcsf/Makefile_cpp +++ b/zcsf/Makefile_cpp @@ -14,15 +14,17 @@ LDFLAGS = # compiler CC=g++ # compiler flags -CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c++17 -ifeq ($(DEBUG),true) +CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c++20 +ifeq ($(DEBUG),true) # debugging flags CXXFLAGS += -g + RODIR = $(ODIR)/debug else # release flags CXXFLAGS += -O2 + RODIR = $(ODIR)/release endif -ifeq ($(STATIC),true) +ifeq ($(STATIC),true) # static links LDFLAGS += else @@ -32,20 +34,20 @@ endif ## END CONFIG ## - - -$(shell mkdir -p $(ODIR)) +$(shell mkdir -p $(RODIR)) $(shell mkdir -p $(BINDIR)) # automatically find .h and .hpp DEPS = $(shell find $(IDIR) -type f -regex '.*\.hp?p?') # automatically find .c and .cpp and make the corresponding .o rule -OBJ = $(shell find $(SRCDIR) -type f -regex '.*\.cp?p?' | sed 's|\.cpp|.o|g;s|\.c|.o|g;s|^$(SRCDIR)/|$(ODIR)/|g') +OBJ = $(shell find $(SRCDIR) -type f -regex '.*\.cp?p?' | sed 's|\.cpp|.o|g;s|\.c|.o|g;s|^$(SRCDIR)/|$(RODIR)/|g') -$(ODIR)/%.o: $(SRCDIR)/%.c $(DEPS) +build: $(BINDIR)/$(NAME) + +$(RODIR)/%.o: $(SRCDIR)/%.c $(DEPS) $(CC) $(CXXFLAGS) -c -o $@ $< -$(ODIR)/%.o: $(SRCDIR)/%.cpp $(DEPS) +$(RODIR)/%.o: $(SRCDIR)/%.cpp $(DEPS) $(CC) $(CXXFLAGS) -c -o $@ $< $(BINDIR)/$(NAME): $(OBJ) @@ -55,7 +57,7 @@ test: $(BINDIR)/$(NAME) $(BINDIR)/$(NAME) clean: - rm $(ODIR)/*.o + rm $(ODIR)/*/*.o clear: rm $(BINDIR)/$(NAME) diff --git a/zcsf/zcsf b/zcsf/zcsf index 169dc59..e932fed 100755 --- a/zcsf/zcsf +++ b/zcsf/zcsf @@ -246,19 +246,19 @@ Types: clear) make clean >/dev/null 2>&1 ; make clear >/dev/null 2>&1 # bin - [ "$BINDIR" != "." ] && rm -rd "$BINDIR" 2> /dev/null + [ "$BINDIR" != "." ] && rm -r "$BINDIR" 2> /dev/null # src if [ "$SRCDIR" != "." ] - then rm -rd "$SRCDIR" 2> /dev/null + then rm -r "$SRCDIR" 2> /dev/null else rm ./*.c ./*.cpp 2> /dev/null fi # include if [ "$IDIR" != "." ] - then rm -rd "$IDIR" 2> /dev/null + then rm -r "$IDIR" 2> /dev/null else rm ./*.h ./*.hpp 2> /dev/null fi # obj - [ "$ODIR" != "." ] && rm -rd "$ODIR" 2> /dev/null + [ "$ODIR" != "." ] && rm -r "$ODIR" 2> /dev/null ;; src|s)