lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #******************************************************************************* |
| 2 | # include build/common makefile |
| 3 | # 以生成两个应用为例,如果只有一个删除EXEC2 OBJS2即可 |
| 4 | #******************************************************************************* |
| 5 | include $(COMMON_MK) |
| 6 | |
| 7 | EXEC = demo1 |
| 8 | OBJS = demo1.o |
| 9 | #EXEC 特有的LIB参数 |
| 10 | #LDLIBS_demo1 = -lnvram_sc -L$(LIB_DIR)/libnvram |
| 11 | |
| 12 | EXEC2 = demo2 |
| 13 | OBJS2 = demo2.o |
| 14 | #EXEC2 特有的LIB参数 |
| 15 | #LDLIBS_demo2 = -lsoft_timer_sc -L$(LIB_DIR)/libsoft_timer |
| 16 | |
| 17 | #宏和头文件目录在CFLAGS里定义,要用+=,不要用=,否则会覆盖COMMON_MK里的值 |
| 18 | #CFLAGS += -I$(APP_DIR)/include |
| 19 | CXXFLAGS = -Wall -g -std=c++11 |
| 20 | |
| 21 | #EXEC EXEC2 公共LIB参数,第一行定义LDLIBS用=,不要用+=,应用连接的库都在本Makefile定义 |
| 22 | LDLIBS = -lpthread |
| 23 | |
| 24 | #******************************************************************************* |
| 25 | # targets |
| 26 | #******************************************************************************* |
| 27 | all: $(EXEC) $(EXEC2) |
| 28 | |
| 29 | $(EXEC): $(OBJS) |
| 30 | $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group |
| 31 | @cp $@ $@.elf |
| 32 | |
| 33 | $(EXEC2): $(OBJS2) |
| 34 | $(CXX) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group |
| 35 | @cp $@ $@.elf |
| 36 | |
| 37 | romfs: |
| 38 | $(ROMFSINST) $(EXEC) /bin/$(EXEC) |
| 39 | $(ROMFSINST) $(EXEC2) /bin/$(EXEC2) |
| 40 | |
| 41 | clean: |
| 42 | -@rm -f $(EXEC) $(EXEC2) *.elf *.gdb *.o |