Skip to content

Commit

Permalink
Build: support library and generator dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jcs authored and awesomekling committed Dec 25, 2019
1 parent 2aeae2a commit c127d16
Show file tree
Hide file tree
Showing 47 changed files with 130 additions and 113 deletions.
2 changes: 1 addition & 1 deletion Applications/About/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"`\"

Expand Down
6 changes: 5 additions & 1 deletion Applications/Browser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/Calculator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ OBJS = \

PROGRAM = Calculator

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Applications/ChanViewer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/DisplayProperties/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/FileManager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions Applications/FontEditor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Applications/Help/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/HexEditor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/IRCClient/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/PaintBrush/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/Piano/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/QuickShow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/SoundPlayer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/SystemDialog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ OBJS = \

PROGRAM = SystemDialog

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/Taskbar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ OBJS = \

PROGRAM = Taskbar

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Applications/Terminal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/TextEditor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Applications/Welcome/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OBJS = \

PROGRAM = Welcome

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

.SUFFIXES: .png
%.png.o: %.png
Expand Down
2 changes: 1 addition & 1 deletion Demos/Fire/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ OBJS = \

PROGRAM = Fire

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI IPC Draw Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Demos/HelloWorld/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ OBJS = \

PROGRAM = HelloWorld

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI IPC Draw Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Demos/HelloWorld2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OBJS = \

PROGRAM = HelloWorld2

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI IPC Draw Core

main.cpp: UI_HelloWorld2.h

Expand Down
2 changes: 1 addition & 1 deletion Demos/WidgetGallery/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ OBJS = \

PROGRAM = WidgetGallery

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI IPC Draw Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion DevTools/HackStudio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion DevTools/Inspector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ OBJS = \

PROGRAM = Inspector

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion DevTools/ProfileViewer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ OBJS = \

PROGRAM = ProfileViewer

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion DevTools/VisualBuilder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ OBJS = \

PROGRAM = VisualBuilder

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI Draw IPC Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Games/Minesweeper/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ OBJS = \

PROGRAM = Minesweeper

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI IPC Draw Core

include ../../Makefile.common
2 changes: 1 addition & 1 deletion Games/Snake/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ OBJS = \

PROGRAM = Snake

LDFLAGS = -lgui -ldraw -lipc -lcore -lc
LIB_DEPS = GUI IPC Draw Core

include ../../Makefile.common
4 changes: 4 additions & 0 deletions Libraries/LibAudio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
15 changes: 10 additions & 5 deletions Libraries/LibC/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.NOTPARALLEL:

AK_OBJS = \
../../AK/StringImpl.o \
../../AK/String.o \
Expand Down Expand Up @@ -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/
Expand Down
5 changes: 5 additions & 0 deletions Libraries/LibGUI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
3 changes: 3 additions & 0 deletions Libraries/LibHTML/CodeGenerators/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBDIRS := $(wildcard */.)

include ../../../Makefile.subdir
23 changes: 19 additions & 4 deletions Libraries/LibHTML/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -91,3 +102,7 @@ install:
cp $(LIBRARY) $(SERENITY_BASE_DIR)/Root/usr/lib/

include ../../Makefile.common

SUBDIRS = CodeGenerators

include ../../Makefile.subdir
Loading

0 comments on commit c127d16

Please sign in to comment.