Changes in kernel/Makefile [646b996:8786aa5] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r646b996 r8786aa5  
    2727#
    2828
     29include Makefile.common
    2930
    30 ## Include configuration
    31 #
     31.PHONY: all clean
    3232
    33 include ../version
    34 -include ../Makefile.config
    35 -include ../config.defs
    36 
    37 INCLUDES = generic/include
    38 OPTIMIZATION = 3
    39 
    40 ifndef CROSS_PREFIX
    41         CROSS_PREFIX = /usr/local
    42 endif
    43 
    44 ## Common compiler flags
    45 #
    46 
    47 DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
    48 
    49 GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
    50         -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    51         -finput-charset=UTF-8 -fno-builtin -Wall -Wextra -Wno-unused-parameter \
    52         -Wmissing-prototypes -Werror -nostdlib -nostdinc -pipe
    53 
    54 ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
    55         -fno-builtin -Wall -Wmissing-prototypes -Werror \
    56         -nostdlib -nostdinc \
    57         -wd170
    58 
    59 SUNCC_CFLAGS = -I$(INCLUDES) -xO$(OPTIMIZATION) \
    60         -xnolib -xc99=all -features=extensions \
    61         -erroff=E_ZERO_SIZED_STRUCT_UNION
    62 
    63 LFLAGS = -M
    64 AFLAGS =
    65 
    66 -include arch/$(KARCH)/Makefile.inc
    67 -include genarch/Makefile.inc
    68 
    69 ## The at-sign
    70 #
    71 # The $(ATSIGN) variable holds the ASCII character representing the at-sign
    72 # ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
    73 # don't use '@' for starting a comment, $(ATSIGN) is merely '@'. However, on
    74 # those that do use it for starting a comment (e.g. arm32), $(ATSIGN) must be
    75 # defined as the percentile-sign ('%') in the architecture-dependent
    76 # Makefile.inc.
    77 #
    78 ATSIGN ?= @
    79 
    80 ## Cross-platform assembly to start a symtab.data section
    81 #
    82 SYMTAB_SECTION=".section symtab.data, \"a\", $(ATSIGN)progbits;"
    83 
    84 ## Simple detection for the type of the host system
    85 #
    86 HOST = $(shell uname)
    87 
    88 ## On Solaris, some utilities have slightly different names
    89 #
    90 ifeq ($(HOST),SunOS)
    91         BINUTILS_PREFIX = "g"
    92 else
    93         BINUTILS_PREFIX = ""
    94 endif
    95 
    96 ## Toolchain configuration
    97 #
    98 
    99 ifeq ($(COMPILER),gcc_native)
    100         CC = gcc
    101         GCC = gcc
    102         AS = $(BINUTILS_PREFIX)as
    103         LD = $(BINUTILS_PREFIX)ld
    104         OBJCOPY = $(BINUTILS_PREFIX)objcopy
    105         OBJDUMP = $(BINUTILS_PREFIX)objdump
    106         LIBDIR = /usr/lib
    107         CFLAGS = $(GCC_CFLAGS)
    108         DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    109 endif
    110 
    111 ifeq ($(COMPILER),icc_native)
    112         CC = icc
    113         GCC = gcc
    114         AS = as
    115         LD = ld
    116         OBJCOPY = objcopy
    117         OBJDUMP = objdump
    118         LIBDIR = /usr/lib
    119         CFLAGS = $(ICC_CFLAGS)
    120         DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    121 endif
    122 
    123 ifeq ($(COMPILER),suncc_native)
    124         CC = suncc
    125         GCC = gcc
    126         AS = $(BINUTILS_PREFIX)as
    127         LD = $(BINUTILS_PREFIX)ld
    128         OBJCOPY = $(BINUTILS_PREFIX)objcopy
    129         OBJDUMP = $(BINUTILS_PREFIX)objdump
    130         LIBDIR = /usr/lib
    131         CFLAGS = $(SUNCC_CFLAGS)
    132         DEFS += $(CONFIG_DEFS)
    133         DEPEND_DEFS = $(DEFS)
    134 endif
    135 
    136 ifeq ($(COMPILER),gcc_cross)
    137         CC = $(TOOLCHAIN_DIR)/bin/$(TARGET)-gcc
    138         GCC = $(CC)
    139         AS = $(TOOLCHAIN_DIR)/bin/$(TARGET)-as
    140         LD = $(TOOLCHAIN_DIR)/bin/$(TARGET)-ld
    141         OBJCOPY = $(TOOLCHAIN_DIR)/bin/$(TARGET)-objcopy
    142         OBJDUMP = $(TOOLCHAIN_DIR)/bin/$(TARGET)-objdump
    143         LIBDIR = $(TOOLCHAIN_DIR)/lib
    144         CFLAGS = $(GCC_CFLAGS)
    145         DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    146 endif
    147 
    148 ## Generic kernel sources
    149 #
    150 
    151 GENERIC_SOURCES = \
    152         generic/src/adt/avl.c \
    153         generic/src/adt/bitmap.c \
    154         generic/src/adt/btree.c \
    155         generic/src/adt/hash_table.c \
    156         generic/src/adt/list.c \
    157         generic/src/console/chardev.c \
    158         generic/src/console/console.c \
    159         generic/src/cpu/cpu.c \
    160         generic/src/ddi/ddi.c \
    161         generic/src/ddi/irq.c \
    162         generic/src/ddi/device.c \
    163         generic/src/debug/symtab.c \
    164         generic/src/interrupt/interrupt.c \
    165         generic/src/main/main.c \
    166         generic/src/main/kinit.c \
    167         generic/src/main/uinit.c \
    168         generic/src/main/version.c \
    169         generic/src/main/shutdown.c \
    170         generic/src/proc/program.c \
    171         generic/src/proc/scheduler.c \
    172         generic/src/proc/thread.c \
    173         generic/src/proc/task.c \
    174         generic/src/proc/the.c \
    175         generic/src/proc/tasklet.c \
    176         generic/src/syscall/syscall.c \
    177         generic/src/syscall/copy.c \
    178         generic/src/mm/buddy.c \
    179         generic/src/mm/frame.c \
    180         generic/src/mm/page.c \
    181         generic/src/mm/tlb.c \
    182         generic/src/mm/as.c \
    183         generic/src/mm/backend_anon.c \
    184         generic/src/mm/backend_elf.c \
    185         generic/src/mm/backend_phys.c \
    186         generic/src/mm/slab.c \
    187         generic/src/lib/func.c \
    188         generic/src/lib/memstr.c \
    189         generic/src/lib/sort.c \
    190         generic/src/lib/string.c \
    191         generic/src/lib/elf.c \
    192         generic/src/lib/rd.c \
    193         generic/src/printf/printf_core.c \
    194         generic/src/printf/printf.c \
    195         generic/src/printf/snprintf.c \
    196         generic/src/printf/vprintf.c \
    197         generic/src/printf/vsnprintf.c \
    198         generic/src/time/clock.c \
    199         generic/src/time/timeout.c \
    200         generic/src/time/delay.c \
    201         generic/src/preempt/preemption.c \
    202         generic/src/synch/spinlock.c \
    203         generic/src/synch/condvar.c \
    204         generic/src/synch/rwlock.c \
    205         generic/src/synch/mutex.c \
    206         generic/src/synch/semaphore.c \
    207         generic/src/synch/smc.c \
    208         generic/src/synch/waitq.c \
    209         generic/src/synch/futex.c \
    210         generic/src/smp/ipi.c \
    211         generic/src/smp/smp.c \
    212         generic/src/ipc/ipc.c \
    213         generic/src/ipc/sysipc.c \
    214         generic/src/ipc/ipcrsc.c \
    215         generic/src/ipc/irq.c \
    216         generic/src/ipc/event.c \
    217         generic/src/security/cap.c \
    218         generic/src/sysinfo/sysinfo.c
    219 
    220 ## Kernel console support
    221 #
    222 
    223 ifeq ($(CONFIG_KCONSOLE),y)
    224 GENERIC_SOURCES += \
    225         generic/src/console/kconsole.c \
    226         generic/src/console/cmd.c
    227 endif
    228 
    229 ## Udebug interface sources
    230 #
    231 
    232 ifeq ($(CONFIG_UDEBUG),y)
    233 GENERIC_SOURCES += \
    234         generic/src/ipc/kbox.c \
    235         generic/src/udebug/udebug.c \
    236         generic/src/udebug/udebug_ops.c \
    237         generic/src/udebug/udebug_ipc.c
    238 endif
    239 
    240 ## Test sources
    241 #
    242 
    243 ifeq ($(CONFIG_TEST),y)
    244         CFLAGS += -Itest/
    245         GENERIC_SOURCES += \
    246                 test/test.c \
    247                 test/atomic/atomic1.c \
    248                 test/btree/btree1.c \
    249                 test/avltree/avltree1.c \
    250                 test/fault/fault1.c \
    251                 test/mm/falloc1.c \
    252                 test/mm/falloc2.c \
    253                 test/mm/mapping1.c \
    254                 test/mm/slab1.c \
    255                 test/mm/slab2.c \
    256                 test/synch/rwlock1.c \
    257                 test/synch/rwlock2.c \
    258                 test/synch/rwlock3.c \
    259                 test/synch/rwlock4.c \
    260                 test/synch/rwlock5.c \
    261                 test/synch/semaphore1.c \
    262                 test/synch/semaphore2.c \
    263                 test/print/print1.c \
    264                 test/print/print2.c \
    265                 test/print/print3.c \
    266                 test/print/print4.c \
    267                 test/thread/thread1.c \
    268                 test/sysinfo/sysinfo1.c
    269        
    270         ifeq ($(KARCH),mips32)
    271                 GENERIC_SOURCES += test/debug/mips1.c
    272         else
    273                 GENERIC_SOURCES += test/debug/mips1_skip.c
    274         endif
    275        
    276         ifeq ($(KARCH),ia64)
    277                 GENERIC_SOURCES += test/mm/purge1.c
    278         else
    279                 GENERIC_SOURCES += test/mm/purge1_skip.c
    280         endif
    281        
    282         ifeq ($(CONFIG_FPU),y)
    283                 ifeq ($(KARCH),ia32)
    284                         TEST_FPU1 = y
    285                         TEST_SSE1 = y
    286                         GENERIC_SOURCES += test/fpu/fpu1_x86.c
    287                 endif
    288                
    289                 ifeq ($(KARCH),amd64)
    290                         TEST_FPU1 = y
    291                         TEST_SSE1 = y
    292                         GENERIC_SOURCES += test/fpu/fpu1_x86.c
    293                 endif
    294                
    295                 ifeq ($(KARCH),ia64)
    296                         TEST_FPU1 = y
    297                         GENERIC_SOURCES += test/fpu/fpu1_ia64.c
    298                 endif
    299                
    300                 ifeq ($(KARCH),mips32)
    301                         TEST_MIPS2 = y
    302                 endif
    303         endif
    304        
    305         ifneq ($(TEST_FPU1),y)
    306                 GENERIC_SOURCES += test/fpu/fpu1_skip.c
    307         endif
    308        
    309         ifeq ($(TEST_SSE1),y)
    310                 GENERIC_SOURCES += test/fpu/sse1.c
    311         else
    312                 GENERIC_SOURCES += test/fpu/sse1_skip.c
    313         endif
    314        
    315         ifeq ($(TEST_MIPS2),y)
    316                 GENERIC_SOURCES += test/fpu/mips2.c
    317         else
    318                 GENERIC_SOURCES += test/fpu/mips2_skip.c
    319         endif
    320        
    321 endif
    322 
    323 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
    324 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
    325 GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
    326 
    327 ifeq ($(CONFIG_SYMTAB),y)
    328         SYMTAB_OBJECTS := generic/src/debug/real_map.o
    329 else
    330         SYMTAB_OBJECTS :=
    331 endif
    332 
    333 .PHONY: all build clean archlinks depend disasm
    334 
    335 all: ../Makefile.config ../config.h ../config.defs
    336         -rm Makefile.depend
    337         $(MAKE) -C . build
    338 
    339 build: kernel.bin disasm
    340 
    341 -include Makefile.depend
     33all: ../version ../Makefile.config ../config.h ../config.defs
     34        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     35        $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
    34236
    34337clean:
    344         -rm -f kernel.bin kernel.raw kernel.map kernel.map.pre kernel.objdump kernel.disasm generic/src/debug/real_map.bin Makefile.depend* generic/include/arch generic/include/genarch arch/$(KARCH)/_link.ld
     38        rm -f $(DEPEND) $(DEPEND_PREV) $(RAW) $(BIN) $(MAP) $(JOB) $(MAP_PREV) $(DISASM) $(DUMP) $(REAL_MAP).* $(ARCH_INCLUDE) $(GENARCH_INCLUDE) arch/*/_link.ld
    34539        find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm \{\} \;
    346         for arch in arch/* ; do \
    347             [ -e $$arch/_link.ld ] && rm $$arch/_link.ld 2>/dev/null ; \
    348         done ; exit 0
    349 
    350 archlinks:
    351         ln -sfn ../../arch/$(KARCH)/include/ generic/include/arch
    352         ln -sfn ../../genarch/include/ generic/include/genarch
    353 
    354 depend: archlinks
    355         -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
    356 
    357 arch/$(KARCH)/_link.ld: arch/$(KARCH)/_link.ld.in
    358         $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
    359 
    360 generic/src/debug/real_map.bin: depend arch/$(KARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
    361         echo $(SYMTAB_SECTION) | $(AS) $(AFLAGS) -o generic/src/debug/empty_map.o
    362         $(LD) -T arch/$(KARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) generic/src/debug/empty_map.o  -o $@ -Map kernel.map.pre
    363         $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > kernel.objdump
    364         tools/genmap.py kernel.map.pre kernel.objdump generic/src/debug/real_map.bin
    365         # Do it once again, this time to get correct even the symbols
    366         # on architectures, that have bss after symtab
    367         echo $(SYMTAB_SECTION)" .incbin \"$@\"" | $(AS) $(AFLAGS) -o generic/src/debug/sizeok_map.o
    368         $(LD) -T arch/$(KARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) generic/src/debug/sizeok_map.o -o $@ -Map kernel.map.pre
    369         $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > kernel.objdump
    370         tools/genmap.py kernel.map.pre kernel.objdump generic/src/debug/real_map.bin
    371 
    372 generic/src/debug/real_map.o: generic/src/debug/real_map.bin
    373         echo $(SYMTAB_SECTION)" .incbin \"$<\"" | $(AS) $(AFLAGS) -o $@
    374 
    375 kernel.raw: depend arch/$(KARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
    376         $(LD) -T arch/$(KARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS) -o $@ -Map kernel.map
    377 
    378 kernel.bin: kernel.raw
    379         $(OBJCOPY) -O $(BFD) kernel.raw kernel.bin
    380 
    381 disasm: kernel.raw
    382         $(OBJDUMP) -d kernel.raw > kernel.disasm
    383 
    384 %.o: %.S
    385         $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
    386 
    387 %.o: %.s
    388         $(AS) $(AFLAGS) $< -o $@
    389 
    390 #
    391 # The FPU tests are the only objects for which we allow the compiler to generate
    392 # FPU instructions.
    393 #
    394 test/fpu/%.o: test/fpu/%.c
    395         $(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) -c $< -o $@
    396 
    397 #
    398 # Ordinary objects.
    399 #
    400 %.o: %.c
    401         $(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) -c $< -o $@
Note: See TracChangeset for help on using the changeset viewer.