Move files out of root into core, dos, and utils
[syslinux.git] / Makefile
blobd522cadec17ad64822dbf34d2bbd6ee4b989b60e
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
17 # No builtin rules
18 MAKEFLAGS += -r
19 MAKE += -r
21 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
23 CC = gcc
25 gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) dummy.c -o $$tmpf 2>/dev/null; \
26 then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
28 comma := ,
29 LDHASH := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
31 OSTYPE = $(shell uname -msr)
32 INCLUDE =
33 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
34 PIC = -fPIC
35 LDFLAGS = -O2 -s $(LDHASH)
36 AR = ar
37 RANLIB = ranlib
38 LD = ld
39 OBJCOPY = objcopy
40 OBJDUMP = objdump
42 NASM = nasm
43 NASMOPT = -O9999
44 NINCLUDE =
45 BINDIR = /usr/bin
46 SBINDIR = /sbin
47 LIBDIR = /usr/lib
48 AUXDIR = $(LIBDIR)/syslinux
49 MANDIR = /usr/man
50 INCDIR = /usr/include
51 TFTPBOOT = /tftpboot
53 PERL = perl
55 VERSION = $(shell cat version)
57 %.o: %.c
58 $(CC) $(INCLUDE) $(CFLAGS) -c $<
61 # The BTARGET refers to objects that are derived from ldlinux.asm; we
62 # like to keep those uniform for debugging reasons; however, distributors
63 # want to recompile the installers (ITARGET).
65 # BOBJECTS and IOBJECTS are the same thing, except used for
66 # installation, so they include objects that may be in subdirectories
67 # with their own Makefiles. Finally, there is a list of those
68 # directories.
71 # syslinux.exe is BTARGET so as to not require everyone to have the
72 # mingw suite installed
73 BTARGET = version.gen version.h
74 BOBJECTS = $(BTARGET) \
75 mbr/mbr.bin mbr/gptmbr.bin \
76 core/pxelinux.0 core/isolinux.bin core/isolinux-debug.bin \
77 gpxe/gpxelinux.0 dos/syslinux.com win32/syslinux.exe \
78 memdisk/memdisk memdump/memdump.com
79 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
80 # and ISUBDIRS are "late", after the root.
81 BESUBDIRS = mbr core
82 BSUBDIRS = memdisk memdump gpxe dos win32
83 ITARGET =
84 IOBJECTS = $(ITARGET) dos/copybs.com utils/gethostip utils/mkdiskimage \
85 mtools/syslinux linux/syslinux extlinux/extlinux
86 IESUBDIRS =
87 ISUBDIRS = mtools linux extlinux utils com32 sample
89 # Things to install in /usr/bin
90 INSTALL_BIN = mtools/syslinux utils/gethostip utils/ppmtolss16 \
91 utils/lss16toppm utils/sha1pass utils/md5pass
92 # Things to install in /sbin
93 INSTALL_SBIN = extlinux/extlinux
94 # Things to install in /usr/lib/syslinux
95 INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 core/isolinux.bin \
96 core/isolinux-debug.bin \
97 dos/syslinux.com dos/copybs.com memdisk/memdisk mbr/mbr.bin
98 INSTALL_AUX_OPT = win32/syslinux.exe
100 all:
101 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
102 $(MAKE) all-local
103 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
104 -ls -l $(BOBJECTS) $(IOBJECTS)
106 all-local: $(BTARGET) $(ITARGET)
108 installer:
109 set -e ; for i in $(IESUBDIRS); do $(MAKE) -C $$i all ; done
110 $(MAKE) installer-local
111 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
112 -ls -l $(BOBJECTS) $(IOBJECTS)
114 installer-local: $(ITARGET) $(BINFILES)
116 version.gen: version version.pl
117 $(PERL) version.pl $< $@ '%define'
119 version.h: version version.pl
120 $(PERL) version.pl $< $@ '#define'
122 install: installer
123 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
124 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
125 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
126 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
127 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
128 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
129 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
130 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
131 install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
132 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
133 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
134 $(MAKE) -C com32 install
136 install-lib: installer
138 install-all: install install-lib
140 NETINSTALLABLE = pxelinux.0 gpxelinux.0 memdisk/memdisk memdump/memdump.com \
141 com32/menu/*.c32 com32/modules/*.c32
143 netinstall: installer
144 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
145 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
147 local-tidy:
148 rm -f *.o *.elf *_bin.c stupid.* patch.offset
149 rm -f *.lsr *.lst *.map *.sec
150 rm -f $(OBSOLETE)
152 tidy: local-tidy
153 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
155 local-clean:
156 rm -f $(ITARGET)
158 clean: local-tidy local-clean
159 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
161 local-dist:
162 find . \( -name '*~' -o -name '#*' -o -name core \
163 -o -name '.*.d' -o -name .depend \) -type f -print0 \
164 | xargs -0rt rm -f
166 dist: local-dist local-tidy
167 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
169 local-spotless:
170 rm -f $(BTARGET) .depend *.so.*
172 spotless: local-clean local-dist local-spotless
173 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
175 local-depend:
177 depend: local-depend
178 $(MAKE) -C memdisk depend
180 # Shortcut to build linux/syslinux using klibc
181 klibc:
182 $(MAKE) clean
183 $(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
185 # Hook to add private Makefile targets for the maintainer.
186 -include Makefile.private