summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk')
-rw-r--r--mk/build.mk33
-rw-r--r--mk/com32.mk98
-rw-r--r--mk/devel.mk2
-rw-r--r--mk/embedded.mk55
-rw-r--r--mk/lib.mk80
-rw-r--r--mk/rosh.mk27
-rw-r--r--mk/syslinux.mk85
7 files changed, 380 insertions, 0 deletions
diff --git a/mk/build.mk b/mk/build.mk
new file mode 100644
index 00000000..0ca82bea
--- /dev/null
+++ b/mk/build.mk
@@ -0,0 +1,33 @@
+## -*- makefile -*- ------------------------------------------------------
+##
+## 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.
+##
+## -----------------------------------------------------------------------
+
+##
+## Right now we don't distinguish between "build" system and the "host"
+## system, although we really should...
+##
+include $(MAKEDIR)/syslinux.mk
+
+OPTFLAGS = -g -Os
+INCLUDES =
+CFLAGS = -W -Wall -Wno-sign-compare -D_FILE_OFFSET_BITS=64 \
+ $(OPTFLAGS) $(INCLUDES)
+LDFLAGS =
+LIBS =
+
+.SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss
+
+%.o: %.c
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
+%.i: %.c
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -E -o $@ $<
+%.s: %.c
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -S -o $@ $<
diff --git a/mk/com32.mk b/mk/com32.mk
new file mode 100644
index 00000000..4a6caae9
--- /dev/null
+++ b/mk/com32.mk
@@ -0,0 +1,98 @@
+## -*- makefile -*- -------------------------------------------------------
+##
+## Copyright 2008-2009 H. Peter Anvin - All Rights Reserved
+## Copyright 2009 Intel Corporation; author: H. Peter Anvin
+##
+## 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 $(MAKEDIR)/syslinux.mk
+
+GCCOPT := $(call gcc_ok,-std=gnu99,)
+GCCOPT += $(call gcc_ok,-m32,)
+GCCOPT += $(call gcc_ok,-fno-stack-protector,)
+GCCOPT += $(call gcc_ok,-fwrapv,)
+GCCOPT += $(call gcc_ok,-freg-struct-return,)
+GCCOPT += -mregparm=3 -DREGPARM=3 -march=i386 -Os
+GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+GCCOPT += $(call gcc_ok,-fno-exceptions,)
+GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
+GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
+GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
+GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+GCCOPT += $(call gcc_ok,-incoming-stack-boundary=2,)
+
+com32 := $(topdir)/com32
+RELOCS := $(com32)/tools/relocs
+
+ifneq ($(NOGPL),1)
+GPLLIB = $(com32)/gpllib/libcom32gpl.a
+GPLINCLUDE = -I$(com32)/gplinclude
+else
+GPLLIB =
+GPLINCLUDE =
+endif
+
+CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+
+COM32LD = $(com32)/lib/com32.ld
+LDFLAGS = -m elf_i386 --emit-relocs -T $(COM32LD)
+LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
+
+LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g \
+ -D_GNU_SOURCE -D_FORTIFY_SOURCE=0 -Wno-error
+LNXSFLAGS = -g
+LNXLDFLAGS = -g
+
+C_LIBS = $(com32)/libutil/libutil_com.a $(GPLLIB) \
+ $(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) $(MAKEDEPS) $(SFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.o
+%.o: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.elf
+%.elf: %.o $(LIBS) $(C_LIBS) $(COM32LD)
+ $(LD) $(LDFLAGS) -o $@ $(filter-out $(COM32LD),$^)
+
+.PRECIOUS: %.lo
+%.lo: %.S
+ $(CC) $(MAKEDEPS) $(LNXSFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.lo
+%.lo: %.c
+ $(CC) $(MAKEDEPS) $(LNXCFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.lnx
+%.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
+ $(CC) $(LNXCFLAGS) -o $@ $^
+
+%.c32: %.elf
+ $(OBJCOPY) -O binary $< $@
+ $(RELOCS) $< >> $@ || ( rm -f $@ ; false )
diff --git a/mk/devel.mk b/mk/devel.mk
new file mode 100644
index 00000000..104207f5
--- /dev/null
+++ b/mk/devel.mk
@@ -0,0 +1,2 @@
+# Useful while doing development, but not for production.
+GCCWARN += -Wno-clobbered -Werror
diff --git a/mk/embedded.mk b/mk/embedded.mk
new file mode 100644
index 00000000..e8f3ae30
--- /dev/null
+++ b/mk/embedded.mk
@@ -0,0 +1,55 @@
+## -*- makefile -*- ------------------------------------------------------
+##
+## 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.
+##
+## -----------------------------------------------------------------------
+
+##
+## Make configuration for embedded directories
+##
+
+include $(MAKEDIR)/syslinux.mk
+
+GCCOPT := $(call gcc_ok,-m32,)
+GCCOPT += $(call gcc_ok,-ffreestanding,)
+GCCOPT += $(call gcc_ok,-fno-stack-protector,)
+GCCOPT += $(call gcc_ok,-fwrapv,)
+GCCOPT += $(call gcc_ok,-freg-struct-return,)
+GCCOPT += -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
+ -msoft-float
+GCCOPT += $(call gcc_ok,-fno-exceptions,)
+GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
+GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
+GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
+GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+GCCOPT += $(call gcc_ok,-mincoming-stack-boundary=2,)
+
+LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
+
+LD += -m elf_i386
+
+# Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local
+CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES)
+SFLAGS += $(CFLAGS) -D__ASSEMBLY__
+
+.SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss
+
+%.o: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
+%.i: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
+%.s: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
+%.o: %.S
+ $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
+%.s: %.S
+ $(CC) $(MAKEDEPS) $(SFLAGS) -E -o $@ $<
diff --git a/mk/lib.mk b/mk/lib.mk
new file mode 100644
index 00000000..48b2a13d
--- /dev/null
+++ b/mk/lib.mk
@@ -0,0 +1,80 @@
+# -*- makefile -*-
+
+include $(MAKEDIR)/syslinux.mk
+
+GCCOPT := $(call gcc_ok,-std=gnu99,)
+GCCOPT += $(call gcc_ok,-m32,)
+GCCOPT += $(call gcc_ok,-fno-stack-protector,)
+GCCOPT += $(call gcc_ok,-fwrapv,)
+GCCOPT += $(call gcc_ok,-freg-struct-return,)
+GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+GCCOPT += $(call gcc_ok,-fno-exceptions,)
+GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
+GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
+GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
+GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+
+INCLUDE = -I.
+STRIP = strip --strip-all -R .comment -R .note
+
+# zlib and libpng configuration flags
+LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \
+ -DPNG_NO_WRITE_SUPPORTED \
+ -DPNG_NO_MNG_FEATURES \
+ -DPNG_NO_READ_tIME -DPNG_NO_WRITE_tIME
+
+# We need some features in libpng which apparently aren't available in the
+# fixed-point versions. It's OK, because we have to have a non-graphical
+# fallback anyway, just use that on old machines...
+# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED
+
+REQFLAGS = $(GCCOPT) -g -mregparm=3 -DREGPARM=3 -D__COM32__ \
+ -nostdinc -iwithprefix include -I. -I./sys -I../include
+OPTFLAGS = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \
+ -falign-labels=0 -ffast-math -fomit-frame-pointer
+WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
+
+CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
+LDFLAGS = -m elf32_i386
+
+.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
+
+% : %.c # Cancel default rule
+
+% : %.S
+
+.c.o:
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
+
+.c.i:
+ $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
+
+.c.s:
+ $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
+
+.S.s:
+ $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $<
+
+.S.lo:
+ $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -c -o $@ $<
+
+.S.ls:
+ $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -E -o $@ $<
+
+.s.o:
+ $(CC) $(MAKEDEPS) $(CFLAGS) -x assembler -c -o $@ $<
+
+.ls.lo:
+ $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -x assembler -c -o $@ $<
+
+.c.lo:
+ $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -c -o $@ $<
+
+.c.ls:
+ $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -S -o $@ $<
diff --git a/mk/rosh.mk b/mk/rosh.mk
new file mode 100644
index 00000000..7fdba0f1
--- /dev/null
+++ b/mk/rosh.mk
@@ -0,0 +1,27 @@
+## -*- 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 GRC configurables
+##
+
+## Include the COM32 common configurables
+include $(MAKEDIR)/com32.mk
+
+# CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
+# -fomit-frame-pointer -D__COM32__ \
+# -nostdinc -iwithprefix include \
+# -I$(com32)/libutil/include -I$(com32)/include
+# -g3 -dD
+
+# LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g3 -D_GNU_SOURCE -dD
+# -U__GNUC__
diff --git a/mk/syslinux.mk b/mk/syslinux.mk
new file mode 100644
index 00000000..6d87187f
--- /dev/null
+++ b/mk/syslinux.mk
@@ -0,0 +1,85 @@
+## -*- 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.
+##
+## -----------------------------------------------------------------------
+
+##
+## Common configurables
+##
+
+# No builtin rules
+MAKEFLAGS += -r
+MAKE += -r
+
+BINDIR = /usr/bin
+SBINDIR = /sbin
+LIBDIR = /usr/lib
+DATADIR = /usr/share
+AUXDIR = $(DATADIR)/syslinux
+DIAGDIR = $(AUXDIR)/diag
+MANDIR = /usr/man
+INCDIR = /usr/include
+TFTPBOOT = /tftpboot
+COM32DIR = $(AUXDIR)/com32
+
+BOOTDIR = /boot
+EXTLINUXDIR = $(BOOTDIR)/extlinux
+
+NASM = nasm
+NASMOPT = -Ox
+
+PERL = perl
+UPX = upx
+
+CHMOD = chmod
+
+CC = gcc
+gcc_ok = $(shell tmpf=gcc_ok.$$$$.tmp; \
+ if $(CC) $(GCCOPT) $(1) -c $(topdir)/dummy.c \
+ -o $$tmpf 2>/dev/null ; \
+ then echo '$(1)'; else echo '$(2)'; fi; \
+ rm -f $$tmpf)
+
+LD = ld
+OBJDUMP = objdump
+OBJCOPY = objcopy
+AR = ar
+NM = nm
+RANLIB = ranlib
+STRIP = strip
+GZIPPROG = gzip
+XZ = xz
+PNGTOPNM = pngtopnm
+MCOPY = mcopy
+MFORMAT = mformat
+MKISOFS = mkisofs
+SED = sed
+WGET = wget
+
+com32 = $(topdir)/com32
+
+# Common warnings we want for all gcc-generated code
+GCCWARN := -W -Wall -Wstrict-prototypes
+# Extremely useful variant for debugging...
+#GCCWARN += -Wno-clobbered -Werror
+
+# Common stanza to make gcc generate .*.d dependency files
+MAKEDEPS = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
+
+# Dependencies that exclude system headers; use whenever we use
+# header files from the platform.
+UMAKEDEPS = -Wp,-MT,$@,-MMD,$(dir $@).$(notdir $@).d
+
+# Items that are only appropriate during development; this file is
+# removed when tarballs are generated.
+-include $(MAKEDIR)/devel.mk
+
+# Local additions, like -DDEBUG can go here
+-include $(MAKEDIR)/local.mk