Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile.common

    r4fb794c r58563585  
    4444#   EXTRA_CLEAN        additional cleanup targets
    4545#
     46#   MATH               set to 'y' to use the math library
    4647#   POSIX_COMPAT       set to 'y' to use POSIX compatibility layer
    4748#
     
    7778        JOB = $(BINARY).job
    7879        OUTPUT = $(BINARY)
     80        TEST_BINARY = test-$(BINARY)
    7981        EXTRA_OUTPUT += $(BINARY).disasm
    8082        EXTRA_CLEAN += $(BINARY).map
     
    8486        JOB = $(LIBRARY).job
    8587        OUTPUT = $(LIBRARY).a
    86 endif
    87 
    88 ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
     88        TEST_BINARY = test-$(LIBRARY)
     89endif
     90
     91ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
    8992        ifneq ($(SLIBRARY),)
    9093                LARCHIVE = $(LIBRARY).la
     
    110113LIBSOFTINT_PREFIX = $(LIB_PREFIX)/softint
    111114
     115LIBMATH_PREFIX = $(LIB_PREFIX)/math
     116LIBMATH_INCLUDES_FLAGS = \
     117        -I$(LIBMATH_PREFIX)/include \
     118        -I$(LIBMATH_PREFIX)/arch/$(UARCH)/include
     119
    112120LIBPOSIX_PREFIX = $(LIB_PREFIX)/posix
    113121
     122LIBCRYPTO_PREFIX = $(LIB_PREFIX)/crypto
    114123LIBBLOCK_PREFIX = $(LIB_PREFIX)/block
     124LIBFDISK_PREFIX = $(LIB_PREFIX)/fdisk
     125LIBLABEL_PREFIX = $(LIB_PREFIX)/label
    115126LIBFS_PREFIX = $(LIB_PREFIX)/fs
    116127LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
     
    131142
    132143LIBDRV_PREFIX = $(LIB_PREFIX)/drv
    133 LIBNET_PREFIX = $(LIB_PREFIX)/net
     144LIBHOUND_PREFIX = $(LIB_PREFIX)/hound
     145LIBPCM_PREFIX = $(LIB_PREFIX)/pcm
    134146LIBNIC_PREFIX = $(LIB_PREFIX)/nic
     147LIBIEEE80211_PREFIX = $(LIB_PREFIX)/ieee80211
    135148LIBMINIX_PREFIX = $(LIB_PREFIX)/minix
     149LIBCOMPRESS_PREFIX = $(LIB_PREFIX)/compress
     150LIBDLTEST_PREFIX = $(LIB_PREFIX)/dltest
    136151
    137152LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi
     153LIBTRACKMOD_PREFIX = $(LIB_PREFIX)/trackmod
    138154
    139155LIBBITHENGE_PREFIX = $(LIB_PREFIX)/bithenge
     156
     157LIBHTTP_PREFIX = $(LIB_PREFIX)/http
     158LIBURI_PREFIX = $(LIB_PREFIX)/uri
     159
     160LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl
     161
     162AFLAGS = --fatal-warnings
     163LFLAGS = --fatal-warnings
    140164
    141165ifeq ($(STATIC_NEEDED),y)
     
    145169                STATIC_BUILD = y
    146170        else
    147                 ifeq ($(CONFIG_USE_SHARED_LIBS), y)
     171                ifeq ($(CONFIG_USE_SHARED_LIBS),y)
    148172                        STATIC_BUILD = n
    149173                else
     
    153177endif
    154178
    155 # Build static whenever we use libusb because that library uses
    156 # thread local variables
    157 ifneq ($(findstring usb, $(LIBS)),)
    158         STATIC_BUILD = y
    159 endif
    160 
    161179ifeq ($(STATIC_BUILD),y)
    162180        BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
     181        ifeq ($(MATH),y)
     182                BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
     183        endif
     184else
     185        BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 $(LIBSOFTINT_PREFIX)/libsoftint.so.0
     186        LINK_DYNAMIC = y
     187        ifeq ($(MATH),y)
     188                BASE_LIBS += $(LIBMATH_PREFIX)/libmath.so.0
     189        endif
     190endif
     191
     192ifeq ($(LINK_DYNAMIC),y)
     193        LFLAGS += -Bdynamic
     194        LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
     195else
    163196        LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
    164 else
    165         BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0
    166         LFLAGS = -Bdynamic
    167         LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
     197endif
     198
     199ifeq ($(MATH),y)
     200        INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) $(LIBMATH_INCLUDES_FLAGS)
     201else
     202        INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
    168203endif
    169204
     
    174209endif
    175210
     211# PCUT-based unit tests
     212ifneq ($(TEST_SOURCES),)
     213        TEST_OUTPUT = $(TEST_BINARY)
     214        TEST_CFLAGS = -I$(LIB_PREFIX)/pcut/include -D__helenos__
     215        TEST_OUTPUT_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
     216        EXTRA_CLEAN += $(TEST_OUTPUT) $(TEST_OUTPUT).map
     217ifneq ($(LIBRARY),)
     218        TEST_OUTPUT_LIBS += $(OUTPUT)
     219endif
     220        TEST_OUTPUT_LIBS += $(TEST_LIBS)
     221endif
     222
    176223.PHONY: all clean
    177224
    178225all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
    179226        -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
     227
     228all-test: $(TEST_OUTPUT)
    180229
    181230clean:
     
    184233        find . -name '*.lo' -follow -exec rm \{\} \;
    185234
    186 GCC_CFLAGS = $(LIBC_INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     235GCC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    187236        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    188237        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     
    191240        -pipe -ggdb -D__$(ENDIANESS)__
    192241
    193 ICC_CFLAGS = $(LIBC_INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     242ICC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    194243        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    195244        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     
    201250# something won't break because of that:
    202251# -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) -finput-charset=UTF-8
    203 CLANG_CFLAGS = $(LIBC_INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     252CLANG_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    204253        -ffreestanding -fno-builtin -nostdlib -nostdinc \
    205254        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    206         -Werror-implicit-function-declaration -Wwrite-strings \
    207         -integrated-as \
    208         -pipe -g -target $(CLANG_TARGET) -D__$(ENDIANESS)__
    209 
    210 LIB_CFLAGS = $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
     255        -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
     256        -integrated-as -pipe -g -target $(CLANG_TARGET) -D__$(ENDIANESS)__
     257
     258LIB_CFLAGS = $(CFLAGS) -fPIC
    211259LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
    212260
     
    217265
    218266ifeq ($(CONFIG_LINE_DEBUG),y)
    219         GCC_CFLAGS += -g
     267        GCC_CFLAGS += -ggdb
    220268        ICC_CFLAGS += -g
    221269        CLANG_CFLAGS += -g
    222270endif
    223271
     272# Prepare for POSIX before including platform specific stuff
     273ifeq ($(POSIX_COMPAT),y)
     274        CFLAGS = -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
     275        BASE_LIBS = $(LIBPOSIX_PREFIX)/libposixaslibc.a $(LIBPOSIX_PREFIX)/libc4posix.a $(LIBSOFTINT_PREFIX)/libsoftint.a
     276endif
     277
    224278## Setup platform configuration
    225279#
     
    232286JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
    233287
    234 ifeq ($(POSIX_COMPAT),y)
    235         CFLAGS = -I$(LIBPOSIX_PREFIX)/include/posix  -I$(LIBPOSIX_PREFIX)/include/
    236         LIBS += $(LIBPOSIX_PREFIX)/libposix.a
    237 endif
    238 
    239288ifeq ($(COMPILER),gcc_cross)
    240         CFLAGS += $(GCC_CFLAGS) $(EXTRA_CFLAGS)
     289        CFLAGS += $(GCC_CFLAGS)
    241290        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    242291endif
    243292
     293ifeq ($(COMPILER),gcc_helenos)
     294        CFLAGS += $(GCC_CFLAGS)
     295        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
     296endif
     297
    244298ifeq ($(COMPILER),gcc_native)
    245         CFLAGS += $(GCC_CFLAGS) $(EXTRA_CFLAGS)
     299        CFLAGS += $(GCC_CFLAGS)
    246300        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    247301endif
    248302
    249303ifeq ($(COMPILER),icc)
    250         CFLAGS += $(ICC_CFLAGS) $(EXTRA_CFLAGS)
     304        CFLAGS += $(ICC_CFLAGS)
    251305        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    252306endif
    253307
    254308ifeq ($(COMPILER),clang)
    255         CFLAGS += $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
    256         GCC_CFLAGS += $(EXTRA_CFLAGS)
     309        CFLAGS += $(CLANG_CFLAGS)
    257310        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    258311endif
    259312
     313ifneq ($(MAKECMDGOALS),clean)
    260314-include $(DEPEND)
     315endif
    261316
    262317OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    263318LOBJECTS := $(addsuffix .lo,$(basename $(SOURCES)))
     319TEST_OBJECTS := $(addsuffix .test.o,$(basename $(TEST_SOURCES)))
    264320
    265321ifneq ($(BINARY),)
     
    297353
    298354ifneq ($(LIBRARY),)
    299 %.a: $(OBJECTS)
     355$(LIBRARY).a: $(OBJECTS)
    300356        $(AR) rc $@ $(OBJECTS)
    301357endif
    302358
    303 ifneq ($(SLIBRARY),)
    304 %.la: $(LOBJECTS)
     359ifneq ($(LARCHIVE),)
     360$(LARCHIVE): $(LOBJECTS)
    305361        $(AR) rc $@ $(LOBJECTS)
    306362endif
    307363
     364ifneq ($(TEST_OUTPUT),)
     365$(TEST_OUTPUT): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS)
     366        $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(TEST_OUTPUT).map -o $@ $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) $(LIBS) $(BASE_LIBS)
     367ifeq ($(CONFIG_STRIP_BINARIES),y)
     368        $(STRIP) $(TEST_OUTPUT)
     369endif
     370endif
     371
    308372%.o: %.S $(DEPEND)
    309         $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
    310 ifeq ($(PRECHECK),y)
    311         $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
     373        $(GCC) $(DEFS) $(GCC_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
     374ifeq ($(PRECHECK),y)
     375        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
    312376endif
    313377
     
    319383
    320384%.o: %.c $(DEPEND)
    321         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
    322 ifeq ($(PRECHECK),y)
    323         $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     385        $(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
     386ifeq ($(PRECHECK),y)
     387        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
     388endif
     389
     390%.test.o: %.c $(DEPEND)
     391        $(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) -c $< -o $@
     392ifeq ($(PRECHECK),y)
     393        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
    324394endif
    325395
    326396%.lo: %.S $(DEPEND)
    327         $(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
    328 ifeq ($(PRECHECK),y)
    329         $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
     397        $(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
     398ifeq ($(PRECHECK),y)
     399        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
    330400endif
    331401
     
    337407
    338408%.lo: %.c $(DEPEND)
    339         $(CC) $(DEFS) $(LIB_CFLAGS) -c $< -o $@
    340 ifeq ($(PRECHECK),y)
    341         $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     409        $(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
     410ifeq ($(PRECHECK),y)
     411        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
    342412endif
    343413
    344414$(DEPEND): $(PRE_DEPEND)
    345         makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
     415        makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -- $(SOURCES) $(TEST_SOURCES) > $@ 2> /dev/null
    346416        -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
    347417
Note: See TracChangeset for help on using the changeset viewer.