source: soft/giet_vm/Makefile @ 585

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

Makefile: build a user library

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