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