From c127d1632679823d2cfe873895fad72aa52cfc87 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Tue, 24 Dec 2019 20:36:04 -0600 Subject: [PATCH] Build: support library and generator dependencies Instead of directly manipulating LDFLAGS, set LIB_DEPS in each subdirectory Makefile listing the libraries needed for building/linking such as "LIB_DEPS = Core GUI Draw IPC Core". This adds each library as an -L and -l argument in LDFLAGS, but also adds the library.a file as a link dependency on the current $(PROGRAM). This causes the given library to be (re)built before linking the current $(PROGRAM), but will also re-link any binaries depending on that library when it is modified, when running make from the root directory. Also turn generator tools like IPCCompiler into dependencies on the files they generate, so they are built on-demand when a particular directory needs them. This all allows the root Makefile to just list directories and not care about the order, as all of the dependency tracking will figure it out. --- Applications/About/Makefile | 2 +- Applications/Browser/Makefile | 6 ++- Applications/Calculator/Makefile | 2 +- Applications/ChanViewer/Makefile | 2 +- Applications/DisplayProperties/Makefile | 2 +- Applications/FileManager/Makefile | 2 +- Applications/FontEditor/Makefile | 6 +-- Applications/Help/Makefile | 2 +- Applications/HexEditor/Makefile | 2 +- Applications/IRCClient/Makefile | 2 +- Applications/PaintBrush/Makefile | 2 +- Applications/Piano/Makefile | 2 +- Applications/QuickShow/Makefile | 2 +- Applications/SoundPlayer/Makefile | 2 +- Applications/SystemDialog/Makefile | 2 +- Applications/SystemMonitor/Makefile | 2 +- Applications/Taskbar/Makefile | 2 +- Applications/Terminal/Makefile | 2 +- Applications/TextEditor/Makefile | 2 +- Applications/Welcome/Makefile | 2 +- Demos/Fire/Makefile | 2 +- Demos/HelloWorld/Makefile | 2 +- Demos/HelloWorld2/Makefile | 2 +- Demos/WidgetGallery/Makefile | 2 +- DevTools/HackStudio/Makefile | 2 +- DevTools/Inspector/Makefile | 2 +- DevTools/ProfileViewer/Makefile | 2 +- DevTools/VisualBuilder/Makefile | 2 +- Games/Minesweeper/Makefile | 2 +- Games/Snake/Makefile | 2 +- Libraries/LibAudio/Makefile | 4 ++ Libraries/LibC/Makefile | 15 ++++--- Libraries/LibGUI/Makefile | 5 +++ Libraries/LibHTML/CodeGenerators/Makefile | 3 ++ Libraries/LibHTML/Makefile | 23 ++++++++-- Makefile | 41 ++++-------------- Makefile.common | 52 +++++++++++++---------- MenuApplets/Audio/Makefile | 2 +- MenuApplets/CPUGraph/Makefile | 2 +- Servers/AudioServer/Makefile | 6 +-- Servers/LookupServer/Makefile | 2 +- Servers/ProtocolServer/Makefile | 6 +-- Servers/SystemServer/Makefile | 2 +- Servers/TelnetServer/Makefile | 2 +- Servers/WindowServer/Makefile | 6 +-- Shell/Makefile | 2 +- Userland/Makefile | 2 +- 47 files changed, 130 insertions(+), 113 deletions(-) create mode 100644 Libraries/LibHTML/CodeGenerators/Makefile diff --git a/Applications/About/Makefile b/Applications/About/Makefile index be5c34c9f67..cb2e9db1671 100755 --- a/Applications/About/Makefile +++ b/Applications/About/Makefile @@ -3,7 +3,7 @@ OBJS = \ PROGRAM = About -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core DEFINES += -DGIT_COMMIT=\"`git rev-parse --short HEAD`\" -DGIT_BRANCH=\"`git rev-parse --abbrev-ref HEAD`\" -DGIT_CHANGES=\"`git diff-index --quiet HEAD -- && echo "tracked"|| echo "untracked"`\" diff --git a/Applications/Browser/Makefile b/Applications/Browser/Makefile index dcb43df5bf4..599282adab8 100755 --- a/Applications/Browser/Makefile +++ b/Applications/Browser/Makefile @@ -3,6 +3,10 @@ OBJS = \ PROGRAM = Browser -LDFLAGS = -lgui -lhtml -ldraw -lprotocol -lipc -lcore -lc +LIB_DEPS = GUI HTML Draw IPC Protocol Core + +main.cpp: ../../Libraries/LibHTML/CSS/PropertyID.h +../../Libraries/LibHTML/CSS/PropertyID.h: + @$(MAKE) -C ../../Libraries/LibHTML include ../../Makefile.common diff --git a/Applications/Calculator/Makefile b/Applications/Calculator/Makefile index 1b4302c106f..59827aed5e3 100644 --- a/Applications/Calculator/Makefile +++ b/Applications/Calculator/Makefile @@ -6,6 +6,6 @@ OBJS = \ PROGRAM = Calculator -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core include ../../Makefile.common diff --git a/Applications/ChanViewer/Makefile b/Applications/ChanViewer/Makefile index 93109019003..45affe18eaf 100755 --- a/Applications/ChanViewer/Makefile +++ b/Applications/ChanViewer/Makefile @@ -5,6 +5,6 @@ OBJS = \ PROGRAM = ChanViewer -LDFLAGS = -lgui -ldraw -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/DisplayProperties/Makefile b/Applications/DisplayProperties/Makefile index 000a6c8727d..ff79479d914 100644 --- a/Applications/DisplayProperties/Makefile +++ b/Applications/DisplayProperties/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = DisplayProperties -LDFLAGS = -lgui -ldraw -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile index 4a9e97aab32..aeb46376d30 100644 --- a/Applications/FileManager/Makefile +++ b/Applications/FileManager/Makefile @@ -6,6 +6,6 @@ OBJS = \ PROGRAM = FileManager -LDFLAGS = -lgui -ldraw -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/FontEditor/Makefile b/Applications/FontEditor/Makefile index 5713cec4e5c..34ad2b4cf1e 100644 --- a/Applications/FontEditor/Makefile +++ b/Applications/FontEditor/Makefile @@ -6,12 +6,12 @@ OBJS = \ PROGRAM = FontEditor -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw Core IPC FontEditor.cpp: UI_FontEditorBottom.h -UI_FontEditorBottom.h: FontEditorBottom.frm - ../../DevTools/FormCompiler/FormCompiler $< > $@ +UI_FontEditorBottom.h: FontEditorBottom.frm FORMCOMPILER + $(QUIET) $(FORMCOMPILER) $< > $@ EXTRA_CLEAN = UI_FontEditorBottom.h diff --git a/Applications/Help/Makefile b/Applications/Help/Makefile index d9fb7df6b4f..0dd85636662 100644 --- a/Applications/Help/Makefile +++ b/Applications/Help/Makefile @@ -7,6 +7,6 @@ OBJS = \ PROGRAM = Help -LDFLAGS = -lgui -lhtml -lmarkdown -ldraw -lipc -lprotocol -lthread -lpthread -lcore -lc +LIB_DEPS = GUI HTML Draw Markdown IPC Protocol Thread Pthread Core include ../../Makefile.common diff --git a/Applications/HexEditor/Makefile b/Applications/HexEditor/Makefile index 2ce7c89bfe1..690ee576f52 100644 --- a/Applications/HexEditor/Makefile +++ b/Applications/HexEditor/Makefile @@ -5,6 +5,6 @@ OBJS = \ PROGRAM = HexEditor -LDFLAGS = -lgui -ldraw -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/IRCClient/Makefile b/Applications/IRCClient/Makefile index e2b7766d62d..6a1fb3f612d 100644 --- a/Applications/IRCClient/Makefile +++ b/Applications/IRCClient/Makefile @@ -11,6 +11,6 @@ OBJS = \ PROGRAM = IRCClient -LDFLAGS = -lgui -lhtml -ldraw -lprotocol -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI HTML Draw Protocol IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/PaintBrush/Makefile b/Applications/PaintBrush/Makefile index b05e21f9ff4..09dce440a13 100644 --- a/Applications/PaintBrush/Makefile +++ b/Applications/PaintBrush/Makefile @@ -14,6 +14,6 @@ OBJS = \ PROGRAM = PaintBrush -LDFLAGS = -lgui -ldraw -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/Piano/Makefile b/Applications/Piano/Makefile index 250a26e8d9c..f39d2ba9f60 100644 --- a/Applications/Piano/Makefile +++ b/Applications/Piano/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = Piano -LDFLAGS = -lgui -ldraw -laudio -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw Audio IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/QuickShow/Makefile b/Applications/QuickShow/Makefile index 9874612ecde..9d27bc44f22 100644 --- a/Applications/QuickShow/Makefile +++ b/Applications/QuickShow/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = QuickShow -LDFLAGS = -lgui -ldraw -lprotocol -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw Protocol IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/SoundPlayer/Makefile b/Applications/SoundPlayer/Makefile index aac1e79ca71..6c2b4766f58 100644 --- a/Applications/SoundPlayer/Makefile +++ b/Applications/SoundPlayer/Makefile @@ -6,6 +6,6 @@ OBJS = \ PROGRAM = SoundPlayer -LDFLAGS = -lgui -ldraw -laudio -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw Audio IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/SystemDialog/Makefile b/Applications/SystemDialog/Makefile index 732637b9a51..6ccf7690e6c 100755 --- a/Applications/SystemDialog/Makefile +++ b/Applications/SystemDialog/Makefile @@ -3,6 +3,6 @@ OBJS = \ PROGRAM = SystemDialog -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core include ../../Makefile.common diff --git a/Applications/SystemMonitor/Makefile b/Applications/SystemMonitor/Makefile index 625d30a9913..34196422b82 100644 --- a/Applications/SystemMonitor/Makefile +++ b/Applications/SystemMonitor/Makefile @@ -12,6 +12,6 @@ OBJS = \ PROGRAM = SystemMonitor -LDFLAGS = -lgui -ldraw -lprotocol -lpcidb -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw Protocol PCIDB IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/Taskbar/Makefile b/Applications/Taskbar/Makefile index 1bdca77abda..9c6463567d9 100644 --- a/Applications/Taskbar/Makefile +++ b/Applications/Taskbar/Makefile @@ -6,6 +6,6 @@ OBJS = \ PROGRAM = Taskbar -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core include ../../Makefile.common diff --git a/Applications/Terminal/Makefile b/Applications/Terminal/Makefile index 1b862da2f9f..b005a755aa2 100644 --- a/Applications/Terminal/Makefile +++ b/Applications/Terminal/Makefile @@ -3,6 +3,6 @@ OBJS = \ PROGRAM = Terminal -LDFLAGS = -lgui -ldraw -lvt -lprotocol -lipc -lcore -lc +LIB_DEPS = GUI Draw VT IPC Protocol Core include ../../Makefile.common diff --git a/Applications/TextEditor/Makefile b/Applications/TextEditor/Makefile index 342640c6bea..6a1b53bc443 100755 --- a/Applications/TextEditor/Makefile +++ b/Applications/TextEditor/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = TextEditor -LDFLAGS = -lgui -ldraw -lvt -lipc -lthread -lpthread -lcore -lc +LIB_DEPS = GUI Draw VT IPC Thread Pthread Core include ../../Makefile.common diff --git a/Applications/Welcome/Makefile b/Applications/Welcome/Makefile index 89e4636d8bf..9fc91bca6bf 100644 --- a/Applications/Welcome/Makefile +++ b/Applications/Welcome/Makefile @@ -5,7 +5,7 @@ OBJS = \ PROGRAM = Welcome -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core .SUFFIXES: .png %.png.o: %.png diff --git a/Demos/Fire/Makefile b/Demos/Fire/Makefile index bae234fe12d..122be1ba317 100644 --- a/Demos/Fire/Makefile +++ b/Demos/Fire/Makefile @@ -3,6 +3,6 @@ OBJS = \ PROGRAM = Fire -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI IPC Draw Core include ../../Makefile.common diff --git a/Demos/HelloWorld/Makefile b/Demos/HelloWorld/Makefile index d4bdac2e7ed..41831f89159 100644 --- a/Demos/HelloWorld/Makefile +++ b/Demos/HelloWorld/Makefile @@ -3,6 +3,6 @@ OBJS = \ PROGRAM = HelloWorld -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI IPC Draw Core include ../../Makefile.common diff --git a/Demos/HelloWorld2/Makefile b/Demos/HelloWorld2/Makefile index cc3904e8d96..11bca8b957e 100644 --- a/Demos/HelloWorld2/Makefile +++ b/Demos/HelloWorld2/Makefile @@ -3,7 +3,7 @@ OBJS = \ PROGRAM = HelloWorld2 -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI IPC Draw Core main.cpp: UI_HelloWorld2.h diff --git a/Demos/WidgetGallery/Makefile b/Demos/WidgetGallery/Makefile index 86d18e66e06..71e40a40b49 100644 --- a/Demos/WidgetGallery/Makefile +++ b/Demos/WidgetGallery/Makefile @@ -3,6 +3,6 @@ OBJS = \ PROGRAM = WidgetGallery -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI IPC Draw Core include ../../Makefile.common diff --git a/DevTools/HackStudio/Makefile b/DevTools/HackStudio/Makefile index 582332f226c..4d902305df4 100644 --- a/DevTools/HackStudio/Makefile +++ b/DevTools/HackStudio/Makefile @@ -18,6 +18,6 @@ OBJS = \ PROGRAM = HackStudio -LDFLAGS = -lvt -lhtml -lprotocol -lipc -lmarkdown -lgui -ldraw -lthread -lpthread -lcore -lc +LIB_DEPS = GUI HTML VT Protocol Markdown Draw IPC Thread Pthread Core include ../../Makefile.common diff --git a/DevTools/Inspector/Makefile b/DevTools/Inspector/Makefile index 09cb351a20a..f2afb507b20 100644 --- a/DevTools/Inspector/Makefile +++ b/DevTools/Inspector/Makefile @@ -7,6 +7,6 @@ OBJS = \ PROGRAM = Inspector -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core include ../../Makefile.common diff --git a/DevTools/ProfileViewer/Makefile b/DevTools/ProfileViewer/Makefile index d72632a549d..01daf3d50a6 100644 --- a/DevTools/ProfileViewer/Makefile +++ b/DevTools/ProfileViewer/Makefile @@ -6,6 +6,6 @@ OBJS = \ PROGRAM = ProfileViewer -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core include ../../Makefile.common diff --git a/DevTools/VisualBuilder/Makefile b/DevTools/VisualBuilder/Makefile index 289c6167b17..a29ba982eb3 100644 --- a/DevTools/VisualBuilder/Makefile +++ b/DevTools/VisualBuilder/Makefile @@ -9,6 +9,6 @@ OBJS = \ PROGRAM = VisualBuilder -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI Draw IPC Core include ../../Makefile.common diff --git a/Games/Minesweeper/Makefile b/Games/Minesweeper/Makefile index ab28043822f..d0d0afe6319 100644 --- a/Games/Minesweeper/Makefile +++ b/Games/Minesweeper/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = Minesweeper -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI IPC Draw Core include ../../Makefile.common diff --git a/Games/Snake/Makefile b/Games/Snake/Makefile index f579637e4f2..cff8a85b271 100644 --- a/Games/Snake/Makefile +++ b/Games/Snake/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = Snake -LDFLAGS = -lgui -ldraw -lipc -lcore -lc +LIB_DEPS = GUI IPC Draw Core include ../../Makefile.common diff --git a/Libraries/LibAudio/Makefile b/Libraries/LibAudio/Makefile index aad4b7122d3..a7bda37485e 100644 --- a/Libraries/LibAudio/Makefile +++ b/Libraries/LibAudio/Makefile @@ -4,6 +4,10 @@ OBJS = \ LIBRARY = libaudio.a +AClientConnection.cpp: ../../Servers/AudioServer/AudioClientEndpoint.h +../../Servers/AudioServer/AudioClientEndpoint.h: + @$(MAKE) -C $(dir $(@)) + install: mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/LibAudio/ cp *.h $(SERENITY_BASE_DIR)/Root/usr/include/LibAudio/ diff --git a/Libraries/LibC/Makefile b/Libraries/LibC/Makefile index 522e5c545b4..76b38328386 100644 --- a/Libraries/LibC/Makefile +++ b/Libraries/LibC/Makefile @@ -1,3 +1,5 @@ +.NOTPARALLEL: + AK_OBJS = \ ../../AK/StringImpl.o \ ../../AK/String.o \ @@ -59,19 +61,22 @@ OBJS = $(AK_OBJS) $(LIBC_OBJS) EXTRA_OBJS = setjmp.ao crti.ao crtn.ao -.PHONY: startfiles -startfiles: $(EXTRA_OBJS) - $(CXX) $(CXXFLAGS) -o crt0.o -c crt0.cpp +crt0.o: crt0.cpp + $(QUIET) $(CXX) $(CXXFLAGS) -o crt0.o -c crt0.cpp + +crtio.o: crti.ao $(QUIET) cp crti.ao crti.o + +crtn.o: crtin.ao $(QUIET) cp crtn.ao crtn.o -EXTRA_CLEAN = crt0.d +EXTRA_CLEAN = crt0.d crt0.o DEFINES = -DSERENITY_LIBC_BUILD LIBRARY = libc.a -all: $(LIBRARY) startfiles install +all: crt0.o $(EXTRA_OBJS) $(LIBRARY) install install: mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/sys/ diff --git a/Libraries/LibGUI/Makefile b/Libraries/LibGUI/Makefile index cc54c54b110..25f23cec2e4 100644 --- a/Libraries/LibGUI/Makefile +++ b/Libraries/LibGUI/Makefile @@ -63,6 +63,11 @@ OBJS = \ LIBRARY = libgui.a +GWindowServerConnection.cpp: ../../Servers/WindowServer/WindowServerEndpoint.h + +../../Servers/WindowServer/WindowServerEndpoint.h: + @$(MAKE) -C $(dir $(@)) + install: mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/LibGUI/ cp ./*.h $(SERENITY_BASE_DIR)/Root/usr/include/LibGUI/ diff --git a/Libraries/LibHTML/CodeGenerators/Makefile b/Libraries/LibHTML/CodeGenerators/Makefile new file mode 100644 index 00000000000..29af0b03ea3 --- /dev/null +++ b/Libraries/LibHTML/CodeGenerators/Makefile @@ -0,0 +1,3 @@ +SUBDIRS := $(wildcard */.) + +include ../../../Makefile.subdir diff --git a/Libraries/LibHTML/Makefile b/Libraries/LibHTML/Makefile index c0a1672c0c3..1ff6b91919f 100644 --- a/Libraries/LibHTML/Makefile +++ b/Libraries/LibHTML/Makefile @@ -67,17 +67,28 @@ EXTRA_SOURCES = \ CSS/PropertyID.h \ CSS/PropertyID.cpp +GENERATE_CSS_PROPERTYID_CPP = CodeGenerators/Generate_CSS_PropertyID_cpp/Generate_CSS_PropertyID_cpp +GENERATE_CSS_PROPERTYID_H = CodeGenerators/Generate_CSS_PropertyID_h/Generate_CSS_PropertyID_h + +$(GENERATE_CSS_PROPERTYID_H): + @$(MAKE) -C $(dir $(GENERATE_CSS_PROPERTYID_H)) + +$(GENERATE_CSS_PROPERTYID_CPP): + @$(MAKE) -C $(dir $(GENERATE_CSS_PROPERTYID_CPP)) + CSS/DefaultStyleSheetSource.cpp: CSS/Default.css Scripts/GenerateStyleSheetSource.sh @echo "GENERATE $@" $(QUIET) Scripts/GenerateStyleSheetSource.sh default_stylesheet_source $< > $@ -CSS/PropertyID.h: CSS/Properties.json CodeGenerators/Generate_CSS_PropertyID_h/Generate_CSS_PropertyID_h.cpp +CSS/PropertyID.h: CSS/Properties.json $(GENERATE_CSS_PROPERTYID_H) @echo "GENERATE $@" - $(QUIET) CodeGenerators/Generate_CSS_PropertyID_h/Generate_CSS_PropertyID_h $< > $@ + $(QUIET) $(GENERATE_CSS_PROPERTYID_H) $< > $@ -CSS/PropertyID.cpp: CSS/Properties.json CodeGenerators/Generate_CSS_PropertyID_cpp/Generate_CSS_PropertyID_cpp.cpp +CSS/PropertyID.cpp: CSS/Properties.json $(GENERATE_CSS_PROPERTYID_CPP) @echo "GENERATE $@" - $(QUIET) CodeGenerators/Generate_CSS_PropertyID_cpp/Generate_CSS_PropertyID_cpp $< > $@ + $(QUIET) $(GENERATE_CSS_PROPERTYID_CPP) $< > $@ + +EXTRA_CLEAN = CSS/DefaultStyleSheetSource.cpp CSS/PropertyID.h CSS/PropertyID.cpp OBJS = $(EXTRA_OBJS) $(LIBHTML_OBJS) @@ -91,3 +102,7 @@ install: cp $(LIBRARY) $(SERENITY_BASE_DIR)/Root/usr/lib/ include ../../Makefile.common + +SUBDIRS = CodeGenerators + +include ../../Makefile.subdir diff --git a/Makefile b/Makefile index 7b23f582200..de5b41c9204 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,17 @@ -# Build the host-side tools first, since they are needed to build some programs. -SUBDIRS = \ - DevTools/IPCCompiler \ - DevTools/FormCompiler \ - Libraries/LibHTML/CodeGenerators/Generate_CSS_PropertyID_cpp \ - Libraries/LibHTML/CodeGenerators/Generate_CSS_PropertyID_h - -# Build some libraries before IPC servers, since they depend on them. SUBDIRS += \ - Libraries/LibC \ - Libraries/LibM \ - Libraries/LibCore \ - Libraries/LibDraw \ - Libraries/LibIPC \ - Libraries/LibThread \ - Libraries/LibPthread - -# Build IPC servers before their client code to ensure the IPC definitions are available. -SUBDIRS += \ - Servers/AudioServer \ - Servers/LookupServer \ - Servers/ProtocolServer \ - Libraries/LibAudio \ - Servers/WindowServer - -SUBDIRS += \ - AK - -SUBDIRS += \ - Libraries \ + AK \ Applications \ DevTools \ + Kernel \ + Libraries \ + MenuApplets \ Servers \ Shell \ - Userland \ - MenuApplets \ - Demos \ + Userland + +SUBDIRS += \ Games \ - Kernel + Demos include Makefile.subdir diff --git a/Makefile.common b/Makefile.common index 01b4bdf54cc..e34944b9950 100644 --- a/Makefile.common +++ b/Makefile.common @@ -20,22 +20,6 @@ INCLUDE_FLAGS += \ -I$(SERENITY_BASE_DIR)/Libraries \ -I$(SERENITY_BASE_DIR)/Servers -LDFLAGS += \ - -L$(SERENITY_BASE_DIR)/Libraries/LibC \ - -L$(SERENITY_BASE_DIR)/Libraries/LibPthread \ - -L$(SERENITY_BASE_DIR)/Libraries/LibCore \ - -L$(SERENITY_BASE_DIR)/Libraries/LibIPC \ - -L$(SERENITY_BASE_DIR)/Libraries/LibM \ - -L$(SERENITY_BASE_DIR)/Libraries/LibDraw \ - -L$(SERENITY_BASE_DIR)/Libraries/LibGUI \ - -L$(SERENITY_BASE_DIR)/Libraries/LibHTML \ - -L$(SERENITY_BASE_DIR)/Libraries/LibMarkdown \ - -L$(SERENITY_BASE_DIR)/Libraries/LibThread \ - -L$(SERENITY_BASE_DIR)/Libraries/LibVT \ - -L$(SERENITY_BASE_DIR)/Libraries/LibPCIDB \ - -L$(SERENITY_BASE_DIR)/Libraries/LibProtocol \ - -L$(SERENITY_BASE_DIR)/Libraries/LibAudio - VERBOSE = 0 ifneq ($(HOST_CXX),) @@ -56,26 +40,33 @@ else -I$(SERENITY_BASE_DIR)/Libraries/LibM \ -I$(SERENITY_BASE_DIR)/Libraries/LibPthread - LDFLAGS += \ - -L$(SERENITY_BASE_DIR)/Libraries/LibC - ifdef KERNEL DEFINES += -DKERNEL + else + # everything else gets -lc -lm + LIB_DEPS += C M endif + # turn "LIB_DEPS=C Core Thread" into "-lc -lcore -lthread -L.../LibC ..." + LDFLAGS += $(foreach lib,$(LIB_DEPS),\ + -l$(shell echo $(lib) | tr A-Z a-z)) + LDFLAGS += $(foreach lib,$(LIB_DEPS),\ + -L$(SERENITY_BASE_DIR)/Libraries/Lib$(lib)) + + STATIC_LIB_DEPS = $(foreach lib,$(LIB_DEPS),\ + $(SERENITY_BASE_DIR)/Libraries/Lib$(lib)/lib$(shell echo $(lib) | tr A-Z a-z).a) + OBJ_SUFFIX ?= endif #CXX = clang $(CLANG_FLAGS) #CLANG_FLAGS = -Wconsumed -m32 -ffreestanding -march=i686 -CXXFLAGS = -MMD -MP $(CXX_WARNING_FLAGS) $(CXX_OPTIMIZATION_FLAGS) $(CXX_FLAVOR_FLAGS) $(ARCH_FLAGS) $(CXX_STANDARD_FLAGS) $(CXX_SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) $(SUBPROJECT_CXXFLAGS) +CXXFLAGS = -MMD -MP $(CXX_WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(CXX_FLAVOR_FLAGS) $(ARCH_FLAGS) $(CXX_STANDARD_FLAGS) $(CXX_SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) $(SUBPROJECT_CXXFLAGS) CFLAGS = -MMD -MP $(C_FLAVOR_FLAGS) $(ARCH_FLAGS) $(C_STANDARD_FLAGS) $(C_SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) $(SUBPROJECT_CXXFLAGS) DEFINES += -DSANITIZE_PTRS -IPCCOMPILER = $(SERENITY_BASE_DIR)/DevTools/IPCCompiler/IPCCompiler - SUFFIXED_OBJS = $(patsubst %.o,%$(OBJ_SUFFIX).o,$(OBJS)) ifeq ($(VERBOSE),1) @@ -98,7 +89,7 @@ endif @echo "AS $@" $(QUIET) $(AS) -o $@ $< -$(PROGRAM): $(SUFFIXED_OBJS) $(EXTRA_OBJS) +$(PROGRAM): $(SUFFIXED_OBJS) $(EXTRA_OBJS) $(STATIC_LIB_DEPS) @echo "LINK $(PROGRAM)" $(QUIET) $(CXX) -o $(PROGRAM) $(EXTRA_OBJS) $(SUFFIXED_OBJS) $(LDFLAGS) @@ -106,6 +97,19 @@ $(LIBRARY): $(SUFFIXED_OBJS) $(EXTRA_OBJS) @echo "LIB $@" $(QUIET) $(AR) rcs $@ $(OBJS) $(EXTRA_OBJS) $(LIBS) +$(STATIC_LIB_DEPS): + @$(MAKE) -C $(dir $(@)) + +IPCCOMPILER = $(SERENITY_BASE_DIR)/DevTools/IPCCompiler/IPCCompiler +IPCCOMPILER: $(IPCCOMPILER) +$(IPCCOMPILER): + @$(MAKE) -C $(dir $(@)) + +FORMCOMPILER = $(SERENITY_BASE_DIR)/DevTools/FormCompiler/FormCompiler +FORMCOMPILER: $(FORMCOMPILER) +$(FORMCOMPILER): + @$(MAKE) -C $(dir $(@)) + .DEFAULT_GOAL := all all: $(PROGRAM) $(LIBRARY) @@ -118,4 +122,6 @@ clean: install: +.DELETE_ON_ERROR: + .PHONY: all clean install diff --git a/MenuApplets/Audio/Makefile b/MenuApplets/Audio/Makefile index 5ccbf2c8b52..505393a09b5 100755 --- a/MenuApplets/Audio/Makefile +++ b/MenuApplets/Audio/Makefile @@ -2,6 +2,6 @@ OBJS = main.o PROGRAM = Audio.MenuApplet -LDFLAGS = -laudio -lgui -lipc -ldraw -lthread -lpthread -lcore -lc +LIB_DEPS = Audio GUI IPC Draw Thread Pthread Core include ../../Makefile.common diff --git a/MenuApplets/CPUGraph/Makefile b/MenuApplets/CPUGraph/Makefile index 79048639093..608636fa6b7 100755 --- a/MenuApplets/CPUGraph/Makefile +++ b/MenuApplets/CPUGraph/Makefile @@ -2,6 +2,6 @@ OBJS = main.o PROGRAM = CPUGraph.MenuApplet -LDFLAGS = -laudio -lgui -lipc -ldraw -lthread -lpthread -lcore -lc +LIB_DEPS = GUI IPC Draw Thread Pthread Core include ../../Makefile.common diff --git a/Servers/AudioServer/Makefile b/Servers/AudioServer/Makefile index 7ea0e7b484c..d08cf0a34f3 100644 --- a/Servers/AudioServer/Makefile +++ b/Servers/AudioServer/Makefile @@ -6,16 +6,16 @@ OBJS = \ PROGRAM = AudioServer -LDFLAGS = -lc -lcore -lipc -lthread -lpthread +LIB_DEPS = Core IPC Thread Pthread EXTRA_CLEAN = AudioServerEndpoint.h AudioClientEndpoint.h *.cpp: AudioServerEndpoint.h AudioClientEndpoint.h -AudioServerEndpoint.h: AudioServer.ipc +AudioServerEndpoint.h: AudioServer.ipc IPCCOMPILER @echo "IPC $<"; $(IPCCOMPILER) $< > $@ -AudioClientEndpoint.h: AudioClient.ipc +AudioClientEndpoint.h: AudioClient.ipc IPCCOMPILER @echo "IPC $<"; $(IPCCOMPILER) $< > $@ install: diff --git a/Servers/LookupServer/Makefile b/Servers/LookupServer/Makefile index 83ea532d5fe..eb16167532b 100644 --- a/Servers/LookupServer/Makefile +++ b/Servers/LookupServer/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = LookupServer -LDFLAGS = -lc -lcore +LIB_DEPS = Core include ../../Makefile.common diff --git a/Servers/ProtocolServer/Makefile b/Servers/ProtocolServer/Makefile index 3d3148d2b00..b4e434345d8 100644 --- a/Servers/ProtocolServer/Makefile +++ b/Servers/ProtocolServer/Makefile @@ -8,14 +8,14 @@ OBJS = \ PROGRAM = ProtocolServer -LDFLAGS = -lc -lcore -lipc +LIB_DEPS = Core IPC *.cpp: ProtocolServerEndpoint.h ProtocolClientEndpoint.h -ProtocolServerEndpoint.h: ProtocolServer.ipc +ProtocolServerEndpoint.h: ProtocolServer.ipc IPCCOMPILER @echo "IPC $<"; $(IPCCOMPILER) $< > $@ -ProtocolClientEndpoint.h: ProtocolClient.ipc +ProtocolClientEndpoint.h: ProtocolClient.ipc IPCCOMPILER @echo "IPC $<"; $(IPCCOMPILER) $< > $@ include ../../Makefile.common diff --git a/Servers/SystemServer/Makefile b/Servers/SystemServer/Makefile index 6fcf27cd78a..0a29c534634 100644 --- a/Servers/SystemServer/Makefile +++ b/Servers/SystemServer/Makefile @@ -4,7 +4,7 @@ OBJS = \ PROGRAM = SystemServer -LDFLAGS = -lcore -lc +LIB_DEPS = Core install: mkdir -p ../../Root/usr/include/SystemServer/ diff --git a/Servers/TelnetServer/Makefile b/Servers/TelnetServer/Makefile index 9606c548f4d..bfee24f38c1 100644 --- a/Servers/TelnetServer/Makefile +++ b/Servers/TelnetServer/Makefile @@ -5,6 +5,6 @@ OBJS = \ PROGRAM = TelnetServer -LDFLAGS = -lcore -lc +LIB_DEPS = Core include ../../Makefile.common diff --git a/Servers/WindowServer/Makefile b/Servers/WindowServer/Makefile index 6dcb3fec6a8..508c7de1bd3 100644 --- a/Servers/WindowServer/Makefile +++ b/Servers/WindowServer/Makefile @@ -18,14 +18,14 @@ OBJS = \ PROGRAM = WindowServer -LDFLAGS = -lc -ldraw -lcore -lthread -lpthread -lipc +LIB_DEPS = Draw Core Thread Pthread IPC *.cpp: WindowServerEndpoint.h WindowClientEndpoint.h -WindowServerEndpoint.h: WindowServer.ipc +WindowServerEndpoint.h: WindowServer.ipc IPCCOMPILER @echo "IPC $<"; $(IPCCOMPILER) $< > $@ -WindowClientEndpoint.h: WindowClient.ipc +WindowClientEndpoint.h: WindowClient.ipc IPCCOMPILER @echo "IPC $<"; $(IPCCOMPILER) $< > $@ EXTRA_CLEAN = WindowServerEndpoint.h WindowClientEndpoint.h diff --git a/Shell/Makefile b/Shell/Makefile index 8c45d96d6b5..b8833507fea 100644 --- a/Shell/Makefile +++ b/Shell/Makefile @@ -5,6 +5,6 @@ OBJS = \ PROGRAM = Shell -LDFLAGS = -lcore -lc +LIB_DEPS = Core include ../Makefile.common diff --git a/Userland/Makefile b/Userland/Makefile index 053b6426cc4..843d33d9a45 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -4,7 +4,7 @@ APPS = ${SRCS:.cpp=} EXTRA_CLEAN = $(APPS) -LDFLAGS = -lc -lhtml -lgui -ldraw -laudio -lipc -lthread -lcore -lpcidb -lmarkdown -lpthread -lprotocol -lipc +LIB_DEPS = HTML GUI Draw Audio Protocol IPC Thread Pthread Core PCIDB Markdown all: $(OBJS) $(APPS)