Work on the stage2 loader:
[newos.git] / boot / i386 / boot.mk
blob49561b654a28729175bdbfd35a842a3065e38ba5
1 ifneq ($(_BOOT_MAKE),1)
2 _BOOT_MAKE = 1
4 # include targets we depend on
5 include lib/lib.mk
6 include kernel/kernel.mk
7 include apps/apps.mk
9 # i386 stage2 makefile
10 BOOT_DIR = boot/$(ARCH)
11 BOOT_OBJ_DIR = $(BOOT_DIR)/$(OBJ_DIR)
12 STAGE2_OBJS = \
13 $(BOOT_OBJ_DIR)/stage2.o \
14 $(BOOT_OBJ_DIR)/smp_boot.o \
15 $(BOOT_OBJ_DIR)/smp_trampoline.o
16 DEPS += $(STAGE2_OBJS:.o=.d)
18 STAGE2 = $(BOOT_OBJ_DIR)/stage2
20 $(STAGE2): $(STAGE2_OBJS) $(KLIBS)
21 $(LD) -dN --script=$(BOOT_DIR)/stage2.ld -L $(LIBGCC_PATH) $(STAGE2_OBJS) $(KLIBS) $(LIBGCC) -o $@
23 stage2: $(STAGE2)
25 stage2clean:
26 rm -f $(STAGE2_OBJS) $(STAGE2)
28 CLEAN += stage2clean
30 FINAL = $(BOOT_DIR)/final
31 BOOTBLOCK = $(BOOT_DIR)/bootblock.bin
32 MAKEFLOP = $(BOOT_DIR)/makeflop
34 bootclean:
35 rm -f $(MAKEFLOP)
37 CLEAN += bootclean
39 $(MAKEFLOP): $(MAKEFLOP).c
40 $(HOST_CC) -O3 $(MAKEFLOP).c -o $@
42 $(FINAL): $(STAGE2) $(KERNEL) $(KERNEL_ADDONS) $(APPS) tools
43 $(BOOTMAKER) $(BOOT_DIR)/config.ini -o $(FINAL)
45 floppy: $(STAGE2) $(KERNEL) $(KERNEL_ADDONS) $(APPS) tools $(MAKEFLOP)
46 $(BOOTMAKER) $(BOOT_DIR)/config.ini -o $(FINAL).pre
47 $(MAKEFLOP) $(BOOTBLOCK) $(FINAL).pre $(FINAL)
48 rm -f $(FINAL).pre
49 rm -f final.$(ARCH);ln -sf $(FINAL) final.$(ARCH)
50 rm -f system.$(ARCH);ln -sf $(KERNEL) system.$(ARCH)
52 disk: floppy
53 ifeq ($(OSTYPE),cygwin)
54 fdimage -q $(FINAL) a:
55 else
56 dd if=$(FINAL) of=/dev/disk/floppy/raw bs=18k
57 endif
59 ldisk: floppy
60 dd if=$(FINAL) of=/dev/fd0 bs=18k
63 $(BOOT_OBJ_DIR)/%.o: $(BOOT_DIR)/%.c
64 @mkdir -p $(BOOT_OBJ_DIR)
65 $(CC) -c $< $(GLOBAL_CFLAGS) $(KERNEL_CFLAGS) -Iinclude -I$(BOOT_DIR) -o $@
67 $(BOOT_OBJ_DIR)/%.d: $(BOOT_DIR)/%.c
68 @mkdir -p $(BOOT_OBJ_DIR)
69 @echo "making deps for $<..."
70 @($(ECHO) -n $(dir $@);$(CC) $(GLOBAL_CFLAGS) $(KERNEL_CFLAGS) -Iinclude -I$(BOOT_DIR) -M -MG $<) > $@
72 $(BOOT_OBJ_DIR)/%.d: $(BOOT_DIR)/%.S
73 @mkdir -p $(BOOT_OBJ_DIR)
74 @echo "making deps for $<..."
75 @($(ECHO) -n $(dir $@);$(CC) $(GLOBAL_CFLAGS) $(KERNEL_CFLAGS) -Iinclude -I$(BOOT_DIR) -M -MG $<) > $@
77 $(BOOT_OBJ_DIR)/%.o: $(BOOT_DIR)/%.S
78 @mkdir -p $(BOOT_OBJ_DIR)
79 $(CC) -c $< $(GLOBAL_CFLAGS) $(KERNEL_CFLAGS) -Iinclude -I$(BOOT_DIR) -o $@
81 endif