Reputation: 1158
I've created an application and a couple of libraries. All these codes need to be cross-compiled for an embedded platform. I have got a custom root file system generated for the Linux kernel which will run on the same platform.
In the application's Makefile, I'm exporting some of the variables to be used by the library Makefiles. Should I export the --sysroot
option as well? If so, at which stage (compile, archive, etc.) should I feed this option?
# ...application specific configuration ...
SYSTEM_ROOT_PATH := /path/to/custom-rootfs
# Variables exported for user-defined libraries
export DEFINES
export CPP_FLAGS
export SANITIZERS
# ... trigger library Makefiles ...
all: $(CPP_OBJECTS)
@$(CC) --sysroot="$(SYSTEM_ROOT_PATH)" -o app.elf $(CPP_OBJECTS) $(SANITIZERS) $(LIBS)
$(PRJ_OBJECTS_DIR)/%.o : $(PRJ_SOURCE_CODE)/%.cpp
@$(CC) $(CPP_FLAGS) $(SANITIZERS) $(INCLUDES) $(DEFINES) -c $< -o $@ -MD -MP
# ... library specific configuration ...
all: $(CPP_OBJECTS)
$(AR) rcs library.a $(CPP_OBJECTS)
$(LIB_OBJECTS_DIR)/%.o : $(LIB_SOURCES)/%.cpp
@$(CC) $(CPP_FLAGS) $(SANITIZERS) $(INCLUDES) $(DEFINES) -c $< -o $@ -MD -MP
Upvotes: 0
Views: 439