b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 1 | # Common make definitions, customized for each platform
|
| 2 |
|
| 3 | # Definitions required in all program directories to compile and link
|
| 4 | # C programs using gcc.
|
| 5 |
|
| 6 | INC_DIR += $(addprefix -I, $(MBTK_INC_DIR))
|
| 7 |
|
| 8 | LIB_DIR += $(addprefix -L, $(MBTK_LIB_DIR))
|
| 9 |
|
| 10 | LIBS += $(addprefix -l, $(MBTK_LIBS))
|
| 11 |
|
| 12 | CFLAGS += $(MBTK_CFLAGS)
|
| 13 |
|
| 14 | ifeq ($(MBTK_BUILD_LIB), Y)
|
| 15 | CFLAGS += -shared -Wl,-shared,-Bsymbolic
|
| 16 | endif
|
| 17 |
|
| 18 | DEFINE += $(addprefix -D, $(MBTK_DEFINE))
|
| 19 |
|
| 20 | LOCAL_SRC_FILES := $(foreach dir,$(MBTK_SRC_DIR),$(wildcard $(dir)/*.c)) $(foreach dir,$(MBTK_SRC_DIR),$(wildcard $(dir)/*.cpp))
|
| 21 |
|
| 22 | OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
|
| 23 | $(info OBJS = $(OBJS))
|
| 24 |
|
| 25 | ifeq ($(MBTK_BUILD_LIB), Y)
|
| 26 | dtarget := $(OUT_DIR)/lib/lib$(MBTK_PROJECT_NAME).so
|
| 27 | else
|
| 28 | dtarget := $(OUT_DIR)/bin/$(MBTK_PROJECT_NAME)
|
| 29 | endif
|
| 30 |
|
| 31 | all: $(dtarget)
|
| 32 |
|
| 33 | $(dtarget): $(OBJS)
|
| 34 | $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $(OBJS) -o $@
|
| 35 |
|
| 36 | %.o:%.c
|
| 37 | $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
|
| 38 |
|
| 39 | %.o:%.cpp
|
| 40 | $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
|
| 41 |
|
| 42 | clean:
|
| 43 | rm -f $(OBJS) $(dtarget) |