Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/Makefile

    r2660ee3 r3a37751  
    3737LIBC_FILE = $(LIBC_PREFIX)/libc.a
    3838
     39FIXED_POSIX_LIBRARY = libposixaslibc.a
    3940FIXED_C_LIBRARY = libc4posix.a
    4041MERGED_C_LIBRARY = libc.a
    4142MERGE_LIBRARIES = \
    4243        $(FIXED_C_LIBRARY) \
    43         $(LIBRARY).a \
     44        $(FIXED_POSIX_LIBRARY) \
    4445        $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a \
    4546        $(LIBSOFTINT_PREFIX)/libsoftint.a
    4647
    47 SPECS = gcc.specs
    48 LIBC_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
    49 LIBC_STARTUP_FILE = $(shell sed -n -e 's/^.*STARTUP(\(.*\)).*$$/\1/p' $(LIBC_LINKER_SCRIPT))
    50 EXPORT_LINKER_SCRIPT = link.ld
    51 EXPORT_STARTUP_FILE = crt0.o
    52 
    53 EXPORT_FILES = \
    54         ../math/libmath.a \
    55         ../clui/libclui.a \
    56         $(MERGED_C_LIBRARY) \
    57         $(EXPORT_STARTUP_FILE) \
    58         $(EXPORT_LINKER_SCRIPT) \
    59         $(SPECS)
    60 
    6148REDEFS_HIDE_LIBC = redefs-hide-libc-symbols.list
     49REDEFS_SHOW_LIBPOSIX = redefs-show-posix-symbols.list
     50COLLISIONS_LIST = collisions.list
    6251
    6352PRE_DEPEND = $(INCLUDE_LIBC)
     
    6554        $(INCLUDE_LIBC) \
    6655        $(REDEFS_HIDE_LIBC) \
     56        $(REDEFS_SHOW_LIBPOSIX) \
     57        $(COLLISIONS_LIST) \
    6758        libc.o
    6859
    69 EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) $(MERGED_C_LIBRARY) $(SPECS) $(EXPORT_LINKER_SCRIPT) $(EXPORT_STARTUP_FILE)
     60EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) $(MERGED_C_LIBRARY)
    7061
    7162SOURCES = \
    72         src/ctype.c \
    73         src/dlfcn.c \
    74         src/fcntl.c \
    75         src/fnmatch.c \
    76         src/locale.c \
    77         src/pthread/condvar.c \
    78         src/pthread/keys.c \
    79         src/pthread/mutex.c \
    80         src/pthread/threads.c \
    81         src/pwd.c \
    82         src/signal.c \
    83         src/stdio.c \
    84         src/stdio/scanf.c \
    85         src/stdlib.c \
    86         src/stdlib/strtold.c \
    87         src/string.c \
    88         src/strings.c \
    89         src/sys/mman.c \
    90         src/sys/stat.c \
    91         src/sys/wait.c \
    92         src/time.c \
    93         src/unistd.c
     63        source/ctype.c \
     64        source/dlfcn.c \
     65        source/errno.c \
     66        source/fcntl.c \
     67        source/fnmatch.c \
     68        source/getopt.c \
     69        source/locale.c \
     70        source/pthread/condvar.c \
     71        source/pthread/keys.c \
     72        source/pthread/mutex.c \
     73        source/pthread/threads.c \
     74        source/pwd.c \
     75        source/signal.c \
     76        source/stdio.c \
     77        source/stdio/scanf.c \
     78        source/stdlib.c \
     79        source/stdlib/strtol.c \
     80        source/stdlib/strtold.c \
     81        source/string.c \
     82        source/strings.c \
     83        source/sys/mman.c \
     84        source/sys/stat.c \
     85        source/sys/wait.c \
     86        source/time.c \
     87        source/unistd.c
    9488
    9589TEST_SOURCES = \
     
    9791        test/scanf.c
    9892
    99 EXPORT_CPPFLAGS = \
    100         -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs \
    101         -isystem $$(HELENOS_EXPORT_ROOT)/include
    102 
    103 EXPORT_LDFLAGS = \
    104         -L$$(HELENOS_EXPORT_ROOT)/lib \
    105         --whole-archive -lc -lmath --no-whole-archive \
    106         -T link.ld
    107 
    108 EXPORT_CFLAGS = \
    109         $(EXPORT_CPPFLAGS) \
    110         $(addprefix -Xlinker , $(EXPORT_LDFLAGS))
    111 
    11293include $(USPACE_PREFIX)/Makefile.common
    11394
    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 $@
     95$(INCLUDE_LIBC): ../c/include
     96        ln -s -f -n ../$^ $@
    12297
    123 $(EXPORT_LINKER_SCRIPT): $(LIBC_LINKER_SCRIPT)
    124         sed 's/STARTUP(.*)/STARTUP(crt0.o)/' $< > $@
     98$(FIXED_C_LIBRARY): $(LIBC_FILE) $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
     99        $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBC_FILE) $@
     100        $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@
    125101
    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 
    133 export: $(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 
    148 export-libs: $(EXPORT_FILES) export-includes
    149         mkdir -p $(EXPORT_DIR)/lib
    150         cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
    151 
    152 export-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
    175 
    176 $(FIXED_C_LIBRARY): $(LIBC_FILE) $(REDEFS_HIDE_LIBC)
    177         $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBC_FILE) $@
     102$(FIXED_POSIX_LIBRARY): $(LIBRARY).a $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
     103        $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBRARY).a $@
     104        $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@
    178105
    179106$(MERGED_C_LIBRARY): $(MERGE_LIBRARIES)
     
    181108        $(AR) rc $@ libc.o
    182109
    183 $(REDEFS_HIDE_LIBC): $(SOURCES)
    184         sed -n -e 's/_HIDE_LIBC_SYMBOL(\(.*\))/\1 __helenos_libc_\1/p' $(SOURCES) >$@
     110$(REDEFS_HIDE_LIBC): $(COLLISIONS_LIST)
     111        sed 's/.*/& __helenos_libc_&/' <$(COLLISIONS_LIST) >$@
     112
     113$(REDEFS_SHOW_LIBPOSIX): $(COLLISIONS_LIST)
     114        sed 's/.*/posix_& &/' <$(COLLISIONS_LIST) >$@
     115
     116$(COLLISIONS_LIST): include/posix/*.h include/posix/*/*.h
     117        find ./include/posix -name '*.h' -exec \
     118                sed -n -e '/^#/d' -e 's/__POSIX_DEF__/\n&/gp' {} \; | \
     119                sed -n -e 's/__POSIX_DEF__(\([^)]*\)).*/\1/p' | \
     120                sort -u >$@
Note: See TracChangeset for help on using the changeset viewer.