2020-05-06 18:40:06 +03:00
|
|
|
set(LIBC_SOURCES
|
|
|
|
arpa/inet.cpp
|
|
|
|
assert.cpp
|
|
|
|
ctype.cpp
|
2020-05-20 15:23:31 +03:00
|
|
|
cxxabi.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
dirent.cpp
|
|
|
|
dlfcn.cpp
|
|
|
|
fcntl.cpp
|
2021-02-24 13:43:47 +03:00
|
|
|
fenv.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
getopt.cpp
|
|
|
|
grp.cpp
|
2021-03-07 19:09:44 +03:00
|
|
|
inttypes.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
ioctl.cpp
|
|
|
|
libcinit.cpp
|
|
|
|
libgen.cpp
|
2021-04-16 22:53:43 +03:00
|
|
|
link.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
locale.cpp
|
|
|
|
malloc.cpp
|
|
|
|
mntent.cpp
|
2021-05-09 20:50:26 +03:00
|
|
|
net.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
netdb.cpp
|
|
|
|
poll.cpp
|
2021-04-17 19:38:32 +03:00
|
|
|
pthread_forward.cpp
|
2021-02-14 18:04:18 +03:00
|
|
|
pthread_integration.cpp
|
2021-04-17 19:38:32 +03:00
|
|
|
pthread_tls.cpp
|
2021-04-30 04:40:38 +03:00
|
|
|
pty.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
pwd.cpp
|
|
|
|
qsort.cpp
|
|
|
|
scanf.cpp
|
|
|
|
sched.cpp
|
|
|
|
serenity.cpp
|
2021-05-01 12:43:38 +03:00
|
|
|
shadow.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
signal.cpp
|
2020-06-16 04:36:08 +03:00
|
|
|
spawn.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
stat.cpp
|
|
|
|
stdio.cpp
|
|
|
|
stdlib.cpp
|
|
|
|
string.cpp
|
|
|
|
strings.cpp
|
2021-02-24 16:54:26 +03:00
|
|
|
stubs.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
syslog.cpp
|
2021-05-14 18:38:33 +03:00
|
|
|
sys/mman.cpp
|
2020-12-25 20:27:42 +03:00
|
|
|
sys/prctl.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
sys/ptrace.cpp
|
|
|
|
sys/select.cpp
|
|
|
|
sys/socket.cpp
|
|
|
|
sys/uio.cpp
|
|
|
|
sys/wait.cpp
|
2021-05-19 12:32:53 +03:00
|
|
|
sys/statvfs.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
termcap.cpp
|
|
|
|
termios.cpp
|
|
|
|
time.cpp
|
|
|
|
times.cpp
|
|
|
|
ulimit.cpp
|
|
|
|
unistd.cpp
|
|
|
|
utime.cpp
|
|
|
|
utsname.cpp
|
|
|
|
wchar.cpp
|
|
|
|
)
|
|
|
|
|
2021-01-12 14:17:30 +03:00
|
|
|
file(GLOB AK_SOURCES CONFIGURE_DEPENDS "../../../AK/*.cpp")
|
2020-10-28 22:01:29 +03:00
|
|
|
file(GLOB ELF_SOURCES CONFIGURE_DEPENDS "../LibELF/*.cpp")
|
2021-02-25 17:26:08 +03:00
|
|
|
|
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "i686")
|
|
|
|
set(ASM_SOURCES "arch/i386/setjmp.S")
|
|
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/i386/plt_trampoline.S)
|
|
|
|
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|
|
|
set(ASM_SOURCES "arch/x86_64/setjmp.S")
|
2021-03-07 18:11:25 +03:00
|
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/x86_64/plt_trampoline.S)
|
2021-02-25 17:26:08 +03:00
|
|
|
endif()
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2020-09-01 12:59:55 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -DSERENITY_LIBC_BUILD")
|
2020-05-20 15:23:31 +03:00
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
add_library(crt0 STATIC crt0.cpp)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET crt0
|
2021-02-15 00:49:25 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:crt0> ${CMAKE_INSTALL_PREFIX}/usr/lib/crt0.o
|
2020-05-06 18:40:06 +03:00
|
|
|
)
|
2020-12-20 23:32:10 +03:00
|
|
|
add_library(crt0_shared STATIC crt0_shared.cpp)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET crt0_shared
|
2021-02-15 00:49:25 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:crt0_shared> ${CMAKE_INSTALL_PREFIX}/usr/lib/crt0_shared.o
|
2020-12-20 23:32:10 +03:00
|
|
|
)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-01-02 02:27:42 +03:00
|
|
|
set_source_files_properties (ssp.cpp PROPERTIES COMPILE_FLAGS
|
|
|
|
"-fno-stack-protector")
|
|
|
|
add_library(ssp STATIC ssp.cpp)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ssp
|
2021-02-15 00:49:25 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:ssp> ${CMAKE_INSTALL_PREFIX}/usr/lib/ssp.o
|
2021-01-02 02:27:42 +03:00
|
|
|
)
|
|
|
|
|
2021-02-25 17:26:08 +03:00
|
|
|
set(SOURCES ${LIBC_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${ASM_SOURCES})
|
2020-11-20 15:18:53 +03:00
|
|
|
|
2021-03-14 22:39:09 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
|
|
|
|
add_library(LibCStaticWithoutDeps STATIC ${SOURCES})
|
2021-04-15 23:00:44 +03:00
|
|
|
target_link_libraries(LibCStaticWithoutDeps ssp)
|
2021-05-24 04:40:22 +03:00
|
|
|
add_dependencies(LibCStaticWithoutDeps LibM LibSystem LibUBSanitizer)
|
2021-03-14 22:39:09 +03:00
|
|
|
|
|
|
|
add_custom_target(LibCStatic
|
|
|
|
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:LibCStaticWithoutDeps>
|
|
|
|
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:ssp>
|
|
|
|
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:LibSystemStatic>
|
2021-05-24 04:40:22 +03:00
|
|
|
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:LibUBSanitizerStatic>
|
2021-03-14 22:39:09 +03:00
|
|
|
COMMAND ${CMAKE_AR} -qcs ${CMAKE_CURRENT_BINARY_DIR}/libc.a *.o
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2021-05-24 04:40:22 +03:00
|
|
|
DEPENDS LibCStaticWithoutDeps ssp LibSystemStatic LibUBSanitizerStatic
|
2021-03-14 22:39:09 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libc.a DESTINATION ${CMAKE_INSTALL_PREFIX}/usr/lib/)
|
|
|
|
file(GLOB TEMP_OBJ_FILES ${CMAKE_CURRENT_BINARY_DIR}/*.o)
|
|
|
|
set_property(
|
|
|
|
TARGET LibCStatic
|
|
|
|
APPEND
|
|
|
|
PROPERTY ADDITIONAL_CLEAN_FILES ${TEMP_OBJ_FILES}
|
|
|
|
)
|
2020-11-20 15:18:53 +03:00
|
|
|
|
2020-11-13 15:47:00 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
|
2020-05-06 18:40:06 +03:00
|
|
|
serenity_libc(LibC c)
|
2021-04-15 23:00:44 +03:00
|
|
|
target_link_libraries(LibC ssp system)
|
2021-03-14 22:39:09 +03:00
|
|
|
|
|
|
|
# We mark LibCStatic as a dependency of LibC because this triggers the build of the LibCStatic target
|
|
|
|
add_dependencies(LibC LibM LibSystem LibCStatic)
|