diff --git a/Applications/About/Makefile b/Applications/About/Makefile index d7fb296ca9..a5aebd48a1 100644 --- a/Applications/About/Makefile +++ b/Applications/About/Makefile @@ -15,11 +15,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-ld AR = i686-pc-serenity-ar +LDFLAGS = -L../../LibC -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile index 867cb0a8b2..7bbfcc64d0 100644 --- a/Applications/FileManager/Makefile +++ b/Applications/FileManager/Makefile @@ -16,11 +16,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-ld AR = i686-pc-serenity-ar +LDFLAGS = -L../../LibC -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/FontEditor/Makefile b/Applications/FontEditor/Makefile index 88ef5cc354..dda8ad1ce6 100644 --- a/Applications/FontEditor/Makefile +++ b/Applications/FontEditor/Makefile @@ -16,11 +16,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-ld AR = i686-pc-serenity-ar +LDFLAGS = -L../../LibC -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/Launcher/Makefile b/Applications/Launcher/Makefile index 960e9c985c..dd93622800 100644 --- a/Applications/Launcher/Makefile +++ b/Applications/Launcher/Makefile @@ -15,11 +15,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-ld AR = i686-pc-serenity-ar +LDFLAGS = -L../../LibC -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/Terminal/Makefile b/Applications/Terminal/Makefile index c8c0ca7455..d1c10de1e1 100644 --- a/Applications/Terminal/Makefile +++ b/Applications/Terminal/Makefile @@ -16,11 +16,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-ld AR = i686-pc-serenity-ar +LDFLAGS = -L../../LibC -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 4621da47d9..5a05b82c6e 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -1,6 +1,7 @@ #pragma once #include +#include #define ENUMERATE_SYSCALLS \ __ENUMERATE_SYSCALL(sleep) \ @@ -83,10 +84,6 @@ __ENUMERATE_SYSCALL(link) \ -#ifdef SERENITY -struct fd_set; -#endif - namespace Syscall { enum Function { diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h index 18e661034d..0f9d835e5b 100644 --- a/Kernel/UnixTypes.h +++ b/Kernel/UnixTypes.h @@ -1,8 +1,5 @@ #pragma once -#define FD_SETSIZE 64 -struct fd_set { unsigned char bits[FD_SETSIZE / 8]; }; - #define WNOHANG 1 #define SIG_DFL ((void*)0) diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh index cecd5a1aaa..d3c5f7fc56 100755 --- a/Kernel/makeall.sh +++ b/Kernel/makeall.sh @@ -4,8 +4,15 @@ sudo id make_cmd="make -j2" +rm -r ../Root/usr && \ $make_cmd -C ../LibC clean && \ $make_cmd -C ../LibC && \ +(cd ../LibC && ./install.sh) && \ +$make_cmd -C ../LibM clean && \ +$make_cmd -C ../LibM && \ +(cd ../LibM && ./install.sh) && \ +$make_cmd -C ../LibM clean && \ +$make_cmd -C ../LibM clean && \ $make_cmd -C ../LibGUI clean && \ $make_cmd -C ../LibGUI && \ $make_cmd -C ../Userland clean && \ diff --git a/LibC/.gitignore b/LibC/.gitignore index 5191909171..34cdcf1531 100644 --- a/LibC/.gitignore +++ b/LibC/.gitignore @@ -1,4 +1,4 @@ *.o *.no *.d -LibC.a +libc.a diff --git a/LibC/Makefile b/LibC/Makefile index 51ce548660..04dbfd7b2b 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -32,7 +32,6 @@ LIBC_OBJS = \ ulimit.o \ qsort.o \ ioctl.o \ - math.o \ utime.o \ sys/select.o \ sys/socket.o \ @@ -45,7 +44,7 @@ ASM_OBJS = setjmp.no CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) -LIBRARY = LibC.a +LIBRARY = libc.a STANDARD_FLAGS = -std=c++17 WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough FLAVOR_FLAGS = -fno-exceptions -fno-rtti diff --git a/LibC/fd_set.h b/LibC/fd_set.h new file mode 100644 index 0000000000..802c0b3385 --- /dev/null +++ b/LibC/fd_set.h @@ -0,0 +1,13 @@ +#pragma once + +#define FD_SETSIZE 64 +#define FD_ZERO(set) memset((set), 0, sizeof(fd_set)); +#define FD_CLR(fd, set) ((set)->bits[(fd / 8)] &= ~(1 << (fd) % 8)) +#define FD_SET(fd, set) ((set)->bits[(fd / 8)] |= (1 << (fd) % 8)) +#define FD_ISSET(fd, set) ((set)->bits[(fd / 8)] & (1 << (fd) % 8)) + +struct __fd_set { + unsigned char bits[FD_SETSIZE / 8]; +}; + +typedef struct __fd_set fd_set; diff --git a/LibC/install-headers.sh b/LibC/install.sh similarity index 67% rename from LibC/install-headers.sh rename to LibC/install.sh index 0609c37541..32da873603 100755 --- a/LibC/install-headers.sh +++ b/LibC/install.sh @@ -1,5 +1,7 @@ #!/bin/bash mkdir -p ../Root/usr/include/sys/ +mkdir -p ../Root/usr/lib/ cp *.h ../Root/usr/include/ cp sys/*.h ../Root/usr/include/sys/ +cp libc.a ../Root/usr/lib/ diff --git a/LibC/math.cpp b/LibC/math.cpp deleted file mode 100644 index 31b9b65e54..0000000000 --- a/LibC/math.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -extern "C" { - -double pow(double x, double y) -{ - (void) x; - (void) y; - assert(false); -} - -} - diff --git a/LibC/sys/select.h b/LibC/sys/select.h index 845ac9d52b..9cc8abae4c 100644 --- a/LibC/sys/select.h +++ b/LibC/sys/select.h @@ -3,21 +3,10 @@ #include #include #include +#include __BEGIN_DECLS -#define FD_SETSIZE 64 -#define FD_ZERO(set) memset((set), 0, sizeof(fd_set)); -#define FD_CLR(fd, set) ((set)->bits[(fd / 8)] &= ~(1 << (fd) % 8)) -#define FD_SET(fd, set) ((set)->bits[(fd / 8)] |= (1 << (fd) % 8)) -#define FD_ISSET(fd, set) ((set)->bits[(fd / 8)] & (1 << (fd) % 8)) - -struct __fd_set { - unsigned char bits[FD_SETSIZE / 8]; -}; - -typedef struct __fd_set fd_set; - int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout); __END_DECLS diff --git a/LibGUI/.gitignore b/LibGUI/.gitignore index 2786c2d53d..322d638d6a 100644 --- a/LibGUI/.gitignore +++ b/LibGUI/.gitignore @@ -1,3 +1,3 @@ *.o *.d -LibGUI.a +libgui.a diff --git a/LibGUI/Makefile b/LibGUI/Makefile index 671c7a396a..f3ac6e262b 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -32,9 +32,9 @@ LIBGUI_OBJS = \ OBJS = $(SHAREDGRAPHICS_OBJS) $(LIBGUI_OBJS) -LIBS = ../LibC/LibC.a +LIBS = -lc -LIBRARY = LibGUI.a +LIBRARY = libgui.a STANDARD_FLAGS = -std=c++17 WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough FLAVOR_FLAGS = -fno-exceptions -fno-rtti diff --git a/LibM/.gitignore b/LibM/.gitignore new file mode 100644 index 0000000000..551948494d --- /dev/null +++ b/LibM/.gitignore @@ -0,0 +1,3 @@ +*.o +*.d +libm.a diff --git a/LibM/Makefile b/LibM/Makefile new file mode 100644 index 0000000000..ebc7927e3e --- /dev/null +++ b/LibM/Makefile @@ -0,0 +1,32 @@ +OBJS = math.o + +LIBRARY = libm.a +STANDARD_FLAGS = -std=c++17 +WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough +FLAVOR_FLAGS = -fno-exceptions -fno-rtti +OPTIMIZATION_FLAGS = -Os +INCLUDE_FLAGS = -I.. -I. + +DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS + +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-pc-serenity-g++ +LD = i686-pc-serenity-ld +AR = i686-pc-serenity-ar + +all: $(LIBRARY) + +$(LIBRARY): $(OBJS) + @echo "LIB $@"; $(AR) rcs $@ $(OBJS) + +.cpp.o: + @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< + +%.no: %.asm + @echo "NASM $@"; nasm -f elf -o $@ $< + +-include $(OBJS:%.o=%.d) + +clean: + @echo "CLEAN"; rm -f $(LIBRARY) $(OBJS) *.d + diff --git a/LibM/install.sh b/LibM/install.sh new file mode 100755 index 0000000000..83c8f6e632 --- /dev/null +++ b/LibM/install.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir -p ../Root/usr/include/sys/ +mkdir -p ../Root/usr/lib/ +cp *.h ../Root/usr/include/ +cp libm.a ../Root/usr/lib/ diff --git a/LibM/math.cpp b/LibM/math.cpp new file mode 100644 index 0000000000..6041c84a56 --- /dev/null +++ b/LibM/math.cpp @@ -0,0 +1,23 @@ +#include +#include + +extern "C" { + +double cos(double) +{ + assert(false); +} + +double sin(double) +{ + assert(false); +} + +double pow(double x, double y) +{ + (void)x; + (void)y; + assert(false); +} + +} diff --git a/LibC/math.h b/LibM/math.h similarity index 100% rename from LibC/math.h rename to LibM/math.h diff --git a/Userland/Makefile b/Userland/Makefile index ce01ce4da0..18f07dc9bc 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -82,110 +82,111 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARC CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-ld AR = i686-pc-serenity-r +LDFLAGS = -L ../LibC all: $(OBJS) $(APPS) id: id.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc sh: sh.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc ps: ps.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc ls: ls.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc fgrep: fgrep.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc sleep: sleep.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc date: date.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc true: true.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc false: false.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc hostname: hostname.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc cat: cat.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc uname: uname.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc clear: clear.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc tst: tst.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc mm: mm.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc dmesg: dmesg.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc kill: kill.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc tty: tty.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc mkdir: mkdir.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc touch: touch.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc sync: sync.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc more: more.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc guitest2: guitest2.o - $(LD) -o $@ $(LDFLAGS) $< ../LibGUI/LibGUI.a ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) -L../LibGUI $< -lgui -lc sysctl: sysctl.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc pape: pape.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc cp: cp.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc rm: rm.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc rmdir: rmdir.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc chmod: chmod.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc top: top.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc ln: ln.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc df: df.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc su: su.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc env: env.o - $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + $(LD) -o $@ $(LDFLAGS) $< -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/WindowServer/Makefile b/WindowServer/Makefile index 0b9c0e5ed3..15802c26a2 100644 --- a/WindowServer/Makefile +++ b/WindowServer/Makefile @@ -27,6 +27,7 @@ WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fal FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. -I../LibC +LDFLAGS = -L../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND @@ -38,7 +39,7 @@ AR = i686-pc-serenity-ar all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibC/LibC.a + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<