Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile.common

    r78a9e5ef r042fbe0  
    4040#   BINARY         (/) binary output name (like appname)
    4141#   LIBRARY        (/) library output name (like libname)
     42#
    4243#   EXTRA_OUTPUT       additional output targets
    4344#   EXTRA_CLEAN        additional cleanup targets
     45#
     46# Optionally, for a binary:
     47#   STATIC_NEEDED      set to 'y' for init binaries, will build statically
     48#                      linked version
     49#   STATIC_ONLY        set to 'y' if binary cannot be linked dynamically
     50#                      (e.g. uses thread-local variables)
     51#
     52# Optionally, for a libary:
     53#   SLIBRARY           Name with full version, e.g. libfoo.so.0.0
     54#   LSONAME            Soname / name with short version, e.g. libfoo.so.0
    4455#
    4556# (x) required variables
     
    7384endif
    7485
     86ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
     87        ifneq ($(SLIBRARY),)
     88                LARCHIVE = $(LIBRARY).la
     89                LOUTPUT = $(SLIBRARY)
     90                EXTRA_OUTPUT += $(LOUTPUT).disasm $(LIBRARY).so $(LSONAME)
     91                EXTRA_CLEAN += $(LOUTPUT).map $(LOUTPUT).ldisasm \
     92                    $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld \
     93                    $(LIBRARY).so $(LSONAME)
     94        endif
     95endif
     96
    7597DEPEND = Makefile.depend
    7698DEPEND_PREV = $(DEPEND).prev
     
    90112LIBNET_PREFIX = $(LIB_PREFIX)/net
    91113
     114ifeq ($(STATIC_NEEDED),y)
     115        STATIC_BUILD = y
     116else
     117        ifeq ($(STATIC_ONLY),y)
     118                STATIC_BUILD = y
     119        else
     120                ifeq ($(CONFIG_USE_SHARED_LIBS), y)
     121                        STATIC_BUILD = n
     122                else
     123                        STATIC_BUILD = y
     124                endif
     125        endif
     126endif
     127
     128ifeq ($(STATIC_BUILD), y)
    92129BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    93 
    94130LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
     131else
     132BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0
     133LFLAGS = -Bdynamic
     134LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
     135endif
    95136
    96137ifeq ($(CONFIG_OPTIMIZE_FOR_SIZE),y)
     
    102143.PHONY: all clean
    103144
    104 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(EXTRA_OUTPUT)
     145all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
    105146        -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
    106147
    107148clean:
    108         rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN)
     149        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(LARCHIVE) $(LOUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN)
    109150        find . -name '*.o' -follow -exec rm \{\} \;
     151        find . -name '*.lo' -follow -exec rm \{\} \;
    110152
    111153GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     
    130172        -pipe -g -arch $(CLANG_ARCH) -D__$(ENDIANESS)__
    131173
     174LIB_CFLAGS = $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
     175LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
     176
    132177ifeq ($(CONFIG_DEBUG),y)
    133178        GCC_CFLAGS += -Werror
     
    135180endif
    136181
     182ifeq ($(CONFIG_LINE_DEBUG),y)
     183        GCC_CFLAGS += -g
     184        ICC_CFLAGS += -g
     185        SUNCC_CFLAGS += -g
     186        CLANG_CFLAGS += -g
     187endif
     188
    137189## Setup platform configuration
    138190#
     
    168220
    169221OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     222LOBJECTS := $(addsuffix .lo,$(basename $(SOURCES)))
    170223
    171224ifneq ($(BINARY),)
     
    178231
    179232$(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBS) $(BASE_LIBS)
    180         $(LD) -N $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(BINARY).map -o $(BINARY) $(OBJECTS) $(LIBS) $(BASE_LIBS)
     233        $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(BINARY).map -o $(BINARY) $(OBJECTS) $(LIBS) $(BASE_LIBS)
    181234ifeq ($(CONFIG_STRIP_BINARIES),y)
    182235        $(STRIP) $(BINARY)
    183236endif
     237endif
     238
     239ifneq ($(SLIBRARY),)
     240%.disasm: $(LOUTPUT)
     241ifeq ($(CONFIG_LINE_DEBUG),y)
     242        $(OBJDUMP) -d -S $< > $@
     243else
     244        $(OBJDUMP) -d $< > $@
     245endif
     246
     247$(LOUTPUT): $(LARCHIVE) $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
     248        $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld $(LIB_LFLAGS) $(LARCHIVE) -o $@ -Map $(LOUTPUT).map
     249
     250$(LIBRARY).so:
     251        ln -s $(SLIBRARY) $@
     252
     253$(LSONAME):
     254        ln -s $(SLIBRARY) $@
    184255endif
    185256
     
    189260endif
    190261
     262ifneq ($(SLIBRARY),)
     263%.la: $(LOBJECTS)
     264        $(AR) rc $@ $(LOBJECTS)
     265endif
     266
    191267%.o: %.S $(DEPEND)
    192268        $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
     
    203279%.o: %.c $(DEPEND)
    204280        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     281ifeq ($(PRECHECK),y)
     282        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     283endif
     284
     285%.lo: %.S $(DEPEND)
     286        $(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
     287ifeq ($(PRECHECK),y)
     288        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
     289endif
     290
     291%.lo: %.s $(DEPEND)
     292        $(AS) $(AFLAGS) -o $@ $<
     293ifeq ($(PRECHECK),y)
     294        $(JOBFILE) $(JOB) $< $@ as asm
     295endif
     296
     297%.lo: %.c $(DEPEND)
     298        $(CC) $(DEFS) $(LIB_CFLAGS) -c $< -o $@
    205299ifeq ($(PRECHECK),y)
    206300        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     
    210304        makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
    211305        -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
     306
     307##
     308# This explicit dependecy of the output binary on the object files seems to be
     309# necessary to prevent parallel build failures (GNU make bug #26893 ???).
     310$(OUTPUT): $(OBJECTS)
     311
     312$(LARCHIVE): $(LOBJECTS)
Note: See TracChangeset for help on using the changeset viewer.