Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2660ee3 in mainline


Ignore:
Timestamp:
2018-01-31T17:47:53Z (4 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial
Children:
a912aff, b500939e, ea42e44
Parents:
14d789c
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-31 17:47:53)
git-committer:
GitHub <noreply@…> (2018-01-31 17:47:53)
Message:

Generate files that a third party can use to build software for HelenOS (#15)

Generate files that a third party can use to build software for HelenOS
without necessarily knowing anything about the build system.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r14d789c r2660ee3  
    4848ERRNO_INPUT = abi/include/abi/errno.in
    4949
    50 .PHONY: all precheck cscope cscope_parts autotool config_auto config_default config distclean clean check releasefile release common boot kernel uspace
     50.PHONY: all precheck cscope cscope_parts autotool config_auto config_default config distclean clean check releasefile release common boot kernel uspace export-posix
    5151
    5252all: kernel uspace
     
    6060uspace: common
    6161        $(MAKE) -r -C uspace PRECHECK=$(PRECHECK)
     62
     63export-posix: common
     64ifndef EXPORT_DIR
     65        @echo ERROR: Variable EXPORT_DIR is not defined. && false
     66else
     67        $(MAKE) -r -C uspace export EXPORT_DIR=$(abspath $(EXPORT_DIR))
     68endif
    6269
    6370precheck: clean
  • tools/autotool.py

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

    r14d789c r2660ee3  
    255255CLEANS := $(addsuffix .clean,$(DIRS) $(LIBS) $(BASE_LIBS))
    256256
    257 .PHONY: all $(BASE_BUILDS) $(BUILDS) $(BUILDS_TESTS) $(CLEANS) clean
     257.PHONY: all $(BASE_BUILDS) $(BUILDS) $(BUILDS_TESTS) $(CLEANS) clean export
    258258
    259259all: $(BUILDS) $(BUILDS_TESTS)
     
    261261$(BUILDS_TESTS): $(BASE_BUILDS) $(BUILDS)
    262262        $(MAKE) -r -C $(basename $@) all-test PRECHECK=$(PRECHECK)
     263
     264export: lib/posix.build lib/math.build lib/clui.build
     265        $(MAKE) -r -C lib/posix export EXPORT_DIR=$(EXPORT_DIR)
    263266
    264267clean: $(CLEANS)
  • uspace/Makefile.common

    r14d789c r2660ee3  
    174174endif
    175175
    176 COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    177         -ffreestanding -nostdlib -nostdinc -fexec-charset=UTF-8 \
    178         -finput-charset=UTF-8 -D__$(ENDIANESS)__ -D_HELENOS_SOURCE -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        -nostdlib \
     210        -nostdinc \
     211        -D__$(ENDIANESS)__
     212
     213# Flags that are always used for HelenOS code, but not for third-party.
     214HELENOS_CFLAGS = \
     215        -std=gnu99 \
     216        $(INCLUDES_FLAGS) \
     217        -imacros $(CONFIG_HEADER) \
     218        -D_HELENOS_SOURCE \
     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
     
    216242endif
    217243
    218 ifeq ($(COMPILER),clang)
    219         CFLAGS += $(COMMON_CFLAGS) $(CLANG_CFLAGS)
    220 else
    221         CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
    222 endif
    223 
    224244ifeq ($(CONFIG_STRIP_BINARIES),y)
    225245        LFLAGS += --strip-all
     
    246266all-test: $(TEST_OUTPUTS)
    247267
    248 clean:
    249         rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk
     268clean: fasterclean
    250269        find . -name '*.o' -follow -exec rm \{\} \;
    251270        find . -name '*.lo' -follow -exec rm \{\} \;
     
    253272
    254273fasterclean:
    255         rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk
     274        rm -rf $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk
    256275
    257276depend: $(PRE_DEPEND)
  • uspace/lib/c/arch/amd64/Makefile.common

    r14d789c r2660ee3  
    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

    r14d789c r2660ee3  
    4545        $(LIBSOFTINT_PREFIX)/libsoftint.a
    4646
     47SPECS = gcc.specs
     48LIBC_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
     49LIBC_STARTUP_FILE = $(shell sed -n -e 's/^.*STARTUP(\(.*\)).*$$/\1/p' $(LIBC_LINKER_SCRIPT))
     50EXPORT_LINKER_SCRIPT = link.ld
     51EXPORT_STARTUP_FILE = crt0.o
     52
     53EXPORT_FILES = \
     54        ../math/libmath.a \
     55        ../clui/libclui.a \
     56        $(MERGED_C_LIBRARY) \
     57        $(EXPORT_STARTUP_FILE) \
     58        $(EXPORT_LINKER_SCRIPT) \
     59        $(SPECS)
     60
    4761REDEFS_HIDE_LIBC = redefs-hide-libc-symbols.list
    4862
     
    5367        libc.o
    5468
    55 EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) $(MERGED_C_LIBRARY)
     69EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) $(MERGED_C_LIBRARY) $(SPECS) $(EXPORT_LINKER_SCRIPT) $(EXPORT_STARTUP_FILE)
    5670
    5771SOURCES = \
     
    8397        test/scanf.c
    8498
     99EXPORT_CPPFLAGS = \
     100        -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs \
     101        -isystem $$(HELENOS_EXPORT_ROOT)/include
     102
     103EXPORT_LDFLAGS = \
     104        -L$$(HELENOS_EXPORT_ROOT)/lib \
     105        --whole-archive -lc -lmath --no-whole-archive \
     106        -T link.ld
     107
     108EXPORT_CFLAGS = \
     109        $(EXPORT_CPPFLAGS) \
     110        $(addprefix -Xlinker , $(EXPORT_LDFLAGS))
     111
    85112include $(USPACE_PREFIX)/Makefile.common
    86113
    87 $(INCLUDE_LIBC): ../c/include
    88         ln -s -f -n ../$^ $@
     114$(SPECS): $(CONFIG_MAKEFILE)
     115        echo '*self_spec:' > $@.new
     116        echo '+ $(COMMON_CFLAGS)' >> $@.new
     117        echo >> $@.new
     118        echo '*lib:' >> $@.new
     119        echo '--whole-archive -lc -lmath --no-whole-archive' >> $@.new
     120        echo >> $@.new
     121        mv $@.new $@
     122
     123$(EXPORT_LINKER_SCRIPT): $(LIBC_LINKER_SCRIPT)
     124        sed 's/STARTUP(.*)/STARTUP(crt0.o)/' $< > $@
     125
     126$(EXPORT_STARTUP_FILE): $(LIBC_STARTUP_FILE)
     127        cp $< $@
     128
     129$(INCLUDE_LIBC): $(shell find ../c/include -name '*.h')
     130        cp -r -L --remove-destination -T ../c/include $@
     131        find ../c/include -type f -and -not -name '*.h' -delete
     132
     133export: $(EXPORT_DIR)/config.mk $(EXPORT_DIR)/config.rc
     134
     135$(EXPORT_DIR)/config.mk: export-libs export-includes
     136        echo '# Generated file, do not modify.' >> $@.new
     137        echo '# Do not forget to set HELENOS_EXPORT_ROOT.' >> $@.new
     138        echo 'HELENOS_CROSS_PATH="$(shell dirname $(CC))"' >> $@.new
     139        echo 'HELENOS_TARGET="$(TARGET)"' >> $@.new
     140        echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
     141        echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
     142        echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
     143        mv $@.new $@
     144
     145$(EXPORT_DIR)/config.rc: $(EXPORT_DIR)/config.mk
     146        sed 's:$$(HELENOS_EXPORT_ROOT):$$HELENOS_EXPORT_ROOT:g' < $< >$@
     147
     148export-libs: $(EXPORT_FILES) export-includes
     149        mkdir -p $(EXPORT_DIR)/lib
     150        cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
     151
     152export-includes: $(INCLUDE_LIBC) $(shell find ./include ../c/arch/$(UARCH)/include $(ROOT_PATH)/abi/include -name '*.h')
     153        mkdir -p $(EXPORT_DIR)/include
     154        rm -rf $(EXPORT_DIR)/include.new
     155        cp -r -L -T ./include/posix $(EXPORT_DIR)/include.new
     156        cp -r -L -T ./include/libc $(EXPORT_DIR)/include.new/libc
     157        cp -r -L ../c/arch/$(UARCH)/include/* $(EXPORT_DIR)/include.new/libc
     158        cp -r -L $(ROOT_PATH)/abi/include/* $(EXPORT_DIR)/include.new
     159        mkdir -p $(EXPORT_DIR)/include.new/libclui
     160        cp -L ../clui/tinput.h $(EXPORT_DIR)/include.new/libclui
     161       
     162        find "$(EXPORT_DIR)/include.new/libc" "$(EXPORT_DIR)/include.new/libclui" -name '*.h' -exec sed \
     163                -e 's:#include <:#include <libc/:' \
     164                -e 's:#include <libc/abi/:#include <abi/:' \
     165                -e 's:#include <libc/_bits/:#include <_bits/:' \
     166                -e 's:#include <libc/libc/:#include <libc/:' \
     167                -i {} \;
     168        find "$(EXPORT_DIR)/include.new" -name '*.h' -exec sed \
     169                -e 's:#include "posix/:#include ":' \
     170                -e 's:#include <posix/:#include <:' \
     171                -i {} \;
     172       
     173        rm -rf $(EXPORT_DIR)/include
     174        mv $(EXPORT_DIR)/include.new $(EXPORT_DIR)/include
    89175
    90176$(FIXED_C_LIBRARY): $(LIBC_FILE) $(REDEFS_HIDE_LIBC)
     
    97183$(REDEFS_HIDE_LIBC): $(SOURCES)
    98184        sed -n -e 's/_HIDE_LIBC_SYMBOL(\(.*\))/\1 __helenos_libc_\1/p' $(SOURCES) >$@
    99 
Note: See TracChangeset for help on using the changeset viewer.