Ãzcsf: fix makefiles
This commit is contained in:
parent
98a7976c94
commit
07533554e6
3 changed files with 27 additions and 21 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue