| ## -*- 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 $(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 |
| |
| ifneq ($(NOGPL),1) |
| GPLLIB = $(com32)/gpllib/libcom32gpl.a |
| GPLINCLUDE = -I$(com32)/gplinclude |
| else |
| GPLLIB = |
| GPLINCLUDE = |
| endif |
| |
| CFLAGS = $(GCCOPT) -W -Wall -march=i386 \ |
| -fomit-frame-pointer -D__COM32__ \ |
| -nostdinc -iwithprefix include \ |
| -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) |
| SFLAGS = $(GCCOPT) -W -Wall -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 -T $(COM32LD) |
| 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 $(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 $< $@ |