Makefile (5622B)
1 # 2 # Copyright 2017 Broadcom 3 # 4 # This program is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License, version 2, as 6 # published by the Free Software Foundation (the "GPL"). 7 # 8 # This program is distributed in the hope that it will be useful, but 9 # WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 # General Public License version 2 (GPLv2) for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # version 2 (GPLv2) along with this source code. 15 # 16 # -*- Makefile -*- 17 # $Id: Makefile,v 1.4 Broadcom SDK $ 18 # $Copyright: (c) 2005 Broadcom Corp. 19 # All Rights Reserved.$ 20 # 21 22 SDK :=$(shell if [ -n "$$SDK" ] ; then\ 23 echo $$SDK;\ 24 else\ 25 cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ 26 dir=`cd ../;pwd`; \ 27 if [ "$$dir" = "/" ] ; then \ 28 echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ 29 exit 1; \ 30 fi ; \ 31 cd $$dir; \ 32 done ; \ 33 pwd; \ 34 fi) 35 36 ifeq ($(SDK),) 37 $(error Please run this in a tree) 38 endif 39 40 export SDK 41 42 override-target=linux-$(platform) 43 44 ifeq ($(LINUX_MAKE_SHARED_LIB),1) 45 libext = so.$(SHAREDLIBVER) 46 else 47 libext = a 48 endif 49 50 ifeq (,$(platform)) 51 $(error Internal error: platform variable is not set) 52 endif 53 54 include $(SDK)/make/Make.config 55 LOCALDIR=systems/linux/user/common 56 include $(SDK)/make/Make.depend 57 kernel-override=linux-$(platform) 58 ifdef BLDCONFIG 59 KERN_BLDROOT=${SDK}/${SDKBUILD}/${BLDCONFIG}/$(kernel-override)$(bldroot_suffix) 60 else 61 KERN_BLDROOT=${SDK}/${SDKBUILD}/$(kernel-override)$(bldroot_suffix) 62 endif 63 64 ifeq (,$(kernel_version)) 65 kernel_version=2_4 66 endif 67 68 ifneq ($(kernel_version),2_4) 69 KOBJ=ko 70 else 71 KOBJ=o 72 endif 73 74 ifneq (,$(TOOLS_DIR)) 75 override PATH := $(TOOLS_DIR):$(PATH) 76 endif 77 78 ifeq ($(DEST_DIR),) 79 DEST_DIR=${BLDDIR} 80 endif 81 82 KERNEL_BDE_LOCAL :=linux-kernel-bde.$(KOBJ) 83 KERNEL_BDE :=$(DEST_DIR)/$(KERNEL_BDE_LOCAL) 84 85 USER_BDE_LOCAL :=linux-user-bde.$(KOBJ) 86 USER_BDE=$(DEST_DIR)/$(USER_BDE_LOCAL) 87 88 KNET_CB_LOCAL := linux-knet-cb.$(KOBJ) 89 KNET_CB := $(DEST_DIR)/$(KNET_CB_LOCAL) 90 91 BCM_KNET_LOCAL :=linux-bcm-knet.$(KOBJ) 92 BCM_KNET=$(DEST_DIR)/$(BCM_KNET_LOCAL) 93 94 ifeq (,$(findstring DELIVER,$(MAKECMDGOALS))) 95 .DEFAULT_GOAL := all 96 all_targets := kernel_modules $(KERNEL_BDE) $(USER_BDE) 97 98 LOCAL_TARGETS := 99 100 ifeq ($(NO_LOCAL_TARGETS),) 101 LOCAL_TARGETS +=$(patsubst %,$(realpath ..)/$(platform)/%,$(KERNEL_BDE_LOCAL) $(USER_BDE_LOCAL)) 102 103 all_targets +=$(LOCAL_TARGETS) 104 endif 105 106 # Build all by default 107 ifndef BUILD_KNET 108 BUILD_KNET = 1 109 endif 110 111 ifeq ($(BUILD_KNET),1) 112 # Kernel network support 113 all_targets += $(BCM_KNET) 114 115 ifeq ($(NO_LOCAL_TARGETS),) 116 LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_KNET_LOCAL)) 117 all_targets +=$(LOCAL_TARGETS) 118 endif 119 120 ifdef BUILD_KNET_CB 121 all_targets += $(KNET_CB) 122 123 ifeq ($(NO_LOCAL_TARGETS),) 124 LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(KNET_CB_LOCAL)) 125 all_targets +=$(LOCAL_TARGETS) 126 endif 127 endif 128 129 ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include 130 COND_KNET_LIBS = libuser.$(libext) 131 endif 132 133 all: $(BLDDIR)/.tree $(all_targets) 134 135 ifeq ($(NO_LOCAL_TARGETS),) 136 define LOCAL_TARGET_DEF 137 $(1) : $(DEST_DIR)/$(notdir $(1)) 138 cp $$? $$@ 139 endef 140 endif 141 142 # User BDE libraries 143 ADD_TO_CFLAGS += -I$(SDK)/systems/bde/linux/include 144 145 # Use raw IOCTL for KNET 146 ADD_TO_CFLAGS += -DPROXY_SUPPORT=0 147 148 CFLAGS += $(ADD_TO_CFLAGS) 149 150 kernel_modules: 151 $(MAKE) -C $(SDK)/systems/bde/linux/kernel kernel_version=$(kernel_version) 152 $(MAKE) -C $(SDK)/systems/bde/linux/user/kernel kernel_version=$(kernel_version) 153 ifeq ($(BUILD_KNET),1) 154 $(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ 155 subdirs="shared bcm-knet" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" 156 ifdef BUILD_KNET_CB 157 $(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ 158 subdirs="knet-cb" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" 159 endif 160 endif 161 162 $(KERNEL_BDE): $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ) 163 mkdir -p $(@D) 164 $(OBJCOPY) --strip-debug $< $@ 165 166 $(USER_BDE): $(KERN_BLDROOT)/linux-user-bde.$(KOBJ) 167 $(OBJCOPY) --strip-debug $< $@ 168 169 $(BCM_KNET): $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ) 170 $(OBJCOPY) --strip-debug $< $@ 171 172 $(KNET_CB): $(KERN_BLDROOT)/linux-knet-cb.$(KOBJ) 173 $(OBJCOPY) --strip-debug $< $@ 174 175 ifeq ($(NO_LOCAL_TARGETS),) 176 $(foreach targ,$(LOCAL_TARGETS),$(eval $(call LOCAL_TARGET_DEF,$(targ)))) 177 endif 178 179 clean:: 180 $(MAKE) -C $(SDK)/systems/bde/linux/kernel $@ 181 $(MAKE) -C $(SDK)/systems/bde/linux/user/kernel $@ 182 $(MAKE) -C $(SDK)/systems/linux/kernel/modules \ 183 subdirs="shared bcm-knet knet-cb" \ 184 override-target=linux-$(platform) $@ 185 $(RM) $(KERNEL_BDE) $(USER_BDE) 186 $(RM) $(BCM_KNET) $(KNET_CB) 187 $(RM) $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ) 188 $(RM) $(KERN_BLDROOT)/linux-user-bde.$(KOBJ) 189 $(RM) $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ) 190 $(RM) $(KERN_BLDROOT)/linux-knet-cb.$(KOBJ) 191 $(RM) $(LOCAL_TARGETS) 192 193 distclean:: clean 194 195 .PHONY: variable 196 197 # 198 # Echo variable values used for configuration 199 # usage: make VAR=CC variable 200 # 201 variable:: 202 @echo $($(VAR)) 203 204 else 205 ifndef DELIVERY 206 $(error DELIVERY required) 207 endif 208 209 DELIVERABLES := $(KERNEL_BDE) $(USER_BDE) 210 # 1= source 211 define DELIVERY_RULE 212 _DEL_TARG += $(DELIVERY)/$(notdir $(1)) 213 $(DELIVERY)/$(notdir $(1)) : $(1) 214 @mkdir -p $(DELIVERY) 215 ifeq ($(filter $(notdir $(BCM)) $(notdir $(BCM).dbg),$(notdir $1)),) 216 $(OBJCOPY) --strip-debug $$< $$@ 217 else 218 $(CP) -p $$< $$@ 219 endif 220 endef 221 222 $(foreach f,$(DELIVERABLES),$(eval $(call DELIVERY_RULE,$(f)))) 223 224 DELIVER: $(_DEL_TARG) 225 endif 226 227 # Make.config defines remaining phony targets 228 .PHONY: build kernel_modules DELIVER 229