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