Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile modify #69

Open
fatalfeel opened this issue Jun 28, 2022 · 0 comments
Open

Makefile modify #69

fatalfeel opened this issue Jun 28, 2022 · 0 comments

Comments

@fatalfeel
Copy link

fatalfeel commented Jun 28, 2022

#auto add thread predefine and faster code
#https://stackoverflow.com/questions/23250863/difference-between-pthread-and-lpthread-while-compiling

TARGET1 = rtsp_server
TARGET2 = rtsp_pusher
TARGET3 = rtsp_h264_file

CROSS_COMPILE =
CXX = $(CROSS_COMPILE)g++
CC = $(CROSS_COMPILE)gcc
#STRIP = $(CROSS_COMPILE)strip

INC = -I$(shell pwd)/src/ -I$(shell pwd)/src/net -I$(shell pwd)/src/xop -I$(shell pwd)/src/3rdpart
LIB =

#DEUBG = -D_DEBUG
#LD_FLAGS = -lrt -pthread -lpthread -ldl -lm $(DEBUG)
#CXX_FLAGS = -std=c++11
#O_FLAG = -O2
CXX_FLAGS = -O3 -g -fPIC -pthread -fmessage-length=0 -std=c++14
LD_FLAGS = -ldl -lm -lrt -lpthread
OBJS_PATH = objs

SRC1 = $(notdir $(wildcard ./src/net/*.cpp))
OBJS1 = $(patsubst %.cpp,$(OBJS_PATH)/%.o,$(SRC1))

SRC2 = $(notdir $(wildcard ./src/xop/*.cpp))
OBJS2 = $(patsubst %.cpp,$(OBJS_PATH)/%.o,$(SRC2))

SRC3 = $(notdir $(wildcard ./example/rtsp_server.cpp))
OBJS3 = $(patsubst %.cpp,$(OBJS_PATH)/%.o,$(SRC3))

SRC4 = $(notdir $(wildcard ./example/rtsp_pusher.cpp))
OBJS4 = $(patsubst %.cpp,$(OBJS_PATH)/%.o,$(SRC4))

SRC5 = $(notdir $(wildcard ./example/rtsp_h264_file.cpp))
OBJS5 = $(patsubst %.cpp,$(OBJS_PATH)/%.o,$(SRC5))

$(OBJS_PATH)/%.o : ./example/%.cpp
$(CXX) $(CXX_FLAGS) $(INC) -c $< -o $@
$(OBJS_PATH)/%.o : ./src/net/%.cpp
$(CXX) $(CXX_FLAGS) $(INC) -c $< -o $@
$(OBJS_PATH)/%.o : ./src/xop/%.cpp
$(CXX) $(CXX_FLAGS) $(INC) -c $< -o $@

$(TARGET1) : $(OBJS1) $(OBJS2) $(OBJS3)
$(CXX) $(CXX_FLAGS) $^ -o $@ $(LD_FLAGS)
$(TARGET2) : $(OBJS1) $(OBJS2) $(OBJS4)
$(CXX) $(CXX_FLAGS) $^ -o $@ $(LD_FLAGS)
$(TARGET3) : $(OBJS1) $(OBJS2) $(OBJS5)
$(CXX) $(CXX_FLAGS) $^ -o $@ $(LD_FLAGS)

BUILD_DIR:
@-mkdir -p $(OBJS_PATH)

all: BUILD_DIR $(TARGET1) $(TARGET2) $(TARGET3)

clean:
-rm -rf $(OBJS_PATH) $(TARGET1) $(TARGET2) $(TARGET3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant