blob: 9fddb8a96fc3432d889f85d1234c0bbc041c7469 [file] [log] [blame]
## -----------------------------------------------------------------------
## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
## Boston MA 02111-1307, USA; either version 2 of the License, or
## (at your option) any later version; incorporated herein by reference.
## -----------------------------------------------------------------------
# Main Makefile for SYSLINUX
# No builtin rules
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) dummy.c -o $$tmpf 2>/dev/null; \
then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
comma := ,
LDHASH := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
OSTYPE = $(shell uname -msr)
CC = gcc
CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
AR = ar
RANLIB = ranlib
NASM = nasm
NASMOPT = -O9999
BINDIR = /usr/bin
SBINDIR = /sbin
LIBDIR = /usr/lib
AUXDIR = $(LIBDIR)/syslinux
MANDIR = /usr/man
INCDIR = /usr/include
PERL = perl
VERSION = $(shell cat version)
%.o: %.c
$(CC) $(INCLUDE) $(CFLAGS) -c $<
# The BTARGET refers to objects that are derived from ldlinux.asm; we
# like to keep those uniform for debugging reasons; however, distributors
# want to recompile the installers (ITARGET).
# BOBJECTS and IOBJECTS are the same thing, except used for
# installation, so they include objects that may be in subdirectories
# with their own Makefiles. Finally, there is a list of those
# directories.
CSRC = gethostip.c
NASMSRC = $(wildcard *.asm)
SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
# _bin.c files required by both BTARGET and ITARGET installers
BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
extlinux_bss_bin.c extlinux_sys_bin.c
# syslinux.exe is BTARGET so as to not require everyone to have the
# mingw suite installed
BTARGET = kwdhash.gen version.gen version.h \
ldlinux.bss ldlinux.sys ldlinux.bin \
pxelinux.0 isolinux.bin isolinux-debug.bin \
extlinux.bin extlinux.bss extlinux.sys
BOBJECTS = $(BTARGET) mbr/mbr.bin dos/ win32/syslinux.exe \
memdisk/memdisk memdump/
# BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
# and ISUBDIRS are "late", after the root.
BSUBDIRS = memdisk memdump dos win32
ITARGET = gethostip mkdiskimage
IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
ISUBDIRS = mtools unix extlinux sample com32
DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
OTHER = Makefile keywords \ version \
ppmtolss16 lss16toppm memdisk \
sha1pass md5pass
OBSOLETE = pxelinux.bin
# Things to install in /usr/bin
INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm \
sha1pass md5pass
# Things to install in /sbin
INSTALL_SBIN = extlinux/extlinux
# Things to install in /usr/lib/syslinux
INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
dos/ memdisk/memdisk mbr/mbr.bin
INSTALL_AUX_OPT = win32/syslinux.exe
# The DATE is set on the make command line when building binaries for
# official release. Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
HEXDATE := $(shell $(PERL) ldlinux.asm pxelinux.asm isolinux.asm)
ifndef DATE
# NOTE: If you don't have the mingw compiler suite installed, you probably
# want to remove win32 from this list; otherwise you're going to get an
# error every time you try to build.
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
$(MAKE) all-local
set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
all-local: $(BTARGET) $(ITARGET) $(BINFILES)
set -e ; for i in $(IESUBDIRS); do $(MAKE) -C $$i all ; done
$(MAKE) installer-local
set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
installer-local: $(ITARGET) $(BINFILES)
version.gen: version
$(PERL) $< $@ '%define'
version.h: version
$(PERL) $< $@ '#define'
kwdhash.gen: keywords
$(PERL) < keywords > kwdhash.gen
# Standard rule for {isolinux,isolinux-debug}.bin
iso%.bin: iso%.asm kwdhash.gen version.gen
-DMAP=$( -l $(@:.bin=.lsr) -o $@ $<
$(PERL) $(@:.bin=.lsr) $( $(@:.bin=.lst)
$(PERL) $@
$(PERL) $( $@
# Standard rule for {ldlinux,pxelinux,extlinux}.bin
%.bin: %.asm kwdhash.gen version.gen
-DMAP=$( -l $(@:.bin=.lsr) -o $@ $<
$(PERL) $(@:.bin=.lsr) $( $(@:.bin=.lst)
$(PERL) $( $@
pxelinux.0: pxelinux.bin
cp pxelinux.bin pxelinux.0
ldlinux.bss: ldlinux.bin
dd if=$< of=$@ bs=512 count=1
ldlinux.sys: ldlinux.bin
dd if=$< of=$@ bs=512 skip=1
extlinux.bss: extlinux.bin
dd if=$< of=$@ bs=512 count=1
extlinux.sys: extlinux.bin
dd if=$< of=$@ bs=512 skip=1
mbr_bin.c: mbr/mbr.bin
$(PERL) syslinux_mbr < $< > $@ copybs.asm
$(NASM) $(NASMOPT) -f bin -l copybs.lst -o copybs.asm
bootsect_bin.c: ldlinux.bss
$(PERL) syslinux_bootsect < $< > $@
ldlinux_bin.c: ldlinux.sys
$(PERL) syslinux_ldlinux < $< > $@
extlinux_bss_bin.c: extlinux.bss
$(PERL) extlinux_bootsect < $< > $@
extlinux_sys_bin.c: extlinux.sys
$(PERL) extlinux_image 512 < $< > $@
gethostip: gethostip.o
$(CC) $(LDFLAGS) -o $@ $^
mkdiskimage: mbr/mbr.bin
$(PERL) < mbr/mbr.bin | cat - > $@
chmod a+x $@
install: installer
mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
-install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
: mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
: install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
$(MAKE) -C com32 install
install-lib: installer
install-all: install install-lib
rm -f *.o *_bin.c stupid.* patch.offset
rm -f *.lsr *.lst *.map
rm -f $(OBSOLETE)
tidy: local-tidy
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
rm -f $(ITARGET)
clean: local-tidy local-clean
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
dist: tidy
for dir in . sample memdisk ; do \
( cd $$dir && rm -f *~ \#* core ) ; \
rm -f $(BTARGET) .depend *.so.*
spotless: local-clean dist local-spotless
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
rm -f .depend
for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
rm -f .depend
$(MAKE) .depend
depend: local-depend
$(MAKE) -C memdisk depend
# Shortcut to build unix/syslinux using klibc
$(MAKE) clean
$(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
# Hook to add private Makefile targets for the maintainer.
-include Makefile.private
# Include dependencies file
include .depend