xref: /DragonOS/user/apps/test_sqlite3/Makefile (revision c566df451ce6dbf2af684333e68b39fdfff86498)
16d81180bSLoGinCC=$(DragonOS_GCC)/x86_64-elf-gcc
26d81180bSLoGinLD=ld
36d81180bSLoGinOBJCOPY=objcopy
46d81180bSLoGinSQLITE_FILENAME=sqlite-amalgamation-3420000
56d81180bSLoGinSQLITE3_DIR=$(shell pwd)/$(SQLITE_FILENAME)
66d81180bSLoGin
76d81180bSLoGinRELIBC_OPT=$(DADK_BUILD_CACHE_DIR_RELIBC_0_1_0)
86d81180bSLoGinCFLAGS=-I $(RELIBC_OPT)/include -I $(SQLITE3_DIR) -D__dragonos__ -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_FLOATING_POINT -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEBUG
96d81180bSLoGin
106d81180bSLoGintmp_output_dir=$(ROOT_PATH)/bin/tmp/user
116d81180bSLoGinoutput_dir=$(DADK_BUILD_CACHE_DIR_TEST_SQLITE3_3_42_0)
126d81180bSLoGin
136d81180bSLoGinLIBC_OBJS:=$(shell find $(RELIBC_OPT)/lib -name "*.o" | sort )
146d81180bSLoGinLIBC_OBJS+=$(RELIBC_OPT)/lib/libc.a
156d81180bSLoGin
166d81180bSLoGin.PHONY: all clean download_sqlite3 __download_sqlite3
176d81180bSLoGin
186d81180bSLoGin
196d81180bSLoGinall: main.o sqlite3.o
206d81180bSLoGin	mkdir -p $(tmp_output_dir)
216d81180bSLoGin
226d81180bSLoGin	$(LD) -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/test_sqlite3  $(shell find . -name "*.o") $(LIBC_OBJS)
236d81180bSLoGin
246d81180bSLoGin	$(OBJCOPY) -I elf64-x86-64 -R ".eh_frame" -R ".comment" -O elf64-x86-64 $(tmp_output_dir)/test_sqlite3 $(output_dir)/test_sqlite3.elf
256d81180bSLoGin	mv $(output_dir)/test_sqlite3.elf $(output_dir)/test_sqlite3
266d81180bSLoGin
276d81180bSLoGinmain.o: main.c
286d81180bSLoGin	$(CC) $(CFLAGS) -c main.c  -o main.o
296d81180bSLoGin
306d81180bSLoGinsqlite3.o: $(SQLITE3_DIR)/sqlite3.c
316d81180bSLoGin	$(CC) $(CFLAGS) -c $(SQLITE3_DIR)/sqlite3.c -o sqlite3.o
326d81180bSLoGin
336d81180bSLoGin__download_sqlite3:
34*c566df45SLoGin	@echo "Download sqlite3 from https://mirrors.dragonos.org.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip"
35*c566df45SLoGin	@wget https://mirrors.dragonos.org.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip || (@echo "Download sqlite3 failed" && rm $(SQLITE_FILENAME).zip && exit 1)
366d81180bSLoGin	@unzip -o $(SQLITE_FILENAME).zip || (@echo "Unzip sqlite3 failed" && exit 1)
376d81180bSLoGin	@rm $(SQLITE_FILENAME).zip || (@echo "Remove $(SQLITE_FILENAME).zip failed" && exit 1)
386d81180bSLoGin
396d81180bSLoGindownload_sqlite3:
406d81180bSLoGin# 如果文件夹不存在,则下载,否则不下载
416d81180bSLoGin	@test -d $(SQLITE3_DIR) || $(MAKE) __download_sqlite3
426d81180bSLoGin
436d81180bSLoGinclean:
446d81180bSLoGin	rm -f *.o
45