source: soft/giet_vm/Makefile @ 445

Last change on this file since 445 was 445, checked in by alain, 10 years ago

Introducing application "display"

File size: 19.3 KB
Line 
1-include build.mk
2
3export # export all variable to sub-Makefile
4CC = mipsel-unknown-elf-gcc
5AS = mipsel-unknown-elf-as
6LD = mipsel-unknown-elf-ld
7DU = mipsel-unknown-elf-objdump
8AR = mipsel-unknown-elf-ar
9
10ARCH      ?= ../tsar-trunk-svn-2013/platforms/tsar_generic_iob
11X_SIZE    ?= 2
12Y_SIZE    ?= 2
13NPROCS    ?= 2
14FBF_WIDTH ?= 1024
15APP       ?= convol
16
17.PHONY: map.bin
18
19### FAT parameters definition for Disk image
20### sector_size          = 512
21### partition_begin_lba  = 300
22### sector_per_cluster   = 8
23### partition sectors    = 524832
24
25### Objects to be linked for the drivers static library
26DRIVERS_OBJS = build/drivers/dma_driver.o \
27               build/drivers/cma_driver.o \
28               build/drivers/xcu_driver.o \
29               build/drivers/ioc_driver.o \
30               build/drivers/bdv_driver.o \
31               build/drivers/hba_driver.o \
32               build/drivers/sdc_driver.o \
33               build/drivers/spi_driver.o \
34               build/drivers/rdk_driver.o \
35               build/drivers/iob_driver.o \
36               build/drivers/mmc_driver.o \
37               build/drivers/mwr_driver.o \
38               build/drivers/nic_driver.o \
39               build/drivers/tim_driver.o \
40               build/drivers/tty_driver.o \
41               build/drivers/pic_driver.o
42
43### Objects to be linked for kernel.elf
44KERNEL_OBJS  = build/common/utils.o        \
45               build/kernel/kernel_utils.o \
46               build/common/vmem.o         \
47               build/fat32/fat32.o         \
48               build/kernel/giet.o         \
49               build/kernel/switch.o       \
50               build/kernel/ctx_handler.o  \
51               build/kernel/exc_handler.o  \
52               build/kernel/sys_handler.o  \
53               build/kernel/irq_handler.o  \
54               build/kernel/kernel_init.o
55
56### Objects to be linked for boot.elf
57BOOT_OBJS    = build/common/utils.o       \
58               build/common/pmem.o        \
59               build/common/vmem.o        \
60               build/fat32/fat32.o        \
61               build/kernel/ctx_handler.o \
62               build/kernel/switch.o      \
63               build/boot/boot.o          \
64               build/boot/boot_entry.o
65
66### Objects to be linked for display.elf
67DISPLAY_OBJS = build/display/main.o \
68               build/libs/stdio.o
69
70### Objects to be linked for router.elf
71ROUTER_OBJS  = build/router/main.o        \
72               build/libs/mwmr_channel.o  \
73               build/libs/stdio.o
74
75### Objects to be linked for hello.elf
76HELLO_OBJS   = build/hello/main.o   \
77               build/libs/stdio.o         
78
79### Objects to be linked for pgcd.elf
80PGCD_OBJS    = build/pgcd/main.o          \
81               build/libs/stdio.o
82
83### Objects to be linked for game.elf
84GAMEOFLIFE_OBJS = build/gameoflife/main.o \
85                  build/libs/stdio.o      \
86                  build/libs/barrier.o    \
87                  build/libs/malloc.o     \
88                  build/libs/spin_lock.o
89                 
90
91### Objects to be linked for dhrystone.elf
92DHRYSTONE_OBJS = build/dhrystone/dhry_1.o \
93                 build/dhrystone/dhry_2.o \
94                 build/libs/stdlib.o      \
95                 build/libs/stdio.o       \
96                 build/libs/string.o      \
97                 build/libs/spin_lock.o   \
98                 build/libs/malloc.o
99
100### Objects to be linked for sort.elf
101SORT_OBJS   = build/sort/main.o          \
102              build/libs/stdio.o         \
103              build/libs/barrier.o       \
104              build/libs/malloc.o        \
105              build/libs/spin_lock.o
106
107### Objects to be linked for transpose.elf
108TRANSPOSE_OBJS = build/transpose/main.o  \
109                 build/libs/stdio.o      \
110                 build/libs/barrier.o    \
111                 build/libs/malloc.o     \
112                 build/libs/spin_lock.o
113
114### Objects to be linked for convol.elf
115CONVOL_OBJS  = build/convol/main.o       \
116               build/libs/stdio.o        \
117               build/libs/stdlib.o       \
118               build/libs/barrier.o      \
119               build/libs/malloc.o       \
120               build/libs/spin_lock.o
121
122CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \
123                 -fno-delete-null-pointer-checks
124
125GIET_INCLUDE = -Igiet_boot    \
126               -Igiet_kernel  \
127               -Igiet_xml     \
128               -Igiet_fat32   \
129               -Igiet_drivers \
130               -Igiet_common  \
131               -Igiet_libs    \
132               -I.
133
134USER_INCLUDE = -Igiet_libs    \
135               -Igiet_xml     \
136               -I.
137
138DISK_IMAGE  := hdd/virt_hdd.dmg
139
140all: map.bin                         \
141     hard_config.h                   \
142     giet_vsegs.ld                   \
143     build/boot/boot.elf             \
144     build/kernel/kernel.elf         \
145     build/display/display.elf       \
146     build/hello/hello.elf           \
147     build/pgcd/pgcd.elf             \
148     build/router/router.elf         \
149     build/dhrystone/dhrystone.elf   \
150     build/gameoflife/gameoflife.elf \
151     build/sort/sort.elf             \
152     build/transpose/transpose.elf   \
153     build/convol/convol.elf         \
154     $(DISK_IMAGE)                   
155         
156### Copy always all files into disk image
157        mcopy -o -i $(DISK_IMAGE) build/kernel/kernel.elf ::/build/kernel
158        mcopy -o -i $(DISK_IMAGE) build/display/display.elf ::/build/display
159        mcopy -o -i $(DISK_IMAGE) build/sort/sort.elf ::/build/sort
160        mcopy -o -i $(DISK_IMAGE) build/transpose/transpose.elf ::/build/transpose
161        mcopy -o -i $(DISK_IMAGE) build/convol/convol.elf ::/build/convol
162        mcopy -o -i $(DISK_IMAGE) build/hello/hello.elf ::/build/hello
163        mcopy -o -i $(DISK_IMAGE) build/pgcd/pgcd.elf ::/build/pgcd
164        mcopy -o -i $(DISK_IMAGE) build/router/router.elf ::/build/router
165        mcopy -o -i $(DISK_IMAGE) build/gameoflife/gameoflife.elf ::/build/gameoflife
166        mcopy -o -i $(DISK_IMAGE) build/dhrystone/dhrystone.elf ::/build/dhrystone
167        mcopy -o -i $(DISK_IMAGE) applications/transpose/images.raw ::/misc
168        mcopy -o -i $(DISK_IMAGE) applications/convol/philips_image.raw ::/misc
169        mcopy -o -i $(DISK_IMAGE) map.bin ::/
170### Copy bootloader into sector 2 of disk image
171        dd if=build/boot/boot.elf of=$(DISK_IMAGE) seek=2 conv=notrunc
172### Checking root directory
173        mdir -/ -b -i $(DISK_IMAGE) ::/
174
175### Disk image generation (no files in this step)
176### This requires the generic LINUX/MacOS script "create_dmg" script
177### written by C.Fuguet. (should be installed in GIET-VM root directory).
178$(DISK_IMAGE):
179        ./create_dmg create $(basename $(DISK_IMAGE))
180        mmd -o -i $(DISK_IMAGE) ::/build
181        mmd -o -i $(DISK_IMAGE) ::/build/kernel
182        mmd -o -i $(DISK_IMAGE) ::/build/display
183        mmd -o -i $(DISK_IMAGE) ::/build/sort 
184        mmd -o -i $(DISK_IMAGE) ::/build/transpose
185        mmd -o -i $(DISK_IMAGE) ::/build/convol
186        mmd -o -i $(DISK_IMAGE) ::/build/hello
187        mmd -o -i $(DISK_IMAGE) ::/build/pgcd 
188        mmd -o -i $(DISK_IMAGE) ::/build/router
189        mmd -o -i $(DISK_IMAGE) ::/build/gameoflife
190        mmd -o -i $(DISK_IMAGE) ::/build/dhrystone
191        mmd -o -i $(DISK_IMAGE) ::/misc
192        dd if=$(DISK_IMAGE) of=temp.dmg count=65536
193        mv temp.dmg $(DISK_IMAGE)
194
195### mapping generation: map.bin / map.xml / hard_config.h / giet_vsegs.ld
196map.bin hard_config.h giet_vsegs.ld: $(ARCH)/arch.py  applications/$(APP)/$(APP).py
197        giet_python/genmap --arch=$(ARCH)     \
198                           --x=$(X_SIZE)      \
199                           --y=$(Y_SIZE)      \
200                           --p=$(NPROCS)      \
201                           --fbf=$(FBF_WIDTH) \
202                           --giet=.           \
203                           --$(APP)           \
204                           --xml=.
205
206### drivers compilation
207build/drivers/cma_driver.o: giet_drivers/cma_driver.c  \
208                            giet_drivers/cma_driver.h  \
209                            hard_config.h              \
210                            giet_config.h
211        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
212
213build/drivers/dma_driver.o: giet_drivers/dma_driver.c  \
214                            giet_drivers/dma_driver.h  \
215                            hard_config.h              \
216                            giet_config.h
217        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
218
219build/drivers/xcu_driver.o: giet_drivers/xcu_driver.c  \
220                            giet_drivers/xcu_driver.h  \
221                            hard_config.h              \
222                            giet_config.h
223        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
224
225build/drivers/ioc_driver.o: giet_drivers/ioc_driver.c  \
226                            giet_drivers/ioc_driver.h  \
227                            hard_config.h              \
228                            giet_config.h
229        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
230
231build/drivers/bdv_driver.o: giet_drivers/bdv_driver.c  \
232                            giet_drivers/bdv_driver.h  \
233                            hard_config.h              \
234                            giet_config.h
235        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
236
237build/drivers/hba_driver.o: giet_drivers/hba_driver.c  \
238                            giet_drivers/hba_driver.h  \
239                            hard_config.h              \
240                            giet_config.h
241        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
242
243build/drivers/sdc_driver.o: giet_drivers/sdc_driver.c  \
244                            giet_drivers/sdc_driver.h  \
245                            hard_config.h              \
246                            giet_config.h
247        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
248
249build/drivers/spi_driver.o: giet_drivers/spi_driver.c  \
250                            giet_drivers/spi_driver.h  \
251                            hard_config.h              \
252                            giet_config.h
253        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
254
255build/drivers/rdk_driver.o: giet_drivers/rdk_driver.c  \
256                            giet_drivers/rdk_driver.h  \
257                            hard_config.h              \
258                            giet_config.h
259        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
260
261build/drivers/iob_driver.o: giet_drivers/iob_driver.c  \
262                            giet_drivers/iob_driver.h  \
263                            hard_config.h              \
264                            giet_config.h
265        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
266
267build/drivers/mmc_driver.o: giet_drivers/mmc_driver.c  \
268                            giet_drivers/mmc_driver.h  \
269                            hard_config.h              \
270                            giet_config.h
271        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
272
273build/drivers/mwr_driver.o: giet_drivers/mwr_driver.c  \
274                            giet_drivers/mwr_driver.h  \
275                            hard_config.h              \
276                            giet_config.h
277        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
278
279build/drivers/nic_driver.o: giet_drivers/nic_driver.c  \
280                            giet_drivers/nic_driver.h  \
281                            hard_config.h              \
282                            giet_config.h
283        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
284
285build/drivers/tim_driver.o: giet_drivers/tim_driver.c  \
286                            giet_drivers/tim_driver.h  \
287                            hard_config.h              \
288                            giet_config.h
289        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
290
291build/drivers/tty_driver.o: giet_drivers/tty_driver.c  \
292                            giet_drivers/tty_driver.h  \
293                            hard_config.h              \
294                            giet_config.h
295        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
296
297build/drivers/pic_driver.o: giet_drivers/pic_driver.c  \
298                            giet_drivers/pic_driver.h  \
299                            hard_config.h              \
300                            giet_config.h
301        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
302
303################################
304### drivers library compilation
305build/drivers/libdrivers.a: $(DRIVERS_OBJS)
306        $(AR) -rcs $@ $(DRIVERS_OBJS)
307
308##########################
309### common compilation
310build/fat32/fat32.o: giet_fat32/fat32.c \
311                     giet_fat32/fat32.h \
312                     hard_config.h      \
313                     giet_config.h
314        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
315
316build/common/utils.o: giet_common/utils.c \
317                      giet_common/utils.h \
318                      hard_config.h       \
319                      giet_config.h
320        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
321
322build/common/vmem.o: giet_common/vmem.c \
323                     giet_common/vmem.h \
324                     hard_config.h      \
325                     giet_config.h
326        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
327
328build/common/pmem.o: giet_common/pmem.c \
329                     giet_common/pmem.h \
330                     hard_config.h      \
331                     giet_config.h
332        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
333
334########################
335### boot compilation
336build/boot/boot.elf: $(BOOT_OBJS)            \
337                     giet_boot/boot.ld       \
338                     build/drivers/libdrivers.a
339        $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers 
340        $(DU) -D $@ > $@.txt
341
342build/boot/boot.o: giet_boot/boot.c          \
343                   giet_common/utils.h       \
344                   giet_fat32/fat32.h        \
345                   giet_common/vmem.h        \
346                   giet_drivers/tty_driver.h \
347                   giet_drivers/ioc_driver.h \
348                   hard_config.h             \
349                   giet_config.h
350        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
351
352build/boot/boot_entry.o: giet_boot/boot_entry.S \
353                         hard_config.h
354        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
355
356#########################
357### kernel compilation
358build/kernel/kernel.elf: $(KERNEL_OBJS)        \
359                         giet_kernel/kernel.ld \
360                         build/drivers/libdrivers.a
361        $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers   
362        $(DU) -D $@ > $@.txt
363
364build/kernel/%.o: giet_kernel/%.c    \
365                  hard_config.h      \
366                  giet_config.h 
367        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
368
369build/kernel/%.o: giet_kernel/%.s    \
370                  hard_config.h      \
371                  giet_config.h
372        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
373
374###########################
375### user libs compilation
376build/libs/stdio.o: giet_libs/stdio.c \
377                    giet_libs/stdio.h \
378                    hard_config.h     \
379                    giet_config.h 
380        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
381
382build/libs/mwmr_channel.o: giet_libs/mwmr_channel.c \
383                           giet_libs/mwmr_channel.h \
384                           hard_config.h            \
385                           giet_config.h
386        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
387
388build/libs/malloc.o: giet_libs/malloc.c         \
389                     giet_libs/malloc.h         \
390                     giet_libs/malloc_private.h \
391                     hard_config.h              \
392                     giet_config.h
393        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
394
395build/libs/barrier.o: giet_libs/barrier.c \
396                      giet_libs/barrier.h \
397                      hard_config.h       \
398                      giet_config.h
399        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
400
401build/libs/stdlib.o: giet_libs/stdlib.c \
402                     giet_libs/stdlib.h \
403                     hard_config.h      \
404                     giet_config.h
405        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
406
407build/libs/string.o: giet_libs/string.c \
408                     giet_libs/string.h \
409                     hard_config.h      \
410                     giet_config.h
411        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
412
413build/libs/spin_lock.o: giet_libs/spin_lock.c \
414                        giet_libs/spin_lock.h \
415                        hard_config.h         \
416                        giet_config.h
417        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
418
419build/libs/sbt_barrier.o: giet_libs/sbt_barrier.c \
420                          hard_config.h         \
421                          giet_config.h
422        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
423
424########################################
425### display application compilation
426build/display/display.elf: $(DISPLAY_OBJS) applications/display/display.ld hard_config.h
427        $(LD) -o $@ -T applications/display/display.ld $(DISPLAY_OBJS)
428        $(DU) -D $@ > $@.txt
429
430build/display/main.o: applications/display/main.c
431        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
432
433########################################
434### router compilation
435build/router/router.elf: $(ROUTER_OBJS) applications/router/router.ld hard_config.h
436        $(LD) -o $@ -T applications/router/router.ld $(ROUTER_OBJS)
437        $(DU) -D $@ > $@.txt
438
439build/router/main.o: applications/router/main.c
440        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
441
442########################################
443### hello compilation
444build/hello/hello.elf: $(HELLO_OBJS) applications/hello/hello.ld hard_config.h
445        $(LD) -o $@ -T applications/hello/hello.ld $(HELLO_OBJS)
446        $(DU) -D $@ > $@.txt
447
448build/hello/main.o: applications/hello/main.c
449        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
450
451########################################
452### pgcd compilation
453build/pgcd/pgcd.elf: $(PGCD_OBJS) applications/pgcd/pgcd.ld hard_config.h
454        $(LD) -o $@ -T applications/pgcd/pgcd.ld $(PGCD_OBJS)
455        $(DU) -D $@ > $@.txt
456
457build/pgcd/main.o: applications/pgcd/main.c
458        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
459
460########################################
461### gameoflife compilation
462build/gameoflife/gameoflife.elf: $(GAMEOFLIFE_OBJS) applications/gameoflife/gameoflife.ld
463        $(LD) -o $@ -T applications/gameoflife/gameoflife.ld $(GAMEOFLIFE_OBJS)
464        $(DU) -D $@ > $@.txt
465
466build/gameoflife/main.o: applications/gameoflife/main.c
467        $(CC) $(USER_INCLUDE) $(CFLAGS) -O3 -c -o $@ $<
468
469########################################
470### dhrystone compilation
471build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) applications/dhrystone/dhrystone.ld hard_config.h
472        $(LD) -o $@ -T applications/dhrystone/dhrystone.ld $(DHRYSTONE_OBJS)
473        $(DU) -D $@ > $@.txt
474
475build/dhrystone/dhry_1.o: applications/dhrystone/dhry_1.c
476        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
477
478build/dhrystone/dhry_2.o: applications/dhrystone/dhry_2.c
479        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
480
481########################################
482### sort compilation
483build/sort/sort.elf: $(SORT_OBJS) applications/sort/sort.ld hard_config.h
484        $(LD) -o $@ -T applications/sort/sort.ld $(SORT_OBJS)
485        $(DU) -D $@ > $@.txt
486
487build/sort/main.o: applications/sort/main.c
488        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
489
490########################################
491### transpose compilation
492build/transpose/transpose.elf: $(TRANSPOSE_OBJS) applications/transpose/transpose.ld hard_config.h
493        $(LD) -o $@ -T applications/transpose/transpose.ld $(TRANSPOSE_OBJS)
494        $(DU) -D $@ > $@.txt
495
496build/transpose/main.o: applications/transpose/main.c
497        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
498
499########################################
500### convol compilation
501build/convol/convol.elf: $(CONVOL_OBJS) applications/convol/convol.ld hard_config.h
502        $(LD) -o $@ -T applications/convol/convol.ld $(CONVOL_OBJS)
503        $(DU) -D $@ > $@.txt
504
505build/convol/main.o: applications/convol/main.c
506        $(CC) $(USER_INCLUDE) $(CFLAGS) -O0 -c -o $@ $<
507
508########################################
509### clean
510clean:
511        rm -f *.o *.elf *.bin *.txt core 
512        rm -f hard_config.h giet_vsegs.ld map.bin map.xml
513        rm -rf build/boot/*
514        rm -rf build/fat32/*
515        rm -rf build/common/*
516        rm -rf build/drivers/*
517        rm -rf build/kernel/*
518        rm -rf build/reset/*
519        rm -rf build/libs/*
520        rm -rf build/pgcd/*
521        rm -rf build/hello/*
522        rm -rf build/display/*
523        rm -rf build/router/*
524        rm -rf build/gameoflife/*
525        rm -rf build/dhrystone/*
526        rm -rf build/sort/*
527        rm -rf build/transpose/*
528        rm -rf build/convol/*
529        rm -rf $(DISK_IMAGE)
Note: See TracBrowser for help on using the repository browser.