summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-08-20 15:15:34 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-08-20 15:15:34 -0700
commitbd09a6d828fa492aed4406adde6c412e0e5c640d (patch)
tree660a4813999ba273afb26fd3e137399cb0a57a97
parent6aa3a1c8380276387430684eb39650e958b0030a (diff)
downloadsyslinux-bd09a6d828fa492aed4406adde6c412e0e5c640d.tar.gz
Major Makefile cleanups; gcc 4.3.0 compatiblity
Cleanup and centralize the Makefile system even more. Fix a gcc 4.3 incompatibility in memdisk (definition of strlen).
-rw-r--r--MCONFIG6
-rw-r--r--Makefile2
-rw-r--r--com32/MCONFIG68
-rw-r--r--com32/lib/Makefile4
-rw-r--r--com32/libutil/Makefile65
-rw-r--r--com32/menu/Makefile67
-rw-r--r--com32/modules/Makefile70
-rw-r--r--com32/samples/Makefile62
-rw-r--r--core/Makefile29
-rw-r--r--dos/Makefile55
-rw-r--r--extlinux/Makefile35
-rw-r--r--linux/Makefile32
-rw-r--r--mbr/Makefile17
-rw-r--r--memdisk/Makefile34
-rw-r--r--memdisk/memdisk.h15
-rw-r--r--memdisk/setup.c8
-rw-r--r--memdump/Makefile53
-rw-r--r--menu/Makefile32
-rw-r--r--mtools/Makefile16
-rw-r--r--sample/Makefile25
-rw-r--r--win32/Makefile4
21 files changed, 271 insertions, 428 deletions
diff --git a/MCONFIG b/MCONFIG
index 09764c8c..6919ce76 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -26,6 +26,7 @@ AUXDIR = $(DATADIR)/syslinux
MANDIR = /usr/man
INCDIR = /usr/include
TFTPBOOT = /tftpboot
+COM32DIR = $(AUXDIR)/com32
BOOTDIR = /boot
EXTLINUXDIR = $(BOOTDIR)/extlinux
@@ -36,8 +37,7 @@ NASMOPT = -O9999
PERL = perl
CC = gcc
-TMPFILE := $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); \
+gcc_ok = $(shell tmpf=gcc_ok.$$$$.tmp; \
if $(CC) $(1) -c $(topdir)/dummy.c -o $$tmpf 2>/dev/null ; \
then echo '$(1)'; else echo '$(2)'; fi; \
rm -f $$tmpf)
@@ -48,3 +48,5 @@ OBJCOPY = objcopy
AR = ar
NM = nm
RANLIB = ranlib
+GZIPPROG = gzip
+PNGTOPNM = pngtopnm
diff --git a/Makefile b/Makefile
index 6b90c094..6c056d8b 100644
--- a/Makefile
+++ b/Makefile
@@ -122,7 +122,7 @@ install-all: install netinstall extbootinstall
local-tidy:
rm -f *.o *.elf *_bin.c stupid.* patch.offset
- rm -f *.lsr *.lst *.map *.sec
+ rm -f *.lsr *.lst *.map *.sec *.tmp
rm -f $(OBSOLETE)
tidy: local-tidy
diff --git a/com32/MCONFIG b/com32/MCONFIG
new file mode 100644
index 00000000..2b7e018b
--- /dev/null
+++ b/com32/MCONFIG
@@ -0,0 +1,68 @@
+## -*- makefile -*- -------------------------------------------------------
+##
+## Copyright 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., 51 Franklin St, Fifth Floor,
+## Boston MA 02110-1301, USA; either version 2 of the License, or
+## (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+##
+## COM32 common configurables
+##
+
+include $(topdir)/MCONFIG
+
+GCCOPT := $(call gcc_ok,-std=gnu99,) \
+ $(call gcc_ok,-m32,) \
+ $(call gcc_ok,-fno-stack-protector,) \
+ -mregparm=3 -DREGPARM=3 -march=i386 -Os
+
+com32 = $(topdir)/com32
+
+CFLAGS = $(GCCOPT) -W -Wall -march=i386 \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I$(com32)/libutil/include -I$(com32)/include
+SFLAGS = $(GCCOPT) -D__COM32__ -march=i386
+LDFLAGS = -m elf_i386 -T $(com32)/lib/com32.ld
+LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
+
+LNXCFLAGS = -I$(com32)/libutil/include -W -Wall -O -g -D_GNU_SOURCE
+LNXSFLAGS = -g
+LNXLDFLAGS = -g
+
+C_LIBS = $(com32)/libutil/libutil_com.a $(com32)/lib/libcom32.a $(LIBGCC)
+C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
+
+.SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
+
+.PRECIOUS: %.o
+%.o: %.S
+ $(CC) $(SFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.o
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.elf
+%.elf: %.o $(LIBS) $(C_LIBS)
+ $(LD) $(LDFLAGS) -o $@ $^
+
+.PRECIOUS: %.lo
+%.lo: %.S
+ $(CC) $(LNXSFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.lo
+%.lo: %.c
+ $(CC) $(LNXCFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.lnx
+%.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
+ $(CC) $(LNXCFLAGS) -o $@ $^
+
+%.c32: %.elf
+ $(OBJCOPY) -O binary $< $@
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index c2b4e3d2..fec93ec7 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -110,8 +110,8 @@ libcom32.a : $(LIBOBJS)
tidy dist:
rm -f sys/vesa/alphatbl.c
- find . -name \*.o -print | xargs -r rm -f
- find . -name .\*.d -print | xargs -r rm -f
+ find . -name \*.o -o -name .\*.d -o -name \*.tmp -print0 | \
+ xargs -0r rm -f
clean: tidy
rm -f *.a
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index 64d78b98..d7967cdb 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -29,45 +29,13 @@
## Utility companion library for the COM32 library
##
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-CC = gcc
+topdir = ../..
+include ../MCONFIG
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-GCCOPT := $(call gcc_ok,-std=gnu99,) \
- $(call gcc_ok,-m32,) \
- $(call gcc_ok,-fno-stack-protector,) \
-
-LD = ld -m elf_i386
-AR = ar
-NASM = nasm
-NASMOPT = -O9999
-RANLIB = ranlib
-CFLAGS = $(GCCOPT) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -D__COM32__ \
- -nostdinc -iwithprefix include \
- -I./include -I../include \
- -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
-SFLAGS = $(M32) -D__COM32__ -march=i386
-LDFLAGS = -T ../lib/com32.ld
-LNXCFLAGS = -I./include -W -Wall -O -g -D_GNU_SOURCE
-LNXSFLAGS = -g
-LNXLDFLAGS = -g
-OBJCOPY = objcopy
LIBOBJS = ansiline.o ansiraw.o get_key.o sha1hash.o unbase64.o \
md5.o crypt-md5.o sha256crypt.o sha512crypt.o base64.o
LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS))
-.SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
-
-BINDIR = /usr/bin
-LIBDIR = /usr/lib
-DATADIR = /usr/share
-AUXDIR = $(DATADIR)/syslinux
-INCDIR = /usr/include
-COM32DIR = $(AUXDIR)/com32
-
all: libutil_com.a libutil_lnx.a
libutil_com.a: $(LIBOBJS)
@@ -80,35 +48,8 @@ libutil_lnx.a: $(LNXLIBOBJS)
$(AR) cq $@ $(LNXLIBOBJS)
$(RANLIB) $@
-.PRECIOUS: %.o
-%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.o
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.elf
-%.elf: %.o $(LIB)
- $(LD) $(LDFLAGS) -o $@ $^ $(LIBGCC)
-
-.PRECIOUS: %.lo
-%.lo: %.S
- $(CC) $(LNXSFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lo
-%.lo: %.c
- $(CC) $(LNXCFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lnx
-%.lnx: %.lo
- $(CC) $(LNXCFLAGS) -o $@ $^
-
-%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
-
tidy dist:
- rm -f *.o *.lo *.lst *.elf .*.d
+ rm -f *.o *.lo *.lst *.elf .*.d *.tmp
clean: tidy
rm -f *.lss *.a *.c32 *.lnx *.com
diff --git a/com32/menu/Makefile b/com32/menu/Makefile
index 5496c6e6..73cf5867 100644
--- a/com32/menu/Makefile
+++ b/com32/menu/Makefile
@@ -14,46 +14,12 @@
## Simple menu system
##
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-CC = gcc
+topdir = ../..
+include ../MCONFIG
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-GCCOPT := $(call gcc_ok,-std=gnu99,) \
- $(call gcc_ok,-m32,) \
- $(call gcc_ok,-fno-stack-protector,) \
-
-LD = ld -m elf_i386
-AR = ar
-NASM = nasm
-NASMOPT = -O9999
-RANLIB = ranlib
-CFLAGS = $(GCCOPT) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -D__COM32__ \
- -nostdinc -iwithprefix include \
- -I../libutil/include -I../include \
- -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
-LNXCFLAGS = -W -Wall -O -g -I../libutil/include -D_GNU_SOURCE
-LNXSFLAGS = -g
-LNXLDFLAGS = -g
-SFLAGS = -D__COM32__ -march=i386
-LDFLAGS = -T ../lib/com32.ld
-OBJCOPY = objcopy
-PPMTOLSS16 = ../ppmtolss16
-LIBGCC := $(shell $(CC) --print-libgcc)
LIBS = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
LNXLIBS = ../libutil/libutil_lnx.a
-.SUFFIXES: .lss .c .o .elf .c32 .lnx
-
-BINDIR = /usr/bin
-LIBDIR = /usr/lib
-DATADIR = /usr/share
-AUXDIR = $(DATADIR)/syslinux
-INCDIR = /usr/include
-COM32DIR = $(AUXDIR)/com32
-
MODULES = menu.c32 vesamenu.c32
TESTFILES =
@@ -62,33 +28,6 @@ COMMONOBJS = menumain.o readconfig.o passwd.o printmsg.o colors.o \
all: $(MODULES) $(TESTFILES)
-.PRECIOUS: %.o
-%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.o
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.elf
-%.elf: %.o $(LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-.PRECIOUS: %.lo
-%.lo: %.S
- $(CC) $(LNXSFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lo
-%.lo: %.c
- $(CC) $(LNXCFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lnx
-%.lnx: %.lo $(LNXLIBS)
- $(CC) $(LNXLDFLAGS) -o $@ $^
-
-%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
-
menu.elf : menu.o $(COMMONOBJS) $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
@@ -96,7 +35,7 @@ vesamenu.elf : vesamenu.o $(COMMONOBJS) $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
- rm -f *.o *.lo *.a *.lst *.elf .*.d
+ rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
clean: tidy
rm -f *.lss *.c32 *.lnx *.com
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 506f6edd..2f6fb252 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -14,45 +14,8 @@
## COM32 standard modules
##
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-GCCOPT := $(call gcc_ok,-std=gnu99,) \
- $(call gcc_ok,-m32,) \
- $(call gcc_ok,-fno-stack-protector,) \
-
-LD = ld -m elf_i386
-AR = ar
-NASM = nasm
-NASMOPT = -O9999
-RANLIB = ranlib
-CFLAGS = $(GCCOPT) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -D__COM32__ \
- -nostdinc -iwithprefix include \
- -I../libutil/include -I../include \
- -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
-LNXCFLAGS = -W -Wall -O -g -I../libutil/include
-LNXSFLAGS = -g
-LNXLDFLAGS = -g
-SFLAGS = -D__COM32__ -march=i386
-LDFLAGS = -T ../lib/com32.ld
-OBJCOPY = objcopy
-PPMTOLSS16 = ../ppmtolss16
-LIBGCC := $(shell $(CC) --print-libgcc)
-LIBS = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
-LNXLIBS = ../libutil/libutil_lnx.a
-
-.SUFFIXES: .lss .c .o .elf .c32 .lnx
-
-BINDIR = /usr/bin
-LIBDIR = /usr/lib
-DATADIR = /usr/share
-AUXDIR = $(DATADIR)/syslinux
-INCDIR = /usr/include
-COM32DIR = $(AUXDIR)/com32
+topdir = ../..
+include ../MCONFIG
MODULES = chain.c32 ethersel.c32 mboot.c32 dmitest.c32 cpuidtest.c32 \
pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 meminfo.c32 \
@@ -62,33 +25,6 @@ TESTFILES =
all: $(MODULES) $(TESTFILES)
-.PRECIOUS: %.o
-%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.o
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.elf
-%.elf: %.o $(LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-.PRECIOUS: %.lo
-%.lo: %.S
- $(CC) $(LNXSFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lo
-%.lo: %.c
- $(CC) $(LNXCFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lnx
-%.lnx: %.lo $(LNXLIBS)
- $(CC) $(LNXLDFLAGS) -o $@ $^
-
-%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
-
pcitest.elf : pcitest.o $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
@@ -102,7 +38,7 @@ ethersel.elf : ethersel.o $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
- rm -f *.o *.lo *.a *.lst *.elf .*.d
+ rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
clean: tidy
rm -f *.lss *.c32 *.lnx *.com
diff --git a/com32/samples/Makefile b/com32/samples/Makefile
index c06668d9..28260a35 100644
--- a/com32/samples/Makefile
+++ b/com32/samples/Makefile
@@ -14,37 +14,8 @@
## samples for syslinux users
##
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-GCCOPT := $(call gcc_ok,-std=gnu99,) \
- $(call gcc_ok,-m32,) \
- $(call gcc_ok,-fno-stack-protector,) \
-
-LD = ld -m elf_i386
-AR = ar
-NASM = nasm
-NASMOPT = -O9999
-RANLIB = ranlib
-CFLAGS = $(GCCOPT) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -D__COM32__ \
- -nostdinc -iwithprefix include \
- -I../libutil/include -I../include \
- -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
-LNXCFLAGS = -W -Wall -O -g -I../libutil/include
-LNXSFLAGS = -g
-LNXLDFLAGS = -g
-SFLAGS = -D__COM32__ -march=i386
-LDFLAGS = -T ../lib/com32.ld
-OBJCOPY = objcopy
-LIBGCC := $(shell $(CC) --print-libgcc)
-LIBS = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
-LNXLIBS = ../libutil/libutil_lnx.a
-
-.SUFFIXES: .lss .c .o .elf .c32 .lnx
+topdir = ../..
+include ../MCONFIG
all: hello.c32 cat.c32 resolv.c32 vesainfo.c32 serialinfo.c32 \
localboot.c32 \
@@ -52,35 +23,8 @@ all: hello.c32 cat.c32 resolv.c32 vesainfo.c32 serialinfo.c32 \
keytest.c32 keytest.lnx \
advdump.c32
-.PRECIOUS: %.o
-%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.o
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.elf
-%.elf: %.o $(LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-.PRECIOUS: %.lo
-%.lo: %.S
- $(CC) $(LNXSFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lo
-%.lo: %.c
- $(CC) $(LNXCFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.lnx
-%.lnx: %.lo $(LNXLIBS)
- $(CC) $(LNXLDFLAGS) -o $@ $^
-
-%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
-
tidy dist:
- rm -f *.o *.lo *.a *.lst *.elf .*.d
+ rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
clean: tidy
rm -f *.lss *.c32 *.lnx *.com
diff --git a/core/Makefile b/core/Makefile
index 278d7afe..12ff8694 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -20,25 +20,24 @@ MAKE += -r
topdir = ..
-include $(topdir)/version.mk
+include $(topdir)/MCONFIG
+
+GCCOPT := $(call gcc_ok,-m32,) \
+ $(call gcc_ok,-ffreestanding,) \
+ $(call gcc_ok,-fno-stack-protector,) \
+ $(call gcc_ok,-fno-top-level-reorder,\
+ $(call gcc_ok,-fno-unit-at-a-time)) \
+ -Os -march=i386 -mregparm=3 -DREGPARM=3 -msoft-float \
+ -fomit-frame-pointer \
+ $(call gcc_ok,-falign-functions=0,-malign-functions=0) \
+ $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) \
+ $(call gcc_ok,-falign-loops=0,-malign-loops=0) \
-CC = gcc
-
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) dummy.c -o $$tmpf 2>/dev/null; \
- then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
-
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) \
- $(call gcc_ok,-fno-stack-protector,) \
- $(call gcc_ok,-fno-top-level-reorder,$(call gcc_ok,-fno-unit-at-a-time))
-
-LD = ld
LDFLAGS = -m elf_i386
-OBJCOPY = objcopy
-OBJDUMP = objdump
-OPTFLAGS = -g -Os -march=i386 -falign-functions=0 -falign-jumps=0 -falign-loops=0 -fomit-frame-pointer
+OPTFLAGS =
INCLUDES =
-CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -msoft-float $(OPTFLAGS) $(INCLUDES)
+CFLAGS = $(GCCOPT) -W -Wall $(OPTFLAGS) $(INCLUDES)
NASM = nasm
NASMOPT = -O9999
diff --git a/dos/Makefile b/dos/Makefile
index 29c1137b..028e8330 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -1,27 +1,38 @@
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+## -----------------------------------------------------------------------
+##
+## Copyright 2001-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.
+##
+## -----------------------------------------------------------------------
+
+##
+## MS-DOS FAT installer
+##
+
+topdir = ..
+include $(topdir)/MCONFIG
+
+GCCOPT := $(call gcc_ok,-m32,) \
+ $(call gcc_ok,-ffreestanding,) \
+ $(call gcc_ok,-fno-stack-protector,) \
+ $(call gcc_ok,-falign-functions=0,-malign-functions=0) \
+ $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) \
+ $(call gcc_ok,-falign-loops=0,-malign-loops=0) \
+ -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
+ -msoft-float
+
+LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) \
- $(call gcc_ok,-fno-stack-protector,) \
- $(call gcc_ok,-fno-top-level-reorder,$(call gcc_ok,-fno-unit-at-a-time))
-
-NASM = nasm
-NASMOPT = -O9999
-
-LD = ld
LDFLAGS = -m elf_i386 -T com16.ld
-OBJCOPY = objcopy
-OPTFLAGS = -g -Os -march=i386 -falign-functions=0 -falign-jumps=0 -falign-loops=0 -fomit-frame-pointer
+OPTFLAGS = -g
INCLUDES = -include code16.h -nostdinc -iwithprefix include \
-I. -I.. -I../libfat -I ../libinstaller
-CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -msoft-float $(OPTFLAGS) $(INCLUDES)
-AR = ar
-RANLIB = ranlib
-LIBGCC := $(shell $(CC) --print-libgcc)
+CFLAGS = $(GCCOPT) -W -Wall -msoft-float $(OPTFLAGS) $(INCLUDES)
SRCS = syslinux.c \
../libinstaller/syslxmod.c \
@@ -42,7 +53,7 @@ TARGETS = syslinux.com copybs.com
all: $(TARGETS)
tidy dist:
- -rm -f *.o *.i *.s *.a .*.d *.elf *.lst
+ -rm -f *.o *.i *.s *.a .*.d *.tmp *.elf *.lst
clean: tidy
@@ -75,4 +86,4 @@ syslinux.com: syslinux.elf
%.com: %.asm
$(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
--include .*.d
+-include .*.d *.tmp
diff --git a/extlinux/Makefile b/extlinux/Makefile
index ec212d68..d915e5a9 100644
--- a/extlinux/Makefile
+++ b/extlinux/Makefile
@@ -1,16 +1,27 @@
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(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,)
+## -----------------------------------------------------------------------
+##
+## Copyright 2001-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.
+##
+## -----------------------------------------------------------------------
+
+##
+## Linux ext2/ext3 installer
+##
+
+topdir = ..
+include $(topdir)/MCONFIG
OPTFLAGS = -g -Os
INCLUDES = -I. -I.. -I../libinstaller
-CFLAGS = -W -Wall -Wno-sign-compare -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
-LDFLAGS = $(LDHASH) # -s
+CFLAGS = -W -Wall -Wno-sign-compare -D_FILE_OFFSET_BITS=64 \
+ $(OPTFLAGS) $(INCLUDES)
+LDFLAGS = # -s
SRCS = main.c \
../libinstaller/setadv.c \
@@ -25,7 +36,7 @@ VPATH = .:../libinstaller
all: installer
tidy dist:
- -rm -f *.o *.i *.s *.a .*.d
+ -rm -f *.o *.i *.s *.a .*.d *.tmp
clean: tidy
-rm -f extlinux
@@ -45,4 +56,4 @@ extlinux: $(OBJS)
%.s: %.c
$(CC) $(CFLAGS) -S -o $@ $<
--include .*.d
+-include .*.d *.tmp
diff --git a/linux/Makefile b/linux/Makefile
index e354171b..00fa0765 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -1,16 +1,26 @@
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+## -----------------------------------------------------------------------
+##
+## Copyright 2001-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.
+##
+## -----------------------------------------------------------------------
+
+##
+## Linux FAT installer
+##
+
+topdir = ..
+include $(topdir)/MCONFIG
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(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,)
-
-CC = gcc
OPTFLAGS = -g -Os
INCLUDES = -I. -I.. -I../libinstaller
CFLAGS = -W -Wall -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
-LDFLAGS = $(LDHASH) -s
+LDFLAGS = -s
SRCS = syslinux.c \
../libinstaller/syslxmod.c \
@@ -25,7 +35,7 @@ VPATH = .:../libinstaller
all: installer
tidy dist:
- -rm -f *.o *.i *.s *.a .*.d
+ -rm -f *.o *.i *.s *.a .*.d *.tmp
clean: tidy
-rm -f syslinux syslinux-nomtools
@@ -48,4 +58,4 @@ syslinux-nomtools: syslinux
%.s: %.c
$(CC) $(CFLAGS) -S -o $@ $<
--include .*.d
+-include .*.d *.tmp
diff --git a/mbr/Makefile b/mbr/Makefile
index d479265c..6ae63719 100644
--- a/mbr/Makefile
+++ b/mbr/Makefile
@@ -14,19 +14,16 @@
# Makefile for MBR
#
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+topdir = ..
+include $(topdir)/MCONFIG
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
+GCCOPT := $(call gcc_ok,-m32,) \
+ $(call gcc_ok,-ffreestanding,) \
+ $(call gcc_ok,-fno-stack-protector) \
+ -march=i386 -Os
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector)
-
-CC = gcc
-LD = ld
LDFLAGS = -m elf_i386
-SFLAGS = $(M32) -march=i386
-OBJCOPY = objcopy
-PERL = perl
+SFLAGS = $(GCCOPT)
.SUFFIXES: .S .s .o .elf
diff --git a/memdisk/Makefile b/memdisk/Makefile
index 529d4a6d..66a6e51a 100644
--- a/memdisk/Makefile
+++ b/memdisk/Makefile
@@ -11,26 +11,22 @@
## -----------------------------------------------------------------------
topdir = ..
+include $(topdir)/MCONFIG
-include $(topdir)/version.mk
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-M32 := $(call gcc_ok,-m32,)
-ALIGN := $(call gcc_ok,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)
-FREE := $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
-
-CFLAGS = $(M32) $(FREE) -g -W -Wall -Wno-sign-compare \
- -Os -fomit-frame-pointer -march=i386 -mregparm=3 $(ALIGN) \
- -DDATE='"$(DATE)"'
-SFLAGS = $(M32) -march=i386 -D__ASSEMBLY__
-LDFLAGS = $(M32) -g
-INCLUDE = -I../com32/include
-LD = ld -m elf_i386
+GCCOPT := $(call gcc_ok,-m32,) \
+ $(call gcc_ok,-ffreestanding,) \
+ $(call gcc_ok,-fno-stack-protector) \
+ $(call gcc_ok,-falign-functions=0,-malign-functions=0) \
+ $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) \
+ $(call gcc_ok,-falign-loops=0,-malign-loops=0) \
+ -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3
+
+CFLAGS = $(GCCOPT) -g -W -Wall -Wno-sign-compare -DDATE='"$(DATE)"'
+SFLAGS = $(GCCOPT) -D__ASSEMBLY__
+LDFLAGS = $(GCCOPT) -g
+INCLUDE = -I$(topdir)/com32/include
+LD += -m elf_i386
NASM = nasm
NASMOPT = -O9999
NFLAGS = -dDATE='"$(DATE)"' -dWITH_EDD
@@ -63,7 +59,7 @@ all: memdisk # e820test
# tidy, clean removes everything except the final binary
tidy dist:
- rm -f *.o *.s *.o16 *.s16 *.bin *.lst *.elf e820test
+ rm -f *.o *.s *.tmp *.o16 *.s16 *.bin *.lst *.elf e820test
clean: tidy
diff --git a/memdisk/memdisk.h b/memdisk/memdisk.h
index 615e3d1e..9d4a4297 100644
--- a/memdisk/memdisk.h
+++ b/memdisk/memdisk.h
@@ -40,11 +40,22 @@ extern void __attribute__((noreturn)) die(void);
#define memcpy(a,b,c) __builtin_memcpy(a,b,c)
#define memset(a,b,c) __builtin_memset(a,b,c)
#define strcpy(a,b) __builtin_strcpy(a,b)
-#define strlen(a) __builtin_strlen(a)
+
+static inline size_t strlen(const char *__a)
+{
+ const char *__D;
+ size_t __c;
+
+ asm("repne;scasb"
+ : "=D" (__D), "=c" (__c)
+ : "D" (__a), "c" (-1), "a" (0), "m" (*__a));
+
+ return __D - __a - 1;
+}
/* memcpy() but returns a pointer to end of buffer */
static inline void *
-memcpy_endptr(void *__d, const void *__s, unsigned int __n)
+mempcpy(void *__d, const void *__s, unsigned int __n)
{
memcpy(__d, __s, __n);
return (void *)((char *)__d + __n);
diff --git a/memdisk/setup.c b/memdisk/setup.c
index b9466335..583570ea 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -751,7 +751,7 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
map -- 12 bytes per range; we may need as many as 2 additional
ranges (each insertrange() can worst-case turn 1 area into 3)
plus the terminating range, over what nranges currently show. */
- cmdlinelen = strlen(shdr->cmdline)+1;
+ cmdlinelen = strlen(shdr->cmdline)+1;
total_size = hptr->total_size; /* Actual memdisk code */
total_size += (nranges+3)*sizeof(ranges[0]); /* E820 memory ranges */
total_size += cmdlinelen; /* Command line */
@@ -873,9 +873,9 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
hptr = (struct memdisk_header *)dpp;
/* Actually copy to low memory */
- dpp = memcpy_endptr(dpp, &_binary_memdisk_bin_start, bin_size);
- dpp = memcpy_endptr(dpp, ranges, (nranges+1)*sizeof(ranges[0]));
- dpp = memcpy_endptr(dpp, shdr->cmdline, cmdlinelen+1);
+ dpp = mempcpy(dpp, &_binary_memdisk_bin_start, bin_size);
+ dpp = mempcpy(dpp, ranges, (nranges+1)*sizeof(ranges[0]));
+ dpp = mempcpy(dpp, shdr->cmdline, cmdlinelen+1);
}
/* Update various BIOS magic data areas (gotta love this shit) */
diff --git a/memdump/Makefile b/memdump/Makefile
index 3f195336..44677239 100644
--- a/memdump/Makefile
+++ b/memdump/Makefile
@@ -1,21 +1,36 @@
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
-
-LD = ld -m elf_i386
-OBJCOPY = objcopy
-OPTFLAGS = -g -Os -march=i386 -falign-functions=0 -falign-jumps=0 -falign-loops=0 -fomit-frame-pointer
+## -----------------------------------------------------------------------
+##
+## Copyright 2001-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.
+##
+## -----------------------------------------------------------------------
+
+##
+## memory dump utility
+##
+
+topdir = ..
+include $(topdir)/MCONFIG
+
+GCCOPT := $(call gcc_ok,-m32,) \
+ $(call gcc_ok,-ffreestanding,) \
+ $(call gcc_ok,-fno-stack-protector,) \
+ $(call gcc_ok,-falign-functions=0,-malign-functions=0) \
+ $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) \
+ $(call gcc_ok,-falign-loops=0,-malign-loops=0) \
+ -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
+ -msoft-float
+
+LD += -m elf_i386
+OPTFLAGS = -g
INCLUDES = -include code16.h -I.
-CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -msoft-float $(OPTFLAGS) $(INCLUDES)
+CFLAGS = $(GCCOPT) -W -Wall $(OPTFLAGS) $(INCLUDES)
LDFLAGS = -T com16.ld
-AR = ar
-RANLIB = ranlib
-LIBGCC := $(shell $(CC) --print-libgcc)
SRCS = main.c serial.c ymsend.c
OBJS = crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
@@ -24,14 +39,12 @@ LIBOBJS = conio.o memcpy.o memset.o skipatou.o strtoul.o \
.SUFFIXES: .c .o .i .s .S .elf .com
-VPATH = .:..:../libfat
-
TARGETS = memdump.com
all: $(TARGETS)
tidy dist:
- -rm -f *.o *.i *.s *.a .*.d *.elf
+ -rm -f *.o *.i *.s *.a .*.d *.tmp *.elf
clean: tidy
@@ -62,4 +75,4 @@ memdump.com: memdump.elf
%.s: %.S
$(CC) $(CFLAGS) -E -o $@ $<
--include .*.d
+-include .*.d *.tmp
diff --git a/menu/Makefile b/menu/Makefile
index 04d2e225..151e2822 100644
--- a/menu/Makefile
+++ b/menu/Makefile
@@ -14,29 +14,13 @@
## samples for syslinux users
##
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-fno-stack-protector,)
-
-CC = gcc
-LD = ld -m elf_i386
-AR = ar
-NASM = nasm
-NASMOPT = -O9999
-RANLIB = ranlib
-COM32DIR = ../com32
-LUDIR = $(COM32DIR)/libutil
-LDIR = $(COM32DIR)/lib
-CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I$(LUDIR)/include -I$(COM32DIR)/include -Ilibmenu -D__COM32__
-SFLAGS = -D__COM32__ -march=i386
-LDFLAGS = -T $(LDIR)/com32.ld
-OBJCOPY = objcopy
-LIBGCC := $(shell $(CC) --print-libgcc)
-
-LIBS = libmenu/libmenu.a $(LUDIR)/libutil_com.a $(LDIR)/libcom32.a $(LIBGCC)
+# This must be defined before MCONFIG is included
+LIBS = libmenu/libmenu.a
+
+topdir = ..
+include $(topdir)/com32/MCONFIG
+
+CFLAGS += -I./libmenu
LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
@@ -61,7 +45,7 @@ MENUS = $(CMENUS) $(IMENUS)
$(CC) $(CFLAGS) -c -o $@ $<
.PRECIOUS: %.elf
-%.elf: %.o $(LIBS)
+%.elf: %.o libmenu/libmenu.a $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
%.c32: %.elf
diff --git a/mtools/Makefile b/mtools/Makefile
index 9e9e5114..b0f0a194 100644
--- a/mtools/Makefile
+++ b/mtools/Makefile
@@ -1,16 +1,10 @@
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+topdir = ..
+include $(topdir)/MCONFIG
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(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,)
-
-CC = gcc
OPTFLAGS = -g -Os
INCLUDES = -I. -I.. -I../libfat -I../libinstaller
CFLAGS = -W -Wall -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
-LDFLAGS = $(LDHASH) -s
+LDFLAGS = -s
SRCS = syslinux.c \
../libinstaller/syslxmod.c \
@@ -26,7 +20,7 @@ VPATH = .:../libfat:../libinstaller
all: installer
tidy dist:
- -rm -f *.o *.i *.s *.a .*.d
+ -rm -f *.o *.i *.s *.a .*.d *.tmp
clean: tidy
-rm -f syslinux
@@ -46,4 +40,4 @@ syslinux: $(OBJS)
%.s: %.c
$(CC) $(CFLAGS) -S -o $@ $<
--include .*.d
+-include .*.d *.tmp
diff --git a/sample/Makefile b/sample/Makefile
index d10b5ed1..d9df4582 100644
--- a/sample/Makefile
+++ b/sample/Makefile
@@ -14,28 +14,15 @@
## samples for syslinux users
##
-TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+topdir = ..
+include $(topdir)/MCONFIG
-CC = gcc
-
-gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
- then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
-
-LD = ld -m elf_i386
-AR = ar
-NASM = nasm
-NASMOPT = -O9999
-RANLIB = ranlib
-CFLAGS = $(M32) -W -Wall -march=i386 -Os -fomit-frame-pointer -I../com32/include
-SFLAGS = $(M32) -march=i386
+LD += -m elf_i386
+CFLAGS = $(GCCOPT) -W -Wall -I$(topdir)/com32/include
+SFLAGS = $(GCCOPT)
LDFLAGS = -s
-OBJCOPY = objcopy
-PPMTOLSS16 = ../utils/ppmtolss16
+PPMTOLSS16 = $(topdir)/utils/ppmtolss16
LIB = liboldcom32.a
-GZIPPROG = gzip
-PNGTOPNM = pngtopnm
LIBOBJS = conio.o atou.o skipatou.o printf.o c32exit.o
diff --git a/win32/Makefile b/win32/Makefile
index 7ec55f20..bb7cb34e 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -64,7 +64,7 @@ all:
endif
tidy dist:
- -rm -f *.o *.i *.s *.a .*.d *_bin.c hello.exe
+ -rm -f *.o *.i *.s *.a .*.d *.tmp *_bin.c hello.exe
clean: tidy
@@ -84,4 +84,4 @@ syslinux.exe: $(OBJS)
%.s: %.c
$(WINCC) $(WINCFLAGS) -S -o $@ $<
--include .*.d
+-include .*.d *.tmp