Changeset 2660ee3 in mainline for uspace/lib/posix/Makefile


Ignore:
Timestamp:
2018-01-31T17:47:53Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.