source: trunk/Makefile.x86 @ 349

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

Remove soclib_iob on x86.

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