Skip to content

Commit

Permalink
Makefiles: Simplify build output.
Browse files Browse the repository at this point in the history
Simplify build output by displaying friendlier
messages about currently build activity when
linking and compiling. The standard "raw" output
can be enabled by passing NOISY_BUILD to make.

Also allow subtargets to be built in parallel,
which was previously (but not intentionally) inhibited.
  • Loading branch information
InterLinked1 committed Feb 6, 2024
1 parent ab5b373 commit 4ba4cbe
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 48 deletions.
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,30 @@ RM = rm -f
LN = ln
INSTALL = install

# Uncomment this to see all build commands instead of 'quiet' output
#NOISY_BUILD=yes

# XXX missing terms since currently no term modules
MOD_SUBDIR:=doors modules nets
SUBDIRS:=$(MOD_SUBDIR)
SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)

# SUBMAKE:=$(MAKE) --quiet --no-print-directory
ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
SUBMAKE:=$(MAKE)
else
SUBMAKE:=$(MAKE) --quiet --no-print-directory
endif

MOD_SUBDIR_CFLAGS="-I$(BBSTOPDIR)/include"

# MODULE_PREFIX:=mod
MAIN_SOURCES := $(wildcard *.c) $(cami/wildcard *.c)
INCLUDE_FILES := $(wildcard include/*.h)
MAIN_OBJ = $(MAIN_SOURCES:.c=.o)

SILENT_BUILD_PREFIX := @

# ALL_C_MODS+=$(foreach p,$(MOD_SUBDIR)/$(MODULE_PREFIX),$(patsubst %.c,%.so,$(wildcard $(p)_*.c)))

export CC
Expand All @@ -62,23 +71,22 @@ export LIBS

export SUBMAKE

# Run sub targets in parallel, but don't run top-level targets in parallel
.NOTPARALLEL:

# This is the first target, so it's the default for just "make":
all : bbs $(MOD_SUBDIR) external
@echo " +--------- LBBS has been compiled ---------+"
@echo " You may now install it by running make install"

bbs : $(MAIN_OBJ)
@echo " +--------- make bbs ---------+"
$(SUBMAKE) --no-builtin-rules -C $@ all
@+$(SUBMAKE) --no-builtin-rules -C $@ all

$(MOD_SUBDIR):
@echo " +--------- make $@ ---------+"
# $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
$(SUBMAKE) --no-builtin-rules -C $@ all
@+$(SUBMAKE) --no-builtin-rules -C $@ all

external tests :
@echo " +--------- make $@ ---------+"
$(SUBMAKE) --no-builtin-rules -C $@ all
@+$(SUBMAKE) --no-builtin-rules -C $@ all

modcheck : external
@external/modman -t
Expand Down
4 changes: 2 additions & 2 deletions bbs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INC = -I..
all: $(EXE)

$(EXE) : $(MAIN_OBJ)
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) $(CFLAGS) -Wl,--export-dynamic -o $(EXE) *.o $(LIBS)

-include $(DEPENDS)
Expand All @@ -18,7 +18,7 @@ $(EXE) : $(MAIN_OBJ)
$(DEPENDS):

%.o : %.c %.d
@echo "== Compiling bbs/$@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -DBBS_IN_CORE -MMD -MP $(INC) -c $<

# Don't automatically remove intermediate .o files, to prevent unnecessary recompilations
Expand Down
7 changes: 3 additions & 4 deletions doors/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ DEPENDS := $(patsubst %.c,%.d,$(MOD_SRC))
INC = -I..

all: $(MOD_SO)
@echo "== Compiling doors"

-include $(DEPENDS)

$(DEPENDS):

%.o : %.c %.d
@echo "== Compiling $@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -fPIC -DBBS_MODULE=\"$(basename $<)\" -DBBS_MODULE_SELF_SYM=__internal_$(basename $<)_self -MMD -MP $(INC) -c $<

%.so : %.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^

door_irc.so : door_irc.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lirc

# Don't automatically remove intermediate .o files, to prevent unnecessary recompilations
Expand Down
2 changes: 2 additions & 0 deletions external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ all: $(EXES)
# XXX: This is not quite right, as it recreates all binaries whenever an object file needs to be recreated.
# What we really want to do is have each EXE depend on its corresponding OBJ file (with .o extension)
$(EXES): $(OBJS)
@echo " [LD] $@.o -> $@"
$(CC) $(CFLAGS) -o $@ $@.o

%.o : %.c
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -c $^

install : all
Expand Down
47 changes: 23 additions & 24 deletions modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,107 +13,106 @@ MYSQL_LIBS := $(shell mysql_config --libs)
ETPANCFLAGS=-I/usr/local/include

all: $(MOD_SO)
@echo "== Compiling modules"

-include $(DEPENDS)

$(DEPENDS):

%.o : %.c %.d
@echo "== Compiling $@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -fPIC -DBBS_MODULE=\"$(basename $<)\" -DBBS_MODULE_SELF_SYM=__internal_$(basename $<)_self -MMD -MP $(INC) -c $<
touch $@

mod_mimeparse.o : mod_mimeparse.c mod_mimeparse.d
@echo "== Compiling $@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -fPIC -DBBS_MODULE=\"$(basename $<)\" -DBBS_MODULE_SELF_SYM=__internal_$(basename $<)_self $(GMIME_FLAGS) -MMD -MP $(INC) -c $<

%.so : %.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^

mod_asterisk_ami.so : mod_asterisk_ami.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lcami

mod_asterisk_queues.so : mod_asterisk_queues.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lcami

mod_discord.so : mod_discord.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -ldiscord

mod_http.so : mod_http.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lmagic

mod_irc_client.so : mod_irc_client.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lirc

mod_lmdb.so : mod_lmdb.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -llmdb

mod_mimeparse.so : mod_mimeparse.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ $(GMIME_LIBS)

mod_mysql.so : mod_mysql.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ $(MYSQL_LIBS)

mod_ncurses.so : mod_ncurses.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lmenu -lncurses

mod_oauth.so : mod_oauth.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -ljansson

mod_operator.so : mod_operator.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -ljansson

mod_sieve.so : mod_sieve.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lsieve

mod_slack.so : mod_slack.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lslackrtm

mod_smtp_delivery_external.so : mod_smtp_delivery_external.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
ifeq ($(UNAME_S),FreeBSD)
$(CC) -shared -fPIC -o $(basename $^).so $^
else
$(CC) -shared -fPIC -o $(basename $^).so $^ -lresolv
endif

mod_smtp_filter_arc.so : mod_smtp_filter_arc.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -lopenarc

mod_smtp_filter_dkim.so : mod_smtp_filter_dkim.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lopendkim

mod_smtp_filter_dmarc.so : mod_smtp_filter_dmarc.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lopendmarc

mod_smtp_filter_spf.so : mod_smtp_filter_spf.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lspf2

mod_webmail.o : mod_webmail.c mod_webmail.d
@echo "== Compiling $@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -funsigned-char -fPIC -DBBS_MODULE=\"$(basename $<)\" -DBBS_MODULE_SELF_SYM=__internal_$(basename $<)_self -MMD -MP $(INC) $(ETPANCFLAGS) -c $<

mod_webmail.so : mod_webmail.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -ljansson -lssl -lcrypto -ldb-5.3 -lz -L/usr/local/lib -Wl,-rpath=/usr/local/lib/ -letpan

# Don't automatically remove intermediate .o files, to prevent unnecessary recompilations
Expand Down
14 changes: 6 additions & 8 deletions nets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,37 @@ ifneq ($(SFTP_SERVER_FREE_EXISTS),0)
endif

all: $(MOD_SO)
@echo "== Compiling nets"

-include $(DEPENDS)

$(DEPENDS):

%.o : %.c %.d
@echo "== Compiling $@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -fPIC -DBBS_MODULE=\"$(basename $<)\" -DBBS_MODULE_SELF_SYM=__internal_$(basename $<)_self -MMD -MP $(INC) -c $<

%.so : %.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^

IMAP_SRC = $(wildcard net_imap/*.c)
IMAP_OBJ = $(patsubst %.c,%.o,$(IMAP_SRC))

# Subdirectory with components for net_imap
net_imap:
@echo " +--------- make $@ ---------+"
$(SUBMAKE) --no-builtin-rules -C $@ all
@+$(SUBMAKE) --no-builtin-rules -C $@ all

net_imap.so : net_imap.o net_imap
@echo "== Linking $@"
@echo " [LD] $< $(IMAP_OBJ) -> $@"
$(CC) -shared -fPIC -o $(basename $<).so $(IMAP_OBJ) $<

# SSHLIB=$(pkg-config --libs libssh)
net_ssh.so : net_ssh.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lssh

net_ws.so : net_ws.o
@echo "== Linking $@"
@echo " [LD] $^ -> $@"
$(CC) -shared -fPIC -o $(basename $^).so $^ -lwss

# Don't automatically remove intermediate .o files, to prevent unnecessary recompilations
Expand Down
3 changes: 1 addition & 2 deletions nets/net_imap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ DEPENDS := $(patsubst %.c,%.d,$(IMAP_SRC))
INC = -I../..

all: $(MOD_SO)
@echo "== Compiling net_imap components"

-include $(DEPENDS)

$(DEPENDS):

%.o : %.c %.d
@echo "== Compiling $@"
@echo " [CC] $< -> $@"
$(CC) $(CFLAGS) -fPIC -DBBS_MODULE_SUBFILE -MMD -MP $(INC) -c $<

all: $(IMAP_OBJ)
Expand Down

0 comments on commit 4ba4cbe

Please sign in to comment.