Initial commit: functional for newer bzImage kernels
[wraplinux.git] / Makefile
1 CC                      = gcc
2 CFLAGS                  = -O2 -g -W -Wall -D_GNU_SOURCE
3 LDFLAGS                 =
4
5 CC_FOR_TARGET           = gcc -m32
6 LD_FOR_TARGET           = ld -m elf_i386
7 OBJCOPY_FOR_TARGET      = objcopy
8 CFLAGS_FOR_TARGET       = -I. -g -Os -march=i386 -mregparm=3 \
9                           -fPIC -ffreestanding
10 LDFLAGS_FOR_TARGET      =
11
12 RELOC_OBJS              = $(patsubst %.c,%.o,$(wildcard reloc/*.c)) \
13                           $(patsubst %.S,%.o,$(wildcard reloc/*.S))
14
15 all: wraplinux
16
17 reloc/%.o: reloc/%.c
18         $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) -c -o $@ $<
19
20 reloc/%.o: reloc/%.S
21         $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) -c -D__ASSEMBLY__ -o $@ $<
22
23 %.o: %.S
24         $(CC) $(CFLAGS) -c -o $@ $<
25
26 %.o: %.c
27         $(CC) $(CFLAGS) -c -o $@ $<
28
29 reloc/reloc.bin: reloc/reloc.elf
30         $(OBJCOPY_FOR_TARGET) -O binary $< $@
31
32 reloc/reloc.elf: $(RELOC_OBJS) reloc/reloc.ld
33         $(LD_FOR_TARGET) $(LDFLAGS_FOR_TARGET) -T reloc/reloc.ld \
34                 -o $@ $(RELOC_OBJS)
35
36 reloc.o: reloc.S reloc/reloc.bin 
37
38 wraplinux: main.o linux.o reloc.o elf.o
39         $(CC) $(LDFLAGS) -o $@ $^
40
41 clean:
42         rm -f wraplinux *.o reloc/*.o reloc/*.bin reloc/*.elf