|
| 1 | +SRC = $(shell readlink -f ../..) |
| 2 | +include $(SRC)/modules/java-base/common.gmk |
| 3 | +INCLUDES += -I. -I../httpserver-api -I $(SRC)/libc/internal |
| 4 | + |
| 5 | +# compiler flags: |
| 6 | +# -g adds debugging information to the executable file |
| 7 | +# -Wall turns on most, but not all, compiler warnings |
| 8 | +autodepend = -MD -MT $@ -MP |
| 9 | +CXXFLAGS = -g -Wall -std=c++11 -fPIC $(INCLUDES) -O2 $(autodepend) -DMONITORING -fvisibility=hidden |
| 10 | +#TODO: Figure out why lto breaks exception handling |
| 11 | +#CXXFLAGS = -g -Wall -std=c++11 -fPIC $(INCLUDES) -O2 $(autodepend) -DMONITORING -fvisibility=hidden -flto |
| 12 | +#LDFLAGS = -flto |
| 13 | +src = $(shell readlink -f ../..) |
| 14 | + |
| 15 | +ifndef ARCH |
| 16 | + ARCH = x64 |
| 17 | +endif |
| 18 | + |
| 19 | +ifndef mode |
| 20 | + mode = release |
| 21 | +endif |
| 22 | + |
| 23 | +ifndef OSV_BUILD_PATH |
| 24 | + OSV_BUILD_PATH = $(src)/build/$(mode).$(ARCH) |
| 25 | +endif |
| 26 | +boost-libs := -lboost_system -lboost_filesystem |
| 27 | + |
| 28 | +# the build target executable: |
| 29 | +TARGET = httpserver-api |
| 30 | +JSON_FILES := $(wildcard api-doc/listings/*.json) |
| 31 | +JSON_CC_FILES := $(subst .json,.json.cc,$(subst api-doc/listings/,autogen/,$(JSON_FILES))) |
| 32 | +CPP_FILES := $(addprefix json/,$(notdir $(wildcard ../httpserver-api/json/*.cc))) \ |
| 33 | + api/fs.cc api/os.cc api/network.cc api/hardware.cc api/env.cc api/file.cc api/api.cc \ |
| 34 | + common.cc main.cc plain_server.cc server.cc connection.cc matcher.cc \ |
| 35 | + reply.cc connection_manager.cc mime_types.cc request_handler.cc \ |
| 36 | + transformers.cc global_server.cc request_parser.cc handlers.cc \ |
| 37 | + path_holder.cc routes.cc $(JSON_CC_FILES) |
| 38 | +OBJ_FILES := $(addprefix obj/,$(CPP_FILES:.cc=.o)) |
| 39 | + |
| 40 | +DYN_LIBS = -lpthread -ldl -L../libtools -ltools $(boost-libs) |
| 41 | + |
| 42 | +LIBS = $(DYN_LIBS) $(STATIC_LIBS) |
| 43 | + |
| 44 | +quiet = $(if $V, $1, @echo " $2"; $1) |
| 45 | +very-quiet = $(if $V, $1, @$1) |
| 46 | + |
| 47 | +DEPS := $(OBJ_FILES:.o=.d) |
| 48 | + |
| 49 | +module: all |
| 50 | + |
| 51 | +all: lib$(TARGET).so |
| 52 | + $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh lib$(TARGET).so > usr.manifest) |
| 53 | + |
| 54 | +lib$(TARGET).so: $(OBJ_FILES) |
| 55 | + $(call quiet, $(CXX) $(CXXFLAGS) -shared $(STATIC_LIBS) -o $@ $^ $(DYN_LIBS), LINK $@) |
| 56 | + |
| 57 | +ifneq ($(MAKECMDGOALS),clean) |
| 58 | +-include $(DEPS) |
| 59 | +endif |
| 60 | + |
| 61 | +autogen/%.cc: api-doc/listings/% ../httpserver-api/json2code.py |
| 62 | + $(call very-quiet, mkdir -p autogen) |
| 63 | + $(call quiet,../httpserver-api/json2code.py -outdir autogen -f $< -ns json, GEN $@) |
| 64 | + |
| 65 | +$(OBJ_FILES): obj/%.o: ../httpserver-api/%.cc |
| 66 | + $(call very-quiet, mkdir -p obj/stub obj/json obj/api obj/autogen) |
| 67 | + $(call quiet, $(CXX) $(CXXFLAGS) -c -MMD -o $@ $<, CXX $@) |
| 68 | + |
| 69 | +clean: |
| 70 | + $(call quiet, $(RM) -f $(TARGET), CLEAN) |
| 71 | + $(call very-quiet, $(RM) -f lib*.so) |
| 72 | + $(call very-quiet, $(RM) -rf obj) |
| 73 | + $(call very-quiet, $(RM) -rf autogen) |
| 74 | + $(call very-quiet, $(RM) -f *usr*.manifest) |
| 75 | + |
| 76 | +check: |
| 77 | + # Test plain readonly HTTP |
| 78 | + cd $(src) && \ |
| 79 | + make image=httpserver-monitoring-api.fg && \ |
| 80 | + PYTHONPATH=$(src)/scripts modules/httpserver-api/tests/testhttpserver-monitoring-api.py |
| 81 | + |
| 82 | +.PHONY: check |
| 83 | + |
| 84 | +.SECONDARY: |
0 commit comments