1
2#*****************************************************************************
3#
4#  Copyright 2000
5#  Broadcom Corporation
6#  16215 Alton Parkway
7#  PO Box 57013
8#  Irvine CA 92619-7013
9#
10#****************************************************************************/
11###############################################################################
12# 
13# swlib SDK Makefile
14#
15###############################################################################
16
17
18ifeq ($(LINUXDIR),)
19ifeq ($(LINUXVER),)
20# Neither one is specified, use uname for version
21LINUXVER = $(shell uname -r)
22endif
23else
24ifeq ($(LINUXVER),)
25# divine LINUXVER from LINUXDIR
26LINUXVER = $(shell sed -ne 's/.*UTS_RELEASE \([^ ]\)/\1/p' -e q < $(LINUXDIR)/include/linux/version.h)
27endif
28endif
29
30# Now try a couple of places for LINUXDIR if not specified
31ifeq ($(LINUXDIR),)
32ifneq ($(wildcard /lib/modules/$(LINUXVER)/build/include/linux/version.h),)
33LINUXDIR = /lib/modules/$(LINUXVER)/build
34else
35ifneq ($(wildcard /tools/linux/src/linux-$(LINUXVER)/include/linux/version.h),)
36LINUXDIR = /tools/linux/src/linux-$(LINUXVER)
37else
38LINUXDIR = /usr/src/linux
39endif
40endif
41endif
42
43CROSS_COMPILATION       =1
44
45# Note: Never set the below in makefiles -- it should already be set
46#CROSS_COMPILE=mipsel-linux-
47
48CC              =$(CROSS_COMPILE)gcc
49LD              =$(CROSS_COMPILE)ld
50RANLIB          =$(CROSS_COMPILE)ranlib
51SWAPIDIR        =../sys
52LINUX          =$(LINUXDIR)
53
54CFLAGS          = -I$(LINUX)/include -Dlinux -D__linux__
55LDFLAGS         = -r
56SWLIBFLAGS      = -I$(SWAPIDIR) -I../swmod -I../../include -D__klsi__
57
58CMD_ECHO= @	# Suppresses shell command echos; comment out for verbose
59MAKE_ECHO= -s	# Suppresses make command echos; comment out for verbose
60SHELL		= /bin/sh
61
62
63BINDIR		= ../../router/install-mipsel/lib
64DBGFLAGS += -g #-DDEBUG
65WARNINGS= -Wall
66CFLAGS  += -O2 -ansi $(INCLUDES) $(DBGFLAGS) $(WARNINGS)
67CFLAGS += $(SWLIBFLAGS)
68LDFLAGS += -r 
69CFLAGS += $(BCM_OEM_DEFINES) -DUSER_APPLICATION
70ifeq ($(BOARD),bcm94702cpci)
71CFLAGS += -DBCM5380
72endif
73ifeq ($(BOARD),bcm5380rr)
74CFLAGS += -DBCM5380
75endif
76
77ifndef BINNAME
78BINNAME=libsw.a
79endif
80
81LIBNAME=
82
83RM = /bin/rm
84RMFLAGS = -f
85
86# to build shared library
87SHRCFLAGS = -O2 -ansi -pedantic -fPIC -c $(INCLUDES) -w $(DBGFLAGS)
88SHRLDFLAGS = -shared $(LINUXIA64) 
89SHRCFLAGS += $(SWLIBFLAGS)
90SHRCFLAGS += $(BCM_OEM_DEFINES) -DUSER_APPLICATION
91ifeq ($(BOARD),bcm94702cpci)
92SHRCFLAGS += -DBCM5380
93endif
94ifeq ($(BOARD),bcm5380rr)
95SHRCFLAGS += -DBCM5380
96endif
97
98ifndef SHRBINNAME
99SHRBINNAME=libsw.so
100endif
101
102
103.SUFFIXES:
104.SUFFIXES: .c .o .so
105
106# files for a (source) distribution
107
108LIBSWOBJ =	swapi.o osl_linux.o
109LIBSWSOBJ =	swapi.so
110
111all: $(BINNAME)  $(SHRBINNAME)
112
113shared: $(SHRBINNAME)
114
115$(BINNAME): $(LIBSWOBJ) $(LIBNAME)
116#	@echo Linking...
117#	$(CMD_ECHO)
118	$(LD) -o $(BINNAME)  $(LDFLAGS) $(LIBSWOBJ) $(LIBNAME)
119
120$(SHRBINNAME): $(LIBSWSOBJ) $(LIBSWOBJ) $(LIBNAME)
121#	@echo Linking...
122#	$(CMD_ECHO)
123	$(LD) -o $(SHRBINNAME) $(SHRLDFLAGS) $(LIBSWOBJ) $(LIBNAME)
124
125clean:
126#	@echo Cleaning up files...
127#	$(CMD_ECHO)
128	$(RM) $(RMFLAGS) $(BINNAME) $(LIBSWOBJ) $(LIBSWSOBJ) $(SHRBINNAME) *~
129
130rebuild:
131	$(CMD_ECHO)make $(MAKE_ECHO) clean
132	$(CMD_ECHO)make $(MAKE_ECHO)
133
134install:  $(SHRBINNAME)
135#	@echo Installing shared swlib...
136#	$(CMD_ECHO)
137	install $(SHRBINNAME) $(BINDIR)
138
139%.o: $(SWAPIDIR)/%.c
140#	@echo Compiling $<...
141#	$(CMD_ECHO)
142	$(CC) $(CFLAGS) -c $<
143
144%.so: $(SWAPIDIR)/%.c
145#	@echo Compiling $< \(shared\) $(LINUXIA64)...
146#	$(CMD_ECHO)
147	$(CC) $(SHRCFLAGS)  -c $< -o $@
148
149# Dependecies
150
151ifneq ($(wildcard ../switch/swmod),)
152DEPENDH = $(SWAPIDIR)/swapi.h $(SWAPIDIR)/etc53xx.h
153endif
154
155swapi.o: $(DEPENDH)
156osl_linux.o: $(DEPENDH)
157swapi.so: $(DEPENDH)
158
159
160