Changes in uspace/Makefile.common [9c14309:e6ae77a] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile.common

    r9c14309 re6ae77a  
    4444#   EXTRA_CLEAN        additional cleanup targets
    4545#
    46 #   MATH               set to 'y' to use the math library
    47 #   POSIX_COMPAT       set to 'y' to use POSIX compatibility layer
    48 #
    4946# Optionally, for a binary:
    5047#   STATIC_NEEDED      set to 'y' for init binaries, will build statically
     
    5350#                      (e.g. uses thread-local variables)
    5451#
    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
     52# Optionally, for a library:
     53#   SOVERSION            shared library version (major.minor),
     54#                        if missing, no shared library is built
    5855#
    5956# (x) required variables
     
    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).ldisasm \
    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
     
    116112
    117113LIBPOSIX_PREFIX = $(LIB_PREFIX)/posix
    118 
    119 LIBCRYPTO_PREFIX = $(LIB_PREFIX)/crypto
    120 LIBBLOCK_PREFIX = $(LIB_PREFIX)/block
    121 LIBFDISK_PREFIX = $(LIB_PREFIX)/fdisk
    122 LIBLABEL_PREFIX = $(LIB_PREFIX)/label
    123 LIBFS_PREFIX = $(LIB_PREFIX)/fs
    124 LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
    125 LIBFMTUTIL_PREFIX = $(LIB_PREFIX)/fmtutil
    126 
    127 LIBGRAPH_PREFIX = $(LIB_PREFIX)/graph
    128 LIBSOFTREND_PREFIX = $(LIB_PREFIX)/softrend
    129 LIBDRAW_PREFIX = $(LIB_PREFIX)/draw
    130 LIBGUI_PREFIX = $(LIB_PREFIX)/gui
    131 
    132 LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4
    133 
    134 LIBUSB_PREFIX = $(LIB_PREFIX)/usb
    135 LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost
    136 LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev
    137 LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid
    138 LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt
    139 
    140 LIBDRV_PREFIX = $(LIB_PREFIX)/drv
    141 LIBHOUND_PREFIX = $(LIB_PREFIX)/hound
    142 LIBPCM_PREFIX = $(LIB_PREFIX)/pcm
    143 LIBNIC_PREFIX = $(LIB_PREFIX)/nic
    144 LIBIEEE80211_PREFIX = $(LIB_PREFIX)/ieee80211
    145 LIBMINIX_PREFIX = $(LIB_PREFIX)/minix
    146 LIBCOMPRESS_PREFIX = $(LIB_PREFIX)/compress
    147114LIBDLTEST_PREFIX = $(LIB_PREFIX)/dltest
    148115
    149 LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi
    150 LIBTRACKMOD_PREFIX = $(LIB_PREFIX)/trackmod
    151 
    152 LIBBITHENGE_PREFIX = $(LIB_PREFIX)/bithenge
    153 
    154 LIBHTTP_PREFIX = $(LIB_PREFIX)/http
    155 LIBURI_PREFIX = $(LIB_PREFIX)/uri
    156 
    157 LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl
    158 
    159 AFLAGS =
    160 LFLAGS = --fatal-warnings
    161 
    162 # FIXME: This condition is a workaround for issues #692 and #693.
    163 ifneq ($(KARCH),ia64)
    164 ifneq ($(KARCH),mips32)
    165         AFLAGS += --fatal-warnings
    166 endif
    167 endif
     116AFLAGS = --fatal-warnings
     117LFLAGS = --fatal-warnings --warn-common
    168118
    169119ifeq ($(STATIC_NEEDED),y)
     
    182132
    183133ifeq ($(STATIC_BUILD),y)
    184         BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    185         ifeq ($(MATH),y)
    186                 BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
    187         endif
    188 else
    189         BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 $(LIBSOFTINT_PREFIX)/libsoftint.so.0
     134        BASE_LIBS = $(LIBC_PREFIX)/libc.a
     135else
     136        BASE_LIBS = $(LIBC_PREFIX)/libc.so.0
    190137        LINK_DYNAMIC = y
    191         ifeq ($(MATH),y)
    192                 BASE_LIBS += $(LIBMATH_PREFIX)/libmath.so.0
    193         endif
    194 endif
     138endif
     139
     140BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    195141
    196142ifeq ($(LINK_DYNAMIC),y)
     
    201147endif
    202148
    203 ifeq ($(MATH),y)
    204         INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) $(LIBMATH_INCLUDES_FLAGS)
    205 else
    206         INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
     149LIB_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
     150
     151INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
     152
     153ifneq ($(LIBRARY),)
     154        INCLUDES_FLAGS += -Iinclude -I.
     155endif
     156
     157INCLUDES_FLAGS += $(foreach lib,$(LIBS), -I$(LIB_PREFIX)/$(lib) -I$(LIB_PREFIX)/$(lib)/include)
     158
     159# TODO: get rid of this special case
     160ifneq ($(filter math, $(LIBS)),)
     161        INCLUDES_FLAGS += $(LIBMATH_INCLUDES_FLAGS)
    207162endif
    208163
    209164# PCUT-based unit tests
    210165ifneq ($(TEST_SOURCES),)
    211         TEST_OUTPUT = $(TEST_BINARY)
    212         TEST_DISASM = $(TEST_BINARY).disasm
     166        TEST_OUTPUTS = $(TEST_BINARY) $(TEST_BINARY).disasm
    213167        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)
     168        TEST_BINARY_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
     169        EXTRA_CLEAN += $(TEST_OUTPUTS) $(TEST_BINARY).map
    216170ifneq ($(LIBRARY),)
    217         TEST_OUTPUT_LIBS += $(OUTPUT)
    218 endif
    219         TEST_OUTPUT_LIBS += $(TEST_LIBS)
    220 endif
    221 
    222 .PHONY: all 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)
    230         find . -name '*.o' -follow -exec rm \{\} \;
    231         find . -name '*.lo' -follow -exec rm \{\} \;
    232         find . -name '*.d' -follow -exec rm \{\} \;
     171        TEST_BINARY_LIBS += $(LIBRARY).a
     172endif
     173        TEST_BINARY_LIBS += $(TEST_LIBS)
     174endif
    233175
    234176COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    235177        -ffreestanding -fno-builtin -nostdlib -nostdinc -fexec-charset=UTF-8 \
    236         -finput-charset=UTF-8 -D__$(ENDIANESS)__
     178        -finput-charset=UTF-8 -D__$(ENDIANESS)__ -fno-common \
     179        -fdebug-prefix-map=$(realpath $(ROOT_PATH))=.
    237180
    238181GCC_CFLAGS = -ffunction-sections -Wall -Wextra -Wno-clobbered \
     
    257200endif
    258201
    259 # Prepare for POSIX before including platform specific stuff
    260 ifeq ($(POSIX_COMPAT),y)
    261         CFLAGS += -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
    262         BASE_LIBS = $(LIBPOSIX_PREFIX)/libposixaslibc.a $(LIBPOSIX_PREFIX)/libc4posix.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    263 endif
    264 
    265202## Setup platform configuration
    266203#
     
    271208#
    272209
    273 JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
     210ifeq ($(PRECHECK),y)
     211        JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
     212        # XXX: Do not change the order of arguments.
     213        CC_JOB = $(JOBFILE) $(JOB) $(CC) $< -o $@
     214else
     215        CC_JOB = $(CC) $< -o $@
     216endif
    274217
    275218ifeq ($(COMPILER),clang)
     
    279222endif
    280223
     224ifeq ($(CONFIG_STRIP_BINARIES),y)
     225        LFLAGS += --strip-all
     226endif
     227
    281228LIB_CFLAGS = $(CFLAGS) -fPIC
    282 LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
     229LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME)
    283230
    284231AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
     
    290237DEPENDS := $(addsuffix .d,$(basename $(SOURCES))) $(addsuffix .test.d,$(basename $(TEST_SOURCES)))
    291238
    292 -include $(DEPENDS)
    293 
    294 ifneq ($(BINARY),)
    295 $(BINARY).disasm: $(BINARY)
     239LIBTAGS := $(foreach lib,$(LIBS), $(USPACE_PREFIX)/lib/$(lib)/tag)
     240LIBARGS := $(addprefix -L$(USPACE_PREFIX)/lib/, $(LIBS)) $(addprefix -l, $(LIBS))
     241
     242.PHONY: all all-test clean fasterclean depend
     243
     244all: tag $(OUTPUTS)
     245
     246all-test: $(TEST_OUTPUTS)
     247
     248clean:
     249        rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk
     250        find . -name '*.o' -follow -exec rm \{\} \;
     251        find . -name '*.lo' -follow -exec rm \{\} \;
     252        find . -name '*.d' -follow -exec rm \{\} \;
     253
     254fasterclean:
     255        rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk
     256
     257depend: $(PRE_DEPEND)
     258
     259# "Tag" files are used to force relink of binaries when dependencies get rebuilt,
     260# regardless of whether the dependency was linked statically or dynamically,
     261# or which version of a dynamic library was used. Prerequisites for this file
     262# are defined further down.
     263tag:
     264        touch tag
     265
     266# Generate inter-module make dependencies.
     267# This is needed to ensure correct build order of libraries and code depending on them.
     268deps.mk: Makefile
     269        echo > $@.new
     270        for lib in $(LIBS); do \
     271                echo "$(SELF_TARGET): lib/$$lib.build" >> $@.new; \
     272        done
     273        mv -f $@.new $@
     274
     275%.disasm: %
    296276ifeq ($(CONFIG_LINE_DEBUG),y)
    297277        $(OBJDUMP) -d -S $< > $@
     
    300280endif
    301281
    302 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBS) $(BASE_LIBS)
    303         $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(BINARY).map -o $(BINARY) $(OBJECTS) $(LIBS) $(BASE_LIBS)
    304 ifeq ($(CONFIG_STRIP_BINARIES),y)
    305         $(STRIP) $(BINARY)
    306 endif
     282ifneq ($(BINARY),)
     283$(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) $(BASE_LIBS)
     284        $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(OBJECTS) $(LIBARGS) $(BASE_LIBS)
     285endif
     286
     287ifneq ($(TEST_BINARY),)
     288$(TEST_BINARY): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBTAGS) $(BASE_LIBS)
     289        $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBARGS) $(BASE_LIBS)
     290endif
     291
     292ifneq ($(LIBRARY),)
     293tag: $(LIBRARY).a
     294
     295$(LIBRARY).a: $(OBJECTS)
     296        $(AR) rc $@ $(OBJECTS)
    307297endif
    308298
    309299ifneq ($(SLIBRARY),)
    310 $(LOUTPUT).disasm: $(LOUTPUT)
    311 ifeq ($(CONFIG_LINE_DEBUG),y)
    312         $(OBJDUMP) -d -S $< > $@
    313 else
    314         $(OBJDUMP) -d $< > $@
    315 endif
    316 
    317 $(LOUTPUT): $(LARCHIVE) $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
    318         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld $(LIB_LFLAGS) $(LARCHIVE) -o $@ -Map $(LOUTPUT).map
    319 
    320 $(LIBRARY).so:
    321         ln -s $(SLIBRARY) $@
     300tag: $(SLIBRARY)
     301
     302$(LIBRARY).la: $(LOBJECTS)
     303        $(AR) rc $@ $(LOBJECTS)
     304
     305$(SLIBRARY): $(LIB_LINKER_SCRIPT) $(LIBRARY).la
     306        $(LD) $(LIB_LFLAGS) -T $(LIB_LINKER_SCRIPT) -Map $@.map -o $@ --whole-archive $(LIBRARY).la --no-whole-archive
    322307
    323308$(LSONAME):
     
    325310endif
    326311
    327 ifneq ($(LIBRARY),)
    328 $(LIBRARY).a: $(OBJECTS)
    329         $(AR) rc $@ $(OBJECTS)
    330 endif
    331 
    332 ifneq ($(LARCHIVE),)
    333 $(LARCHIVE): $(LOBJECTS)
    334         $(AR) rc $@ $(LOBJECTS)
    335 endif
    336 
    337 ifneq ($(TEST_OUTPUT),)
    338 $(TEST_OUTPUT): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS)
    339         $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(TEST_OUTPUT).map -o $@ $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) $(LIBS) $(BASE_LIBS)
    340 ifeq ($(CONFIG_STRIP_BINARIES),y)
    341         $(STRIP) $(TEST_OUTPUT)
    342 endif
    343 $(TEST_BINARY).disasm: $(TEST_BINARY)
    344 ifeq ($(CONFIG_LINE_DEBUG),y)
    345         $(OBJDUMP) -d -S $< > $@
    346 else
    347         $(OBJDUMP) -d $< > $@
    348 endif
    349 endif
    350 
    351312%.o: %.S | depend
    352         $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    353 ifeq ($(PRECHECK),y)
    354         $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
    355 endif
     313        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    356314
    357315%.o: %.s | depend
    358         $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    359 ifeq ($(PRECHECK),y)
    360         $(JOBFILE) $(JOB) $< $@ as asm
    361 endif
     316        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    362317
    363318%.o: %.c | depend
    364         $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
    365 ifeq ($(PRECHECK),y)
    366         $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
    367 endif
     319        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
    368320
    369321%.test.o: %.c | depend
    370         $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) -c $< -o $@
    371 ifeq ($(PRECHECK),y)
    372         $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
    373 endif
     322        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
    374323
    375324%.lo: %.S | depend
    376         $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    377 ifeq ($(PRECHECK),y)
    378         $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
    379 endif
     325        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    380326
    381327%.lo: %.s | depend
    382         $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    383 ifeq ($(PRECHECK),y)
    384         $(JOBFILE) $(JOB) $< $@ as asm
    385 endif
     328        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
    386329
    387330%.lo: %.c | depend
    388         $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
    389 ifeq ($(PRECHECK),y)
    390         $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
    391 endif
    392 
    393 depend: $(PRE_DEPEND)
    394 
    395 ##
    396 # This explicit dependecy of the output binary on the object files seems to be
    397 # necessary to prevent parallel build failures (GNU make bug #26893 ???).
    398 $(OUTPUT): $(OBJECTS)
    399 
    400 $(LARCHIVE): $(LOBJECTS)
     331        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
     332
     333-include $(DEPENDS)
     334
Note: See TracChangeset for help on using the changeset viewer.