1*6d81180bSLoGinCC=$(DragonOS_GCC)/x86_64-elf-gcc 2*6d81180bSLoGinLD=ld 3*6d81180bSLoGinOBJCOPY=objcopy 4*6d81180bSLoGinSQLITE_FILENAME=sqlite-amalgamation-3420000 5*6d81180bSLoGinSQLITE3_DIR=$(shell pwd)/$(SQLITE_FILENAME) 6*6d81180bSLoGin 7*6d81180bSLoGinRELIBC_OPT=$(DADK_BUILD_CACHE_DIR_RELIBC_0_1_0) 8*6d81180bSLoGinCFLAGS=-I $(RELIBC_OPT)/include -I $(SQLITE3_DIR) -D__dragonos__ -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_FLOATING_POINT -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEBUG 9*6d81180bSLoGin 10*6d81180bSLoGintmp_output_dir=$(ROOT_PATH)/bin/tmp/user 11*6d81180bSLoGinoutput_dir=$(DADK_BUILD_CACHE_DIR_TEST_SQLITE3_3_42_0) 12*6d81180bSLoGin 13*6d81180bSLoGinLIBC_OBJS:=$(shell find $(RELIBC_OPT)/lib -name "*.o" | sort ) 14*6d81180bSLoGinLIBC_OBJS+=$(RELIBC_OPT)/lib/libc.a 15*6d81180bSLoGin 16*6d81180bSLoGin.PHONY: all clean download_sqlite3 __download_sqlite3 17*6d81180bSLoGin 18*6d81180bSLoGin 19*6d81180bSLoGinall: main.o sqlite3.o 20*6d81180bSLoGin mkdir -p $(tmp_output_dir) 21*6d81180bSLoGin 22*6d81180bSLoGin $(LD) -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/test_sqlite3 $(shell find . -name "*.o") $(LIBC_OBJS) 23*6d81180bSLoGin 24*6d81180bSLoGin $(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*6d81180bSLoGin mv $(output_dir)/test_sqlite3.elf $(output_dir)/test_sqlite3 26*6d81180bSLoGin 27*6d81180bSLoGinmain.o: main.c 28*6d81180bSLoGin $(CC) $(CFLAGS) -c main.c -o main.o 29*6d81180bSLoGin 30*6d81180bSLoGinsqlite3.o: $(SQLITE3_DIR)/sqlite3.c 31*6d81180bSLoGin $(CC) $(CFLAGS) -c $(SQLITE3_DIR)/sqlite3.c -o sqlite3.o 32*6d81180bSLoGin 33*6d81180bSLoGin__download_sqlite3: 34*6d81180bSLoGin @echo "Download sqlite3 from https://mirrors.ringotek.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip" 35*6d81180bSLoGin @wget https://mirrors.ringotek.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip || (@echo "Download sqlite3 failed" && rm $(SQLITE_FILENAME).zip && exit 1) 36*6d81180bSLoGin @unzip -o $(SQLITE_FILENAME).zip || (@echo "Unzip sqlite3 failed" && exit 1) 37*6d81180bSLoGin @rm $(SQLITE_FILENAME).zip || (@echo "Remove $(SQLITE_FILENAME).zip failed" && exit 1) 38*6d81180bSLoGin 39*6d81180bSLoGindownload_sqlite3: 40*6d81180bSLoGin# 如果文件夹不存在,则下载,否则不下载 41*6d81180bSLoGin @test -d $(SQLITE3_DIR) || $(MAKE) __download_sqlite3 42*6d81180bSLoGin 43*6d81180bSLoGinclean: 44*6d81180bSLoGin rm -f *.o 45