source: soft/giet_vm/Makefile @ 432

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

1) Introduce the "applications" directory.
2) Introduce the fixed format (X_WIDTH / Y_WIDTH / P_WIDTH) for processor index in all applications.

File size: 19.8 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/fbf_driver.o \
29               build/drivers/xcu_driver.o \
30               build/drivers/icu_driver.o \
31               build/drivers/ioc_driver.o \
32               build/drivers/bdv_driver.o \
33               build/drivers/hba_driver.o \
34               build/drivers/sdc_driver.o \
35               build/drivers/spi_driver.o \
36               build/drivers/rdk_driver.o \
37               build/drivers/iob_driver.o \
38               build/drivers/mmc_driver.o \
39               build/drivers/mwr_driver.o \
40               build/drivers/nic_driver.o \
41               build/drivers/tim_driver.o \
42               build/drivers/tty_driver.o \
43               build/drivers/pic_driver.o
44
45### Objects to be linked for kernel.elf
46KERNEL_OBJS  = build/common/utils.o       \
47               build/common/vmem.o        \
48               build/fat32/fat32.o        \
49               build/kernel/giet.o        \
50               build/kernel/switch.o      \
51               build/kernel/ctx_handler.o \
52               build/kernel/exc_handler.o \
53               build/kernel/sys_handler.o \
54               build/kernel/irq_handler.o \
55               build/kernel/kernel_init.o
56
57### Objects to be linked for boot.elf
58BOOT_OBJS    = build/common/utils.o       \
59               build/common/pmem.o        \
60               build/common/vmem.o        \
61               build/fat32/fat32.o        \
62               build/kernel/ctx_handler.o \
63               build/kernel/switch.o      \
64               build/boot/boot.o          \
65               build/boot/boot_entry.o
66
67### Objects to be linked for display.elf
68DISPLAY_OBJS = build/display/main.o \
69               build/libs/stdio.o
70
71### Objects to be linked for router.elf
72ROUTER_OBJS  = build/router/main.o        \
73               build/libs/mwmr_channel.o  \
74               build/libs/stdio.o
75
76### Objects to be linked for hello.elf
77HELLO_OBJS   = build/hello/main.o   \
78               build/libs/stdio.o         
79
80### Objects to be linked for pgcd.elf
81PGCD_OBJS    = build/pgcd/main.o          \
82               build/libs/stdio.o
83
84### Objects to be linked for game.elf
85GAMEOFLIFE_OBJS = build/gameoflife/main.o \
86                  build/libs/stdio.o      \
87                  build/libs/barrier.o    \
88                  build/libs/malloc.o     \
89                  build/libs/spin_lock.o
90                 
91
92### Objects to be linked for dhrystone.elf
93DHRYSTONE_OBJS = build/dhrystone/dhry_1.o \
94                 build/dhrystone/dhry_2.o \
95                 build/libs/stdlib.o      \
96                 build/libs/stdio.o       \
97                 build/libs/string.o      \
98                 build/libs/spin_lock.o   \
99                 build/libs/malloc.o
100
101### Objects to be linked for sort.elf
102SORT_OBJS   = build/sort/main.o          \
103              build/libs/stdio.o         \
104              build/libs/barrier.o       \
105              build/libs/malloc.o        \
106              build/libs/spin_lock.o
107
108### Objects to be linked for transpose.elf
109TRANSPOSE_OBJS = build/transpose/main.o  \
110                 build/libs/stdio.o      \
111                 build/libs/barrier.o    \
112                 build/libs/malloc.o     \
113                 build/libs/spin_lock.o
114
115### Objects to be linked for convol.elf
116CONVOL_OBJS  = build/convol/main.o       \
117               build/libs/stdio.o        \
118               build/libs/stdlib.o       \
119               build/libs/barrier.o      \
120               build/libs/malloc.o       \
121               build/libs/spin_lock.o
122
123CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2
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/fbf_driver.o: giet_drivers/fbf_driver.c  \
220                            giet_drivers/fbf_driver.h  \
221                            hard_config.h              \
222                            giet_config.h
223        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
224
225build/drivers/xcu_driver.o: giet_drivers/xcu_driver.c  \
226                            giet_drivers/xcu_driver.h  \
227                            hard_config.h              \
228                            giet_config.h
229        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
230
231build/drivers/icu_driver.o: giet_drivers/icu_driver.c  \
232                            giet_drivers/icu_driver.h  \
233                            hard_config.h              \
234                            giet_config.h
235        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
236
237build/drivers/ioc_driver.o: giet_drivers/ioc_driver.c  \
238                            giet_drivers/ioc_driver.h  \
239                            hard_config.h              \
240                            giet_config.h
241        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
242
243build/drivers/bdv_driver.o: giet_drivers/bdv_driver.c  \
244                            giet_drivers/bdv_driver.h  \
245                            hard_config.h              \
246                            giet_config.h
247        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
248
249build/drivers/hba_driver.o: giet_drivers/hba_driver.c  \
250                            giet_drivers/hba_driver.h  \
251                            hard_config.h              \
252                            giet_config.h
253        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
254
255build/drivers/sdc_driver.o: giet_drivers/sdc_driver.c  \
256                            giet_drivers/sdc_driver.h  \
257                            hard_config.h              \
258                            giet_config.h
259        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
260
261build/drivers/spi_driver.o: giet_drivers/spi_driver.c  \
262                            giet_drivers/spi_driver.h  \
263                            hard_config.h              \
264                            giet_config.h
265        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
266
267build/drivers/rdk_driver.o: giet_drivers/rdk_driver.c  \
268                            giet_drivers/rdk_driver.h  \
269                            hard_config.h              \
270                            giet_config.h
271        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
272
273build/drivers/iob_driver.o: giet_drivers/iob_driver.c  \
274                            giet_drivers/iob_driver.h  \
275                            hard_config.h              \
276                            giet_config.h
277        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
278
279build/drivers/mmc_driver.o: giet_drivers/mmc_driver.c  \
280                            giet_drivers/mmc_driver.h  \
281                            hard_config.h              \
282                            giet_config.h
283        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
284
285build/drivers/mwr_driver.o: giet_drivers/mwr_driver.c  \
286                            giet_drivers/mwr_driver.h  \
287                            hard_config.h              \
288                            giet_config.h
289        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
290
291build/drivers/nic_driver.o: giet_drivers/nic_driver.c  \
292                            giet_drivers/nic_driver.h  \
293                            hard_config.h              \
294                            giet_config.h
295        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
296
297build/drivers/tim_driver.o: giet_drivers/tim_driver.c  \
298                            giet_drivers/tim_driver.h  \
299                            hard_config.h              \
300                            giet_config.h
301        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
302
303build/drivers/tty_driver.o: giet_drivers/tty_driver.c  \
304                            giet_drivers/tty_driver.h  \
305                            hard_config.h              \
306                            giet_config.h
307        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
308
309build/drivers/pic_driver.o: giet_drivers/pic_driver.c  \
310                            giet_drivers/pic_driver.h  \
311                            hard_config.h              \
312                            giet_config.h
313        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
314
315################################
316### drivers library compilation
317build/drivers/libdrivers.a: $(DRIVERS_OBJS)
318        $(AR) -rcs $@ $(DRIVERS_OBJS)
319
320##########################
321### common compilation
322build/fat32/fat32.o: giet_fat32/fat32.c \
323                     giet_fat32/fat32.h \
324                     hard_config.h      \
325                     giet_config.h
326        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
327
328build/common/utils.o: giet_common/utils.c \
329                      giet_common/utils.h \
330                      hard_config.h       \
331                      giet_config.h
332        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
333
334build/common/vmem.o: giet_common/vmem.c \
335                     giet_common/vmem.h \
336                     hard_config.h      \
337                     giet_config.h
338        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
339
340build/common/pmem.o: giet_common/pmem.c \
341                     giet_common/pmem.h \
342                     hard_config.h      \
343                     giet_config.h
344        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
345
346########################
347### boot compilation
348build/boot/boot.elf: $(BOOT_OBJS)            \
349                     giet_boot/boot.ld       \
350                     build/drivers/libdrivers.a
351        $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers 
352        $(DU) -D $@ > $@.txt
353
354build/boot/boot.o: giet_boot/boot.c          \
355                   giet_common/utils.h       \
356                   giet_fat32/fat32.h        \
357                   giet_common/vmem.h        \
358                   giet_drivers/tty_driver.h \
359                   giet_drivers/ioc_driver.h \
360                   hard_config.h             \
361                   giet_config.h
362        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
363
364build/boot/boot_entry.o: giet_boot/boot_entry.S \
365                         hard_config.h
366        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
367
368#########################
369### kernel compilation
370build/kernel/kernel.elf: $(KERNEL_OBJS)        \
371                         giet_kernel/kernel.ld \
372                         build/drivers/libdrivers.a
373        $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers   
374        $(DU) -D $@ > $@.txt
375
376build/kernel/%.o: giet_kernel/%.c    \
377                  hard_config.h      \
378                  giet_config.h 
379        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
380
381build/kernel/%.o: giet_kernel/%.s    \
382                  hard_config.h      \
383                  giet_config.h
384        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
385
386###########################
387### user libs compilation
388build/libs/stdio.o: giet_libs/stdio.c \
389                    giet_libs/stdio.h \
390                    hard_config.h     \
391                    giet_config.h 
392        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
393
394build/libs/mwmr_channel.o: giet_libs/mwmr_channel.c \
395                           giet_libs/mwmr_channel.h \
396                           hard_config.h            \
397                           giet_config.h
398        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
399
400build/libs/malloc.o: giet_libs/malloc.c         \
401                     giet_libs/malloc.h         \
402                     giet_libs/malloc_private.h \
403                     hard_config.h              \
404                     giet_config.h
405        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
406
407build/libs/barrier.o: giet_libs/barrier.c \
408                      giet_libs/barrier.h \
409                      hard_config.h       \
410                      giet_config.h
411        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
412
413build/libs/stdlib.o: giet_libs/stdlib.c \
414                     giet_libs/stdlib.h \
415                     hard_config.h      \
416                     giet_config.h
417        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
418
419build/libs/string.o: giet_libs/string.c \
420                     giet_libs/string.h \
421                     hard_config.h      \
422                     giet_config.h
423        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
424
425build/libs/spin_lock.o: giet_libs/spin_lock.c \
426                        giet_libs/spin_lock.h \
427                        hard_config.h         \
428                        giet_config.h
429        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
430
431build/libs/sbt_barrier.o: giet_libs/sbt_barrier.c \
432                          hard_config.h         \
433                          giet_config.h
434        $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $<
435
436########################################
437### display application compilation
438build/display/display.elf: $(DISPLAY_OBJS) applications/display/display.ld hard_config.h
439        $(LD) -o $@ -T applications/display/display.ld $(DISPLAY_OBJS)
440        $(DU) -D $@ > $@.txt
441
442build/display/main.o: applications/display/main_cma.c
443        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
444
445########################################
446### router compilation
447build/router/router.elf: $(ROUTER_OBJS) applications/router/router.ld hard_config.h
448        $(LD) -o $@ -T applications/router/router.ld $(ROUTER_OBJS)
449        $(DU) -D $@ > $@.txt
450
451build/router/main.o: applications/router/main.c
452        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
453
454########################################
455### hello compilation
456build/hello/hello.elf: $(HELLO_OBJS) applications/hello/hello.ld hard_config.h
457        $(LD) -o $@ -T applications/hello/hello.ld $(HELLO_OBJS)
458        $(DU) -D $@ > $@.txt
459
460build/hello/main.o: applications/hello/main.c
461        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
462
463########################################
464### pgcd compilation
465build/pgcd/pgcd.elf: $(PGCD_OBJS) applications/pgcd/pgcd.ld hard_config.h
466        $(LD) -o $@ -T applications/pgcd/pgcd.ld $(PGCD_OBJS)
467        $(DU) -D $@ > $@.txt
468
469build/pgcd/main.o: applications/pgcd/main.c
470        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
471
472########################################
473### gameoflife compilation
474build/gameoflife/gameoflife.elf: $(GAMEOFLIFE_OBJS) applications/gameoflife/gameoflife.ld
475        $(LD) -o $@ -T applications/gameoflife/gameoflife.ld $(GAMEOFLIFE_OBJS)
476        $(DU) -D $@ > $@.txt
477
478build/gameoflife/main.o: applications/gameoflife/main.c
479        $(CC) $(USER_INCLUDE) $(CFLAGS) -O3 -c -o $@ $<
480
481########################################
482### dhrystone compilation
483build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) applications/dhrystone/dhrystone.ld hard_config.h
484        $(LD) -o $@ -T applications/dhrystone/dhrystone.ld $(DHRYSTONE_OBJS)
485        $(DU) -D $@ > $@.txt
486
487build/dhrystone/dhry_1.o: applications/dhrystone/dhry_1.c
488        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
489
490build/dhrystone/dhry_2.o: applications/dhrystone/dhry_2.c
491        $(CC) $(USER_INCLUDE) $(CFLAGS)  -c -o $@ $<
492
493########################################
494### sort compilation
495build/sort/sort.elf: $(SORT_OBJS) applications/sort/sort.ld hard_config.h
496        $(LD) -o $@ -T applications/sort/sort.ld $(SORT_OBJS)
497        $(DU) -D $@ > $@.txt
498
499build/sort/main.o: applications/sort/main.c
500        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
501
502########################################
503### transpose compilation
504build/transpose/transpose.elf: $(TRANSPOSE_OBJS) applications/transpose/transpose.ld hard_config.h
505        $(LD) -o $@ -T applications/transpose/transpose.ld $(TRANSPOSE_OBJS)
506        $(DU) -D $@ > $@.txt
507
508build/transpose/main.o: applications/transpose/main.c
509        $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $<
510
511########################################
512### convol compilation
513build/convol/convol.elf: $(CONVOL_OBJS) applications/convol/convol.ld hard_config.h
514        $(LD) -o $@ -T applications/convol/convol.ld $(CONVOL_OBJS)
515        $(DU) -D $@ > $@.txt
516
517build/convol/main.o: applications/convol/main.c
518        $(CC) $(USER_INCLUDE) $(CFLAGS) -O0 -c -o $@ $<
519
520########################################
521### clean
522clean:
523        rm -f *.o *.elf *.bin *.txt core 
524        rm -f hard_config.h giet_vsegs.ld map.bin map.xml
525        rm -rf build/boot/*
526        rm -rf build/fat32/*
527        rm -rf build/common/*
528        rm -rf build/drivers/*
529        rm -rf build/kernel/*
530        rm -rf build/reset/*
531        rm -rf build/libs/*
532        rm -rf build/pgcd/*
533        rm -rf build/hello/*
534        rm -rf build/display/*
535        rm -rf build/router/*
536        rm -rf build/gameoflife/*
537        rm -rf build/dhrystone/*
538        rm -rf build/sort/*
539        rm -rf build/transpose/*
540        rm -rf build/convol/*
541        rm -rf $(DISK_IMAGE)
Note: See TracBrowser for help on using the repository browser.