Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c631734 in mainline


Ignore:
Timestamp:
2017-11-07T23:14:00Z (4 years ago)
Author:
jzr <zarevucky.jiri@…>
Branches:
lfn, master
Children:
cecba66e
Parents:
b8d4af4b
Message:

Mostly cleanup in uspace/Makefile.common.

  • Pass -MP in addition to -MD (also in boot and kernel).
  • Derive SLIBRARY and LSONAME from LIBRARY and (new)SOVERSION.
  • Removed include of version "makefile", which was unused.
  • Replaced OUTPUT and LOUTPUT with plural OUTPUTS, updated rules to match.
  • Moved things around so that first rule is after last variable assignment.
  • Removed '-n'(undesirable) and '-M'(redundant) from linker options.
  • Removed redundant rules at the tail of the file. GNU make bug #26893 seems to have been fixed years ago, and I can't reproduce any problem.
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.build

    rb8d4af4b rc631734  
    9393
    9494%.o: %.s | depend
    95         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
     95        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
    9696
    9797%.o: %.S | depend
    98         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
     98        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
    9999
    100100%.o: %.c | depend
    101         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS)
     101        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS)
    102102
    103103depend: $(PRE_DEPEND)
  • kernel/Makefile

    rb8d4af4b rc631734  
    414414
    415415%.o: %.S | depend
    416         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
     416        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
    417417
    418418%.o: %.s | depend
    419         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
     419        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__
    420420
    421421%.o: %.c | depend
    422         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) $(if $(findstring $<,$(INSTRUMENTED_SOURCES)),$(INSTRUMENTATION))
     422        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) $(if $(findstring $<,$(INSTRUMENTED_SOURCES)),$(INSTRUMENTATION))
    423423
    424424$(REAL_MAP).o: $(REAL_MAP).bin
  • uspace/Makefile.common

    rb8d4af4b rc631734  
    5353#                      (e.g. uses thread-local variables)
    5454#
    55 # Optionally, for a libary:
    56 #   SLIBRARY           Name with full version, e.g. libfoo.so.0.0
    57 #   LSONAME            Soname / name with short version, e.g. libfoo.so.0
     55# Optionally, for a library:
     56#   SOVERSION            shared library version (major.minor),
     57#                        if missing, no shared library is built
    5858#
    5959# (x) required variables
     
    6363ROOT_PATH = $(USPACE_PREFIX)/..
    6464
    65 VERSION_DEF = $(ROOT_PATH)/version
    66 
    6765COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
    6866COMMON_HEADER = $(ROOT_PATH)/common.h
     
    7169CONFIG_HEADER = $(ROOT_PATH)/config.h
    7270
    73 -include $(VERSION_DEF)
    7471-include $(COMMON_MAKEFILE)
    7572-include $(CONFIG_MAKEFILE)
    7673
     74OUTPUTS = $(EXTRA_OUTPUT)
     75
    7776ifneq ($(BINARY),)
    7877        JOB = $(BINARY).job
    79         OUTPUT = $(BINARY)
    8078        TEST_BINARY = test-$(BINARY)
    81         EXTRA_OUTPUT += $(BINARY).disasm
     79        OUTPUTS += $(BINARY) $(BINARY).disasm
    8280        EXTRA_CLEAN += $(BINARY).map
    8381endif
     
    8583ifneq ($(LIBRARY),)
    8684        JOB = $(LIBRARY).job
    87         OUTPUT = $(LIBRARY).a
    8885        TEST_BINARY = test-$(LIBRARY)
     86        OUTPUTS += $(LIBRARY).a
    8987endif
    9088
    9189ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
    92         ifneq ($(SLIBRARY),)
    93                 LARCHIVE = $(LIBRARY).la
    94                 LOUTPUT = $(SLIBRARY)
    95                 EXTRA_OUTPUT += $(LOUTPUT).disasm $(LIBRARY).so $(LSONAME)
    96                 EXTRA_CLEAN += $(LOUTPUT).map $(LOUTPUT).disasm \
    97                     $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld \
    98                     $(LIBRARY).so $(LSONAME)
     90        ifneq ($(SOVERSION),)
     91                SLIBRARY = $(LIBRARY).so.$(SOVERSION)
     92                LSONAME = $(LIBRARY).so.$(basename $(SOVERSION))
     93                OUTPUTS += $(SLIBRARY) $(SLIBRARY).disasm $(LSONAME)
     94                EXTRA_CLEAN += $(LIBRARY).la $(SLIBRARY).map
    9995        endif
    10096endif
     
    201197endif
    202198
     199LIB_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
     200
    203201ifeq ($(MATH),y)
    204202        INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) $(LIBMATH_INCLUDES_FLAGS)
     
    209207# PCUT-based unit tests
    210208ifneq ($(TEST_SOURCES),)
    211         TEST_OUTPUT = $(TEST_BINARY)
    212         TEST_DISASM = $(TEST_BINARY).disasm
     209        TEST_OUTPUTS = $(TEST_BINARY) $(TEST_BINARY).disasm
    213210        TEST_CFLAGS = -I$(LIB_PREFIX)/pcut/include -D__helenos__
    214         TEST_OUTPUT_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
    215         EXTRA_CLEAN += $(TEST_OUTPUT) $(TEST_OUTPUT).map $(TEST_DISASM)
     211        TEST_BINARY_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
     212        EXTRA_CLEAN += $(TEST_OUTPUTS) $(TEST_BINARY).map
    216213ifneq ($(LIBRARY),)
    217         TEST_OUTPUT_LIBS += $(OUTPUT)
    218 endif
    219         TEST_OUTPUT_LIBS += $(TEST_LIBS)
    220 endif
    221 
    222 .PHONY: all all-test clean depend
    223 
    224 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
    225 
    226 all-test: $(TEST_OUTPUT) $(TEST_DISASM)
    227 
    228 clean:
    229         rm -f $(JOB) $(OUTPUT) $(LARCHIVE) $(LOUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN)
     214        TEST_BINARY_LIBS += $(LIBRARY).a
     215endif
     216        TEST_BINARY_LIBS += $(TEST_LIBS)
     217endif
    230218
    231219COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     
    288276
    289277LIB_CFLAGS = $(CFLAGS) -fPIC
    290 LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
     278LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME)
    291279
    292280AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
     
    300288-include $(DEPENDS)
    301289
     290.PHONY: all all-test clean depend
     291
     292all: $(OUTPUTS)
     293
     294all-test: $(TEST_OUTPUTS)
     295
     296clean:
     297        rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN)
     298
     299depend: $(PRE_DEPEND)
     300
    302301%.disasm: %
    303302ifeq ($(CONFIG_LINE_DEBUG),y)
     
    309308ifneq ($(BINARY),)
    310309$(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBS) $(BASE_LIBS)
    311         $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(BINARY).map -o $(BINARY) $(OBJECTS) $(LIBS) $(BASE_LIBS)
    312 endif
    313 
    314 ifneq ($(SLIBRARY),)
    315 $(LOUTPUT): $(LARCHIVE) $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
    316         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld $(LIB_LFLAGS) $(LARCHIVE) -o $@ -Map $(LOUTPUT).map
    317 
    318 $(LIBRARY).so:
    319         ln -s $(SLIBRARY) $@
    320 
    321 $(LSONAME):
    322         ln -s $(SLIBRARY) $@
     310        $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(OBJECTS) $(LIBS) $(BASE_LIBS)
     311endif
     312
     313ifneq ($(TEST_BINARY),)
     314$(TEST_BINARY): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_BINARY_LIBS)
     315        $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBS) $(BASE_LIBS)
    323316endif
    324317
     
    328321endif
    329322
    330 ifneq ($(LARCHIVE),)
    331 $(LARCHIVE): $(LOBJECTS)
     323ifneq ($(SLIBRARY),)
     324$(LIBRARY).la: $(LOBJECTS)
    332325        $(AR) rc $@ $(LOBJECTS)
    333 endif
    334 
    335 ifneq ($(TEST_OUTPUT),)
    336 $(TEST_OUTPUT): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS)
    337         $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(TEST_OUTPUT).map -o $@ $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) $(LIBS) $(BASE_LIBS)
     326
     327$(SLIBRARY): $(LIB_LINKER_SCRIPT) $(LIBRARY).la
     328        $(LD) $(LIB_LFLAGS) -T $(LIB_LINKER_SCRIPT) -Map $@.map -o $@ --whole-archive $(LIBRARY).la --no-whole-archive
     329
     330$(LSONAME):
     331        ln -s $(SLIBRARY) $@
    338332endif
    339333
    340334%.o: %.S | depend
    341         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     335        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    342336
    343337%.o: %.s | depend
    344         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     338        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    345339
    346340%.o: %.c | depend
    347         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
     341        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
    348342
    349343%.test.o: %.c | depend
    350         $(CC_JOB) -c -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
     344        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
    351345
    352346%.lo: %.S | depend
    353         $(CC_JOB) -c -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     347        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    354348
    355349%.lo: %.s | depend
    356         $(CC_JOB) -c -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     350        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    357351
    358352%.lo: %.c | depend
    359         $(CC_JOB) -c -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
    360 
    361 depend: $(PRE_DEPEND)
    362 
    363 ##
    364 # This explicit dependecy of the output binary on the object files seems to be
    365 # necessary to prevent parallel build failures (GNU make bug #26893 ???).
    366 $(OUTPUT): $(OBJECTS)
    367 
    368 $(LARCHIVE): $(LOBJECTS)
     353        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
     354
  • uspace/lib/c/Makefile

    rb8d4af4b rc631734  
    4343EXTRA_CLEAN = $(LINKER_SCRIPTS)
    4444LIBRARY = libc
    45 SLIBRARY = libc.so.0.0
    46 LSONAME = libc.so.0
     45SOVERSION = 0.0
    4746
    4847-include $(CONFIG_MAKEFILE)
  • uspace/lib/dltest/Makefile

    rb8d4af4b rc631734  
    2929USPACE_PREFIX = ../..
    3030LIBRARY = libdltest
    31 SLIBRARY = libdltest.so.0.0
    32 LSONAME = libdltest.so.0
     31SOVERSION = 0.0
    3332
    3433SOURCES = \
  • uspace/lib/math/Makefile

    rb8d4af4b rc631734  
    3333
    3434LIBRARY = libmath
    35 SLIBRARY = libmath.so.0.0
    36 LSONAME = libmath.so.0
     35SOVERSION = 0.0
    3736MATH = y
    3837
  • uspace/lib/pcut/Makefile

    rb8d4af4b rc631734  
    3535all-test: $(SELF_TESTS)
    3636
    37 test-libpcut-%: $(OUTPUT)
    38         $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -o $@ $(STARTUP) $^ $(OUTPUT) $(BASE_LIBS)
     37test-libpcut-%: $(LIBRARY).a
     38        $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -o $@ $(STARTUP) $^ $(LIBRARY).a $(BASE_LIBS)
    3939
  • uspace/lib/pcut/update-from-master.sh

    rb8d4af4b rc631734  
    7979all-test: $(SELF_TESTS)
    8080
    81 test-libpcut-%: $(OUTPUT)
    82         $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -o $@ $(STARTUP) $^ $(OUTPUT) $(BASE_LIBS)
     81test-libpcut-%: $(LIBRARY).a
     82        $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -o $@ $(STARTUP) $^ $(LIBRARY).a $(BASE_LIBS)
    8383
    8484EOF_MAKEFILE_TAIL
  • uspace/lib/softint/Makefile

    rb8d4af4b rc631734  
    3131EXTRA_CFLAGS = -Iinclude
    3232LIBRARY = libsoftint
    33 SLIBRARY = libsoftint.so.0.0
    34 LSONAME = libsoftint.so.0
     33SOVERSION = 0.0
    3534
    3635SOURCES = \
Note: See TracChangeset for help on using the changeset viewer.