W dniu 31.07.2020 o 22:21, Mike Terry pisze:
I compiled dirtyphp.cpp under Linux Mint with -E option and I noticed
that in dirtyphp.i file TRACE("main called" << endl); is expanded to
single semicolon. This means that DEBUG symbol is undefined although I
use -DDEBUG option of the compiler:
debug: CXXFLAGS += -DDEBUG -g
and I see this option during compilation:
c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -c
src/dirtyphp.cpp -o build/objects/src/dirtyphp.o -L/usr/lib -lstdc++
-lstdc++fs -lm
c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -c
src/common.cpp -o build/objects/src/common.o -L/usr/lib -lstdc++
-lstdc++fs -lm
c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -c
src/source_file.cpp -o build/objects/src/source_file.o -L/usr/lib
-lstdc++ -lstdc++fs -lm
c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -c
src/obfuscator.cpp -o build/objects/src/obfuscator.o -L/usr/lib -lstdc++
-lstdc++fs -lm
c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -o ./build/apps/dirtyphp
build/objects/src/dirtyphp.o build/objects/src/common.o
build/objects/src/source_file.o build/objects/src/obfuscator.o
-L/usr/lib -lstdc++ -lstdc++fs -lm
Here's my Makefile:
#ifeq ($(ARCH),win32)
## Windows with the VC++ compiler
#ObjSuf = obj
#SrcSuf = cxx
#ExeSuf = .exe
#DllSuf = dll
#OutPutOpt = -out:
#CXX = cl
#CXXOPT = -O2
#CXXOPT = -Z7
#CXXFLAGS = $(CXXOPT) -G5 -GR -GX -MD -DWIN32 -D_WINDOWS -nologo \
# -DVISUAL_CPLUSPLUS -D_X86_=1 -D_DLL
#LD = link
#LDOPT = -opt:ref
#LDOPT = -debug
#LDFLAGS = $(LDOPT) -pdb:none -nologo
#SOFLAGS = -DLL
CXX := -c++ # gcc czy g++?
CXXFLAGS := -Wall -Wextra -Werror -no-pie # -pedantic-errors; add
"-no-pie" to the CMAKE_CXX_FLAGS
LDFLAGS := -L/usr/lib -lstdc++ -lstdc++fs -lm # -Lsrc/boost_1_65_0/lib/
-lboost_regex-gcc34-mt-d-1_3
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/apps
TARGET := dirtyphp
INCLUDE := -Iinclude/ # -I src/boost_1_65_0
SRC := $(wildcard src/*.cpp)
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
all: build $(APP_DIR)/$(TARGET)
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ $(LDFLAGS)
$(APP_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS)
.PHONY: all build clean debug release
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug: CXXFLAGS += -DDEBUG -g
debug: all
test: CXXFLAGS += -pg # dodałem dynamic execution profiler
test: all
release: CXXFLAGS += -O2
release: all # production
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*