# Common make definitions, customized for each platform | |
# Definitions required in all program directories to compile and link | |
# C programs using gcc. | |
INC_DIR += $(addprefix -I, $(MBTK_INC_DIR)) | |
LIB_DIR += $(addprefix -L, $(MBTK_LIB_DIR)) | |
LIBS += $(addprefix -l, $(MBTK_LIBS)) | |
CFLAGS += $(MBTK_CFLAGS) | |
ifeq ($(MBTK_BUILD_LIB), Y) | |
CFLAGS += -shared -Wl,-shared,-Bsymbolic | |
endif | |
DEFINE += $(addprefix -D, $(MBTK_DEFINE)) | |
LOCAL_SRC_FILES := $(foreach dir,$(MBTK_SRC_DIR),$(wildcard $(dir)/*.c)) $(foreach dir,$(MBTK_SRC_DIR),$(wildcard $(dir)/*.cpp)) | |
OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES))) | |
$(info OBJS = $(OBJS)) | |
ifeq ($(MBTK_BUILD_LIB), Y) | |
dtarget := $(OUT_DIR)/lib/lib$(MBTK_PROJECT_NAME).so | |
else | |
dtarget := $(OUT_DIR)/bin/$(MBTK_PROJECT_NAME) | |
endif | |
all: $(dtarget) | |
$(dtarget): $(OBJS) | |
$(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $(OBJS) -o $@ | |
%.o:%.c | |
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@ | |
%.o:%.cpp | |
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@ | |
clean: | |
rm -f $(OBJS) $(dtarget) |