Changes in kernel/Makefile [7c682dd1:656437a0] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

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