xref: /DragonOS/user/apps/test_sqlite3/Makefile (revision bc6f0a967c8cb1e9379ced184b25a7722fbda2a4)
1ifeq ($(ARCH), x86_64)
2	CROSS_COMPILE=x86_64-linux-musl-
3else ifeq ($(ARCH), riscv64)
4	CROSS_COMPILE=riscv64-linux-musl-
5endif
6
7SQLITE_FILENAME=sqlite-amalgamation-3420000
8SQLITE3_DIR=$(shell pwd)/$(SQLITE_FILENAME)
9CC=$(CROSS_COMPILE)gcc
10
11.PHONY: all
12all: main.c $(SQLITE3_DIR)/sqlite3.c
13	$(CC) -I $(SQLITE3_DIR) -static -o test_sqlite3 main.c $(SQLITE3_DIR)/sqlite3.c
14
15.PHONY: install clean download_sqlite3 __download_sqlite3
16install: all
17	mv test_sqlite3 $(DADK_CURRENT_BUILD_DIR)/test_sqlite3
18
19clean:
20	rm test_sqlite3 *.o
21
22__download_sqlite3:
23	@echo "Download sqlite3 from https://mirrors.dragonos.org.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip"
24	@wget https://mirrors.dragonos.org.cn/pub/third_party/sqlite/$(SQLITE_FILENAME).zip || (@echo "Download sqlite3 failed" && rm $(SQLITE_FILENAME).zip && exit 1)
25	@unzip -o $(SQLITE_FILENAME).zip || (@echo "Unzip sqlite3 failed" && exit 1)
26	@rm $(SQLITE_FILENAME).zip || (@echo "Remove $(SQLITE_FILENAME).zip failed" && exit 1)
27
28download_sqlite3:
29# 如果文件夹不存在,则下载,否则不下载
30	@test -d $(SQLITE3_DIR) || $(MAKE) __download_sqlite3
31
32fmt:
33