Changeset dfeb4e2 in mainline


Ignore:
Timestamp:
2018-01-06T02:37:59Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
c9e09f2
Parents:
3d95c9d
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-02 18:06:21)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-06 02:37:59)
Message:

Integrate ports into the main tree as a submodule.

A stripped down version of hsct.sh is added to tools, and Makefiles
gain new targets that implement part of hsct's prior functionality.

This arrangement improves usability and maintainability of ports,
reduces the likelihood of ports being broken by mainline changes,
and partially solves the issue with build logic being duplicated
in multiple places.

It is newly possible to build individual ports using make ports-NAME,
and all ports using make ports-all. This also installs the outputs to
uspace/dist, so ideally, simple make ports-all && make would create
an image with all ports included. This currently doesn't work only
because some ports fail to build.

Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r3d95c9d rdfeb4e2  
    6060uspace: common
    6161        $(MAKE) -r -C uspace PRECHECK=$(PRECHECK)
     62
     63ports-%: common
     64        $(MAKE) -r -C uspace $@ PRECHECK=$(PRECHECK)
    6265
    6366precheck: clean
  • tools/autotool.py

    r3d95c9d rdfeb4e2  
    615615                                path = "%s/%s/bin" % (cross_prefix, platform)
    616616               
     617                common['TARGET'] = target
    617618                prefix = "%s-" % target
    618619               
  • uspace/Makefile

    r3d95c9d rdfeb4e2  
    255255CLEANS := $(addsuffix .clean,$(DIRS) $(LIBS) $(BASE_LIBS))
    256256
    257 .PHONY: all $(BASE_BUILDS) $(BUILDS) $(BUILDS_TESTS) $(CLEANS) clean
     257PORTS_BUILD_DIR := ../build/ports
     258PORT_CFLAGS := \
     259        -specs $(abspath lib/posix/gcc.specs) \
     260        -isystem $(abspath $(PORTS_BUILD_DIR)/include) \
     261        -isystem $(abspath $(PORTS_BUILD_DIR)/include/posix) \
     262        -isystem $(abspath $(PORTS_BUILD_DIR)/include/libc) \
     263        -L$(abspath $(PORTS_BUILD_DIR)/lib) \
     264        -Wl,-T,link.ld \
     265        -Wl,--whole-archive,-lc,-lmath,--no-whole-archive
     266
     267.PHONY: all $(BASE_BUILDS) $(BUILDS) $(BUILDS_TESTS) $(CLEANS) clean ports_cache
    258268
    259269all: $(BUILDS) $(BUILDS_TESTS)
     270
     271ports_cache: lib/posix.build lib/math.build lib/clui.build
     272        git submodule update --init -- ports
     273       
     274        # Copy libs
     275        mkdir -p $(PORTS_BUILD_DIR)/lib
     276        cp lib/posix/link.ld $(PORTS_BUILD_DIR)/lib/link.ld
     277        cp lib/posix/libc.a $(PORTS_BUILD_DIR)/lib/libc.a
     278        # We don't currently build a dedicated debug-enabled libc version.
     279        cp lib/posix/libc.a $(PORTS_BUILD_DIR)/lib/libg.a
     280        cp lib/math/libmath.a $(PORTS_BUILD_DIR)/lib/libmath.a
     281        cp lib/clui/libclui.a $(PORTS_BUILD_DIR)/lib/libclui.a
     282       
     283        # Copy headers
     284        mkdir -p $(PORTS_BUILD_DIR)/include
     285        cp -L -R lib/posix/include/posix/ $(PORTS_BUILD_DIR)/include/
     286        mkdir -p $(PORTS_BUILD_DIR)/include/libc
     287        cp -L -R lib/c/include/* $(PORTS_BUILD_DIR)/include/libc
     288        cp -L -R lib/c/arch/$(UARCH)/include/libarch $(PORTS_BUILD_DIR)/include/
     289        cp -L -R lib/math/include/* $(PORTS_BUILD_DIR)/include/libc
     290        cp -L -R lib/math/arch/$(UARCH)/include/libarch/ $(PORTS_BUILD_DIR)/include/
     291        cp -L -R ../abi/include/* $(PORTS_BUILD_DIR)/include/
     292        ln -s -f -n libc $(PORTS_BUILD_DIR)/include/libmath
     293       
     294        # FIXME: Just for temporary compatibility.
     295        touch $(PORTS_BUILD_DIR)/coastline.specs
     296       
     297        mkdir -p $(PORTS_BUILD_DIR)/include/libclui
     298        cp -L lib/clui/tinput.h $(PORTS_BUILD_DIR)/include/libclui/
     299       
     300        # TODO: Get rid of this.
     301        find $(PORTS_BUILD_DIR)/include/libc $(PORTS_BUILD_DIR)/include/libarch -name '*.h' -exec sed \
     302                -e 's:#include <:#include <libc/:' \
     303                -e 's:#include <libc/libarch/:#include <libarch/:' \
     304                -e 's:#include <libc/abi/:#include <abi/:' \
     305                -e 's:#include <libc/_bits/:#include <_bits/:' \
     306                -e 's:#include <libc/libc/:#include <libc/:' \
     307                -i {} \;
     308       
     309        mkdir -p overlay
     310
     311ports-all: ports_cache
     312        for x in ports/*; do if [ -d "$$x" ]; then $(MAKE) ports-install-`basename $$x` || exit 1; fi; done
     313
     314ports-%: ports_cache
     315        $(MAKE) $(@:ports-%=ports-install-%)
     316
     317# This is a separate target to avoid running ports_cache multiple times.
     318ports-install-%:
     319        PATH="$(CROSS_PREFIX)/$(TARGET)/bin:$$PATH" \
     320        HSCT_HELENOS_ROOT="$(abspath ..)" \
     321        HSCT_HOME="$(abspath ports)" \
     322        HSCT_HSCT="$(abspath ../tools/hsct.sh)" \
     323        HSCT_SOURCES_DIR="$(abspath $(PORTS_BUILD_DIR)/sources)" \
     324        HSCT_BUILD_DIR="$(abspath $(PORTS_BUILD_DIR)/build)" \
     325        HSCT_INCLUDE_DIR="$(abspath $(PORTS_BUILD_DIR)/include)" \
     326        HSCT_LIB_DIR="$(abspath $(PORTS_BUILD_DIR)/lib)" \
     327        HSCT_CACHE_DIR="$(abspath $(PORTS_BUILD_DIR))" \
     328        HSCT_CACHE_LIB="$(abspath $(PORTS_BUILD_DIR)/lib)" \
     329        HSCT_DIST_DIR="$(abspath $(PORTS_BUILD_DIR)/dist)" \
     330        HSCT_ARCHIVE_DIR="$(abspath $(PORTS_BUILD_DIR)/archives)" \
     331        HSCT_PARALLELISM="$(JOBS)" \
     332        HSCT_GNU_TARGET="$(TARGET)" \
     333        HSCT_CC="$(CC) $(PORT_CFLAGS)" \
     334        HSCT_CFLAGS="" \
     335        HSCT_LDFLAGS_FOR_CC="" \
     336        HSCT_LD="$(LD)" \
     337        HSCT_AR="$(AR)" \
     338        HSCT_RANLIB="$(RANLIB)" \
     339        HSCT_OBJDUMP="$(OBJDUMP)" \
     340        HSCT_OBJCOPY="$(OBJCOPY)" \
     341        HSCT_AS="$(AS)" \
     342        HSCT_STRIP="$(STRIP)" \
     343        ../tools/hsct.sh install $(@:ports-install-%=%)
    260344
    261345$(BUILDS_TESTS): $(BASE_BUILDS) $(BUILDS)
  • uspace/Makefile.common

    r3d95c9d rdfeb4e2  
    174174endif
    175175
    176 COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    177         -ffreestanding -fno-builtin -nostdlib -nostdinc -fexec-charset=UTF-8 \
    178         -finput-charset=UTF-8 -D__$(ENDIANESS)__ -fno-common \
     176# Flags that are not necessary, and can be overriden, but are used by default.
     177DEFAULT_CFLAGS = \
     178        -O$(OPTIMIZATION) \
     179        -ffunction-sections \
     180        -pipe \
     181        -Wall \
     182        -Wextra \
     183        -Wno-unused-parameter \
     184        -Wmissing-prototypes \
     185        -Wwrite-strings \
     186        -Werror-implicit-function-declaration
     187
     188ifeq ($(CONFIG_DEBUG),y)
     189        DEFAULT_CFLAGS += -Werror
     190endif
     191
     192ifeq ($(COMPILER),clang)
     193        DEFAULT_CFLAGS += \
     194                -Wno-missing-field-initializers \
     195                -Wno-typedef-redefinition \
     196                -Wno-unused-command-line-argument
     197else
     198        DEFAULT_CFLAGS += \
     199                -Wno-clobbered
     200endif
     201
     202ifeq ($(CONFIG_LINE_DEBUG),y)
     203        DEFAULT_CFLAGS += -ggdb
     204endif
     205
     206# Flags that should always be used, even for third-party software.
     207COMMON_CFLAGS = \
     208        -ffreestanding \
     209        -fno-builtin \
     210        -nostdlib \
     211        -nostdinc \
     212        -D__$(ENDIANESS)__
     213
     214# Flags that are always used for HelenOS code, but not for third-party.
     215HELENOS_CFLAGS = \
     216        -std=gnu99 \
     217        $(INCLUDES_FLAGS) \
     218        -imacros $(CONFIG_HEADER) \
     219        -fexec-charset=UTF-8 \
     220        -finput-charset=UTF-8 \
     221        -fno-common \
    179222        -fdebug-prefix-map=$(realpath $(ROOT_PATH))=.
    180223
    181 GCC_CFLAGS = -ffunction-sections -Wall -Wextra -Wno-clobbered \
    182         -Wno-unused-parameter -Wmissing-prototypes -std=gnu99 \
    183         -Werror-implicit-function-declaration \
    184         -Wwrite-strings -pipe
    185 
    186 # -Wno-missing-prototypes is there because it warns about main().
    187 # This should be fixed elsewhere.
    188 CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-typedef-redefinition \
    189         -Wno-missing-prototypes -Wno-unused-command-line-argument \
    190         -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
    191         -pipe -fno-stack-protector -fno-PIC
    192 
    193 ifeq ($(CONFIG_DEBUG),y)
    194         COMMON_CFLAGS += -Werror
    195 endif
    196 
    197 ifeq ($(CONFIG_LINE_DEBUG),y)
    198         GCC_CFLAGS += -ggdb
    199         CLANG_CFLAGS += -g
    200 endif
     224# TODO: Use a different name.
     225# CFLAGS variable is traditionally used for overridable flags.
     226CFLAGS = $(COMMON_CFLAGS) $(HELENOS_CFLAGS) $(DEFAULT_CFLAGS)
    201227
    202228## Setup platform configuration
     
    214240else
    215241        CC_JOB = $(CC) $< -o $@
    216 endif
    217 
    218 ifeq ($(COMPILER),clang)
    219         CFLAGS += $(COMMON_CFLAGS) $(CLANG_CFLAGS)
    220 else
    221         CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
    222242endif
    223243
  • uspace/lib/c/Makefile

    r3d95c9d rdfeb4e2  
    4444LIBRARY = libc
    4545SOVERSION = 0.0
     46
     47EXTRA_CFLAGS = -fno-builtin
    4648
    4749-include $(CONFIG_MAKEFILE)
  • uspace/lib/c/arch/amd64/Makefile.common

    r3d95c9d rdfeb4e2  
    3131# XXX: clang doesn't support this flag, but the optimization is OS-specific,
    3232#      so it isn't used for amd64-unknown-elf target.
    33 GCC_CFLAGS += -mno-tls-direct-seg-refs
     33
     34ifneq ($(COMPILER),clang)
     35        COMMON_CFLAGS += -mno-tls-direct-seg-refs
     36endif
    3437
    3538LFLAGS += --gc-sections
  • uspace/lib/posix/Makefile

    r3d95c9d rdfeb4e2  
    4646        $(LIBSOFTINT_PREFIX)/libsoftint.a
    4747
     48SPECS = gcc.specs
     49LINKER_SCRIPT = link.ld
     50STARTUP_FILE = crt0.o
     51LIBC_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
     52LIBC_STARTUP_FILE = $(LIBC_PREFIX)/arch/$(UARCH)/src/entry.o
     53
    4854REDEFS_HIDE_LIBC = redefs-hide-libc-symbols.list
    4955REDEFS_SHOW_LIBPOSIX = redefs-show-posix-symbols.list
     
    5864        libc.o
    5965
    60 EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) $(MERGED_C_LIBRARY)
     66EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) $(MERGED_C_LIBRARY) $(SPECS) $(LINKER_SCRIPT) $(STARTUP_FILE)
    6167
    6268SOURCES = \
     
    9298include $(USPACE_PREFIX)/Makefile.common
    9399
     100$(SPECS): $(CONFIG_MAKEFILE)
     101        echo '*self_spec:' > $@.new
     102        echo '+ $(COMMON_CFLAGS)' >> $@.new
     103        echo >> $@.new
     104        echo '*lib:' >> $@.new
     105        echo '--whole-archive -lc -lm --no-whole-archive' >> $@.new
     106        echo >> $@.new
     107        mv $@.new $@
     108
     109$(LINKER_SCRIPT): $(LIBC_LINKER_SCRIPT)
     110        cp $< $@
     111
     112$(STARTUP_FILE): $(LIBC_STARTUP_FILE)
     113        cp $< $@
     114
    94115$(INCLUDE_LIBC): ../c/include
    95116        ln -s -f -n ../$^ $@
  • uspace/lib/posix/include/posix/stdio.h

    r3d95c9d rdfeb4e2  
    7272typedef struct _IO_FILE FILE;
    7373
    74 #ifndef LIBPOSIX_INTERNAL
     74#if !defined(LIBPOSIX_INTERNAL) && !defined(LIBC_STDIO_H_)
    7575        enum _buffer_type {
    7676                /** No buffering */
Note: See TracChangeset for help on using the changeset viewer.