sqlite-jdbc / Makefile.purejava

include Makefile.common

nestedvm_version := 2009-08-09
nestedvm := nestedvm-$(nestedvm_version)

WORK := target
BUILD := $(WORK)/build

default: test

test: $(BUILD)/org/sqlite/SQLite.class

	$(MAKE) CFLAGS='' -C $(BUILD)/$(nestedvm) $*

	@mkdir -p $(dir $@)
#	cp ../archive/$(nestedvm).tgz $@
	curl -o$(BUILD)/dl/$(nestedvm).tgz$(nestedvm).tgz

	@mkdir -p $(dir $@)
	curl -o$(BUILD)/dl/$(sqlite) \$(subst .,_,$(version)).zip

$(BUILD)/$(nestedvm)/Makefile: $(BUILD)/dl/$(nestedvm).tgz
	tar xfz $(BUILD)/dl/$(nestedvm).tgz -C$(BUILD)

$(BUILD)/SQLite.mips: $(BUILD)/$(nestedvm)/Makefile $(BUILD)/$(nestedvm)/ $(BUILD)/dl/$(sqlite)
	@mkdir -p $(BUILD)
	@mkdir -p $(BUILD)/$(sqlite)-nestedvm
	unzip -qo $(BUILD)/dl/$(sqlite) -d $(BUILD)/$(sqlite)-nestedvm
	cp src/main/java/org/sqlite/Nested*.c $(BUILD)/$(sqlite)-nestedvm
	perl -pi -e "s/sqlite3_api;/sqlite3_api = 0;/g" \
	# we need a dummy main
	echo 'int main() { return 0; }' >> $(BUILD)/$(sqlite)-nestedvm/sqlite3.c
	# remove utimes
	perl -npe '$$_ =~ s/utimes.*//g;' -i $(BUILD)/$(sqlite)-nestedvm/sqlite3.c 
	# insert a code for loading extension functions
	perl -pi -e "s/^opendb_out:/  if(!db->mallocFailed && rc==SQLITE_OK){ rc = RegisterExtensionFunctions(db); }\nopendb_out:/;" \
	cat src/main/ext/*.c >> $(BUILD)/$(sqlite)-nestedvm/sqlite3.c
	(. ./$(BUILD)/$(nestedvm)/; cd $(BUILD)/$(sqlite)-nestedvm; \
	$$CC -c $$CFLAGS -I. -o sqlite3.o \
            -DSQLITE_ENABLE_STAT2 \
            $(SQLITE_FLAGS) \
		sqlite3.c; \
	$$CC -c $$CFLAGS -o NestedDB.o Nested*.c)
	./$(BUILD)/$(nestedvm)/upstream/install/bin/mips-unknown-elf-gcc \
	        -march=mips1 --static \
	        -o $@ $(BUILD)/$(sqlite)-nestedvm/sqlite3.o \
			      $(BUILD)/$(sqlite)-nestedvm/NestedDB.o -lm -lc

$(BUILD)/org/sqlite/SQLite.class: $(BUILD)/SQLite.mips
	$(JAVA) -cp $(BUILD)/$(nestedvm)/build$(sep)$(BUILD)/$(nestedvm)/upstream/build/classgen/build \
	    org.ibex.nestedvm.Compiler \
	    -outformat class -d $(BUILD) -o unixRuntime \
	    org.sqlite.SQLite $(BUILD)/SQLite.mips

	rm -rf $(BUILD)
#	rm -rf dist
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.