1 jelson 1.1 #
|
2 jelson 1.17 # CENS EmStar Repository Master Makefile
|
3 jelson 1.1 #
|
4 thanos 1.56 # $Id: Makefile,v 1.55 2005/10/27 01:28:14 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 jelson 1.16 KCFLAGS += -DCVSTAG=\"$(CVSTAG)\"
|
131 girod 1.52 CXXFLAGS += -Wall -Werror -I. $(GLIB_CFLAGS) -I$(INCDIR) -DCVSTAG=\"$(CVSTAG)\"
|
132 jelson 1.5
|
133 jelson 1.17 # path to find the automatically generated rules
134 RULES := $(OBJDIR)/$(BUILDDIR)/easybuild.rules
|
135 jelson 1.1
|
136 girod 1.26 # export some variables to be picked up by sub-makes
|
137 girod 1.18 export PKG_CONFIG_PATH
|
138 girod 1.26 export USE_SHARED
139
140 # export some variables needed for TOS integration
141 export EMSTAR_MAKE=1
142 export EMSTAR_ROOT = $(PWD)
|
143 girod 1.18 export TOSDIR
144 export TOS_CONTRIB
145 export MAKERULES
146 PATH += :$(NESC_DIR)/bin:$(AVR_DIR)/bin
147 export PATH
|
148 girod 1.26 export EMTOS_MAKE_OBJDIR = $(OBJDIR)
149 export EMTOS_MAKE_CC = $(CC)
150 export EMTOS_MAKE_GCCINCLUDE
|
151 girod 1.41 export GLIB_CFLAGS
|
152 girod 1.24 # set up the default location for the cross-compiled glib library
|
153 girod 1.26 ifndef EMTOS_MAKE_LDFLAGS
154 EMTOS_MAKE_LDFLAGS = $(PWD)/$(GLIB_PATH)
|
155 girod 1.24 endif
|
156 girod 1.28 EMTOS_MAKE_LDFLAGS += -lpthread
|
157 girod 1.26 export EMTOS_MAKE_LDFLAGS
|
158 girod 1.18
|
159 mlukac 1.43 # setup stuff for 2.6 on kfusd
160 ifeq ($(strip $(BUILD_KMODULES)),1)
161 ifeq ($(strip $(BUILD_KMODULES_26)),1)
162 FUSD_26 := $(OBJDIR)/fusd/kfusd.ko
163 endif
164 endif
165
|
166 jelson 1.12 # the default target
|
167 mlukac 1.43 .DEFAULT default: $(RULES) default-targets $(FUSD_26)
|
168 jelson 1.12
|
169 jelson 1.15 # clean target: delete all generated files
|
170 jelson 1.12 clean:
171 rm -rf ./$(OBJDIR)/$(BUILDDIR)
172 rm -f $(ALL_TARGETS) $(RULES)
|
173 thanos 1.53 rm -f config.make
|
174 jelson 1.15
175 # strip target: strips all binaries other than kernel modules
176 strip: default-targets
177 @echo Stripping all binaries...
178 @$(BINSTRIP) $(ALL_STRIP_TARGETS)
|
179 jelson 1.12
|
180 girod 1.50 ##
181 ## If TinyOS not present, download it
182 ##
183
|
184 girod 1.49 # Include that causes tinyos to download
185 include tinyos-1.x/.force
186
|
187 girod 1.50 tinyos-1.x/.force:
|
188 girod 1.51 @if [[ -d tinyos-1.x ]]; then \
189 echo **** Using TinyOS installation that is already there... ; \
190 else \
191 echo TinyOS installation not found! ; \
192 echo Downloading and installing TinyOS-1.x from EmStar website... ; \
193 wget http://cvs.cens.ucla.edu/emstar-platforms/tinyos-1.1.13-linked.tgz -O - | tar -xzf - ; \
194 fi
|
195 girod 1.50 touch tinyos-1.x/.force
196
|
197 jelson 1.1 # Include rules to build the "easybuild" system itself
|
198 jelson 1.6 include make/make.easybuild
|
199 jelson 1.1
|
200 jelson 1.7 # Include the rules automatically generated by easybuild
|
201 jelson 1.12 include $(RULES)
|
202 jelson 1.1
|
203 jelson 1.3 # And, finally, a rule to invoke easybuild. The rules should be
204 # regenerated if any of three things change: 1) the root BUILD file in
205 # this directory; 2) any of the BUILD files that are recursively read
206 # by easybuild (this list is in the BUILD_LIST variable, which is set
207 # by easybuild and written in .easybuild.rules); or, 3) the easybuild
208 # program itself.
|
209 jelson 1.12 $(RULES): BUILD $(BUILD_LIST) $(NATIVE_OBJDIR)/make/easybuild
210 @mkdir -p $(OBJDIR)/$(BUILDDIR)
|
211 girod 1.25 $(NATIVE_OBJDIR)/make/easybuild > $@ || (rm -f $@; exit 1)
|
212 girod 1.18
213 ##
214 ## The 'help' target.
215 ## This target provides info about what vars are set and
216 ## what platforms are available
217 ##
218
219 # For debugging purposes, a rule that shows the environment
220 # and active variables..
221 help:
222 @echo Help:
223 @echo " make ARCH=<platform> [executable path]"
224 @echo
225 @echo " EmStar supports the following platforms:"
226 @echo
227 @echo " i686-linux (default) is the 'native' platform"
228 @echo " used to buld to run on your host. Check Make.conf"
229 @echo " to locally customize the native platform."
230 @echo
231 @echo " arm-linux builds for iPAQ"
|
232 eugene 1.31 @echo " ipaq-sa builds for all StrongARM-based iPAQs (Familiar)"
|
233 girod 1.26 @echo " stargate builds for Stargate release 7"
234 @echo " stargate-ucla builds for Stargate UCLA release 5"
|
235 girod 1.18 @echo " pasta builds for PASTA"
|
236 girod 1.34 @echo " ilense-104 builds for the ilense testbed"
|
237 girod 1.18 @echo
|
238 girod 1.42 @echo " mica, mica2, mica2dot, cricket, micaz, telos build Mote targets"
|
239 girod 1.18 @echo
240 @echo Environment:
241 @echo " NATIVE_KCFLAGS=$(NATIVE_KCFLAGS)"
|
242 girod 1.29 @echo " PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)"
243 @echo " GLIB_PATH=$(GLIB_PATH)"
|
244 girod 1.26 @echo " USE_SHARED='$(USE_SHARED)'"
|
245 girod 1.29 @echo " USE_DEVFS='$(USE_DEVFS)'"
|
246 girod 1.26 @echo " BUILD_EMTOS='$(BUILD_EMTOS)'"
|
247 girod 1.21 @echo " TOSDIR=$(TOSDIR)"
248 @echo " TOS_CONTRIB=$(TOS_CONTRIB)"
249 @echo " MAKERULES=$(MAKERULES)"
|
250 girod 1.18 @echo " NESC_DIR=$(NESC_DIR)"
251 @echo " AVR_DIR=$(AVR_DIR)"
252
|
253 eugene 1.32 KERNELVERSION := $(shell uname -r)
|
254 mlukac 1.44 KVERS_MAJOR := $(shell uname -r | cut -d . -f 2)
255 # Installs kfusd and fusdd. Must be done as root!
|
256 eugene 1.32 install-fusd: default
|
257 mlukac 1.44 @echo "You must be root for this to work!!!"
258 @echo "Copying module kfusd... "
|
259 eugene 1.32 mkdir -p /lib/modules/$(KERNELVERSION)/kernel/misc
|
260 mlukac 1.44 ifeq ($(strip $(KVERS_MAJOR)),6)
|
261 mlukac 1.45 cp -f $(OBJDIR)/fusd/kfusd.ko /lib/modules/$(KERNELVERSION)/kernel/misc
|
262 mlukac 1.44 @chmod u+x /lib/modules/$(KERNELVERSION)/kernel/misc/kfusd.ko
263 else
|
264 mlukac 1.45 cp -f $(OBJDIR)/fusd/kfusd.o /lib/modules/$(KERNELVERSION)/kernel/misc
|
265 eugene 1.32 @chmod u+x /lib/modules/$(KERNELVERSION)/kernel/misc/kfusd.o
|
266 mlukac 1.44 endif
|
267 eugene 1.32 @echo "Resolving dependencies... "
268 @/sbin/depmod -a
|
269 girod 1.40 @echo "Installing fusdd in /usr/sbin..."
270 @cp -f $(OBJDIR)/fusd/fusdd /usr/sbin
|
271 mlukac 1.45 # @echo "Loading kfusd... running fusdd "
272 # @/usr/sbin/fusdd
273 @echo "Now as root, just run /usr/sbin/fusdd"
|
274 girod 1.37
|
275 thanos 1.53 config.make:
276 @echo "Building config.make"
|
277 thanos 1.54 perl make/htosh.pl $(PWD)
|