loadfile: make sure we don't trash errno
[syslinux.git] / Makefile
blobfa49c2c6552e9f890cc7a09cf9990384a7aca917
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ## Boston MA 02111-1307, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
14 # Main Makefile for SYSLINUX
16 topdir = .
17 include $(topdir)/MCONFIG
19 VERSION := $(shell cat version)
22 # The BTARGET refers to objects that are derived from ldlinux.asm; we
23 # like to keep those uniform for debugging reasons; however, distributors
24 # want to recompile the installers (ITARGET).
26 # BOBJECTS and IOBJECTS are the same thing, except used for
27 # installation, so they include objects that may be in subdirectories
28 # with their own Makefiles. Finally, there is a list of those
29 # directories.
32 # syslinux.exe is BTARGET so as to not require everyone to have the
33 # mingw suite installed
34 BTARGET = version.gen version.h
35 BOBJECTS = $(BTARGET) \
36 mbr/mbr.bin mbr/gptmbr.bin \
37 core/pxelinux.0 core/isolinux.bin core/isolinux-debug.bin \
38 gpxe/gpxelinux.0 dos/syslinux.com win32/syslinux.exe \
39 memdisk/memdisk memdump/memdump.com
40 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
41 # and ISUBDIRS are "late", after the root.
42 BESUBDIRS =
43 BSUBDIRS = codepage core memdisk mbr memdump gpxe dos win32
44 ITARGET =
45 IOBJECTS = $(ITARGET) dos/copybs.com utils/gethostip utils/mkdiskimage \
46 mtools/syslinux linux/syslinux extlinux/extlinux
47 IESUBDIRS =
48 ISUBDIRS = mtools linux extlinux utils com32 sample
50 # Things to install in /usr/bin
51 INSTALL_BIN = mtools/syslinux
52 # Things to install in /sbin
53 INSTALL_SBIN = extlinux/extlinux
54 # Things to install in /usr/lib/syslinux
55 INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 core/isolinux.bin \
56 core/isolinux-debug.bin \
57 dos/syslinux.com dos/copybs.com win32/syslinux.exe \
58 memdisk/memdisk memdump/memdump.com \
59 mbr/mbr.bin mbr/gptmbr.bin
60 INSTALL_AUX_OPT = win32/syslinux.exe
62 # These directories manage their own installables
63 INSTALLSUBDIRS = com32 utils
65 # Things to install in /boot/extlinux
66 EXTBOOTINSTALL = memdisk/memdisk memdump/memdump.com \
67 com32/menu/*.c32 com32/modules/*.c32
69 # Things to install in /tftpboot
70 NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 memdisk/memdisk \
71 memdump/memdump.com com32/menu/*.c32 com32/modules/*.c32
73 all:
74 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
75 $(MAKE) all-local
76 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
77 -ls -l $(BOBJECTS) $(IOBJECTS)
79 all-local: $(BTARGET) $(ITARGET)
81 installer:
82 set -e ; for i in $(IESUBDIRS); do $(MAKE) -C $$i all ; done
83 $(MAKE) installer-local
84 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
85 -ls -l $(BOBJECTS) $(IOBJECTS)
87 installer-local: $(ITARGET) $(BINFILES)
89 version.gen: version version.pl
90 $(PERL) version.pl $< $@ '%define'
92 version.h: version version.pl
93 $(PERL) version.pl $< $@ '#define'
95 local-install: installer
96 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
97 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
98 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
99 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
100 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
101 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
102 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
103 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
104 install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
105 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
106 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
108 install: local-install
109 set -e ; for i in $(INSTALLSUBDIRS) ; do $(MAKE) -C $$i $@ ; done
111 netinstall: installer
112 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
113 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
115 extbootinstall: installer
116 mkdir -m 755 -p $(INSTALLROOT)$(EXTLINUXDIR)
117 install -m 644 $(EXTBOOTINSTALL) $(INSTALLROOT)$(EXTLINUXDIR)
119 install-all: install netinstall extbootinstall
121 local-tidy:
122 rm -f *.o *.elf *_bin.c stupid.* patch.offset
123 rm -f *.lsr *.lst *.map *.sec
124 rm -f $(OBSOLETE)
126 tidy: local-tidy
127 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
129 local-clean:
130 rm -f $(ITARGET)
132 clean: local-tidy local-clean
133 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
135 local-dist:
136 find . \( -name '*~' -o -name '#*' -o -name core \
137 -o -name '.*.d' -o -name .depend \) -type f -print0 \
138 | xargs -0rt rm -f
140 dist: local-dist local-tidy
141 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
143 local-spotless:
144 rm -f $(BTARGET) .depend *.so.*
146 spotless: local-clean local-dist local-spotless
147 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
149 local-depend:
151 depend: local-depend
152 $(MAKE) -C memdisk depend
154 # Shortcut to build linux/syslinux using klibc
155 klibc:
156 $(MAKE) clean
157 $(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
159 # Hook to add private Makefile targets for the maintainer.
160 -include Makefile.private