C与C++ 工具不一样,分别标示目标
#CROSS = arm-linux-gnueabi-
CC = $(CROSS)gcc
CXX = $(CROSS)g++
C_SRC := $(wildcard *.c)
X_SRC := $(wildcard *.cpp)
C_OBJ := $(C_SRC:%.c=%.o)
X_OBJ := $(X_SRC:%.cpp=%.o)
C_TAG := $(C_OBJ:%.o=%)
X_TAG := $(X_OBJ:%.o=%)
all: $(C_TAG) $(X_TAG)
$(C_TAG):%:%.c
@echo $< $@
$(CC) $< -o $@ $(LIBS) $(CFLAGS)
$(X_TAG):%:%.cpp
@echo $< $@
$(CXX) $< -o $@ $(LIBS) $(CFLAGS)
clean:
@rm $(C_TAG) $(X_TAG)
####### C C++ 混编
#CROSS = arm-linux-gnueabi-
CC = $(CROSS)gcc
CXX = $(CROSS)g++
.PHONY :all
.PHONY :clean
C_SRC := $(wildcard *.c)
X_SRC := $(wildcard *.cpp)
C_OBJ := $(C_SRC:%.c=%.o)
X_OBJ := $(X_SRC:%.cpp=%.o)
C_TAG := $(C_OBJ:%.o=%)
X_TAG := $(X_OBJ:%.o=%)
TARGET = $(C_TAG) $(X_TAG)
CFLAGS = -static -Wall
LIBS = -lpthread
CV_INC +=`pkg-config --cflags opencv4`
CV_LIBS +=`pkg-config --libs opencv4`
CPPFLAGS += -g -std=c++11 -Wall
all: $(TARGET)
$(C_TAG):%:%.o
$(CC) $^ -o $@ $(LIBS) $(CFLAGS)
$(C_OBJ):%.o:%.c
$(CC) -c $< -o $@
$(X_TAG):%:%.o
$(CXX) $(CPPFLAGS) $< -o $@ $(CV_LIBS)
$(X_OBJ):%.o:%.cpp
$(CXX) $(CV_INC) $(CPPFLAGS) -c $< -o $@
clean:
@rm $(C_TAG) $(X_TAG)
@rm $(C_OBJ) $(X_OBJ)