xref: /DragonOS/user/apps/test_sqlite3/Makefile (revision 52da9a59374752b4d01907b052135a0d317781dd)
1CC=$(DragonOS_GCC)/x86_64-elf-gcc
2LD=ld
3OBJCOPY=objcopy
4SQLITE_FILENAME=sqlite-amalgamation-3420000
5SQLITE3_DIR=$(shell pwd)/$(SQLITE_FILENAME)
6
7RELIBC_OPT=$(DADK_BUILD_CACHE_DIR_RELIBC_0_1_0)
8CFLAGS=-I $(RELIBC_OPT)/include -I $(SQLITE3_DIR) -D__dragonos__ -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_FLOATING_POINT -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEBUG
9
10tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
11output_dir=$(DADK_BUILD_CACHE_DIR_TEST_SQLITE3_3_42_0)
12
13LIBC_OBJS:=$(shell find $(RELIBC_OPT)/lib -name "*.o" | sort )
14LIBC_OBJS+=$(RELIBC_OPT)/lib/libc.a
15
16.PHONY: all clean download_sqlite3 __download_sqlite3
17
18
19all: main.o sqlite3.o
20	mkdir -p $(tmp_output_dir)
21
22	$(LD) -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/test_sqlite3  $(shell find . -name "*.o") $(LIBC_OBJS)
23
24	$(OBJCOPY) -I elf64-x86-64 -R ".eh_frame" -R ".comment" -O elf64-x86-64 $(tmp_output_dir)/test_sqlite3 $(output_dir)/test_sqlite3.elf
25	mv $(output_dir)/test_sqlite3.elf $(output_dir)/test_sqlite3
26
27main.o: main.c
28	$(CC) $(CFLAGS) -c main.c  -o main.o
29
30sqlite3.o: $(SQLITE3_DIR)/sqlite3.c
31	$(CC) $(CFLAGS) -c $(SQLITE3_DIR)/sqlite3.c -o sqlite3.o
32
33__download_sqlite3:
34	@echo "Download sqlite3 from https://mirrors.dragonos.org.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip"
35	@wget https://mirrors.dragonos.org.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip || (@echo "Download sqlite3 failed" && rm $(SQLITE_FILENAME).zip && exit 1)
36	@unzip -o $(SQLITE_FILENAME).zip || (@echo "Unzip sqlite3 failed" && exit 1)
37	@rm $(SQLITE_FILENAME).zip || (@echo "Remove $(SQLITE_FILENAME).zip failed" && exit 1)
38
39download_sqlite3:
40# 如果文件夹不存在,则下载,否则不下载
41	@test -d $(SQLITE3_DIR) || $(MAKE) __download_sqlite3
42
43clean:
44	rm -f *.o
45