source: trunk/Makefile.x86 @ 256

Last change on this file since 256 was 251, checked in by max@…, 7 years ago

Don't objdump each component; the kernel is enough.

File size: 17.5 KB
RevLine 
[26]1#############################################################################
[27]2#                       ALMOS-MKH  Makefile for x86_64                      #
[26]3#############################################################################
4
5-include params.mk
6
7# Compilation flags.
8CFLAGS = -Wall -ffreestanding -mno-red-zone -mno-mmx -mno-sse -mno-avx -g \
[47]9                 -fno-delete-null-pointer-checks -mcmodel=large
[26]10
11# Export all variables to applications sub-Makefile.
[27]12export
[26]13CC = gcc
14AS = as
15LD = ld
16DU = objdump
17AR = ar
18
[27]19# Rules that don't build target files
[26]20# always out-of-date, need to be regenerated everytime they are called
21.PHONY: compile                         \
22                dirs                                \
23                list                                \
24                extract                             \
25                fsck                                \
26                clean                               \
27                build-disk                          \
28                build/kernel/kernel.elf
29
[27]30# Objects to be linked for the soclib drivers library
[247]31DRIVERS_OBJS = build/kernel/drivers/soclib_mmc.o  \
[218]32               build/kernel/drivers/ioc_ata.o     \
[197]33               build/kernel/drivers/pic_apic.o    \
[247]34               build/kernel/drivers/txt_rs232.o   \
[26]35               build/kernel/drivers/soclib_nic.o  \
36               build/kernel/drivers/soclib_dma.o  \
37               build/kernel/drivers/soclib_iob.o
38
[27]39# Objects to be linked for kernel.elf generation
[26]40KERN_OBJS       = build/kernel/kern/kernel_init.o     \
41              build/kernel/kern/printk.o          \
42              build/kernel/kern/thread.o          \
43              build/kernel/kern/process.o         \
44              build/kernel/kern/chdev.o           \
45              build/kernel/kern/cluster.o         \
46              build/kernel/kern/scheduler.o       \
47              build/kernel/kern/core.o            \
48              build/kernel/kern/dqdt.o            \
49              build/kernel/kern/do_syscall.o      \
50              build/kernel/kern/do_interrupt.o    \
51              build/kernel/kern/do_exception.o    \
52              build/kernel/kern/rpc.o             \
53              build/kernel/kern/signal.o
54
55HAL_OBJS    = \
56              build/kernel/hal/hal_boot.o         \
[236]57              build/kernel/hal/hal_smpboot.o      \
[30]58              build/kernel/hal/hal_init.o         \
59              build/kernel/hal/hal_cpu.o          \
60              build/kernel/hal/hal_kentry.o       \
[36]61              build/kernel/hal/hal_acpi.o         \
[82]62              build/kernel/hal/hal_apic.o         \
[30]63              build/kernel/hal/x86_printf.o       \
[77]64              build/kernel/hal/hal_drivers.o      \
[26]65              build/kernel/hal/hal_special.o      \
66              build/kernel/hal/hal_context.o      \
67              build/kernel/hal/hal_atomic.o       \
68              build/kernel/hal/hal_remote.o       \
69              build/kernel/hal/hal_uspace.o       \
70              build/kernel/hal/hal_irqmask.o      \
71              build/kernel/hal/hal_gpt.o          \
[54]72              build/kernel/hal/hal_ppm.o          \
[26]73              build/kernel/hal/hal_exception.o    \
74              build/kernel/hal/hal_interrupt.o    \
[30]75              build/kernel/hal/hal_syscall.o
[26]76
77DEV_OBJS    = build/kernel/devices/dev_txt.o      \
78              build/kernel/devices/dev_ioc.o      \
79              build/kernel/devices/dev_mmc.o      \
80              build/kernel/devices/dev_nic.o      \
81              build/kernel/devices/dev_pic.o      \
82              build/kernel/devices/dev_dma.o      \
83              build/kernel/devices/dev_fbf.o      \
[27]84              build/kernel/devices/dev_iob.o
[26]85
86MM_OBJS     = build/kernel/mm/ppm.o               \
87              build/kernel/mm/vmm.o               \
88              build/kernel/mm/vseg.o              \
89              build/kernel/mm/page.o              \
90              build/kernel/mm/kcm.o               \
91              build/kernel/mm/khm.o               \
92              build/kernel/mm/mapper.o            \
93              build/kernel/mm/kmem.o
94
95LIBK_OBJS   = build/kernel/libk/grdxt.o           \
96              build/kernel/libk/bits.o            \
97              build/kernel/libk/elf.o             \
98              build/kernel/libk/string.o          \
99              build/kernel/libk/ctype.o           \
100              build/kernel/libk/rwlock.o          \
101              build/kernel/libk/spinlock.o        \
102              build/kernel/libk/barrier.o         \
103              build/kernel/libk/remote_barrier.o  \
104              build/kernel/libk/remote_spinlock.o \
105              build/kernel/libk/remote_rwlock.o   \
106              build/kernel/libk/remote_fifo.o     \
107              build/kernel/libk/remote_mutex.o    \
108              build/kernel/libk/remote_sem.o      \
109              build/kernel/libk/remote_condvar.o  \
110              build/kernel/libk/memcpy.o          \
111              build/kernel/libk/htab.o            \
112              build/kernel/libk/xhtab.o
113
114SYS_OBJS_0  = build/kernel/syscalls/sys_thread_exit.o     \
115              build/kernel/syscalls/sys_mmap.o            \
116              build/kernel/syscalls/sys_thread_create.o   \
117              build/kernel/syscalls/sys_thread_join.o     \
118              build/kernel/syscalls/sys_thread_detach.o   \
119              build/kernel/syscalls/sys_thread_yield.o    \
120              build/kernel/syscalls/sys_sem.o             \
121              build/kernel/syscalls/sys_condvar.o         \
122              build/kernel/syscalls/sys_barrier.o         \
123              build/kernel/syscalls/sys_mutex.o
124
125SYS_OBJS_1  = build/kernel/syscalls/sys_thread_sleep.o    \
126              build/kernel/syscalls/sys_thread_wakeup.o   \
127              build/kernel/syscalls/sys_open.o            \
128              build/kernel/syscalls/sys_creat.o           \
129              build/kernel/syscalls/sys_read.o            \
130              build/kernel/syscalls/sys_write.o           \
131              build/kernel/syscalls/sys_lseek.o           \
132              build/kernel/syscalls/sys_close.o           \
133              build/kernel/syscalls/sys_unlink.o          \
134              build/kernel/syscalls/sys_pipe.o
135
136SYS_OBJS_2  = build/kernel/syscalls/sys_chdir.o           \
137              build/kernel/syscalls/sys_mkdir.o           \
138              build/kernel/syscalls/sys_mkfifo.o          \
139              build/kernel/syscalls/sys_opendir.o         \
140              build/kernel/syscalls/sys_readdir.o         \
141              build/kernel/syscalls/sys_closedir.o        \
142              build/kernel/syscalls/sys_getcwd.o          \
143              build/kernel/syscalls/sys_clock.o           \
144              build/kernel/syscalls/sys_alarm.o           \
[27]145              build/kernel/syscalls/sys_rmdir.o
[26]146
147SYS_OBJS_3  = build/kernel/syscalls/sys_utls.o            \
148              build/kernel/syscalls/sys_chmod.o           \
149              build/kernel/syscalls/sys_signal.o          \
[54]150              build/kernel/syscalls/sys_timeofday.o       \
[26]151              build/kernel/syscalls/sys_kill.o            \
152              build/kernel/syscalls/sys_getpid.o          \
153              build/kernel/syscalls/sys_fork.o            \
154              build/kernel/syscalls/sys_exec.o            \
155              build/kernel/syscalls/sys_stat.o            \
[27]156              build/kernel/syscalls/sys_trace.o
[26]157
158VFS_OBJS    = build/kernel/vfs/vfs.o              \
159              build/kernel/vfs/fatfs.o            \
160              build/kernel/vfs/devfs.o            \
161              build/kernel/vfs/ramfs.o
162
163# List of directories to be searched for included files
[27]164# when compiling for kernel.elf generation
[26]165KERNEL_INCLUDE = -Ikernel                \
166                 -Ikernel/kern           \
167                 -Ikernel/devices        \
168                 -Ikernel/syscalls       \
[75]169                 -Ihal/x86_64/drivers    \
[26]170                 -Ikernel/syscalls       \
171                 -Ikernel/libk           \
172                 -Ikernel/mm             \
173                 -Ikernel/vfs            \
174                 -Ikernel/fatfs          \
175                 -Ikernel/sysfs          \
176                 -Ikernel/ramfs          \
177                 -Ikernel/devfs          \
178                 -Itools/arch_info       \
179                 -Ihal/generic           \
[51]180                 -Ihal/x86_64/core       \
[26]181                 -I.
182
183# Macros to be processed by the C preprocessor.
184MACROS           = -DARCHINFO_PATHNAME="\"arch_info.bin\""              \
185                           -DKERNEL_PATHNAME="\"/bin/kernel/kernel.elf\""
186
187# Virtual disk path
188DISK_IMAGE      := hdd/virt_hdd.dmg
189
190# The Mtools used to build the FAT32 disk image perfom a few sanity checks, to
191# make sure that the disk is indeed an MS-DOS disk. However, the size of the
[27]192# disk image used by ALMOS-VM is not MS-DOS compliant.
[26]193# Setting this variable prevents these checks.
194MTOOLS_SKIP_CHECK := 1
195
196# Rule to compile kernel.elf, and update virtual disk.
197compile: dirs                               \
198                 hard_config.h              \
199         build/kernel/kernel.elf    \
200         list
201
202# Rule to create the build directories.
203dirs:
204        @mkdir -p build/kernel
205        @mkdir -p build/kernel/kern
206        @mkdir -p build/kernel/hal
207        @mkdir -p build/kernel/devices
208        @mkdir -p build/kernel/mm
209        @mkdir -p build/kernel/libk
210        @mkdir -p build/kernel/drivers
[27]211        @mkdir -p build/kernel/vfs
[26]212        @mkdir -p build/kernel/syscalls
213        @mkdir -p hdd
214
215# Rule to make a recursive list of the virtual disk content.
216list:
217        mdir -/ -w -i $(DISK_IMAGE) ::/
218
219# Rule to make a file system check for the virtual disk.
220fsck:
221        fsck.msdos $(DISK_IMAGE)
222
223##############################################################
[27]224# Rule to copy the files generated by the virtual prototype
[26]225# from the virtual disk 'home' directory to the current directory.
226extract:
227        mcopy -o -i $(DISK_IMAGE) ::/home .
228
[27]229# Rules to delete all binary files from Unix File System
[26]230# without modifying the virtual disk.
231clean:
232        rm -f *.o *.elf *.bin *.txt core
233        rm -f hard_config.h
234        rm -rf build
235
236####################################################   
237# Rule for building a new virtual disk from scratch.
238# It creates the bin / home directories.
239# This requires the generic Linux/MacOS 'create_dmg' script, that should be
240# placed in the same directory as this Makefile.
241build-disk:
242        rm -f $(DISK_IMAGE)
243        ./create_dmg    create $(basename $(DISK_IMAGE))
244        dd                              if=$(DISK_IMAGE) of=temp.dmg count=65536
245        mv                              temp.dmg $(DISK_IMAGE)
246        mmd                     -o -i $(DISK_IMAGE) ::/bin         || true
247        mmd                     -o -i $(DISK_IMAGE) ::/bin/kernel  || true
248        mmd                     -o -i $(DISK_IMAGE) ::/home        || true
249        mdir             -/ -b -i $(DISK_IMAGE) ::/
250       
251##############################################################
252# Rules to generate hardware description files (hard_config.h,
253# arch_info.bin and arch_info.xml), and update the virtual disk.
254hard_config.h:
255        echo "!!! UNUSED !!!" # XXX: cleanup later
256
257
258##############################
[27]259# rules to compile the drivers
[75]260build/kernel/drivers/%.o:       hal/x86_64/drivers/%.c   \
261                                hal/x86_64/drivers/%.h   \
[26]262                                kernel_config.h             \
[51]263                                hal/x86_64/core/hal_types.h
[26]264        $(CC) $(KERNEL_INCLUDE) $(CFLAGS)  -c -o $@ $<
265
266#######################################
267# Rules to generate kernel/kern objects
268build/kernel/kern/%.o:              kernel/kern/%.c             \
269                                kernel/kern/%.h             \
270                                kernel_config.h             \
[51]271                                hal/x86_64/core/hal_types.h
[26]272        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
273
274######################################
275# Rules to generate kernel/hal objects
[51]276build/kernel/hal/%.o:           hal/x86_64/core/%.c         \
[26]277                                hal/generic/%.h             \
278                                kernel_config.h             \
[51]279                                hal/x86_64/core/hal_types.h
[26]280        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
281
[51]282build/kernel/hal/hal_boot.o:    hal/x86_64/core/hal_boot.S \
283                                hal/x86_64/core/hal_boot.h        \
284                                hal/x86_64/core/hal_multiboot.h   \
285                                hal/x86_64/core/hal_segmentation.h \
[26]286                                kernel_config.h              \
[51]287                                hal/x86_64/core/hal_types.h
[26]288        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
289
[236]290build/kernel/hal/hal_smpboot.o: hal/x86_64/core/hal_smpboot.S \
291                                hal/x86_64/core/hal_boot.h        \
292                                hal/x86_64/core/hal_multiboot.h   \
293                                hal/x86_64/core/hal_segmentation.h \
294                                kernel_config.h              \
295                                hal/x86_64/core/hal_types.h
296        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
297
[51]298build/kernel/hal/hal_init.o:    hal/x86_64/core/hal_init.c         \
299                                hal/x86_64/core/hal_boot.h         \
300                                hal/x86_64/core/hal_multiboot.h    \
301                                hal/x86_64/core/hal_segmentation.h \
302                                hal/x86_64/core/hal_acpi.h         \
[82]303                                hal/x86_64/core/hal_apic.h         \
[51]304                                hal/x86_64/core/hal_internal.h     \
[45]305                                kernel_config.h               \
[51]306                                hal/x86_64/core/hal_types.h
[26]307        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
308
[51]309build/kernel/hal/hal_cpu.o:     hal/x86_64/core/hal_cpu.S \
310                                hal/x86_64/core/hal_boot.h        \
311                                hal/x86_64/core/hal_segmentation.h \
[30]312                                kernel_config.h              \
[51]313                                hal/x86_64/core/hal_types.h
[30]314        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
315
[51]316build/kernel/hal/hal_kentry.o:  hal/x86_64/core/hal_kentry.S      \
317                                hal/x86_64/core/hal_kentry.h      \
318                                hal/x86_64/core/hal_boot.h        \
[30]319                                kernel_config.h              \
[51]320                                hal/x86_64/core/hal_types.h
[30]321        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
322
[51]323build/kernel/hal/hal_acpi.o:    hal/x86_64/core/hal_acpi.c        \
324                                hal/x86_64/core/hal_acpi.h        \
[36]325                                kernel_config.h              \
[51]326                                hal/x86_64/core/hal_types.h
[36]327        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
328
[82]329build/kernel/hal/hal_apic.o:    hal/x86_64/core/hal_apic.c        \
330                                hal/x86_64/core/hal_apic.h        \
[45]331                                kernel_config.h              \
[51]332                                hal/x86_64/core/hal_types.h
[45]333        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
334
[51]335build/kernel/hal/x86_printf.o:  hal/x86_64/core/x86_printf.c      \
[30]336                                kernel_config.h              \
[51]337                                hal/x86_64/core/hal_types.h
[30]338        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
339
[26]340######################################
341# Rules to generate kernel/dev objects
342build/kernel/devices/%.o:       kernel/devices/%.c          \
343                                kernel/devices/%.h          \
344                                kernel_config.h             \
[51]345                                hal/x86_64/core/hal_types.h
[26]346        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
347
348#####################################
349# Rules to generate kernel/mm objects
350build/kernel/mm/%.o:            kernel/mm/%.c               \
351                                kernel/mm/%.h               \
352                                kernel_config.h             \
[51]353                                hal/x86_64/core/hal_types.h
[26]354        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
355
356#######################################
357# Rules to generate kernel/libk objects
358build/kernel/libk/%.o:          kernel/libk/%.c             \
359                                kernel/libk/%.h             \
360                                kernel_config.h             \
[51]361                                hal/x86_64/core/hal_types.h
[26]362        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
363
364###########################################
365# Rules to generate kernel/syscalls objects
366build/kernel/syscalls/%.o:      kernel/syscalls/%.c         \
367                                kernel/syscalls/syscalls.h  \
368                                kernel_config.h             \
[51]369                                hal/x86_64/core/hal_types.h
[26]370        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
371
372#######################################
373# Rules to generate kernel/vfs objects
374build/kernel/vfs/%.o:           kernel/vfs/%.c              \
375                                kernel/vfs/%.h              \
376                                kernel_config.h             \
[51]377                                hal/x86_64/core/hal_types.h
[26]378        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
379
380###########################################################
381# Rule to generate kernel.elf and place it on virtual disk
382build/kernel/kernel.elf:            $(KERN_OBJS)                \
383                                $(HAL_OBJS)                 \
384                                $(DEV_OBJS)                 \
385                                $(MM_OBJS)                  \
386                                $(LIBK_OBJS)                \
387                                $(DRIVERS_OBJS)             \
388                                $(VFS_OBJS)                 \
389                                $(SYS_OBJS_0)               \
390                                $(SYS_OBJS_1)               \
391                                $(SYS_OBJS_2)               \
392                                $(SYS_OBJS_3)               \
[57]393                                hal/x86_64/kernel.ld
394        $(LD) -o $@ -z max-page-size=0x1000 -T hal/x86_64/kernel.ld \
[26]395          $(KERN_OBJS) $(HAL_OBJS) $(DEV_OBJS) $(MM_OBJS)   \
396          $(LIBK_OBJS) $(DRIVERS_OBJS) $(VFS_OBJS)          \
397          $(SYS_OBJS_0) $(SYS_OBJS_1) $(SYS_OBJS_2)         \
398          $(SYS_OBJS_3)
399
400        $(DU) -D $@ > $@.txt
401        mcopy -o -i $(DISK_IMAGE) build/kernel/kernel.elf ::/bin/kernel
402
Note: See TracBrowser for help on using the repository browser.