Fix build makefile
Change-Id: I26851cdf0a1339dcd3768d6353f3f11b4821ac5d
diff --git a/.gitignore b/.gitignore
index dd490d6..a75a245 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
build.log
out/
-
+*.o
diff --git a/mbtk/lynq_lib/Makefile b/mbtk/lynq_lib/Makefile
index 6e5be89..22a5e03 100755
--- a/mbtk/lynq_lib/Makefile
+++ b/mbtk/lynq_lib/Makefile
@@ -22,20 +22,23 @@
#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
#endif
-MY_FILES_SUFFIX:=%.c %.cpp
-My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
-MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
-MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
-LOCAL_SRC_FILES += $(MY_SRC_LIST)
-$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+LOCAL_SRC_FILES = $(wildcard src/*.c) $(wildcard src/*.cpp)
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
dtarget := $(OUT_DIR)/lib/liblynq_lib.so
all: $(dtarget)
-$(dtarget):
- $(CC) $(CFLAGS) $(LOCAL_SRC_FILES) -o $@ $(DEFINE) $(INC_DIR) $(LIB_DIR) $(LIBS)
+$(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)
diff --git a/mbtk/mbtk_lib/Makefile b/mbtk/mbtk_lib/Makefile
index b078162..9ab7896 100755
--- a/mbtk/mbtk_lib/Makefile
+++ b/mbtk/mbtk_lib/Makefile
@@ -37,21 +37,73 @@
#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
#endif
-MY_FILES_SUFFIX:=%.c %.cpp
-My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
-MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
-MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
-LOCAL_SRC_FILES += $(MY_SRC_LIST)
-$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+#MY_FILES_SUFFIX:=%.c %.cpp
+#My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
+#MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
+#MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
+#LOCAL_SRC_FILES += $(MY_SRC_LIST)
+
+LOCAL_SRC_FILES = src/ds_ASBuffer.cpp \
+ src/ds_ASString.cpp \
+ src/g711_pcm_convert.c \
+ src/mbtk_adc.c \
+ src/mbtk_at.c \
+ src/mbtk_audio_alsa.c \
+ src/mbtk_audio.c \
+ src/mbtk_basic_at_wrapper.c \
+ src/mbtk_bs_position.c \
+ src/mbtk_coap_api.cpp \
+ src/mbtk_coap.c \
+ src/mbtk_coap_pdu.cpp \
+ src/mbtk_dhcp.c \
+ src/mbtk_file.c \
+ src/mbtk_ftp_at.c \
+ src/mbtk_ftp.c \
+ src/mbtk_gnss.c \
+ src/mbtk_gnss_update.c \
+ src/mbtk_gpio.c \
+ src/mbtk_http_base.c \
+ src/mbtk_http.c \
+ src/mbtk_http_chunks.c \
+ src/mbtk_ifc.c \
+ src/mbtk_info_api.c \
+ src/mbtk_info.c \
+ src/mbtk_list.c \
+ src/mbtk_log.c \
+ src/mbtk_map.c \
+ src/mbtk_net_control.c \
+ src/mbtk_ntp.c \
+ src/mbtk_pdu_sms.c \
+ src/mbtk_queue.c \
+ src/mbtk_sock2.c \
+ src/mbtk_sock.c \
+ src/mbtk_str.c \
+ src/mbtk_task.c \
+ src/mbtk_tcpip_at.c \
+ src/mbtk_utf.c \
+ src/mbtk_utils.c \
+ src/ringbuffer.c
+
+ifeq ($(BUILD_PLATFORM), asr1803)
+LOCAL_SRC_FILES += src/mbtk_mp3_to_wav.c
+endif
+
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
dtarget := $(OUT_DIR)/lib/libmbtk_lib.so
all: $(dtarget)
-$(dtarget):
- $(CC) $(CFLAGS) $(LOCAL_SRC_FILES) -o $@ $(DEFINE) $(INC_DIR) $(LIB_DIR) $(LIBS)
+$(dtarget):$(OBJS)
+ $(CC) $(CFLAGS) $(DEFINE) $(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)
diff --git a/mbtk/mbtk_mqtt/Makefile b/mbtk/mbtk_mqtt/Makefile
index 9102863..4c89d96 100755
--- a/mbtk/mbtk_mqtt/Makefile
+++ b/mbtk/mbtk_mqtt/Makefile
@@ -25,20 +25,23 @@
#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
#endif
-MY_FILES_SUFFIX:=%.c %.cpp
-My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
-MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
-MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
-LOCAL_SRC_FILES += $(MY_SRC_LIST)
-$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+LOCAL_SRC_FILES = $(wildcard MQTTPacket/*.c) $(wildcard *.c)
+OBJS = $(patsubst %.c, %.o, $(LOCAL_SRC_FILES))
+$(info OBJS = $(OBJS))
dtarget := $(OUT_DIR)/lib/libmbtk_mqtt_lib.so
all: $(dtarget)
-$(dtarget):
- $(CC) $(CFLAGS) $(LOCAL_SRC_FILES) -o $@ $(DEFINE) $(INC_DIR) $(LIB_DIR) $(LIBS)
+$(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)
diff --git a/mbtk/mbtk_ril/Makefile b/mbtk/mbtk_ril/Makefile
index 813d94b..e75fe08 100755
--- a/mbtk/mbtk_ril/Makefile
+++ b/mbtk/mbtk_ril/Makefile
@@ -24,21 +24,24 @@
#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
#endif
-MY_FILES_SUFFIX:=%.c %.cpp
-My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
-MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
-MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
-LOCAL_SRC_FILES += $(MY_SRC_LIST)
-$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+LOCAL_SRC_FILES = $(wildcard src/*.c) $(wildcard src/*.cpp)
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
dtarget := $(OUT_DIR)/bin/mbtk_ril
all: $(dtarget)
-$(dtarget):
+$(dtarget): $(OBJS)
@echo " BIN $@"
- $(CC) $(CFLAGS) $(LOCAL_SRC_FILES) -o $@ $(DEFINE) $(INC_DIR) $(LIB_DIR) $(LIBS)
+ $(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)
diff --git a/mbtk/ql_lib/Makefile b/mbtk/ql_lib/Makefile
index f802fef..db8e557 100755
--- a/mbtk/ql_lib/Makefile
+++ b/mbtk/ql_lib/Makefile
@@ -22,20 +22,30 @@
#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
#endif
-MY_FILES_SUFFIX:=%.c %.cpp
-My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
-MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
-MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
-LOCAL_SRC_FILES += $(MY_SRC_LIST)
+#MY_FILES_SUFFIX:=%.c %.cpp
+#My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
+#MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
+#MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
+
+LOCAL_SRC_FILES = $(wildcard src/*.c) $(wildcard src/*.cpp)
$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
+
dtarget := $(OUT_DIR)/lib/libql_lib.so
all: $(dtarget)
-$(dtarget):
- $(CC) $(CFLAGS) $(LOCAL_SRC_FILES) -o $@ $(DEFINE) $(INC_DIR) $(LIB_DIR) $(LIBS)
+$(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)
diff --git a/mbtk/test/Makefile b/mbtk/test/Makefile
index 289c074..61f800f 100755
--- a/mbtk/test/Makefile
+++ b/mbtk/test/Makefile
@@ -26,19 +26,30 @@
#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
#endif
-MY_FILES_SUFFIX:=%.c %.cpp
-My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
-MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
-MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
-LOCAL_SRC_FILES += $(MY_SRC_LIST)
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
-BINS = $(patsubst %.c,%,$(LOCAL_SRC_FILES))
+# *.cc 文件需要手动添加才会编译
+ifeq ($(BUILD_PLATFORM), asr1803)
+LOCAL_SRC_FILES += polarssl_demo.cc
+endif
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(LOCAL_SRC_FILES))))
+BINS = $(patsubst %.o,%,$(OBJS))
all: $(BINS)
-$(BINS):
+$(BINS):$(OBJS)
@echo " BIN $@"
- $(CC) $(CFLAGS) -o $(OUT_DIR)/bin/$@ $@.c $(DEFINE) $(INC_DIR) $(LIB_DIR) $(LIBS)
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cc
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
clean:
diff --git a/mbtk/test/polarssl_demo.c b/mbtk/test/polarssl_demo.cc
similarity index 100%
rename from mbtk/test/polarssl_demo.c
rename to mbtk/test/polarssl_demo.cc