Makefile 1.1 KB

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