[BACK]Return to Makefile.inc CVS log [TXT][DIR] Up to [local] / prex-old / mk

Annotation of prex-old/mk/Makefile.inc, Revision 1.1

1.1     ! nbrk        1: #
        !             2: # Makefile.inc - common make rules to build Prex
        !             3: #
        !             4:
        !             5: # Supported environment variables
        !             6: #
        !             7: #  SRCDIR        ... Root directory of source tree
        !             8: #  ARCH          ... Architecture name
        !             9: #  PLATFORM      ... Platform name
        !            10: #  NDEBUG        ... 0 for debug, 1 for release (default: 0)
        !            11: #  LIBGCC_PATH   ... Full path for libgcc.a
        !            12: #  CROSS_COMPILE ... Prefix of tools for cross compile
        !            13: #
        !            14: # Variables in local Makefile
        !            15: #
        !            16: #  TARGET      ... Target file name
        !            17: #  TYPE                ... Traget type
        !            18: #                  e.g. OBJECT,LIBRARY,KERNEL,BINARY,EXEC,DRIVER,OS_IMAGE
        !            19: #  SUBDIR      ... List of subdirectories
        !            20: #  OBJS                ... Object files
        !            21: #  OBJS-y      ... Object files (for drivers)
        !            22: #  LIBS                ... Libraries
        !            23: #  MAP         ... Name of map file
        !            24: #  DISASM      ... Disassemble list file
        !            25: #  SYMBOL      ... Symbol files
        !            26: #
        !            27:
        !            28: #
        !            29: # Option for cross compile
        !            30: #
        !            31: #CROSS_COMPILE=
        !            32: #CROSS_COMPILE=        i386-elf-
        !            33: #CROSS_COMPILE=        arm-elf-
        !            34: #CROSS_COMPILE=        powerpc-eabi-
        !            35: #CROSS_COMPILE=        sh-elf-
        !            36: #CROSS_COMPILE=        mips-elf-
        !            37:
        !            38: #
        !            39: # Tools
        !            40: #
        !            41: CC=            $(CROSS_COMPILE)gcc
        !            42: CPP=           $(CROSS_COMPILE)cpp
        !            43: AS=            $(CROSS_COMPILE)as
        !            44: LD=            $(CROSS_COMPILE)ld
        !            45: AR=            $(CROSS_COMPILE)ar
        !            46: OBJCOPY=       $(CROSS_COMPILE)objcopy
        !            47: OBJDUMP=       $(CROSS_COMPILE)objdump
        !            48: STRIP=         $(CROSS_COMPILE)strip
        !            49: LINT=          splint
        !            50: MAKE=          make
        !            51: #SHELL=                /bin/sh
        !            52: ifdef SHELL_PATH
        !            53: SHELL=         $(SHELL_PATH)
        !            54: endif
        !            55: ifdef DISASM
        !            56: ASMGEN=                $(OBJDUMP) $@ --disassemble-all > $(DISASM)
        !            57: endif
        !            58:
        !            59: #
        !            60: # System dependent options
        !            61: #
        !            62: include $(SRCDIR)/mk/own.mk
        !            63:
        !            64: #
        !            65: # Flags
        !            66: #
        !            67: DEFS=          -D__$(ARCH)__ -D__$(PLATFORM)__ \
        !            68:                -D__ARCH__=$(ARCH) -D__PLATFORM__=$(PLATFORM) \
        !            69:                -U$(ARCH) -U$(PLATFORM)
        !            70:
        !            71: CFLAGS+=       -Os -ansi -pedantic -fno-strict-aliasing \
        !            72:                -Wall -Wundef -Wstrict-prototypes -Wpointer-arith \
        !            73:                $(CONFIG_CFLAGS) $(DEFS)
        !            74:
        !            75: ifeq ($(NDEBUG),1)
        !            76: CFLAGS+=       -fomit-frame-pointer
        !            77: else
        !            78: CFLAGS+=       -fno-omit-frame-pointer -DDEBUG -g
        !            79: endif
        !            80:
        !            81: CPPFLAGS+=     $(DEFS)
        !            82: ASFLAGS+=      $(DEFS) -D__ASSEMBLY__
        !            83: ifdef MAP
        !            84: LDFLAGS+=      -Map $(MAP)
        !            85: endif
        !            86: LDFLAGS+=
        !            87: MAKEFLAGS+=    -rR --no-print-directory
        !            88: LINTFLAGS+=    -D__lint__ $(DEFS) -nolib -weak -fcnuse -nestcomment \
        !            89:                -retvalother -fullinitblock
        !            90:
        !            91: #
        !            92: # Specify path for libgcc.a
        !            93: #
        !            94: ifndef LIBGCC_PATH
        !            95: LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
        !            96: endif
        !            97: LIBGCC = $(LIBGCC_PATH)libgcc.a
        !            98:
        !            99: #
        !           100: # Inference rules
        !           101: #
        !           102: %.o: %.c
        !           103:        $(CC) $(CFLAGS) -c -o $@ $<
        !           104:
        !           105: %.o: %.s
        !           106:        $(AS) -o $@ $<
        !           107:
        !           108: %.o: %.S
        !           109:        $(CPP) $(ASFLAGS) $< $*.tmp
        !           110:        $(AS) -o $@ $*.tmp
        !           111:        rm -f $*.tmp
        !           112:
        !           113: #
        !           114: # Target
        !           115: #
        !           116: all: $(SUBDIR) $(TARGET)
        !           117:
        !           118: #
        !           119: # Check configuration
        !           120: #
        !           121: ifeq (0, ${MAKELEVEL})
        !           122: # add dependency on config.h
        !           123: $(SUBDIR):$(SRCDIR)/conf/config.h
        !           124:
        !           125: $(SRCDIR)/conf/config.h: dummy
        !           126:        @if [ ! -f $@ ]; then \
        !           127:                echo 'You must run `configure` before make.' ;\
        !           128:                exit 1 ;\
        !           129:        fi
        !           130: endif
        !           131:
        !           132: #
        !           133: # Rules to process sub-directory
        !           134: #
        !           135: ifdef SUBDIR
        !           136: .PHONY: $(SUBDIR)
        !           137: $(SUBDIR): dummy
        !           138:        $(MAKE) -C $@
        !           139: endif
        !           140:
        !           141: #
        !           142: # Rules to link a set of .o files into one .o file
        !           143: #
        !           144: ifeq ($(TYPE),OBJECT)
        !           145: $(TARGET): $(OBJS) $(OBJS-y)
        !           146:        $(LD) $(LDFLAGS) -r -o $@ $^
        !           147: endif
        !           148:
        !           149: #
        !           150: # Rules to compile library
        !           151: #
        !           152: ifeq ($(TYPE),LIBRARY)
        !           153: $(TARGET): $(OBJS) ar-target
        !           154:
        !           155: .PHONY: ar-target
        !           156: ar-target: $(OBJS)
        !           157:        $(AR) rucs $(TARGET) $?
        !           158:        $(STRIP) -x -R .comment -R .note $(TARGET)
        !           159: endif
        !           160:
        !           161: #
        !           162: # Rules to compile kernel
        !           163: #
        !           164: ifeq ($(TYPE),KERNEL)
        !           165: $(TARGET): $(OBJS) $(LIBS) $(LDS_SCRIPT)
        !           166:        $(LD) $(LDFLAGS) -T $(LD_SCRIPT) -o $@ $(OBJS) $(LIBS) $(LIBGCC)
        !           167:        $(ASMGEN)
        !           168: ifdef SYMBOL
        !           169:        cp $@ $(SYMBOL)
        !           170: endif
        !           171:        $(STRIP) -s $@
        !           172: endif
        !           173:
        !           174: #
        !           175: # Rules to compile device driver
        !           176: #
        !           177: ifeq ($(TYPE),DRIVER)
        !           178: $(TARGET):  $(OBJS) $(OBJS-y) $(LDS_SCRIPT)
        !           179:        $(LD) --error-unresolved-symbols $(LDFLAGS) -T $(LD_SCRIPT) -o $@.tmp $(OBJS) $(LIBS) $(LIBGCC)
        !           180:        rm -f $@.tmp
        !           181:        $(LD) -r $(LDFLAGS) -T $(LD_SCRIPT) -o $@ $(OBJS) $(LIBS) $(LIBGCC)
        !           182:        $(ASMGEN)
        !           183: ifdef SYMBOL
        !           184:        cp $@ $(SYMBOL)
        !           185: endif
        !           186:        $(STRIP) --strip-debug --strip-unneeded $@
        !           187: endif
        !           188:
        !           189: #
        !           190: # Rules to compile binary file
        !           191: #
        !           192: ifeq ($(TYPE),BINARY)
        !           193: $(TARGET): $(OBJS) $(LDS_SCRIPT)
        !           194:        $(LD) $(LDFLAGS) -T $(LD_SCRIPT) -o $@ $(OBJS) $(LIBS) $(LIBGCC)
        !           195:        $(ASMGEN)
        !           196: ifdef SYMBOL
        !           197:        cp $@ $(SYMBOL)
        !           198: endif
        !           199:        $(OBJCOPY) $(OBJCOPYFLAGS) $@
        !           200: endif
        !           201:
        !           202: #
        !           203: # Rules to compile executable file
        !           204: #
        !           205: ifeq ($(TYPE),EXEC)
        !           206: $(TARGET): $(OBJS) $(LIBS) $(LDS_SCRIPT)
        !           207:        $(LD) $(LDFLAGS) -T $(LD_SCRIPT) -o $@ \
        !           208:        $(CRT0) $(OBJS) $(LIBS) $(LIBC) $(LIBGCC)
        !           209:        $(ASMGEN)
        !           210: ifdef SYMBOL
        !           211:        cp $@ $(SYMBOL)
        !           212: endif
        !           213:        $(STRIP) --strip-debug --strip-unneeded $@
        !           214: endif
        !           215:
        !           216: #
        !           217: # Rules to create OS image
        !           218: #
        !           219: ifeq ($(TYPE),OS_IMAGE)
        !           220: $(TARGET): dummy
        !           221: ifdef BOOTFILES
        !           222:        $(AR) rcS ramdisk.a $(BOOTFILES)
        !           223:        $(AR) t ramdisk.a
        !           224:        $(AR) rcS tmp.a $(KERNEL) $(DRIVER) $(BOOTTASKS) ramdisk.a
        !           225:        rm ramdisk.a
        !           226: else
        !           227:        $(AR) rcS tmp.a $(KERNEL) $(DRIVER) $(BOOTTASKS)
        !           228: endif
        !           229:        $(AR) t tmp.a
        !           230:        cat $(LOADER) tmp.a > $@
        !           231:        rm tmp.a
        !           232: endif
        !           233:
        !           234:
        !           235: -include Makefile.dep
        !           236:
        !           237: C_SRCS = $(wildcard *.c) $(wildcard *.S)
        !           238:
        !           239: #
        !           240: # Depend
        !           241: #
        !           242: .PHONY: depend dep
        !           243: depend dep:
        !           244: ifdef SUBDIR
        !           245:        @(for d in $(SUBDIR) _ ; do \
        !           246:          if [ "$$d" != "_" ] ; then $(MAKE) -C $$d depend; fi; \
        !           247:        done);
        !           248: endif
        !           249:        rm -f Makefile.dep
        !           250:        @(for d in $(C_SRCS) _ ; do \
        !           251:          if [ "$$d" != "_" ] ; then \
        !           252:          $(CPP) -M $(CPPFLAGS) $$d >> Makefile.dep; fi; \
        !           253:        done);
        !           254: #
        !           255: # Lint
        !           256: #
        !           257: .PHONY: lint
        !           258: lint:
        !           259:        @(for d in $(C_SRCS) _ ; do \
        !           260:          if [ "$$d" != "_" ] ; then \
        !           261:          $(LINT) $(LINTFLAGS) $(INCLUDE) $$d; fi; \
        !           262:        done);
        !           263:
        !           264: #
        !           265: # Clean up
        !           266: #
        !           267: .PHONY: clean
        !           268: clean:
        !           269: ifdef SUBDIR
        !           270:        @(for d in $(SUBDIR) _ ; do \
        !           271:          if [ "$$d" != "_" ] ; then $(MAKE) -C $$d clean; fi; \
        !           272:        done);
        !           273: endif
        !           274:        rm -f Makefile.dep $(TARGET) $(OBJS) $(OBJS-y) $(DISASM) $(MAP) $(SYMBOL) $(CLEANS)
        !           275:
        !           276: .PHONY: dummy

CVSweb