| 1 | ## ----------------------------------------------------------------------- |
|---|
| 2 | ## |
|---|
| 3 | ## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved |
|---|
| 4 | ## Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin |
|---|
| 5 | ## |
|---|
| 6 | ## This program is free software; you can redistribute it and/or modify |
|---|
| 7 | ## it under the terms of the GNU General Public License as published by |
|---|
| 8 | ## the Free Software Foundation, Inc., 53 Temple Place Ste 330, |
|---|
| 9 | ## Boston MA 02111-1307, USA; either version 2 of the License, or |
|---|
| 10 | ## (at your option) any later version; incorporated herein by reference. |
|---|
| 11 | ## |
|---|
| 12 | ## ----------------------------------------------------------------------- |
|---|
| 13 | |
|---|
| 14 | # |
|---|
| 15 | # Makefile for the SYSLINUX core |
|---|
| 16 | # |
|---|
| 17 | |
|---|
| 18 | # No builtin rules |
|---|
| 19 | MAKEFLAGS += -r |
|---|
| 20 | MAKE += -r |
|---|
| 21 | |
|---|
| 22 | topdir = .. |
|---|
| 23 | MAKEDIR = $(topdir)/mk |
|---|
| 24 | include $(MAKEDIR)/embedded.mk |
|---|
| 25 | -include $(topdir)/version.mk |
|---|
| 26 | |
|---|
| 27 | OPTFLAGS = |
|---|
| 28 | INCLUDES = -I./include -I$(com32)/include |
|---|
| 29 | |
|---|
| 30 | # This is very similar to cp437; technically it's for Norway and Denmark, |
|---|
| 31 | # but it's unlikely the characters that are different will be used in |
|---|
| 32 | # filenames by other users. |
|---|
| 33 | CODEPAGE = cp865 |
|---|
| 34 | |
|---|
| 35 | # The targets to build in this directory... |
|---|
| 36 | BTARGET = kwdhash.gen \ |
|---|
| 37 | ldlinux.bss ldlinux.sys ldlinux.bin \ |
|---|
| 38 | isolinux.bin isolinux-debug.bin pxelinux.0 |
|---|
| 39 | |
|---|
| 40 | # All primary source files for the main syslinux files |
|---|
| 41 | NASMSRC := $(wildcard *.asm) |
|---|
| 42 | NASMHDR := $(wildcard *.inc) |
|---|
| 43 | CSRC := $(wildcard *.c */*.c */*/*.c) |
|---|
| 44 | SSRC := $(wildcard *.S */*.S */*/*.S) |
|---|
| 45 | CHDR := $(wildcard *.h) |
|---|
| 46 | OTHERSRC := keywords |
|---|
| 47 | ALLSRC = $(NASMSRC) $(NASMHDR) $(CSRC) $(SSRC) $(CHDR) $(OTHERSRC) |
|---|
| 48 | |
|---|
| 49 | COBJ := $(patsubst %.c,%.o,$(CSRC)) |
|---|
| 50 | SOBJ := $(patsubst %.S,%.o,$(SSRC)) |
|---|
| 51 | |
|---|
| 52 | LIB = libcore.a |
|---|
| 53 | LIBS = $(LIB) $(com32)/lib/libcomcore.a $(LIBGCC) |
|---|
| 54 | LIBOBJS = $(COBJ) $(SOBJ) |
|---|
| 55 | |
|---|
| 56 | NASMDEBUG = -g -F dwarf |
|---|
| 57 | NASMOPT += $(NASMDEBUG) |
|---|
| 58 | |
|---|
| 59 | PREPCORE = ../lzo/prepcore |
|---|
| 60 | |
|---|
| 61 | # CFLAGS += -DDEBUG=1 |
|---|
| 62 | |
|---|
| 63 | # The DATE is set on the make command line when building binaries for |
|---|
| 64 | # official release. Otherwise, substitute a hex string that is pretty much |
|---|
| 65 | # guaranteed to be unique to be unique from build to build. |
|---|
| 66 | ifndef HEXDATE |
|---|
| 67 | HEXDATE := $(shell $(PERL) ../now.pl $(SRCS)) |
|---|
| 68 | endif |
|---|
| 69 | ifndef DATE |
|---|
| 70 | DATE := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE)) |
|---|
| 71 | endif |
|---|
| 72 | |
|---|
| 73 | all: $(BTARGET) |
|---|
| 74 | |
|---|
| 75 | kwdhash.gen: keywords genhash.pl |
|---|
| 76 | $(PERL) genhash.pl < keywords > kwdhash.gen |
|---|
| 77 | |
|---|
| 78 | .PRECIOUS: %.elf |
|---|
| 79 | |
|---|
| 80 | %.raw: %.elf |
|---|
| 81 | $(OBJCOPY) -O binary $< $(@:.bin=.raw) |
|---|
| 82 | |
|---|
| 83 | # GNU make 3.82 gets confused by the first form |
|---|
| 84 | .PRECIOUS: %.raw |
|---|
| 85 | |
|---|
| 86 | %.bin: %.raw $(PREPCORE) |
|---|
| 87 | $(PREPCORE) $< $@ |
|---|
| 88 | |
|---|
| 89 | %.o: %.asm kwdhash.gen ../version.gen |
|---|
| 90 | $(NASM) -f elf $(NASMOPT) -DDATE_STR="'$(DATE)'" \ |
|---|
| 91 | -DHEXDATE="$(HEXDATE)" \ |
|---|
| 92 | -l $(@:.o=.lsr) -o $@ -MP -MD .$@.d $< |
|---|
| 93 | |
|---|
| 94 | %.elf: %.o $(LIBS) syslinux.ld |
|---|
| 95 | $(LD) $(LDFLAGS) -T syslinux.ld -M -o $@ $< \ |
|---|
| 96 | --start-group $(LIBS) --end-group \ |
|---|
| 97 | > $(@:.elf=.map) |
|---|
| 98 | $(OBJDUMP) -h $@ > $(@:.elf=.sec) |
|---|
| 99 | $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst) |
|---|
| 100 | |
|---|
| 101 | $(LIB): $(LIBOBJS) |
|---|
| 102 | rm -f $@ |
|---|
| 103 | $(AR) cq $@ $^ |
|---|
| 104 | $(RANLIB) $@ |
|---|
| 105 | |
|---|
| 106 | pxelinux.0: pxelinux.bin |
|---|
| 107 | cp -f $< $@ |
|---|
| 108 | |
|---|
| 109 | ldlinux.bss: ldlinux.bin |
|---|
| 110 | dd if=$< of=$@ bs=512 count=1 |
|---|
| 111 | |
|---|
| 112 | ldlinux.sys: ldlinux.bin |
|---|
| 113 | dd if=$< of=$@ bs=512 skip=2 |
|---|
| 114 | |
|---|
| 115 | codepage.cp: ../codepage/$(CODEPAGE).cp |
|---|
| 116 | cp -f $< $@ |
|---|
| 117 | |
|---|
| 118 | codepage.o: codepage.S codepage.cp |
|---|
| 119 | |
|---|
| 120 | install: installer |
|---|
| 121 | |
|---|
| 122 | install-lib: installer |
|---|
| 123 | |
|---|
| 124 | install-all: install install-lib |
|---|
| 125 | |
|---|
| 126 | netinstall: installer |
|---|
| 127 | |
|---|
| 128 | tidy dist: |
|---|
| 129 | rm -f codepage.cp *.o *.elf *.a stupid.* patch.offset .depend .*.d |
|---|
| 130 | rm -f *.elf.tmp *.sym |
|---|
| 131 | rm -f *.lsr *.lst *.map *.sec *.raw |
|---|
| 132 | rm -f */*.o */*/*.o */*.lst */*/*.lst */.*.d */*/.*.d |
|---|
| 133 | rm -f $(OBSOLETE) $(LIB) |
|---|
| 134 | |
|---|
| 135 | clean: tidy |
|---|
| 136 | |
|---|
| 137 | spotless: clean |
|---|
| 138 | rm -f $(BTARGET) *.bin *_bin.c |
|---|
| 139 | |
|---|
| 140 | # Include dependencies file |
|---|
| 141 | -include .*.d */.*.d */*/.*.d |
|---|