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


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile.common

    re6ae77a r9c14309  
    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#
    4649# Optionally, for a binary:
    4750#   STATIC_NEEDED      set to 'y' for init binaries, will build statically
     
    5053#                      (e.g. uses thread-local variables)
    5154#
    52 # Optionally, for a library:
    53 #   SOVERSION            shared library version (major.minor),
    54 #                        if missing, no shared library is built
     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
    5558#
    5659# (x) required variables
     
    7275-include $(CONFIG_MAKEFILE)
    7376
    74 OUTPUTS = $(EXTRA_OUTPUT)
    75 
    7677ifneq ($(BINARY),)
    7778        JOB = $(BINARY).job
     79        OUTPUT = $(BINARY)
    7880        TEST_BINARY = test-$(BINARY)
    79         OUTPUTS += $(BINARY) $(BINARY).disasm
     81        EXTRA_OUTPUT += $(BINARY).disasm
    8082        EXTRA_CLEAN += $(BINARY).map
    8183endif
     
    8385ifneq ($(LIBRARY),)
    8486        JOB = $(LIBRARY).job
     87        OUTPUT = $(LIBRARY).a
    8588        TEST_BINARY = test-$(LIBRARY)
    86         OUTPUTS += $(LIBRARY).a
    8789endif
    8890
    8991ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
    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
     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)
    9599        endif
    96100endif
     
    112116
    113117LIBPOSIX_PREFIX = $(LIB_PREFIX)/posix
     118
     119LIBCRYPTO_PREFIX = $(LIB_PREFIX)/crypto
     120LIBBLOCK_PREFIX = $(LIB_PREFIX)/block
     121LIBFDISK_PREFIX = $(LIB_PREFIX)/fdisk
     122LIBLABEL_PREFIX = $(LIB_PREFIX)/label
     123LIBFS_PREFIX = $(LIB_PREFIX)/fs
     124LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
     125LIBFMTUTIL_PREFIX = $(LIB_PREFIX)/fmtutil
     126
     127LIBGRAPH_PREFIX = $(LIB_PREFIX)/graph
     128LIBSOFTREND_PREFIX = $(LIB_PREFIX)/softrend
     129LIBDRAW_PREFIX = $(LIB_PREFIX)/draw
     130LIBGUI_PREFIX = $(LIB_PREFIX)/gui
     131
     132LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4
     133
     134LIBUSB_PREFIX = $(LIB_PREFIX)/usb
     135LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost
     136LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev
     137LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid
     138LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt
     139
     140LIBDRV_PREFIX = $(LIB_PREFIX)/drv
     141LIBHOUND_PREFIX = $(LIB_PREFIX)/hound
     142LIBPCM_PREFIX = $(LIB_PREFIX)/pcm
     143LIBNIC_PREFIX = $(LIB_PREFIX)/nic
     144LIBIEEE80211_PREFIX = $(LIB_PREFIX)/ieee80211
     145LIBMINIX_PREFIX = $(LIB_PREFIX)/minix
     146LIBCOMPRESS_PREFIX = $(LIB_PREFIX)/compress
    114147LIBDLTEST_PREFIX = $(LIB_PREFIX)/dltest
    115148
    116 AFLAGS = --fatal-warnings
    117 LFLAGS = --fatal-warnings --warn-common
     149LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi
     150LIBTRACKMOD_PREFIX = $(LIB_PREFIX)/trackmod
     151
     152LIBBITHENGE_PREFIX = $(LIB_PREFIX)/bithenge
     153
     154LIBHTTP_PREFIX = $(LIB_PREFIX)/http
     155LIBURI_PREFIX = $(LIB_PREFIX)/uri
     156
     157LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl
     158
     159AFLAGS =
     160LFLAGS = --fatal-warnings
     161
     162# FIXME: This condition is a workaround for issues #692 and #693.
     163ifneq ($(KARCH),ia64)
     164ifneq ($(KARCH),mips32)
     165        AFLAGS += --fatal-warnings
     166endif
     167endif
    118168
    119169ifeq ($(STATIC_NEEDED),y)
     
    132182
    133183ifeq ($(STATIC_BUILD),y)
    134         BASE_LIBS = $(LIBC_PREFIX)/libc.a
    135 else
    136         BASE_LIBS = $(LIBC_PREFIX)/libc.so.0
     184        BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
     185        ifeq ($(MATH),y)
     186                BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
     187        endif
     188else
     189        BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 $(LIBSOFTINT_PREFIX)/libsoftint.so.0
    137190        LINK_DYNAMIC = y
    138 endif
    139 
    140 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a $(LIBSOFTINT_PREFIX)/libsoftint.a
     191        ifeq ($(MATH),y)
     192                BASE_LIBS += $(LIBMATH_PREFIX)/libmath.so.0
     193        endif
     194endif
    141195
    142196ifeq ($(LINK_DYNAMIC),y)
     
    147201endif
    148202
    149 LIB_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
    150 
    151 INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
    152 
    153 ifneq ($(LIBRARY),)
    154         INCLUDES_FLAGS += -Iinclude -I.
    155 endif
    156 
    157 INCLUDES_FLAGS += $(foreach lib,$(LIBS), -I$(LIB_PREFIX)/$(lib) -I$(LIB_PREFIX)/$(lib)/include)
    158 
    159 # TODO: get rid of this special case
    160 ifneq ($(filter math, $(LIBS)),)
    161         INCLUDES_FLAGS += $(LIBMATH_INCLUDES_FLAGS)
     203ifeq ($(MATH),y)
     204        INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) $(LIBMATH_INCLUDES_FLAGS)
     205else
     206        INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
    162207endif
    163208
    164209# PCUT-based unit tests
    165210ifneq ($(TEST_SOURCES),)
    166         TEST_OUTPUTS = $(TEST_BINARY) $(TEST_BINARY).disasm
     211        TEST_OUTPUT = $(TEST_BINARY)
     212        TEST_DISASM = $(TEST_BINARY).disasm
    167213        TEST_CFLAGS = -I$(LIB_PREFIX)/pcut/include -D__helenos__
    168         TEST_BINARY_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
    169         EXTRA_CLEAN += $(TEST_OUTPUTS) $(TEST_BINARY).map
     214        TEST_OUTPUT_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
     215        EXTRA_CLEAN += $(TEST_OUTPUT) $(TEST_OUTPUT).map $(TEST_DISASM)
    170216ifneq ($(LIBRARY),)
    171         TEST_BINARY_LIBS += $(LIBRARY).a
    172 endif
    173         TEST_BINARY_LIBS += $(TEST_LIBS)
    174 endif
     217        TEST_OUTPUT_LIBS += $(OUTPUT)
     218endif
     219        TEST_OUTPUT_LIBS += $(TEST_LIBS)
     220endif
     221
     222.PHONY: all clean depend
     223
     224all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
     225
     226all-test: $(TEST_OUTPUT) $(TEST_DISASM)
     227
     228clean:
     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 \{\} \;
    175233
    176234COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    177235        -ffreestanding -fno-builtin -nostdlib -nostdinc -fexec-charset=UTF-8 \
    178         -finput-charset=UTF-8 -D__$(ENDIANESS)__ -fno-common \
    179         -fdebug-prefix-map=$(realpath $(ROOT_PATH))=.
     236        -finput-charset=UTF-8 -D__$(ENDIANESS)__
    180237
    181238GCC_CFLAGS = -ffunction-sections -Wall -Wextra -Wno-clobbered \
     
    200257endif
    201258
     259# Prepare for POSIX before including platform specific stuff
     260ifeq ($(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
     263endif
     264
    202265## Setup platform configuration
    203266#
     
    208271#
    209272
    210 ifeq ($(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 $@
    214 else
    215         CC_JOB = $(CC) $< -o $@
    216 endif
     273JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
    217274
    218275ifeq ($(COMPILER),clang)
     
    222279endif
    223280
    224 ifeq ($(CONFIG_STRIP_BINARIES),y)
    225         LFLAGS += --strip-all
    226 endif
    227 
    228281LIB_CFLAGS = $(CFLAGS) -fPIC
    229 LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME)
     282LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
    230283
    231284AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
     
    237290DEPENDS := $(addsuffix .d,$(basename $(SOURCES))) $(addsuffix .test.d,$(basename $(TEST_SOURCES)))
    238291
    239 LIBTAGS := $(foreach lib,$(LIBS), $(USPACE_PREFIX)/lib/$(lib)/tag)
    240 LIBARGS := $(addprefix -L$(USPACE_PREFIX)/lib/, $(LIBS)) $(addprefix -l, $(LIBS))
    241 
    242 .PHONY: all all-test clean fasterclean depend
    243 
    244 all: tag $(OUTPUTS)
    245 
    246 all-test: $(TEST_OUTPUTS)
    247 
    248 clean:
    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 
    254 fasterclean:
    255         rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk
    256 
    257 depend: $(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.
    263 tag:
    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.
    268 deps.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: %
     292-include $(DEPENDS)
     293
     294ifneq ($(BINARY),)
     295$(BINARY).disasm: $(BINARY)
    276296ifeq ($(CONFIG_LINE_DEBUG),y)
    277297        $(OBJDUMP) -d -S $< > $@
     
    280300endif
    281301
    282 ifneq ($(BINARY),)
    283 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) $(BASE_LIBS)
    284         $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(OBJECTS) $(LIBARGS) $(BASE_LIBS)
    285 endif
    286 
    287 ifneq ($(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)
     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)
     304ifeq ($(CONFIG_STRIP_BINARIES),y)
     305        $(STRIP) $(BINARY)
     306endif
     307endif
     308
     309ifneq ($(SLIBRARY),)
     310$(LOUTPUT).disasm: $(LOUTPUT)
     311ifeq ($(CONFIG_LINE_DEBUG),y)
     312        $(OBJDUMP) -d -S $< > $@
     313else
     314        $(OBJDUMP) -d $< > $@
     315endif
     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) $@
     322
     323$(LSONAME):
     324        ln -s $(SLIBRARY) $@
    290325endif
    291326
    292327ifneq ($(LIBRARY),)
    293 tag: $(LIBRARY).a
    294 
    295328$(LIBRARY).a: $(OBJECTS)
    296329        $(AR) rc $@ $(OBJECTS)
    297330endif
    298331
    299 ifneq ($(SLIBRARY),)
    300 tag: $(SLIBRARY)
    301 
    302 $(LIBRARY).la: $(LOBJECTS)
     332ifneq ($(LARCHIVE),)
     333$(LARCHIVE): $(LOBJECTS)
    303334        $(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
    307 
    308 $(LSONAME):
    309         ln -s $(SLIBRARY) $@
     335endif
     336
     337ifneq ($(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)
     340ifeq ($(CONFIG_STRIP_BINARIES),y)
     341        $(STRIP) $(TEST_OUTPUT)
     342endif
     343$(TEST_BINARY).disasm: $(TEST_BINARY)
     344ifeq ($(CONFIG_LINE_DEBUG),y)
     345        $(OBJDUMP) -d -S $< > $@
     346else
     347        $(OBJDUMP) -d $< > $@
     348endif
    310349endif
    311350
    312351%.o: %.S | depend
    313         $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     352        $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
     353ifeq ($(PRECHECK),y)
     354        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
     355endif
    314356
    315357%.o: %.s | depend
    316         $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     358        $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
     359ifeq ($(PRECHECK),y)
     360        $(JOBFILE) $(JOB) $< $@ as asm
     361endif
    317362
    318363%.o: %.c | depend
    319         $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
     364        $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
     365ifeq ($(PRECHECK),y)
     366        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
     367endif
    320368
    321369%.test.o: %.c | depend
    322         $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
     370        $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) -c $< -o $@
     371ifeq ($(PRECHECK),y)
     372        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
     373endif
    323374
    324375%.lo: %.S | depend
    325         $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     376        $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
     377ifeq ($(PRECHECK),y)
     378        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
     379endif
    326380
    327381%.lo: %.s | depend
    328         $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__
     382        $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
     383ifeq ($(PRECHECK),y)
     384        $(JOBFILE) $(JOB) $< $@ as asm
     385endif
    329386
    330387%.lo: %.c | depend
    331         $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
    332 
    333 -include $(DEPENDS)
    334 
     388        $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
     389ifeq ($(PRECHECK),y)
     390        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
     391endif
     392
     393depend: $(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)
Note: See TracChangeset for help on using the changeset viewer.