Skip to content
Snippets Groups Projects
Makefile 2.99 KiB
Newer Older
  • Learn to ignore specific revisions
  • EXECS = mapcontroller
    
    CFLAGS+=-I. -Iutils -D_GNU_SOURCE
    
    #CFLAGS+= -g -Wall -Werror
    CFLAGS+= -g -Wall
    
    ifeq (,$(findstring EASYMESH_VERSION,$(CFLAGS)))
    
    Anjan Chanda's avatar
    Anjan Chanda committed
    $(info EASYMESH_VERSION is not set. Build for 6)
    EASYMESH_VERSION=6
    
    CFLAGS+=-DEASYMESH_VERSION=6
    
    Anjan Chanda's avatar
    Anjan Chanda committed
    else
    EASYMESH_VERSION=$(patsubst -DEASYMESH_VERSION=%,%,$(filter -DEASYMESH_VERSION=%,$(CFLAGS)))
    $(info EASYMESH_VERSION passed is $(EASYMESH_VERSION))
    
    	utils/debug.o \
    	utils/liblist.o \
    	utils/utils.o \
    
    	wifi_opclass.o \
    
    	cntlr_commands.o \
    	cntlr_commands_impl.o \
    
    	cntlr_ubus.o \
    	cntlr.o \
    	cntlr_map.o \
    
    	cntlr_tlv.o \
    	cntlr_cmdu.o \
    
    Anjan Chanda's avatar
    Anjan Chanda committed
    	qos.o \
    
    INCDIR=/usr/include/map-controller
    header-files=cntlr_commands.h cntlr_commands_impl.h \
    	wifi_dataelements.h timer.h timer_impl.h \
    	cntlr_apis.h wifi_opclass.h steer_module.h \
    	utils/debug.h
    
    
    ifneq (,$(findstring EASYMESH_VENDOR_EXT,$(CFLAGS)))
    OBJS += cntlr_extension.o
    endif
    
    
    LIBS = -lubus -lubox -ljson-c -lblobmsg_json -luci -pthread
    LIBS += -rdynamic -ldl
    
    LIBS += -leasy -lwifiutils
    
    Anjan Chanda's avatar
    Anjan Chanda committed
    LIBS += -lieee1905 -lmaputil
    
    ifneq (,$(findstring USE_LIBDPP,$(CFLAGS)))
    LIBS += -ldpp
    endif
    
    plugin_subdirs ?= $(wildcard plugins/*/*)
    
    plugin_sofile = $(wildcard $(d)/*.so)
    plugin_files = $(foreach d, $(plugin_subdirs), $(plugin_sofile))
    
    HOOKS = pre-commit
    
    Anjan Chanda's avatar
    Anjan Chanda committed
    .PHONY: all version.h check clean plugins FORCE
    
    all: version $(EXECS) libcntlr-apis.so plugins
    
    
    %.o: %.c
    	$(CC) $(CFLAGS) -c -o $@ $<
    
    
    libcntlr-apis.so: cntlr_apis.o
    	$(CC) -shared -Wl,-soname,libcntlr-apis.so $^ -o $@ $(LIBS) -L.
    
    
    Anjan Chanda's avatar
    Anjan Chanda committed
    version.h:
    	@(\
    	[ command -v git > /dev/null 2>&1 ] || { \
    		h=$(shell git rev-parse --short=8 HEAD); \
    	}; \
    	echo "const char *verstring = \"6.0\";" > $@; \
    	echo "const char *githash = \"$$h\";" >> $@; \
    	)
    
    version: version.h
    
    
    mapcontroller: $(OBJS)
    
    	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
    
    plugins:
    	@echo "$(plugin_subdirs)"
    
    	for i in $(plugin_subdirs); do [ -d $$i ] && CFLAGS="$(CFLAGS)" $(MAKE) -C $$i all; done
    
    
    -include Makefile.inc
    
    install: install-headers install-libs install-bins
    
    
    install-hooks:
    	$(foreach hook, $(HOOKS), ln -s -f ../../hooks/$(hook) ../.git/hooks/$(hook);)
    
    
    check: FORCE
    	@cppcheck --quiet --enable=all --inconclusive --std=c99 \
    		--suppress=variableScope \
    		--suppress=unusedVariable \
    		--suppress=unreadVariable \
    		--suppress=funcArgNamesDifferent \
    		--suppress=unusedFunction \
    
    		--suppress=wrongPrintfScanfArgNum \
    		--suppress=redundantAssignment \
    
    test: CFLAGS += -fPIC
    
    test: ${OBJS}
    	${CC} ${LDFLAGS} -shared -o libmapcontroller.so ${OBJS} ${LIBS}
    
    
    unit-test: coverage
    	make -C ../test/cmocka unit-test MAPCNTLR_LIB_DIR=$(PWD)
    
    coverage: CFLAGS  += -g -O0 -fprofile-arcs -ftest-coverage -fPIC
    coverage: LDFLAGS += --coverage
    coverage: test mapcontroller
    	$(foreach testprog, $(CODECOVERAGE_SRC), $(GCOV) $(testprog);)
    
    
    
    	rm -f *.o *.so utils/*.o utils/*.so $(EXECS)
    
    	for i in $(plugin_subdirs); do [ -d $$i ] && $(MAKE) -C $$i clean; done
    
    FORCE: