bd459c3cee2a32986c0f612da6619d2f636d5e5a
[keystone-rtos/netapi.git] / ti / runtime / netapi / applications / ipsec_offload / ipsecmgr / build / Makefile
1 # Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 space =$(empty) $(empty)
5 export ARMV7OBJDIR ?= ./obj
6 export ARMV7BINDIR ?= ./bin
7 export ARMV7LIBDIR ?= ./lib
8 export ARMV7SALIBDIR ?= ./lib
10 # INCLUDE Directories
11 SA_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/sa
12 QMSS_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/qmss
13 CPPI_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/cppi
14 NWAL_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/nwal
15 PKTLIB_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/runtime/pktlib
17 HPLIB_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
18 NETAPI_INC_DIR ?=  $(TRANS_SDK_INSTALL_PATH)
19 NETAPI_SRC_DIR ?= $(TRANS_SDK_INSTALL_PATH)/ti/runtime/netapi
21 PDK_ARMV7LIBDIR ?= ARMV7LIBDIR
24 ifeq ($(DEVICE), k2h)
25 CSL_DEVICE = -DDEVICE_K2H
26 PA_LIB   = pa
27 endif
28 ifeq  ($(DEVICE), k2k)
29 CSL_DEVICE = -DDEVICE_K2K
30 PA_LIB   = pa
31 endif
32 ifeq ($(DEVICE), k2l)
33 CSL_DEVICE = -DDEVICE_K2L
34 PA_LIB   = pa2
35 endif
36 ifeq ($(DEVICE), k2e)
37 CSL_DEVICE = -DDEVICE_K2E
38 PA_LIB   = pa2
39 endif
41 #default if DEVICE not provided
42 CSL_DEVICE ?= -DDEVICE_K2L
43 PA_LIB ?=-lpa2
46 ifdef CROSS_TOOL_INSTALL_PATH
47 ## Support backwards compatibility with KeyStone1 approach
48  CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
49  AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
50  AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
51  LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
52 endif
54 #QUIET_CMD=@
55 EXE_NAME_PRFX=ipsecmgr_daemon
57 ###############################################################################
58 # Set default options
59 ###############################################################################
60 CFLAGS+= $(DEBUG_FLAG) -I../ -I. $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
62 ifeq ($(ENABLE_ADD_POLICY),y)
63         CFLAGS += -DENABLE_ADD_POLICY
64 endif
65 OUTPUT_FILE_OPTION = -o
67 EXE_NAME = $(EXE_NAME_PRFX).out
69 ROOT_DIR = ..
70 #IPSECMGR_IFACE_DIR?= ../../../
71 IPSECMGR_UTIL_IFACE_DIR?= ../../../utils/iface
72 IPSECMGR_IFACE_DIR?= ../
75 QMSS_LIB=qmss
76 CPPI_LIB=cppi
77 HPLIB_LIB=hplib
78 SA_LIB=sa
79 PKTLIB_LIB=pktlib
80 NWAL_LIB=nwalsa
81 NETAPI_LIB=netapi
82 IPSECMGR_SNOOP_LIB=ipsecmgr_snoop
83 IPSECMGR_IPC_LIB=ipsecmgr_ipc
84 IPSECMGR_SYSLOG_LIB=ipsecmgr_syslog
86 LIBNL_LD_OPTS = -lnl-3 -lnl-xfrm -lnl-route-3
88 LD_OPTS += -pthread -lrt
90 LD_OPTS += -L $(ARMV7LIBDIR) -L $(PDK_ARMV7LIBDIR) -l$(IPSECMGR_SNOOP_LIB) -l$(IPSECMGR_IPC_LIB) -l$(IPSECMGR_SYSLOG_LIB) -l$(NETAPI_LIB) -l$(NWAL_LIB) -l$(PKTLIB_LIB) -l$(SA_LIB) -l$(QMSS_LIB) -l$(CPPI_LIB) -l$(PA_LIB) -l$(HPLIB_LIB) $(LIBNL_LD_OPTS)
91 ###############################################################################
92 # List of modules and their files
93 ###############################################################################
94 DAEMON_SRC_DIR ?= ../src/
95 DAEMON_FILES = \
96         netapi_ipsecmgr.c \
97         netapilib_interface.c
99 VPATH = $(DAEMON_SRC_DIR)
100 FILES = $(DAEMON_FILES)
102 INCL_DIRS= $(IPSECMGR_IFACE_DIR) $(IPSECMGR_UTIL_IFACE_DIR) $(NETAPI_INC_DIR) $(CPPI_INC_DIR) $(QMSS_INC_DIR) $(HPLIB_INC_DIR) $(SA_INSTALL_PATH) $(PDK_INSTALL_PATH) 
104 HEADERS = $(filter %.h, $(FILES))
105 INCL = -I. $(patsubst %,-I%,$(INCL_DIRS))
108 BIN_DIR = $(ARMV7BINDIR)/netapi/applications/ipsec_offload/ipsecmgr
109 OBJ_DIR = $(ARMV7OBJDIR)/netapi/applications/ipsec_offload/ipsecmgr
110 DAEMON_OBJS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(filter %.c, $(FILES)))
113 all: app install
115 app: $(BIN_DIR)/.created $(BIN_DIR)/$(EXE_NAME)
116 ###############################################################################
117 # Normal make process                                                         
118 ###############################################################################
120 $(OBJ_DIR)/%.o: %.c $(OBJ_DIR)/.created
121         @echo compiling $<
122         $(CC) -c  $(CFLAGS) $(INCL)  $<  -o $@
124 $(OBJ_DIR)/.created:
125         $(QUIET_CMD)@echo "making $@" 
126         @mkdir -p $(OBJ_DIR)
128 $(BIN_DIR)/.created:
129         @mkdir -p $(BIN_DIR)
131 $(BIN_DIR)/$(EXE_NAME): $(DAEMON_OBJS) $(BIN_DIR)/.created
132         $(QUIET_CMD)@echo "linking $@" 
133         $(QUIET_CMD)@echo "$(LD_OPTS)" 
134         $(CC) $(DAEMON_OBJS) $(LD_OPTS) -o $(BIN_DIR)/$(EXE_NAME)
136 install:
137         install -d $(INSTALL_BIN_BASE_DIR)
138         install -c -m 755 $(BIN_DIR)/ipsecmgr_daemon $(INSTALL_BIN_BASE_DIR)/ipsecmgr_daemon_$(DEVICE)
139         install -c -m 755 $(BIN_DIR)/$(EXE_NAME) $(INSTALL_BIN_BASE_DIR)/$(EXE_NAME_PRFX)_$(DEVICE).out
140 clean:
141         rm -rf $(OBJ_DIR)
142         rm -rf $(BIN_DIR)