source: soft/giet_vm/Makefile @ 676

Last change on this file since 676 was 675, checked in by guerin, 9 years ago

raycast: add texture files

File size: 15.9 KB
RevLine 
[595]1-include params.mk
[302]2
[595]3export # export all variable to applications sub-Makefile
4
[232]5CC = mipsel-unknown-elf-gcc
6AS = mipsel-unknown-elf-as
7LD = mipsel-unknown-elf-ld
8DU = mipsel-unknown-elf-objdump
[380]9AR = mipsel-unknown-elf-ar
[158]10
[595]11# Defaults values for hardware parameters and applications
[611]12# These parameters should be defined in the params.mk file
[595]13ARCH      ?= pathname
[581]14X_SIZE    ?= 1
15Y_SIZE    ?= 1
[595]16NB_PROCS  ?= 1
[580]17NB_TTYS   ?= 1
[595]18FBF_WIDTH ?= 256
19IOC_TYPE  ?= BDV
[611]20APPLIS    ?= shell
[326]21
[595]22# build the list of applications used as argument by genmap
23GENMAP_APPLIS := $(addprefix --,$(APPLIS))
[510]24
[649]25# build the list of application.py (used as dependencies by genmap)
26APPLIS_PY      = applications/classif/classif.py        \
27                 applications/convol/convol.py          \
28                 applications/coproc/coproc.py          \
29                 applications/display/display.py        \
30                 applications/dhrystone/dhrystone.py    \
31                 applications/gameoflife/gameoflife.py  \
32                 applications/ocean/ocean.py            \
[673]33                 applications/raycast/raycast.py        \
[649]34                 applications/router/router.py          \
35                 applications/shell/shell.py            \
36                 applications/sort/sort.py              \
37                 applications/transpose/transpose.py
[326]38
[595]39# build the list of applications to be executed (used in the all rule)
40APPLIS_ELF    := $(addsuffix /appli.elf,$(addprefix applications/,$(APPLIS)))
[204]41
[600]42# Build PYTHONPATH
[602]43PYTHONPATH := $(shell find . -name *.py | grep -o "\(.*\)/" | sort -u | tr '\n' :)
[600]44
[595]45# check hardware platform definition
46ifeq ($(wildcard $(ARCH)),)
47$(error please define in ARCH parameter the path to the platform)
48endif
[580]49
[608]50### Rules that don't build a target file
[662]51.PHONY: all dirs list extract clean clean-disk install-disk $(APPLIS_ELF)
[595]52
[463]53### Objects to be linked for the drivers library
[535]54DRIVERS_OBJS = build/drivers/dma_driver.o      \
55               build/drivers/cma_driver.o      \
56               build/drivers/xcu_driver.o      \
57               build/drivers/bdv_driver.o      \
58               build/drivers/hba_driver.o      \
59               build/drivers/sdc_driver.o      \
60               build/drivers/spi_driver.o      \
61               build/drivers/rdk_driver.o      \
62               build/drivers/iob_driver.o      \
63               build/drivers/mmc_driver.o      \
64               build/drivers/mwr_driver.o      \
65               build/drivers/nic_driver.o      \
66               build/drivers/tim_driver.o      \
67               build/drivers/tty_driver.o      \
[380]68               build/drivers/pic_driver.o
69
70### Objects to be linked for kernel.elf
[510]71KERNEL_OBJS  = build/common/utils.o            \
72               build/common/kernel_locks.o     \
73               build/common/kernel_barriers.o  \
74               build/common/tty0.o             \
75               build/common/vmem.o             \
76               build/common/kernel_malloc.o    \
77               build/fat32/fat32.o             \
78               build/kernel/giet.o             \
79               build/kernel/switch.o           \
80               build/kernel/ctx_handler.o      \
81               build/kernel/exc_handler.o      \
82               build/kernel/sys_handler.o      \
83               build/kernel/irq_handler.o      \
[258]84               build/kernel/kernel_init.o
[162]85
[258]86### Objects to be linked for boot.elf
[510]87BOOT_OBJS    = build/common/utils.o            \
88               build/common/kernel_locks.o     \
89               build/common/kernel_barriers.o  \
90               build/common/tty0.o             \
91               build/common/pmem.o             \
92               build/common/vmem.o             \
93               build/common/kernel_malloc.o    \
94               build/fat32/fat32.o             \
95               build/kernel/ctx_handler.o      \
[535]96               build/kernel/irq_handler.o      \
[595]97               build/kernel/sys_handler.o      \
[510]98               build/kernel/switch.o           \
99               build/boot/boot.o               \
[366]100               build/boot/boot_entry.o
[258]101
[585]102### Objects to be linked for the user library
103USER_OBJS     = build/libs/malloc.o            \
104                build/libs/mwmr_channel.o      \
105                build/libs/stdio.o             \
106                build/libs/stdlib.o            \
107                build/libs/string.o            \
108                build/libs/user_barrier.o      \
109                build/libs/user_lock.o         \
[595]110                build/libs/user_sqt_lock.o     
[585]111
[583]112### Objects to be linked for the math library
113MATH_OBJS     = build/libs/math/e_pow.o        \
114                build/libs/math/e_rem_pio2.o   \
115                build/libs/math/k_cos.o        \
116                build/libs/math/k_rem_pio2.o   \
117                build/libs/math/k_sin.o        \
118                build/libs/math/s_copysign.o   \
119                build/libs/math/s_fabs.o       \
120                build/libs/math/s_finite.o     \
121                build/libs/math/s_floor.o      \
122                build/libs/math/s_isnan.o      \
123                build/libs/math/sqrt.o         \
124                build/libs/math/s_rint.o       \
125                build/libs/math/s_scalbn.o     \
126                build/libs/math/s_sin.o        \
[667]127                build/libs/math/s_cos.o        \
[595]128                build/libs/math/e_sqrt.o       
[580]129
[162]130
[435]131CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \
132                 -fno-delete-null-pointer-checks
[158]133
[258]134GIET_INCLUDE = -Igiet_boot    \
135               -Igiet_kernel  \
136               -Igiet_xml     \
137               -Igiet_fat32   \
138               -Igiet_drivers \
139               -Igiet_common  \
140               -Igiet_libs    \
141               -I.
[158]142
[302]143DISK_IMAGE  := hdd/virt_hdd.dmg
144
[595]145### The Mtools used to build the FAT32 disk image perform a few sanity checks,
[582]146### to make sure that the disk is indeed an MS-DOS disk. However, the size
147### of the disk image used by the Giet-VM is not MS-DOS compliant.
148### Setting this variable prevents these checks.
149MTOOLS_SKIP_CHECK := 1
150
[595]151##################################
152### first rule executed (make all)
[599]153all: dirs                            \
[573]154     map.bin                         \
[326]155     hard_config.h                   \
156     giet_vsegs.ld                   \
[609]157     install-disk
[580]158        mdir -/ -b -i $(DISK_IMAGE) ::/
[160]159
[608]160#####################################################
161### create build directories
[599]162dirs:
163        @mkdir -p build/boot
164        @mkdir -p build/common
165        @mkdir -p build/drivers
166        @mkdir -p build/fat32
167        @mkdir -p build/kernel
168        @mkdir -p build/libs/math
169        @mkdir -p hdd
170
[608]171#####################################################
172### make a recursive list of the virtual disk content
173list:
174         mdir -/ -w -i $(DISK_IMAGE) ::/
175
176########################################################
177### copy the files generated by the virtual prototype on
178### the virtual disk "home" directory to the giet_vm home directory
179extract:
180        mcopy -o -i $(DISK_IMAGE) ::/home .
181
182########################################
183### clean all binary files
184clean:
185        rm -f *.o *.elf *.bin *.txt core
186        rm -f hard_config.h giet_vsegs.ld map.bin map.xml
187        rm -rf build/kernel/*
188        rm -rf build/boot/*
189        rm -rf build/libs/*
[611]190        cd applications/classif      && $(MAKE) clean && cd ../..
191        cd applications/convol       && $(MAKE) clean && cd ../..
192        cd applications/coproc       && $(MAKE) clean && cd ../..
193        cd applications/display      && $(MAKE) clean && cd ../..
194        cd applications/dhrystone    && $(MAKE) clean && cd ../..
195        cd applications/gameoflife   && $(MAKE) clean && cd ../..
196        cd applications/ocean        && $(MAKE) clean && cd ../..
[673]197        cd applications/raycast      && $(MAKE) clean && cd ../..
[611]198        cd applications/router       && $(MAKE) clean && cd ../..
199        cd applications/shell        && $(MAKE) clean && cd ../..
200        cd applications/sort         && $(MAKE) clean && cd ../..
201        cd applications/transpose    && $(MAKE) clean && cd ../..
[608]202
203########################################
204### delete disk image
205clean-disk:
206        rm -f $(DISK_IMAGE)
207
[609]208########################################
209### Copy content in the disk image
210### create the three build / misc / home directories
211### store the images files into misc
212install-disk: $(DISK_IMAGE) build/kernel/kernel.elf $(APPLIS_ELF)
[611]213        mmd -o -i $< ::/bin               || true
214        mmd -o -i $< ::/bin/kernel        || true
215        mmd -o -i $< ::/bin/classif       || true
216        mmd -o -i $< ::/bin/convol        || true
217        mmd -o -i $< ::/bin/coproc        || true
218        mmd -o -i $< ::/bin/dhrystone     || true
219        mmd -o -i $< ::/bin/display       || true
220        mmd -o -i $< ::/bin/gameoflife    || true
221        mmd -o -i $< ::/bin/ocean         || true
[673]222        mmd -o -i $< ::/bin/raycast       || true
[611]223        mmd -o -i $< ::/bin/router        || true
224        mmd -o -i $< ::/bin/shell         || true
225        mmd -o -i $< ::/bin/sort          || true
226        mmd -o -i $< ::/bin/transpose     || true
227        mmd -o -i $< ::/misc              || true
228        mmd -o -i $< ::/home              || true
[609]229        mcopy -o -i $< map.bin ::/
[611]230        mcopy -o -i $< build/kernel/kernel.elf ::/bin/kernel
231        mcopy -o -i $< applications/classif/appli.elf ::/bin/classif          || true
232        mcopy -o -i $< applications/convol/appli.elf ::/bin/convol            || true
233        mcopy -o -i $< applications/coproc/appli.elf ::/bin/coproc            || true
234        mcopy -o -i $< applications/dhrystone/appli.elf ::/bin/dhrystone      || true
235        mcopy -o -i $< applications/display/appli.elf ::/bin/display          || true
236        mcopy -o -i $< applications/gameoflife/appli.elf ::/bin/gameoflife    || true
237        mcopy -o -i $< applications/ocean/appli.elf ::/bin/ocean              || true
[673]238        mcopy -o -i $< applications/raycast/appli.elf ::/bin/raycast          || true
[611]239        mcopy -o -i $< applications/router/appli.elf ::/bin/router            || true
240        mcopy -o -i $< applications/shell/appli.elf ::/bin/shell              || true
241        mcopy -o -i $< applications/sort/appli.elf ::/bin/sort                || true
242        mcopy -o -i $< applications/transpose/appli.elf ::/bin/transpose      || true
[609]243        mcopy -o -i $< images/images_128.raw ::/misc
244        mcopy -o -i $< images/philips_1024.raw ::/misc
245        mcopy -o -i $< images/lena_256.raw ::/misc
246        mcopy -o -i $< images/bridge_256.raw ::/misc
247        mcopy -o -i $< images/couple_512.raw ::/misc
[675]248        mcopy -o -i $< images/door_32.raw ::/misc
249        mcopy -o -i $< images/handle_32.raw ::/misc
250        mcopy -o -i $< images/rock_32.raw ::/misc
251        mcopy -o -i $< images/wood_32.raw ::/misc
[609]252
[595]253#########################
254### Disk image generation
[582]255### This requires the generic LINUX/MacOS script "create_dmg" script
[258]256### written by C.Fuguet. (should be installed in GIET-VM root directory).
[609]257$(DISK_IMAGE): build/boot/boot.elf
258        rm -f $@
259        ./create_dmg create $(basename $@)
260        dd if=$@ of=temp.dmg count=65536
261        mv temp.dmg $@
262        dd if=build/boot/boot.elf of=$@ seek=2 conv=notrunc
[295]263
[595]264#########################################################################
[326]265### mapping generation: map.bin / map.xml / hard_config.h / giet_vsegs.ld
[595]266### TODO add dépendancies on appli.py files : $(APPLIS_DEPS)
[600]267map.bin hard_config.h giet_vsegs.ld: $(ARCH)/arch.py $(APPLIS_PY)
[510]268        giet_python/genmap --arch=$(ARCH)     \
269                       --x=$(X_SIZE)      \
270                       --y=$(Y_SIZE)      \
271                       --p=$(NB_PROCS)    \
272                       --tty=$(NB_TTYS)   \
273                       --fbf=$(FBF_WIDTH) \
[553]274                       --ioc=$(IOC_TYPE)  \
[510]275                       --giet=.           \
[595]276                       $(GENMAP_APPLIS)   \
[510]277                       --xml=.
[158]278
[583]279################################
280### drivers library compilation
281build/drivers/%.o: giet_drivers/%.c \
282                   giet_drivers/%.h \
283                   hard_config.h    \
284                   giet_config.h
[295]285        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
286
[380]287build/drivers/libdrivers.a: $(DRIVERS_OBJS)
288        $(AR) -rcs $@ $(DRIVERS_OBJS)
289
[374]290##########################
[583]291### fat32 compilation
[258]292build/fat32/fat32.o: giet_fat32/fat32.c \
293                     giet_fat32/fat32.h \
[326]294                     hard_config.h      \
295                     giet_config.h
[258]296        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
297
[583]298##########################
299### common compilation
300build/common/%.o: giet_common/%.c   \
301                  giet_common/%.h   \
302                  hard_config.h     \
303                  giet_config.h
[258]304        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
305
[374]306########################
[177]307### boot compilation
[573]308### Copy bootloader into sector 2 of disk image
[326]309build/boot/boot.elf: $(BOOT_OBJS)            \
[380]310                     giet_boot/boot.ld       \
[583]311                     build/drivers/libdrivers.a
[582]312        $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers
[189]313        $(DU) -D $@ > $@.txt
[158]314
[258]315build/boot/boot.o: giet_boot/boot.c          \
316                   giet_common/utils.h       \
317                   giet_fat32/fat32.h        \
[289]318                   giet_common/vmem.h        \
[326]319                   hard_config.h             \
[366]320                   giet_config.h
[258]321        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
[158]322
[366]323build/boot/boot_entry.o: giet_boot/boot_entry.S \
324                         hard_config.h
325        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
326
[374]327#########################
[258]328### kernel compilation
[326]329build/kernel/kernel.elf: $(KERNEL_OBJS)        \
[380]330                         giet_kernel/kernel.ld \
331                         build/drivers/libdrivers.a
[582]332        $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers
333        $(DU) -D $@ > $@.txt
[158]334
[326]335build/kernel/%.o: giet_kernel/%.c    \
336                  hard_config.h      \
[582]337                  giet_config.h
[258]338        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
339
[326]340build/kernel/%.o: giet_kernel/%.s    \
341                  hard_config.h      \
[582]342                  giet_config.h
[258]343        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
344
[374]345###########################
[585]346### user library compilation
[595]347build/libs/%.o: giet_libs/%.c        \
348                     giet_libs/%.h   \
349                     hard_config.h   \
350                     giet_config.h
351        $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $<
[258]352
[585]353build/libs/libuser.a: $(USER_OBJS)
354        $(AR) -rcs $@ $^
355
[583]356################################
357### math library compilation
358build/libs/math/%.o: giet_libs/math/%.c             \
359                     giet_libs/math/math_private.h  \
360                     giet_libs/math.h
[595]361        $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $<
[258]362
[583]363build/libs/libmath.a: $(MATH_OBJS)
[580]364        $(AR) -rcs $@ $^
365
[374]366########################################
[595]367### classif   application compilation
[609]368applications/classif/appli.elf: build/libs/libuser.a
[595]369        $(MAKE) -C applications/classif
[189]370
[595]371########################################
372### convol   application compilation
[609]373applications/convol/appli.elf: build/libs/libuser.a
[595]374        $(MAKE) -C applications/convol
[189]375
[374]376########################################
[595]377### coproc   application compilation
[609]378applications/coproc/appli.elf: build/libs/libuser.a
[595]379        $(MAKE) -C applications/coproc
[189]380
[595]381########################################
382### dhrystone   application compilation
[609]383applications/dhrystone/appli.elf: build/libs/libuser.a
[595]384        $(MAKE) -C applications/dhrystone
[189]385
[374]386########################################
[595]387### display  application compilation
[609]388applications/display/appli.elf: build/libs/libuser.a
[595]389        $(MAKE) -C applications/display
[189]390
[374]391########################################
[595]392### gameoflife  application compilation
[609]393applications/gameoflife/appli.elf: build/libs/libuser.a
[595]394        $(MAKE) -C applications/gameoflife
[251]395
[595]396########################################
397### ocean  application compilation
[609]398applications/ocean/appli.elf: build/libs/libmath.a  build/libs/libuser.a
[598]399        cd applications/ocean && $(MAKE) && cd ../..
[251]400
[374]401########################################
[673]402### raycast application compilation
403applications/raycast/appli.elf: build/libs/libmath.a build/libs/libuser.a
404        $(MAKE) -C applications/raycast
405
406########################################
[595]407### router  application compilation
[609]408applications/router/appli.elf: build/libs/libuser.a
[595]409        $(MAKE) -C applications/router
[241]410
[595]411########################################
412### shell  application compilation
[609]413applications/shell/appli.elf: build/libs/libuser.a
[595]414        $(MAKE) -C applications/shell
[241]415
[374]416########################################
[595]417### sort  application compilation
[609]418applications/sort/appli.elf: build/libs/libuser.a
[595]419        $(MAKE) -C applications/sort
[256]420
[374]421########################################
[295]422### transpose compilation
[609]423applications/transpose/appli.elf: build/libs/libuser.a
[595]424        $(MAKE) -C applications/transpose
[295]425
Note: See TracBrowser for help on using the repository browser.