The Makefiles in the netconf/src/* sub-directories get most of their rules and definitions from an include file located in netconf/src/platform/platform.profile. 


This file can be customized as needed, but it is subject to change from release to release.


The 17.10 version of platform.profile is shown below:


 

#
# platform.profile
#

# libncx and libagt versions (use the same!)
# need some way to set versions without using
# environment vars, so it works in plain debuild, rpmbuild
#
LIBNCX_MAJOR_VERSION=17
LIBNCX_MINOR_VERSION=10
SOVERSION=$(LIBNCX_MAJOR_VERSION).$(LIBNCX_MINOR_VERSION)

# default DESTDIR is NULL; it is only used by packaging builds

ifdef MAC
 INSTALL_PREFIX ?= /usr/local
else
 INSTALL_PREFIX ?= /usr
endif  # MAC

INC_PREFIX ?= $(DESTDIR)$(INSTALL_PREFIX)/include
LIB_PREFIX ?= $(INSTALL_PREFIX)/lib

ifdef CPP98
  CXXFLAGS += -std=c++98 -Wno-c++0x-compat -DCPP98
  $(info Compiling in C++98 mode)
else ifdef UCLINUX
  CFLAGS += -D__USE_UNIX98=1
  CXXFLAGS += -std=c++98 -Wno-c++0x-compat -DCPP98
  $(info Compiling in UCLINUX C++98 mode)
else
  CXXFLAGS += -std=c++0x
  $(info Compiling in C++11 mode)
endif  # CPP98

CDEFS=

ifdef NETCONFD_LIB
CFLAGS += -DNETCONFD_LIB=1
endif

ifdef STATIC_SERVER
CFLAGS += -DSTATIC_SERVER=1
endif

ifdef GPROFILE
  CPPFLAGS += -g
endif

ifdef PTHREADS
  CPPFLAGS += -DPTHREADS=1
  CPPFLAGS += -pthread
endif

ifdef TEST_PTHREADS
  CPPFLAGS += -DTEST_PTHREADS=1
endif

ifdef WINDOWS
   CINC += -I/usr/i586-mingw32msvc/include
endif

CINC +=-I. -I../agt -I../mgr -I../ncx -I../platform -I../ydump -I../ycli -I../../../libdict/include

ifdef WITH_COAP
CINC += -I../../../libcoap/include -I../../../libcoap/include/coap
CDEFS += -DWITH_POSIX=1
endif # WITH_COAP

ifndef UCLINUX
CINC += -I$(INC_PREFIX) \
    -I$(INC_PREFIX)/libxml2 \
    -I$(INC_PREFIX)/libxml2/libxml

ifdef WITH_SNMP
CINC += -I$(INC_PREFIX)/net-snmp
endif # WITH_SNMP
endif # UCLINUX

ifdef COVERITY
 ifneq "$(INSTALL_PREFIX)" "/usr"
   CINC += -I${SYSROOT}/usr/include -I${SYSROOT}/usr/include/libxml2 \
   -I${SYSROOT}/usr/include/libxml2/libxml
 endif
endif

ifdef FREEBSD
FPATH=-L/usr/local/lib
CINC += -I${SYSROOT}/usr/local/include \
    -I${SYSROOT}/usr/local/include/libxml2 \
    -I${SYSROOT}/usr/local/include/libxml2/libxml
endif # FREEBSD

# add user includes if present
CINC += $(USER_SERVER_INC)

TBASE=../../target

ifdef UCLINUX
LBASE=$(TBASE)/lib
else
 ifdef BITBAKE
LBASE=$(TBASE)/lib
 else
  ifdef DESTDIR
LBASE=$(DESTDIR)$(INSTALL_PREFIX)/lib
  else
LBASE=$(TBASE)/lib
  endif # DESTDIR
 endif # BITBAKE
endif # UCLINUX

LPATH=-L$(LBASE)

LFLAGS += -lm $(LDFLAGS)


ifndef OWNER
ifdef DESTDIR
OWNER=
else
ifdef FREEBSD
OWNER=-o root
else
ifdef MAC
OWNER=-oroot
else
ifdef CYGWIN
OWNER=
else
OWNER= --owner=root
endif
endif
endif
endif
endif

#ifdef EVAL
#CPPFLAGS += -DEVAL_VERSION=1
#endif

ifdef USE_WERROR
WERROR=-Werror
else
WERROR=
endif

CWARN=-std=gnu99 -Wbad-function-cast -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wnested-externs -Wshadow -Waggregate-return -Winline

CXXWARN=-Wall -Wno-long-long -Wformat-y2k -Winit-self -Wswitch-default -Wunused-parameter -Wextra -Wundef -Wpointer-arith -Wwrite-strings -Wcast-qual -Wmissing-declarations -Wpacked -Winvalid-pch -Wformat -Wformat-security -Wredundant-decls -Wreturn-type $(WERROR)


# -Wunreachable-code removed due to -O3
# -O3 changed to -O2 due to code bloat from inline functions


ifdef WINDOWS
CDEFS +=-DWINDOWS=1 -DGCC=1
else
CDEFS +=-DLINUX=1 -DGCC=1
endif

ifndef PRODUCTION
CDEFS += -DDEBUG=1
endif

ifdef DEBUG2
CDEFS += -DDEBUG2=1
endif

ifdef DEBUG3
CDEFS += -DDEBUG3=1
endif

ifdef DEBUG4
CDEFS += -DDEBUG4=1
endif

ifdef FREEBSD
CDEFS += -DFREEBSD=1
endif

ifdef KEY
  CDEFS += -DKEY=$(KEY)
endif

ifndef NOFLOAT
  CDEFS += -DHAS_FLOAT=1
endif

ifdef LIB64
  CDEFS += -DLIB64=1
endif

ifdef PATCH_RELEASE
  CDEFS += -DPATCH_RELEASE=1
endif

ifdef UCLINUX
   CDEFS += -DUCLINUX=1
endif

ifdef BITBAKE
   CDEFS += -DBITBAKE=1
endif

ifdef PIPE_RESTRICTED
   CDEFS += -DPIPE_RESTRICTED=1
endif

CFLAGS += $(CWARN)

CPPFLAGS += $(CDEFS) $(CXXWARN)

FPIC=

ifndef CYGWIN
 ifndef UCLINUX
  ifndef STATIC
   CPPFLAGS += -fPIC
   FPIC=-fPIC
  endif # STATIC
 endif # UCLINUX
endif # CYGWIN

ifdef UCLINUX
 ifdef DEBUG
 CPPFLAGS += -g -O0
 endif
else
 ifndef GPROFILE
  ifdef DEBUG
  CPPFLAGS += -ggdb3
  else
  CPPFLAGS += -O2
   ifdef WITH_GDB
   CPPFLAGS += -ggdb3
   endif # WITH_GDB
  endif # DEBUG
 endif # GPROFILE
endif # UCLINUX

# memory leak debugging mode
ifdef MEMTRACE
  CPPFLAGS += -DMEMORY_DEBUG=1
endif

# gprof profiling
ifdef GPROFILE
  CPPFLAGS += -pg
endif

# strsignal not on CENTOS5
ifndef CENTOS5
  CPPFLAGS += -DHAS_STRSIGNAL=1
endif

# check if debian or RPM release build
ifdef RELEASE
  CPPFLAGS += -DRELEASE=$(RELEASE)
endif

# check if cygwin build
ifdef CYGWIN
  CPPFLAGS += -DCYGWIN=1
endif

# check if IETF CallHome supprt requested
ifdef WITH_CALLHOME
  CPPFLAGS += -DWITH_CALLHOME=1
else
 ifdef EVERYTHING
   CPPFLAGS += -DWITH_CALLHOME=1
 endif
endif

# check if server CLI protocol requested
ifdef WITH_CLI
  CPPFLAGS += -DWITH_CLI=1
else
 ifdef EVERYTHING
   CPPFLAGS += -DWITH_CLI=1
 endif
endif

# check if server YANG-API protocol requested
ifdef WITH_YANGAPI
  CPPFLAGS += -DWITH_YANGAPI=1
endif

# check if server RESTCONF protocol requested
ifdef WITH_RESTCONF
  CPPFLAGS += -DWITH_RESTCONF=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_RESTCONF=1
 endif
endif

# check if libcurl enabled
ifdef WITH_CURL
  CPPFLAGS += -DWITH_CURL=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_CURL=1
 endif
endif

ifdef NO_LIBSSH2
  CPPFLAGS += -DNO_LIBSSH2=1
endif

# used by yangcli-pro only
ifdef NO_LIBSSL
  CPPFLAGS += -DNO_LIBSSL=1
endif

# check if server YP-CoAP protocol requested
ifdef WITH_COAP
  CPPFLAGS += -DWITH_COAP=1
#else
# ifdef EVERYTHING
#  CPPFLAGS += -DWITH_COAP=1
# endif
endif

# check if server YP-SNMP protocol requested
ifdef WITH_SNMP
  CFLAGS += -DWITH_SNMP=1
endif

# check if distributed server YControl protocol requested
ifdef WITH_YCONTROL
  CPPFLAGS += -DWITH_YCONTROL=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_YCONTROL=1
 endif
endif

# check if YP-HA server redundancy protocol requested
ifdef WITH_YCONTROL
 ifdef WITH_YP_HA
  CPPFLAGS += -DWITH_YP_HA=1
 else
  ifdef EVERYTHING
  CPPFLAGS += -DWITH_YP_HA=1
  endif # EVERYTHING
 endif # WITH_YP_HA
else
 ifdef EVERYTHING
  ifdef WITH_YP_HA
  CPPFLAGS += -DWITH_YP_HA=1
  else
   ifdef EVERYTHING
  CPPFLAGS += -DWITH_YP_HA=1
   endif # EVERYTHING
  endif # WITH_YP_HA
 endif  # EVERYTHING
endif # WITH_YCONTROL

# check if openssl enabled; used by server only
ifdef WITH_OPENSSL
  CPPFLAGS += -DWITH_OPENSSL=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_OPENSSL=1
 endif
endif

# this is experimental; DO NOT USE
ifdef WITH_YANG_HASH
  CPPFLAGS += -DWITH_YANG_HASH=1
endif

ifndef MAC
 ifndef CYGWIN
  ifndef CENTOS5
   CPPFLAGS += -DHAS_SIGNALFD=1
  endif # CENTOS5
 endif # CYGWIN
endif # MAC

# check if server configuration templates requested
ifdef WITH_TEMPLATES
  CPPFLAGS += -DWITH_TEMPLATES=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_TEMPLATES=1
 endif
endif

# check if yumaworks-support-save requested
ifdef WITH_SUPPORT_SAVE
  CPPFLAGS += -DWITH_SUPPORT_SAVE=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_SUPPORT_SAVE=1
 endif
endif

ifdef STATIC
 CPPFLAGS += -DSTATIC_LINK=1
endif # STATIC

ifdef STATIC_SERVER
 CPPFLAGS += -DSTATIC_SERVER=1
endif # STATIC_SERVER

# check if YANG mapping feature requested
ifdef WITH_YANGMAP
  CPPFLAGS += -DWITH_YANGMAP=1
else
 ifdef EVERYTHING
  CPPFLAGS += -DWITH_YANGMAP=1
 endif
endif


ifndef GRP
 ifdef MAC
   GRP=
 else
  ifdef FREEBSD
    GRP=-g wheel
  else
   ifdef DESTDIR
     GRP=
   else
    ifdef CYGWIN
      GRP=
    else
      GRP=--group=root
    endif  # CYGWIN
   endif # DESTDIR
  endif # FREEBSD
 endif # MAC
endif # GRP

ifdef STATIC
  LIBSUFFIX=a
  LIBNCXSUFFIX=a
else # not STATIC
 ifdef MAC
   ifdef COVERITY
     LIBSUFFIX=so
     LIBNCXSUFFIX=so.$(SOVERSION)
   else
     LIBSUFFIX=dylib
     LIBNCXSUFFIX=dylib
   endif # COVERITY
 else # not MAC
   LIBSUFFIX=so
   LIBNCXSUFFIX=so.$(SOVERSION)
 endif # MAC
endif # STATIC

ifdef CLANG
  CC = clang
  CCPP = clang++
endif

ifdef CLANG_ASAN
  CC= clang -O1 -fsanitize=address -fno-omit-frame-pointer
  CCPP= clang++ -O1 -fsanitize=address -fno-omit-frame-pointer
  LINK= clang++ -g -fsanitize=address
endif

ifdef BITBAKE
  CCPP = $(CXX)
endif

ifdef COVERITY
  CC = gcc
endif

ifdef WINDOWS
  CC ?= i586-mingw32msvc-gcc
  CCPP ?= i586-mingw32msvc-g++
  LINK ?= i586-mingw32msvc-g++
  RANLIB ?= i586-mingw32msvc-ranlib
else
 ifdef CROSS_TARGET
   CC ?= $(CROSS_TARGET)gcc
   CCPP ?= $(CROSS_TARGET)g++
   AR ?= $(CROSS_TARGET)ar
   RANLIB ?= $(CROSS_TARGET)ranlib
   LD ?= $(CROSS_TARGET)ld
 else
  ifdef UCLINUX
   CC := $(CROSS_COMPILE_APPS)gcc
   CCPP := $(CROSS_COMPILE_APPS)g++
   AR := $(CROSS_COMPILE_APPS)ar
   RANLIB := $(CROSS_COMPILE_APPS)ranlib
   LD := $(CROSS_COMPILE_APPS)ld
  else
   CC ?= gcc
   CCPP ?= g++
   AR ?= ar
   RANLIB ?= ranlib
   LD ?= ld
  endif # UCLINUX
 endif # CROSS_TARGET
endif # WINDOWS

LINK ?= $(CCPP)
AR ?= $(CROSS_TARGET)ar
RANLIB ?= $(CROSS_TARGET)ranlib

# heap corruption debugging mode
ifdef MCHECK
  LFLAGS += -lmcheck
endif

# not needed because CFLAGS sent to linker
#ifdef GPROFILE
#   LFLAGS += -pg
#endif


CEES = $(wildcard *.c)
CPPS = $(wildcard *.cpp)

HEES = $(wildcard *.h)
HPPS = $(wildcard *.hpp)

AR ?= ar

RANLIB ?= ranlib

################ OBJS RULE #############
OBJS = $(patsubst %.cpp,$(TARGET)/%.o,$(CPPS)) $(patsubst %.c,$(TARGET)/%.o,$(CEES))

################ DEPS RULE #############
DEPS = $(patsubst %.c,%.D,$(wildcard *.c)) $(patsubst %.cpp,%.D,$(wildcard *.cpp))

######################## PLATFORM DEFINITIONS #############
PLATFORM_CPP=

distclean: superclean

.PHONY: all superclean clean test install uninstall distclean depend notabs addheader

######################### MAKE RULES ######################
#COMPILE.c= $(CC) $(CFLAGS) $(CPPFLAGS) $(PLATFORM_CPP) $(CINC) $(SUBDIR_CPP) $(TARGET_ARCH) -c

#COMPILE.cpp = $(CC) $(CXXFLAGS) $(CPPFLAGS) $(PLATFORM_CPP) $(CINC) $(SUBDIR_CPP) $(TARGET_ARCH) -c


COMMON_DEF= $(CPPFLAGS) $(PLATFORM_CPP) $(FPIC) $(CINC) $(SUBDIR_CPP) $(TARGET_ARCH)

$(TARGET)/%.o: %.c
  $(CC) $(CFLAGS) $(COMMON_DEF) -c -o $@ $<

$(TARGET)/%.o: %.cpp
  $(CCPP) $(CXXFLAGS) $(COMMON_DEF)  -c -o $@ $<


# Common library rule

#### common cleanup rules


# dependency rule to make temp .D files from .c sources
# all the .D files are collected and appended to the
# appropriate Makefile when 'make depend' is run
# this rule is kept here to make sure it matches COMPILE.c
%.D: %.c
  $(CC) -MM -MG -MT $(TARGET)/$(patsubst %.c,%.o,$<) -Wall -Wcomment $(CPPFLAGS) $(PLATFORM_CPP) $(CINC) $(CFLAGS) $(SUBDIR_CPP) $(TARGET_ARCH) -c $< > $@
%.D: %.cpp
  $(CCPP) -MM -MG -MT $(TARGET)/$(patsubst %.cpp,%.o,$<) -Wall -Wcomment $(CPPFLAGS) $(PLATFORM_CPP) $(CINC) $(CXXFLAGS) $(SUBDIR_CPP) $(TARGET_ARCH) -c $< > $@


notabs:
  for c in $(CEES); do\
    cp $$c $$c.save;\
    expand $$c > $$c.ex;\
    mv $$c.ex $$c;\
  done

addheader:
  if [ ! -f ../platform/header.txt]; then \
    echo "Error: platform/header.txt is missing!"; \
    exit 1; \
  fi
  for c in $(CEES); do\
    cp $$c $$c.save;\
    cp ../platform/header.txt $$c.hdr;\
    cat $$c >> $$c.hdr;\
    mv $$c.hdr $$c;\
  done
  for h in $(HEES); do\
    cp $$h $$h.save;\
    cp ../platform/header.txt $$h.hdr;\
    cat $$h >> $$h.hdr;\
    mv $$h.hdr $$h;\
  done