Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile.common

    r6480827 r874ed210  
    4646#   STATIC_NEEDED      set to 'y' for init binaries, will build statically
    4747#                      linked version
    48 #   STATIC_ONLY        set to 'y' if binary cannot be linked dynamically
    49 #                      (e.g. uses thread-local variables)
    5048#
    5149# Optionally, for a library:
     
    111109START_FILES = $(LIBC_PREFIX)/crt0.o $(LIBC_PREFIX)/crt1.o
    112110
    113 AFLAGS = --fatal-warnings
    114111LDFLAGS = -Wl,--fatal-warnings,--warn-common
     112
     113STATIC_BUILD = n
    115114
    116115ifeq ($(STATIC_NEEDED),y)
    117116        STATIC_BUILD = y
    118 else
    119         ifeq ($(STATIC_ONLY),y)
     117endif
     118
     119ifneq ($(CONFIG_BUILD_SHARED_LIBS),y)
     120        STATIC_BUILD = y
     121endif
     122
     123ifneq ($(CONFIG_USE_SHARED_LIBS),y)
     124        ifeq ($(LIBRARY),)
    120125                STATIC_BUILD = y
    121         else
    122                 ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
    123                         ifeq ($(CONFIG_USE_SHARED_LIBS),y)
    124                                 STATIC_BUILD = n
    125                         else
    126                                 ifeq ($(LIBRARY),)
    127                                         STATIC_BUILD = y
    128                                 else
    129                                         STATIC_BUILD = n
    130                                 endif
    131                         endif
    132                 else
    133                         STATIC_BUILD = y
    134                 endif
    135126        endif
    136127endif
    137128
    138 ifneq ($(STATIC_BUILD),y)
    139         LINK_DYNAMIC = y
     129# LINK_DYNAMIC is only here to allow app/dltest to link dynamically in otherwise static build.
     130ifeq ($(LINK_DYNAMIC),y)
     131        STATIC_BUILD = n
     132endif
     133
     134ifeq ($(STATIC_BUILD),y)
     135        LDFLAGS += -static
    140136endif
    141137
     
    152148BASE_LIBS += -lgcc
    153149
    154 ifneq ($(LINK_DYNAMIC),y)
    155         LDFLAGS += -static
    156 endif
    157 
    158150INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
    159151
     
    164156INCLUDES_FLAGS += $(foreach lib,$(LIBS), -I$(LIB_PREFIX)/$(lib) -I$(LIB_PREFIX)/$(lib)/include)
    165157
    166 # TODO: get rid of this special case
    167 ifneq ($(filter math, $(LIBS)),)
    168         INCLUDES_FLAGS += $(LIBMATH_INCLUDES_FLAGS)
     158DEPLIBS := $(LIBS)
     159
     160ifneq ($(filter %.cpp %.cc %.cxx, $(SOURCES)),)
     161        ifneq ($(LIBRARY),libcpp)
     162                DEPLIBS += cpp
     163        endif
     164endif
     165
     166ifneq ($(LIBRARY),libc)
     167        DEPLIBS += c
    169168endif
    170169
     
    194193        -Werror-implicit-function-declaration \
    195194        -Wsystem-headers \
    196         -Wunknown-pragmas
     195        -Wunknown-pragmas \
     196        -Wa,--fatal-warnings
    197197
    198198# XXX: -fno-builtin-strftime is for a seemingly spurious format warning.
     
    296296
    297297LIB_CFLAGS = $(CFLAGS) -fPIC
     298LIB_CXXFLAGS = $(CXXFLAGS) -fPIC
    298299LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname,$(LSONAME) -Wl,--no-undefined,--no-allow-shlib-undefined
    299 
    300 AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
    301300
    302301OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     
    305304DEPENDS := $(addsuffix .d,$(basename $(SOURCES))) $(addsuffix .test.d,$(basename $(TEST_SOURCES)))
    306305
    307 LIBTAGS := $(foreach lib,$(LIBS), $(USPACE_PREFIX)/lib/$(lib)/tag)
     306LIBTAGS := $(foreach lib,$(DEPLIBS), $(USPACE_PREFIX)/lib/$(lib)/tag)
    308307LIBARGS := $(addprefix -L$(USPACE_PREFIX)/lib/, $(LIBS)) $(addprefix -l, $(LIBS))
    309 
    310 ifneq ($(LIBRARY),libc)
    311         LIBTAGS := $(LIBC_PREFIX)/tag $(LIBTAGS)
    312 endif
    313308
    314309.PHONY: all all-test clean fasterclean depend
     
    339334deps.mk: Makefile
    340335        echo > $@.new
    341         for lib in $(LIBS); do \
     336        for lib in $(DEPLIBS); do \
    342337                echo "$(SELF_TARGET): lib/$$lib.build" >> $@.new; \
    343338        done
     
    389384
    390385%.o: %.S | depend
    391         $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS)
     386        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
    392387
    393388%.o: %.s | depend
    394         $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS)
     389        $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
    395390
    396391%.o: %.c | depend
     
    410405
    411406%.lo: %.S | depend
    412         $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS)
     407        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
    413408
    414409%.lo: %.s | depend
    415         $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS)
     410        $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
    416411
    417412%.lo: %.c | depend
     
    419414
    420415%.lo: %.cpp | depend
    421         $(CXX_JOB) -c -MD -MP $(DEFS) $(CXXFLAGS) $(EXTRA_CXXFLAGS)
     416        $(CXX_JOB) -c -MD -MP $(DEFS) $(LIB_CXXFLAGS) $(EXTRA_CXXFLAGS)
    422417
    423418%.lo: %.cxx | depend
    424         $(CXX_JOB) -c -MD -MP $(DEFS) $(CXXFLAGS) $(EXTRA_CXXFLAGS)
     419        $(CXX_JOB) -c -MD -MP $(DEFS) $(LIB_CXXFLAGS) $(EXTRA_CXXFLAGS)
    425420
    426421%.lo: %.cc | depend
    427         $(CXX_JOB) -c -MD -MP $(DEFS) $(CXXFLAGS) $(EXTRA_CXXFLAGS)
     422        $(CXX_JOB) -c -MD -MP $(DEFS) $(LIB_CXXFLAGS) $(EXTRA_CXXFLAGS)
    428423
    429424-include $(DEPENDS)
Note: See TracChangeset for help on using the changeset viewer.