1 jelson 1.1 #
|
2 jelson 1.17 # CENS EmStar Repository Master Makefile
|
3 jelson 1.1 #
|
4 thanos 1.55 # $Id: Makefile,v 1.54 2005/10/27 00:39:46 thanos Exp $
|
5 jelson 1.1 #
6
|
7 jelson 1.2 ################### NOTE!!!! ###########################
8 ## Most of the time you want to edit the files called ##
|
9 girod 1.18 ## 'BUILD' and Make.conf, NOT this Makefile. ##
|
10 jelson 1.2 ########################################################
11
|
12 girod 1.20 ## Sets user-modifiable variables
13 ## e.g. enable TOS, Kernel, native kernel headers, etc
|
14 girod 1.18 include Make.conf
|
15 thanos 1.53 ifeq ($(strip $(USE_CONFIGURE)), 1)
16 include config.make
17 endif
|
18 girod 1.18
|
19 girod 1.40 ## USE_DEVFS. This flag causes the FUSD kernel module to build with
20 ## devfs support. DevFS seems to have race conditions and we do not
21 ## recommend using it
22 USE_DEVFS := 0
23
|
24 girod 1.29 ##
25 ## If you are using shared libraries, you can turn off the following
26 ## flag to cause EmStar to use relative paths to discover its shared
27 ## libs. This is not generally recommended -- using LD_LIBRARY_PATH
28 ## is a better idea.
29 ##
30 REQUIRE_LD_LIBRARY_PATH := 1
31
32 ########################################################
33 ##
34 ## Set various TinyOS related environment variables.
35 ##
36 ## *** WARNING: Changing the settings below is not
|
37 girod 1.33 ## recommended because it does not generally work!
38 ## Use symlinks instead!!
|
39 girod 1.29 ##
40 ## Please see <http://cvs.cens.ucla.edu/emstar/install.html>
41 ## for more detailed information.
42 ##
43 ## NOTE: If you want to configure EmStar to use other
44 ## locations for tinyos or tos-contrib, simply move
45 ## away the bundled versions and add symlinks to
46 ## the locations of the versions you want to use.
47 ##
48 ## We recommend this approach because using environment
49 ## variables is more fragile and harder to track with
50 ## revision control.
51 ##
|
52 girod 1.33 ## The BUILD rules in EmStar are all coded to be relative
53 ## to the EmStar tree, and assume that tinyos and tos-contrib
54 ## are linked from inside it, or are present there.
55 ## Lots of things will break horribly if this is not the
56 ## case.
|
57 girod 1.29 ##
58 ########################################################
59
60 ## TOSDIR points to the SourceForge TinyOS repo.
61 ## This setting points to the version bundled with EmStar
|
62 eugene 1.32 TOSDIR := $(PWD)/tinyos-1.x/tos
|
63 girod 1.29
64 ## TOS_CONTRIB points to the CENS tos-contrib repo
65 ## This setting points to the version checked out with EmStar
66 TOS_CONTRIB := $(PWD)/tos-contrib/
67
68 ## MAKERULES controls aspects of the TOS build system
69 ## This setting should be compatible with your TOSDIR setting
70 MAKERULES := $(TOSDIR)/../tools/make/Makerules
71
72 #########################################################
73 #########################################################
74
75 # enable/disable DevFS
|
76 girod 1.52 ifeq ($(strip $(USE_DEVFS)),1)
|
77 girod 1.29 DEVFS_KCFLAG := -DUSE_DEVFS
78 else
79 DEVFS_KCFLAG :=
80 endif
81
82 #########################################################
83 #########################################################
84
|
85 jelson 1.7 # Set platform-dependent variables. Including this fragment sets:
86 # ARCH -- the target architecture (e.g., arm-linux or i686-linux)
87 # NATIVE_ARCH -- the architecture we're compiling under
88 # CC, CPP, AR, LD, BINSTRIP -- paths to various utils
89 include make/make.platform
90
|
91 girod 1.26 # If shared libraries are in use, config the suffix to .so
|
92 girod 1.52 ifeq ($(strip $(USE_SHARED)),1)
|
93 girod 1.26 LIB_SUFFIX := .so
|
94 girod 1.52 ifeq ($(strip $(REQUIRE_LD_LIBRARY_PATH)),0)
|
95 girod 1.26 SHARED_LIB_PREFIX := lib/
96 endif
97 else
98 LIB_SUFFIX := .a
99 endif
|
100 girod 1.27
101 # phread a dependency of glib (though we don't generally use it)
|
102 girod 1.28 LDFLAGS += -lm -lpthread $(GLIB_PATH)
|
103 girod 1.26
|
104 jelson 1.7 # names of various target directories
|
105 jelson 1.1 OBJDIR := obj.$(ARCH)
106 NATIVE_OBJDIR := obj.$(NATIVE_ARCH)
|
107 jelson 1.2 BUILDDIR := .build
|
108 jelson 1.5 INCDIR := include
109
|
110 jelson 1.8 # figure out if a cvs tag has been used here
111 CVSTAG := $(shell make/get-cvs-tag.pl)
112
|
113 jelson 1.9 # default compiler and linker flags used by everything
114 # NOTE: some platform-specific flags might be set in make.platform
|
115 jelson 1.36 ifndef NO_PIC
116 CFLAGS += -fPIC
117 CXXFLAGS += -fPIC
118 endif
119
|
120 girod 1.52 # Set up cflags for stuff that's going in a library and stuff
121 # that's going in an executable...
122 ifeq ($(strip $(DEBUG_LIBS)),1)
123 CFLAGS_LIBS += -g
124 endif
125 ifeq ($(strip $(DEBUG_EXES)),1)
126 CFLAGS_EXES += -g
127 endif
128
129 CFLAGS += -Wall -Werror -I. $(GLIB_CFLAGS) -I$(INCDIR) -DCVSTAG=\"$(CVSTAG)\"
|
130 thanos 1.55 # add no-pointer-sign if we have gcc >=4
|
131 thanos 1.53 ifdef HAVE_GCC_4
|
132 thanos 1.55 CFLAGS += -Wno-pointer-sign -D__HAVE_GCC_4
|
133 thanos 1.53 endif
|
134 jelson 1.16 KCFLAGS += -DCVSTAG=\"$(CVSTAG)\"
|
135 girod 1.52 CXXFLAGS += -Wall -Werror -I. $(GLIB_CFLAGS) -I$(INCDIR) -DCVSTAG=\"$(CVSTAG)\"
|
136 jelson 1.5
|
137 jelson 1.17 # path to find the automatically generated rules
138 RULES := $(OBJDIR)/$(BUILDDIR)/easybuild.rules
|
139 jelson 1.1
|
140 girod 1.26 # export some variables to be picked up by sub-makes
|
141 girod 1.18 export PKG_CONFIG_PATH
|
142 girod 1.26 export USE_SHARED
143
144 # export some variables needed for TOS integration
145 export EMSTAR_MAKE=1
146 export EMSTAR_ROOT = $(PWD)
|
147 girod 1.18 export TOSDIR
148 export TOS_CONTRIB
149 export MAKERULES
150 PATH += :$(NESC_DIR)/bin:$(AVR_DIR)/bin
151 export PATH
|
152 girod 1.26 export EMTOS_MAKE_OBJDIR = $(OBJDIR)
153 export EMTOS_MAKE_CC = $(CC)
154 export EMTOS_MAKE_GCCINCLUDE
|
155 girod 1.41 export GLIB_CFLAGS
|
156 thanos 1.55 # export this if we have gcc_4 so we can include the right thing
157 # on the emtos build
158 ifdef HAVE_GCC_4
159 export HAVE_GCC_4
160 endif
|
161 girod 1.24 # set up the default location for the cross-compiled glib library
|
162 girod 1.26 ifndef EMTOS_MAKE_LDFLAGS
163 EMTOS_MAKE_LDFLAGS = $(PWD)/$(GLIB_PATH)
|
164 girod 1.24 endif
|
165 girod 1.28 EMTOS_MAKE_LDFLAGS += -lpthread
|
166 girod 1.26 export EMTOS_MAKE_LDFLAGS
|
167 girod 1.18
|
168 mlukac 1.43 # setup stuff for 2.6 on kfusd
169 ifeq ($(strip $(BUILD_KMODULES)),1)
170 ifeq ($(strip $(BUILD_KMODULES_26)),1)
171 FUSD_26 := $(OBJDIR)/fusd/kfusd.ko
172 endif
173 endif
174
|
175 jelson 1.12 # the default target
|
176 mlukac 1.43 .DEFAULT default: $(RULES) default-targets $(FUSD_26)
|
177 jelson 1.12
|
178 jelson 1.15 # clean target: delete all generated files
|
179 jelson 1.12 clean:
180 rm -rf ./$(OBJDIR)/$(BUILDDIR)
181 rm -f $(ALL_TARGETS) $(RULES)
|
182 thanos 1.53 rm -f config.make
|
183 jelson 1.15
184 # strip target: strips all binaries other than kernel modules
185 strip: default-targets
186 @echo Stripping all binaries...
187 @$(BINSTRIP) $(ALL_STRIP_TARGETS)
|
188 jelson 1.12
|
189 girod 1.50 ##
190 ## If TinyOS not present, download it
191 ##
192
|
193 girod 1.49 # Include that causes tinyos to download
194 include tinyos-1.x/.force
195
|
196 girod 1.50 tinyos-1.x/.force:
|
197 girod 1.51 @if [[ -d tinyos-1.x ]]; then \
198 echo **** Using TinyOS installation that is already there... ; \
199 else \
200 echo TinyOS installation not found! ; \
201 echo Downloading and installing TinyOS-1.x from EmStar website... ; \
202 wget http://cvs.cens.ucla.edu/emstar-platforms/tinyos-1.1.13-linked.tgz -O - | tar -xzf - ; \
203 fi
|
204 girod 1.50 touch tinyos-1.x/.force
205
|
206 jelson 1.1 # Include rules to build the "easybuild" system itself
|
207 jelson 1.6 include make/make.easybuild
|
208 jelson 1.1
|
209 jelson 1.7 # Include the rules automatically generated by easybuild
|
210 jelson 1.12 include $(RULES)
|
211 jelson 1.1
|
212 jelson 1.3 # And, finally, a rule to invoke easybuild. The rules should be
213 # regenerated if any of three things change: 1) the root BUILD file in
214 # this directory; 2) any of the BUILD files that are recursively read
215 # by easybuild (this list is in the BUILD_LIST variable, which is set
216 # by easybuild and written in .easybuild.rules); or, 3) the easybuild
217 # program itself.
|
218 jelson 1.12 $(RULES): BUILD $(BUILD_LIST) $(NATIVE_OBJDIR)/make/easybuild
219 @mkdir -p $(OBJDIR)/$(BUILDDIR)
|
220 girod 1.25 $(NATIVE_OBJDIR)/make/easybuild > $@ || (rm -f $@; exit 1)
|
221 girod 1.18
222 ##
223 ## The 'help' target.
224 ## This target provides info about what vars are set and
225 ## what platforms are available
226 ##
227
228 # For debugging purposes, a rule that shows the environment
229 # and active variables..
230 help:
231 @echo Help:
232 @echo " make ARCH=<platform> [executable path]"
233 @echo
234 @echo " EmStar supports the following platforms:"
235 @echo
236 @echo " i686-linux (default) is the 'native' platform"
237 @echo " used to buld to run on your host. Check Make.conf"
238 @echo " to locally customize the native platform."
239 @echo
240 @echo " arm-linux builds for iPAQ"
|
241 eugene 1.31 @echo " ipaq-sa builds for all StrongARM-based iPAQs (Familiar)"
|
242 girod 1.26 @echo " stargate builds for Stargate release 7"
243 @echo " stargate-ucla builds for Stargate UCLA release 5"
|
244 girod 1.18 @echo " pasta builds for PASTA"
|
245 girod 1.34 @echo " ilense-104 builds for the ilense testbed"
|
246 girod 1.18 @echo
|
247 girod 1.42 @echo " mica, mica2, mica2dot, cricket, micaz, telos build Mote targets"
|
248 girod 1.18 @echo
249 @echo Environment:
250 @echo " NATIVE_KCFLAGS=$(NATIVE_KCFLAGS)"
|
251 girod 1.29 @echo " PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)"
252 @echo " GLIB_PATH=$(GLIB_PATH)"
|
253 girod 1.26 @echo " USE_SHARED='$(USE_SHARED)'"
|
254 girod 1.29 @echo " USE_DEVFS='$(USE_DEVFS)'"
|
255 girod 1.26 @echo " BUILD_EMTOS='$(BUILD_EMTOS)'"
|
256 girod 1.21 @echo " TOSDIR=$(TOSDIR)"
257 @echo " TOS_CONTRIB=$(TOS_CONTRIB)"
258 @echo " MAKERULES=$(MAKERULES)"
|
259 girod 1.18 @echo " NESC_DIR=$(NESC_DIR)"
260 @echo " AVR_DIR=$(AVR_DIR)"
261
|
262 eugene 1.32 KERNELVERSION := $(shell uname -r)
|
263 mlukac 1.44 KVERS_MAJOR := $(shell uname -r | cut -d . -f 2)
264 # Installs kfusd and fusdd. Must be done as root!
|
265 eugene 1.32 install-fusd: default
|
266 mlukac 1.44 @echo "You must be root for this to work!!!"
267 @echo "Copying module kfusd... "
|
268 eugene 1.32 mkdir -p /lib/modules/$(KERNELVERSION)/kernel/misc
|
269 mlukac 1.44 ifeq ($(strip $(KVERS_MAJOR)),6)
|
270 mlukac 1.45 cp -f $(OBJDIR)/fusd/kfusd.ko /lib/modules/$(KERNELVERSION)/kernel/misc
|
271 mlukac 1.44 @chmod u+x /lib/modules/$(KERNELVERSION)/kernel/misc/kfusd.ko
272 else
|
273 mlukac 1.45 cp -f $(OBJDIR)/fusd/kfusd.o /lib/modules/$(KERNELVERSION)/kernel/misc
|
274 eugene 1.32 @chmod u+x /lib/modules/$(KERNELVERSION)/kernel/misc/kfusd.o
|
275 mlukac 1.44 endif
|
276 eugene 1.32 @echo "Resolving dependencies... "
277 @/sbin/depmod -a
|
278 girod 1.40 @echo "Installing fusdd in /usr/sbin..."
279 @cp -f $(OBJDIR)/fusd/fusdd /usr/sbin
|
280 mlukac 1.45 # @echo "Loading kfusd... running fusdd "
281 # @/usr/sbin/fusdd
282 @echo "Now as root, just run /usr/sbin/fusdd"
|
283 girod 1.37
|
284 thanos 1.53 config.make:
285 @echo "Building config.make"
|
286 thanos 1.54 perl make/htosh.pl $(PWD)
|