96 lines
1.9 KiB
Makefile
96 lines
1.9 KiB
Makefile
## CONFIG ##
|
|
|
|
IDIR=include
|
|
SRCDIR=src
|
|
ODIR=obj
|
|
BINDIR=.
|
|
|
|
# binary name, default name of dir
|
|
NAME = $(shell readlink -f . | xargs basename)
|
|
|
|
# global links
|
|
LDFLAGS = -lpthread
|
|
|
|
# compiler
|
|
CC=g++
|
|
# compiler flags
|
|
CXXFLAGS= -I$(IDIR) -Wall -std=c++20
|
|
ifeq ($(DEBUG),true)
|
|
# debugging flags
|
|
CXXFLAGS += -g -D DEBUG_MODE
|
|
RODIR = $(ODIR)/debug
|
|
else
|
|
# release flags
|
|
CXXFLAGS += -Ofast
|
|
RODIR = $(ODIR)/release
|
|
endif
|
|
ifeq ($(STATIC),true)
|
|
# static links
|
|
LDFLAGS += -l:libztd.a
|
|
else
|
|
# dynamic links
|
|
LDFLAGS += -lztd
|
|
endif
|
|
|
|
|
|
ifeq ($(PROFILE),true)
|
|
CXXFLAGS += -pg
|
|
endif
|
|
|
|
ifneq ($(RELEASE), true)
|
|
VSUFFIX=-dev-$(SHA_SHORT)
|
|
endif
|
|
|
|
## END CONFIG ##
|
|
|
|
|
|
$(shell ./generate_version.sh)
|
|
$(shell ./generate_shellcode.sh)
|
|
|
|
$(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)/|$(RODIR)/|g')
|
|
|
|
build: $(BINDIR)/$(NAME)
|
|
|
|
# specific files for autogenerated headers
|
|
$(OBJDIR)/options.o: $(SRCDIR)/options.cpp $(DEPS) $(IDIR)/g_version.h
|
|
$(CC) $(CXXFLAGS) -c -o $@ $<
|
|
|
|
$(OBJDIR)/shellcode.o: $(SRCDIR)/shellcode.cpp $(DEPS) $(IDIR)/g_shellcode.h
|
|
$(CC) $(CXXFLAGS) -c -o $@ $<
|
|
|
|
$(OBJDIR)/debashify.o: $(SRCDIR)/debashify.cpp $(DEPS) $(IDIR)/g_shellcode.h
|
|
$(CC) $(CXXFLAGS) -c -o $@ $<
|
|
|
|
# generic files
|
|
|
|
$(RODIR)/%.o: $(SRCDIR)/%.c $(DEPS)
|
|
$(CC) $(CXXFLAGS) -c -o $@ $<
|
|
|
|
$(RODIR)/%.o: $(SRCDIR)/%.cpp $(DEPS)
|
|
$(CC) $(CXXFLAGS) -c -o $@ $<
|
|
|
|
|
|
$(BINDIR)/$(NAME): $(OBJ)
|
|
$(CC) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
test: $(BINDIR)/$(NAME)
|
|
$(BINDIR)/$(NAME)
|
|
|
|
clean:
|
|
rm $(ODIR)/*/*.o
|
|
|
|
clear:
|
|
rm $(BINDIR)/$(NAME)
|
|
|
|
install:
|
|
cp lxsh /usr/local/bin
|
|
cp completion/lxsh.bash /etc/bash_completion.d
|
|
|
|
uninstall:
|
|
rm /usr/local/bin/lxsh /etc/bash_completion.d/lxsh.bash
|