Source

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

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

$(BUILD)/dl/$(nestedvm).tgz:
	@mkdir -p $(dir $@)
#	cp ../archive/$(nestedvm).tgz $@
	curl -o$(BUILD)/dl/$(nestedvm).tgz http://nestedvm.ibex.org/dist/$(nestedvm).tgz

$(BUILD)/dl/$(sqlite)-amal.zip:
	@mkdir -p $(dir $@)
	curl -o$(BUILD)/dl/$(sqlite)-amal.zip \
	http://www.sqlite.org/sqlite-amalgamation-$(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)/env.sh $(BUILD)/dl/$(sqlite)-amal.zip
	@mkdir -p $(BUILD)
	@mkdir -p $(BUILD)/$(sqlite)-nestedvm
	unzip -qo $(BUILD)/dl/$(sqlite)-amal.zip -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" \
	    $(BUILD)/$(sqlite)-nestedvm/sqlite3ext.h
	# 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:/;" \
	    $(BUILD)/$(sqlite)-nestedvm/sqlite3.c
	cat src/main/ext/*.c >> $(BUILD)/$(sqlite)-nestedvm/sqlite3.c
	(. ./$(BUILD)/$(nestedvm)/env.sh; cd $(BUILD)/$(sqlite)-nestedvm; \
	$$CC -c $$CFLAGS -I. -o sqlite3.o \
	    -DSQLITE_THREADSAFE=0 \
            -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
	    -DSQLITE_ENABLE_COLUMN_METADATA \
	    -DSQLITE_CORE \
	    -DSQLITE_ENABLE_FTS3 \
	    -DSQLITE_ENABLE_FTS3_PARENTHESIS \
	    -DSQLITE_ENABLE_RTREE \
            -DSQLITE_ENABLE_STAT2 \
	    -DSQLITE_OMIT_LOAD_EXTENSION \
            $(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

clean:
	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 ProjectModifiedEvent.java.
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.