我有以下由python脚本执行的makefile:
// Pipeline
[
// Stage 1
{
$match: {
"openBalance": {
"$ne": 0.0
}
}
},
// Stage 2
{
$lookup: {
"from": "customers",
"localField": "customer.id",
"foreignField": "_id",
"as": "customer"
}
},
// Stage 3
{
$unwind: {
"path": "$customer"
}
},
// Stage 4
{
$lookup: {
"from": "visits",
"localField": "visit.id",
"foreignField": "_id",
"as": "visit"
}
},
// Stage 5
{
$unwind: {
"path": "$visit"
}
},
// Stage 6
{
$group: {
"_id": "$customer._id",
"submissions": {
"$push": "$submissions"
},
"staffMember": {
"$first": "$staffMember.id"
},
"visit": {
"$first": "$visit"
},
"openBalance": {
"$sum": "$openBalance"
},
"customerResponsibleOpenBalance": {
"$sum": {
"$cond": ["$visit.customerResponsibility", 1, 0]
}
},
"agencyResponsibleOpenBalance": {
"$sum": {
"$cond": ["$visit.customerResponsibility", 0, 1]
}
},
"openClaims": {
"$sum": {
"$cond": {
"if": {
"$gt": ["$submissions.0.responses.balance", 0.0]
},
"then": 1.0,
"else": 0.0
}
}
}
}
},
// Stage 7
{
$addFields: {
"payerInfo": "$submissions.0.details.agency._id"
}
},
// Stage 8
{
$lookup: {
"from": "agencies",
"localField": "submissions.0.details.agency._id",
"foreignField": "_id",
"as": "agency"
}
},
// Stage 9
{
$unwind: {
"path": "$agency"
}
},
// Stage 10
{
$addFields: {
"claimSupervisor": "$agency.claims.supervisor"
}
},
// Stage 11
{
$lookup: {
"from": "staffmembers",
"localField": "claimSupervisor",
"foreignField": "_id",
"as": "claimSupervisor"
}
},
// Stage 12
{
$unwind: {
"path": "$claimSupervisor"
}
},
// Stage 13
{
$lookup: {
"from": "customers",
"localField": "_id",
"foreignField": "_id",
"as": "customer"
}
},
// Stage 14
{
$unwind: {
"path": "$customer"
}
},
// Stage 15
{
$lookup: {
"from": "locales",
"localField": "customer.locale",
"foreignField": "_id",
"as": "locale"
}
},
// Stage 16
{
$unwind: {
"path": "$locale"
}
},
// Stage 17
{
$lookup: {
"from": "agencies",
"localField": "agencies",
"foreignField": "_id",
"as": "agencies"
}
},
// Stage 18
{
$project: {
"customer": {
"_id": 1.0,
"name": 1.0
},
"agency": {
"_id": 1.0,
"name": 1.0,
"transactionType": 1.0
},
"visit": {
"_id": 1.0,
"customerResponsibility": 1.0
},
"openBalance": 1.0,
"openClaims": 1.0,
"customerResponsibleOpenBalance": {
"$sum": "$customerResponsibleOpenBalance"
},
"agencyResponsibleOpenBalance": {
"$sum": "$agencyResponsibleOpenBalance"
},
"locale": {
"_id": 1.0,
"name": 1.0
},
"firstSubmission": {
"$arrayElemAt": ["$submissions", 0.0]
},
"lastSubmission": {
"$arrayElemAt": ["$submissions", -1.0]
},
"claimSupervisor": {
"_id": 1.0,
"name": 1.0
}
}
},
// Stage 19
{
$unwind: {
"path": "$firstSubmission"
}
},
// Stage 20
{
$unwind: {
"path": "$lastSubmission"
}
},
// Stage 21
{
$project: {
"firstSubmission": {
"details": 0.0,
"responses": 0.0
},
"lastSubmission": {
"details": 0.0,
"responses": 0.0
}
}
},
],
);
这是项目树
-> / sources /
-> /sources/libmylib.a
-> / makefile
我想添加
SOURCES_DIRECTORY = sources
# These directories should be created by build.py script
BUILD_DIRECTORY = builds
OBJECTS_DIRECTORY = objs
CORE = cortex-m4
LINKER_SCRIPT = linker_rom.ld
# C definitions
ifeq ($(RAM_FLASH), 1)
C_DEFS = -DRAM_FLASH
else
C_DEFS =
endif
INC_DIRS = sources
SRCS_DIRS = sources
# extension of C files
C_EXT = c
# wildcard for C source files (all files with C_EXT extension found in current
# folder and SRCS_DIRS folders will be compiled and linked)
C_SRCS = $(wildcard $(patsubst %, %/*.$(C_EXT), . $(SRCS_DIRS)))
# extension of ASM files
AS_EXT = s
# wildcard for ASM source files (all files with AS_EXT extension found in
# current folder and SRCS_DIRS folders will be compiled and linked)
AS_SRCS = $(wildcard $(patsubst %, %/*.$(AS_EXT), . $(SRCS_DIRS)))
# optimization flags ("-O0" - no optimization, "-O1" - optimize, "-O2" -
# optimize even more, "-Os" - optimize for size or "-O3" - optimize yet more)
OPTIMIZATION = -Og
# set to 1 to optimize size by removing unused code and data during link phase
REMOVE_UNUSED = 1
C_WARNINGS = -Wall -Wextra -Werror
# C language standard ("c89" / "iso9899:1990", "iso9899:199409",
# "c99" / "iso9899:1999", "gnu89" - default, "gnu99")
C_STD = c99
VPATH = $(SRCS_DIRS)
#============================================#
# Toolchain Configuration #
#============================================#
TOOLCHAIN = arm-none-eabi-
CXX = $(TOOLCHAIN)g++
CC = $(TOOLCHAIN)gcc
AS = $(TOOLCHAIN)gcc -x assembler-with-cpp
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump
SIZE = $(TOOLCHAIN)size
RM = rm -f
.PHONY: all clean
#=============================================================================#
# various compilation flags
#=============================================================================#
# core flags
CORE_FLAGS = -mcpu=$(CORE) -mthumb -specs=nano.specs -specs=nosys.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard
# flags for C compiler
C_FLAGS = -std=$(C_STD) -g -ggdb3 -fverbose-asm -Wa,-ahlms=$(OBJECTS_DIRECTORY)/$(notdir $(<:.$(C_EXT)=.lst)) -DSTM32F429xx $(FLAGS)
# flags for assembler
AS_FLAGS = -g -ggdb3 -Wa,-amhls=$(OBJECTS_DIRECTORY)/$(notdir $(<:.$(AS_EXT)=.lst)) $(FLAGS)
# flags for linker
LD_FLAGS = -T$(LINKER_SCRIPT) -g -Wl,-Map=$(OBJECTS_DIRECTORY)/test.map,--cref,--no-warn-mismatch
# process option for removing unused code
ifeq ($(REMOVE_UNUSED), 1)
LD_FLAGS += -Wl,--gc-sections
OPTIMIZATION += -ffunction-sections -fdata-sections
endif
LIBS = libmylib.a
LIB_DIRS = ./sources
#=============================================================================#
# do some formatting
#=============================================================================#
C_OBJS = $(addprefix $(OBJECTS_DIRECTORY)/, $(notdir $(C_SRCS:.$(C_EXT)=.o)))
AS_OBJS = $(addprefix $(OBJECTS_DIRECTORY)/, $(notdir $(AS_SRCS:.$(AS_EXT)=.o)))
OBJS = $(AS_OBJS) $(C_OBJS) $(CXX_OBJS) $(USER_OBJS)
DEPS = $(OBJS:.o=.d)
INC_DIRS_F = -I. $(patsubst %, -I%, $(INC_DIRS))
LIB_DIRS_F = $(patsubst %, -L%, $(LIB_DIRS))
ELF = $(BUILD_DIRECTORY)/$(NAME).elf
HEX = $(BUILD_DIRECTORY)/$(NAME).hex
BIN = $(BUILD_DIRECTORY)/$(NAME).bin
LSS = $(BUILD_DIRECTORY)/$(NAME).lss
DMP = $(BUILD_DIRECTORY)/$(NAME).dmp
# format final flags for tools, request dependancies for C++, C and asm
C_FLAGS_F = $(CORE_FLAGS) $(OPTIMIZATION) $(C_WARNINGS) $(C_FLAGS) $(C_DEFS) -MD -MP -MF $(OBJECTS_DIRECTORY)/$(@F:.o=.d) $(INC_DIRS_F)
AS_FLAGS_F = $(CORE_FLAGS) $(AS_FLAGS) $(AS_DEFS) -MD -MP -MF $(OBJECTS_DIRECTORY)/$(@F:.o=.d) $(INC_DIRS_F)
LD_FLAGS_F = $(CORE_FLAGS) $(LD_FLAGS) $(LIB_DIRS_F)
#contents of output directory
GENERATED = $(wildcard $(patsubst %, $(BUILD_DIRECTORY)/*.%, bin d dmp elf hex lss lst map o))
#=============================================================================#
# make all
#=============================================================================#
all : $(ELF) $(LSS) $(DMP) $(HEX) $(BIN)
# make object files dependent on Makefile
$(OBJS) : $(MAKEFILE_NAME)
# make .elf file dependent on linker script
$(ELF) : $(LINKER_SCRIPT)
#-----------------------------------------------------------------------------#
# linking - objects -> elf
#-----------------------------------------------------------------------------#
$(ELF) : $(OBJS)
$(CC) $(LD_FLAGS_F) $(OBJS) $(LIBS) -o $@
#-----------------------------------------------------------------------------#
# compiling - C source -> objects
#-----------------------------------------------------------------------------#
objs/%.o : %.$(C_EXT)
$(CC) -c $(C_FLAGS_F) $< -o $@
#-----------------------------------------------------------------------------#
# assembling - ASM source -> objects
#-----------------------------------------------------------------------------#
objs/%.o : %.$(AS_EXT)
$(AS) -c $(AS_FLAGS_F) $< -o $@
#-----------------------------------------------------------------------------#
# memory images - elf -> hex, elf -> bin
#-----------------------------------------------------------------------------#
$(HEX) : $(ELF)
$(OBJCOPY) -O ihex $< $@
$(BIN) : $(ELF)
$(OBJCOPY) -O binary $< $@
#-----------------------------------------------------------------------------#
# memory dump - elf -> dmp
#-----------------------------------------------------------------------------#
$(DMP) : $(ELF)
$(OBJDUMP) -x --syms $< > $@
#-----------------------------------------------------------------------------#
# extended listing - elf -> lss
#-----------------------------------------------------------------------------#
$(LSS) : $(ELF)
$(OBJDUMP) -S $< > $@
# include dependancy files
-include $(DEPS)
将解决问题。我的库是libmylib.a文件。但是,控制台仍会输出带有未定义功能引用的错误。我应该改变什么? 带有源,对象,标题和标志的目录的路径由python脚本作为参数动态传递。
答案 0 :(得分:3)
应该是:
LIBS = -lmylib
编译器将在lib
之前加上.a
到您指定的库中,以使其查找名为libmylib.a
的库文件。