build: Makefile cleanup

master
Sean McBride 4 years ago
parent 4751c52ede
commit 9d95308a57

@ -83,7 +83,15 @@ CFLAGS += -D${ARCH}
CFLAGS += -DUSE_MEM_VM CFLAGS += -DUSE_MEM_VM
# Preprocessor # Preprocessor
# SLEdge serverless functions are *.so shared-libraries. The runtime thus requires the dynamic linker
# to load these functions at runtime. These *.so shared-libraries also depend on specific symbols from
# the runtime to execute. The export-dynamic Linker flag adds all globals to the dynamic symbol table,
# allowing the libraries acess to such symbols. The libm math library is used several places, including
# in backing functions that implement the WebAssembly instruction set.
LDFLAGS += -Wl,--export-dynamic -ldl -lm LDFLAGS += -Wl,--export-dynamic -ldl -lm
# Our third-party dependencies build into a single dist directory to simplify configuration here.
LDFLAGS += -Lthirdparty/dist/lib/ LDFLAGS += -Lthirdparty/dist/lib/
INCLUDES += -Iinclude/ -Ithirdparty/dist/include/ INCLUDES += -Iinclude/ -Ithirdparty/dist/include/
@ -99,34 +107,35 @@ CFILES += thirdparty/dist/lib/http_parser.o
JSMNCFLAGS += -DJSMN_STATIC JSMNCFLAGS += -DJSMN_STATIC
JSMNCFLAGS += -DJSMN_STRICT JSMNCFLAGS += -DJSMN_STRICT
.PHONY: all
all: runtime all: runtime
runtime: bin/sledgert: ${CFILES}
@echo "Compiling runtime" @echo "Compiling runtime"
@mkdir -p bin/ @mkdir -p bin/
@${CC} ${CC_OPTIONS} ${INCLUDES} ${CFLAGS} ${LDFLAGS} ${CFILES} ${JSMNCFLAGS} -L/usr/lib/ $^ -o bin/${BINARY_NAME} @${CC} ${CC_OPTIONS} ${INCLUDES} ${CFLAGS} ${LDFLAGS} ${CFILES} ${JSMNCFLAGS} -L/usr/lib/ $^ -o bin/sledgert
.PHONY: runtime
runtime: bin/sledgert
.PHONY: thirdparty
thirdparty: thirdparty:
@echo "Compiling thirdparty" @echo "Compiling thirdparty"
@make --no-print-directory -C thirdparty build @make --no-print-directory -C thirdparty build
tools: .PHONY: clean
# @echo "Compiling tools"
@make --no-print-directory -C tools
clean: clean:
@rm -f core @rm -f core
@echo "Cleaning up runtime" @echo "Cleaning up runtime"
@rm -f bin/${BINARY_NAME} @rm -f bin/${BINARY_NAME}
# @echo "Cleaning up tools"
# @make --no-print-directory -C tools clean
.PHONY: distclean
distclean: clean distclean: clean
@make --no-print-directory -C thirdparty clean @make --no-print-directory -C thirdparty clean
.PHONY: submodules
fetch: fetch:
@git submodule update --init --recursive @git submodule update --init --recursive
.PHONY: init
init: fetch clean thirdparty runtime init: fetch clean thirdparty runtime
.PHONY: all init clean fetch thirdparty runtime tools

@ -4,46 +4,39 @@ TESTS=fibonacci empty work work1k work10k work100k work1m forever filesys sockse
TESTSRT=$(TESTS:%=%_rt) TESTSRT=$(TESTS:%=%_rt)
.PHONY: all clean rttests tinyekf cifar10 gocr sod .PHONY: all
all: rttests tinyekf cifar10 gocr sod all: rttests tinyekf cifar10 gocr sod
@echo "Test Compilation done!" @echo "Test Compilation done!"
.PHONY: rttests
rttests: $(TESTSRT) rttests: $(TESTSRT)
.PHONY: clean
clean: clean:
@echo "Cleaning Test Applications" @echo "Cleaning Test Applications"
@make clean -C ./empty/ @rm -rf ${TMP_DIR}
@rm -f wasm/empty.wasm bc/empty.bc so/empty.so @make clean -C ./gocr/src/ -f wasm.mk
@rm -rf ${SLEDGE_BIN_DIR}/empty.so ${SLEDGE_BIN_DIR}/test_empty.json @make clean -C ./sod/
@make clean -C ./echo/
@rm -f wasm/echo.wasm bc/echo.bc so/echo.so
@rm -rf ${SLEDGE_BIN_DIR}/echo.so ${SLEDGE_BIN_DIR}/test_echo.json
@make clean -C ./fibonacci/
@rm -f wasm/fibonacci.wasm bc/fibonacci.bc so/fibonacci.so
@rm -rf ${SLEDGE_BIN_DIR}/fibonacci.so ${SLEDGE_BIN_DIR}/test_fibonacci.json
@make clean -C ./TinyEKF/ -f wasm.mk
@rm -f wasm/gps_ekf.wasm bc/gps_ekf.bc so/gps_ekf.so
@rm -rf ${SLEDGE_BIN_DIR}/gps_ekf.so ${SLEDGE_BIN_DIR}/test_gps_ekf.json
.PHONY: tinyekf
tinyekf: tinyekf:
@echo "Making and Installing tinyekf" @echo "Making and Installing tinyekf"
@make gps_ekf_fn.so -C ./TinyEKF/extras/c/ -f wasm.mk @make gps_ekf_fn.so -C ./TinyEKF/extras/c/ -f wasm.mk
@cp ./TinyEKF/extras/c/gps_ekf_fn.so ${SLEDGE_BIN_DIR}/ekf_wasm.so @cp ./TinyEKF/extras/c/gps_ekf_fn.so ${SLEDGE_BIN_DIR}/ekf_wasm.so
.PHONY: cifar10
cifar10: cifar10:
@echo "Making and Installing cifar10" @echo "Making and Installing cifar10"
@make cifar10.so -C ./CMSIS_5_NN/ -f Makefile @make cifar10.so -C ./CMSIS_5_NN/ -f Makefile
@cp ./CMSIS_5_NN/cifar10.so ${SLEDGE_BIN_DIR}/cifar10_wasm.so @cp ./CMSIS_5_NN/cifar10.so ${SLEDGE_BIN_DIR}/cifar10_wasm.so
.PHONY: gocr
gocr: gocr:
@echo "Making and Installing gocr" @echo "Making and Installing gocr"
@make gocr.so -C ./gocr/src/ -f wasm.mk @make gocr.so -C ./gocr/src/ -f wasm.mk
@cp ./gocr/src/gocr.so ${SLEDGE_BIN_DIR}/gocr_wasm.so @cp ./gocr/src/gocr.so ${SLEDGE_BIN_DIR}/gocr_wasm.so
.PHONY: sod
sod: sod:
@echo "Making and Installing license_plate_detection and image_resize" @echo "Making and Installing license_plate_detection and image_resize"
@make dir samples.so -C ./sod/ @make dir samples.so -C ./sod/
@ -52,10 +45,16 @@ sod:
%_rt: %_rt:
@mkdir -p ${TMP_DIR} @mkdir -p ${TMP_DIR}
# Compile the wasm file
@echo "Compiling $(@:%_rt=%)" @echo "Compiling $(@:%_rt=%)"
${WASMCC} ${$(@:%_rt=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} $(@:%_rt=%)/*.c $(AWSM_DUMMY) -o ${TMP_DIR}/$(@:%_rt=%).wasm ${WASMCC} ${$(@:%_rt=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} $(@:%_rt=%)/*.c $(AWSM_DUMMY) -o ${TMP_DIR}/$(@:%_rt=%).wasm
# Compile the *.bc file
${AWSM_NAME} --inline-constant-globals --runtime-globals ${TMP_DIR}/$(@:%_rt=%).wasm -o ${TMP_DIR}/$(@:%_rt=%).bc ${AWSM_NAME} --inline-constant-globals --runtime-globals ${TMP_DIR}/$(@:%_rt=%).wasm -o ${TMP_DIR}/$(@:%_rt=%).bc
# Compile the *.so file
${CC} --shared -fPIC ${OPTFLAGS} -I${SLEDGE_RT_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${SLEDGE_MEMC} ${SLEDGE_WASMISA} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${CC} --shared -fPIC ${OPTFLAGS} -I${SLEDGE_RT_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${SLEDGE_MEMC} ${SLEDGE_WASMISA} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.so
# Copy the *.so file to the binary directory
@cp ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${SLEDGE_BIN_DIR} @cp ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${SLEDGE_BIN_DIR}
# @rm -rf ${TMP_DIR} # @rm -rf ${TMP_DIR}

@ -1,24 +1,45 @@
CURR_DIR= $(shell pwd) CURR_DIR= $(shell pwd)
DIST_PREFIX=${CURR_DIR}/dist/ DIST_PREFIX=${CURR_DIR}/dist/
.PHONY: all
all: clean build all: clean build
.PHONY: build
build: ck jsmn http-parser build: ck jsmn http-parser
ck: # Concurrency Kit
.PHONY: ck
ck: ck/configure ck/Makefile
mkdir -p ${DIST_PREFIX} mkdir -p ${DIST_PREFIX}
cd ck; ./configure --cores=$(shell getconf _NPROCESSORS_CONF) --prefix=${DIST_PREFIX} cd ck; ./configure --cores=$(shell getconf _NPROCESSORS_CONF) --prefix=${DIST_PREFIX}
make -C ck all make -C ck all
make -C ck install make -C ck install
http-parser: http-parser/http_parser.c # HTTP Parser
${DIST_PREFIX}/include/http_parser.h: http-parser/http_parser.h
mkdir -p ${DIST_PREFIX}
mkdir -p ${DIST_PREFIX}/include/
cp http-parser/http_parser.h ${DIST_PREFIX}/include/
${DIST_PREFIX}/lib/http_parser.o: http-parser/http_parser.c http-parser/http_parser.h
mkdir -p ${DIST_PREFIX}
mkdir -p ${DIST_PREFIX}/lib/ mkdir -p ${DIST_PREFIX}/lib/
cd http-parser; $(CC) $(CFLAGS) -I. -c http_parser.c; mv http_parser.o ${DIST_PREFIX}/lib/; cp http_parser.h ${DIST_PREFIX}/include/ cd http-parser; $(CC) $(CFLAGS) -I. -c http_parser.c
mv http-parser/http_parser.o ${DIST_PREFIX}/lib/
jsmn: .PHONY: http-parser
http-parser: ${DIST_PREFIX}/lib/http_parser.o ${DIST_PREFIX}/include/http_parser.h
# Jasmine JSON Parser
${DIST_PREFIX}/include/jsmn.h: jsmn/jsmn.h
mkdir -p ${DIST_PREFIX}
mkdir -p ${DIST_PREFIX}/include/ mkdir -p ${DIST_PREFIX}/include/
cp jsmn/jsmn.h ${DIST_PREFIX}/include/ cp jsmn/jsmn.h ${DIST_PREFIX}/include/
.PHONY: jsmn
jsmn: ${DIST_PREFIX}/include/jsmn.h
.PHONY: clean
clean: clean:
make -C ck uninstall make -C ck uninstall
rm -rf ${DIST_PREFIX} rm -rf ${DIST_PREFIX}

Loading…
Cancel
Save