From 68de9e35d3bc16c1199ed94f0f5822e6b4f40e4f Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 27 Sep 2005 22:38:00 +0200 Subject: [PATCH] Automagically link in subdir lib.o files It is a little ugly since I couldn't get $(wildcard) to expand *.o files so it just checks if there are any *.c files and then link in the lib.o based on that. --- Makefile.lib | 9 +++++++++ src/Makefile | 39 +++----------------------------------- src/bookmarks/Makefile | 7 +------ src/document/Makefile | 13 +------------ src/document/sgml/Makefile | 2 +- src/ecmascript/Makefile | 3 +-- src/intl/Makefile | 3 +-- src/mime/Makefile | 3 +-- src/network/Makefile | 3 +-- src/osdep/Makefile | 12 +----------- src/protocol/Makefile | 29 +--------------------------- src/scripting/Makefile | 7 +------ src/viewer/Makefile | 4 +--- 13 files changed, 23 insertions(+), 111 deletions(-) diff --git a/Makefile.lib b/Makefile.lib index 2ce36b7b9..baf964441 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -56,6 +56,15 @@ endif >> .deps/$(*F).P; \ rm .deps/$(*F).pp +ifdef SUBDIRS +# Apparently wildcard won't expand *.o files so check if there are any *.c +# files and use that to magically add the lib.o file of the subdirectory. +subobjs := $(strip $(foreach subdir,$(SUBDIRS),$(if $(wildcard $(subdir)/*.c),$(subdir)/lib.o))) +endif +ifneq ($(subobjs),) +OBJS += $(subobjs) +endif + ifdef OBJS CLEAN += $(OBJS) diff --git a/src/Makefile b/src/Makefile index 43996591f..f9aa5d197 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,32 +3,26 @@ include $(path_to_top)/Makefile.config ifeq ($(CONFIG_BOOKMARKS),yes) bookmarksdir = bookmarks -bookmarkslib = $(bookmarksdir)/lib.o endif ifeq ($(CONFIG_COOKIES),yes) cookiesdir = cookies -cookieslib = $(cookiesdir)/lib.o endif ifeq ($(CONFIG_FORMHIST),yes) formhistdir = formhist -formhistlib = $(formhistdir)/lib.o endif ifeq ($(CONFIG_GLOBHIST),yes) globhistdir = globhist -globhistlib = $(globhistdir)/lib.o endif ifeq ($(CONFIG_ECMASCRIPT),yes) ecmascriptdir = ecmascript -ecmascriptlib = $(ecmascriptdir)/lib.o endif ifeq ($(CONFIG_SCRIPTING),yes) scriptingdir = scripting -scriptinglib = $(scriptingdir)/lib.o endif SUBDIRS = \ @@ -55,49 +49,22 @@ SUBDIRS = \ util \ viewer -# Order of this is purely magic and random, so that ld doesn't fail for some -# strange reason. Try to swap randomly when ld will start to complain about -# mysteriously unresolved symbols. -ELINKSLIBS = \ - main/lib.o \ - $(cookieslib) \ - viewer/lib.o \ - cache/lib.o \ - document/lib.o \ - intl/lib.o \ - session/lib.o \ - network/lib.o \ - terminal/lib.o \ - $(scriptinglib) \ - osdep/lib.o \ - protocol/lib.o \ - $(bookmarkslib) \ - $(formhistlib) \ - $(globhistlib) \ - $(ecmascriptlib) \ - config/lib.o \ - dialogs/lib.o \ - mime/lib.o \ - bfu/lib.o \ - encoding/lib.o \ - intl/lib.o \ - util/lib.o - # Get the GIT HEAD ID if possible ifdef CG_COMMIT_ID BUILD_ID=$(shell $(CG_COMMIT_ID) 2> /dev/null) endif INCLUDES += -DBUILD_ID="\"$(BUILD_ID)\"" -OBJS = vernum.o $(ELINKSLIBS) +OBJS = vernum.o vernum.o: FORCE FORCE: all-local: elinks -elinks: $(OBJS) +elinks: lib.o $(call cmd,link) install-local: $(INSTALL_PROGRAM) elinks $(DESTDIR)$(bindir) include $(path_to_top)/Makefile.lib + diff --git a/src/bookmarks/Makefile b/src/bookmarks/Makefile index f8724b51e..c55631e2f 100644 --- a/src/bookmarks/Makefile +++ b/src/bookmarks/Makefile @@ -3,11 +3,6 @@ include $(path_to_top)/Makefile.config SUBDIRS = backend -ifeq ($(CONFIG_XBEL_BOOKMARKS),yes) -xbelobj = xbel.o -endif - -BACK_OBJS = common.o default.o $(xbelobj) -OBJS = bookmarks.o dialogs.o $(foreach obj,$(BACK_OBJS),backend/$(obj)) +OBJS = bookmarks.o dialogs.o include $(path_to_top)/Makefile.lib diff --git a/src/document/Makefile b/src/document/Makefile index 838779172..01ac9724d 100644 --- a/src/document/Makefile +++ b/src/document/Makefile @@ -3,26 +3,15 @@ include $(path_to_top)/Makefile.config ifeq ($(CONFIG_CSS),yes) cssdir = css -cssobj = $(cssdir)/lib.o endif ifeq ($(CONFIG_DOM),yes) domdir = dom -domobj = $(domdir)/lib.o - sgmldir = sgml -sgmlobj = $(sgmldir)/lib.o endif SUBDIRS = $(cssdir) $(domdir) html plain $(sgmldir) -SUB_OBJS = \ - $(cssobj) \ - $(domobj) \ - html/lib.o \ - plain/lib.o \ - $(sgmlobj) - -OBJS = docdata.o document.o forms.o options.o refresh.o renderer.o $(SUB_OBJS) +OBJS = docdata.o document.o forms.o options.o refresh.o renderer.o include $(path_to_top)/Makefile.lib diff --git a/src/document/sgml/Makefile b/src/document/sgml/Makefile index 77fd02dc8..b4faff3ac 100644 --- a/src/document/sgml/Makefile +++ b/src/document/sgml/Makefile @@ -3,6 +3,6 @@ include $(path_to_top)/Makefile.config SUBDIRS = html -OBJS = sgml.o parser.o scanner.o html/lib.o +OBJS = sgml.o parser.o scanner.o include $(path_to_top)/Makefile.lib diff --git a/src/ecmascript/Makefile b/src/ecmascript/Makefile index 84c61ab78..3e547c08d 100644 --- a/src/ecmascript/Makefile +++ b/src/ecmascript/Makefile @@ -4,7 +4,6 @@ INCLUDES += $(SPIDERMONKEY_CFLAGS) SUBDIRS = spidermonkey -SM_OBJS = document.o form.o location.o navigator.o unibar.o window.o -OBJS = ecmascript.o spidermonkey.o spidermonkey/lib.o +OBJS = ecmascript.o spidermonkey.o include $(path_to_top)/Makefile.lib diff --git a/src/intl/Makefile b/src/intl/Makefile index 54924846b..8e4cc998c 100644 --- a/src/intl/Makefile +++ b/src/intl/Makefile @@ -3,11 +3,10 @@ include $(path_to_top)/Makefile.config ifeq ($(CONFIG_NLS),yes) gettextdir = gettext -gettextobj = $(gettextdir)/lib.o endif SUBDIRS = $(gettextdir) -OBJS = charsets.o $(gettextobj) +OBJS = charsets.o include $(path_to_top)/Makefile.lib diff --git a/src/mime/Makefile b/src/mime/Makefile index 865675eaf..1ec6dbc82 100644 --- a/src/mime/Makefile +++ b/src/mime/Makefile @@ -5,7 +5,6 @@ SUBDIRS = backend OBJS = \ dialogs.o \ - mime.o \ - backend/lib.o \ + mime.o include $(path_to_top)/Makefile.lib diff --git a/src/network/Makefile b/src/network/Makefile index 81e67ea1c..68280af5d 100644 --- a/src/network/Makefile +++ b/src/network/Makefile @@ -3,11 +3,10 @@ include $(path_to_top)/Makefile.config ifeq ($(CONFIG_SSL),yes) ssldir = ssl -sslobj = $(ssldir)/lib.o endif SUBDIRS = $(ssldir) -OBJS = connection.o dns.o progress.o socket.o state.o $(sslobj) +OBJS = connection.o dns.o progress.o socket.o state.o include $(path_to_top)/Makefile.lib diff --git a/src/osdep/Makefile b/src/osdep/Makefile index 945dc06ab..75176c766 100644 --- a/src/osdep/Makefile +++ b/src/osdep/Makefile @@ -4,27 +4,22 @@ INCLUDES += $(X_CFLAGS) ifeq ($(CONFIG_BEOS),yes) beosdir = beos -beosobj = $(beosdir)/lib.o endif ifeq ($(CONFIG_OS2),yes) os2dir = os2 -os2obj = $(os2dir)/lib.o endif ifeq ($(CONFIG_RISCOS),yes) riscosdir = riscos -riscosobj = $(riscosdir)/lib.o endif ifeq ($(CONFIG_UNIX),yes) unixdir = unix -unixobj = $(unixdir)/lib.o endif ifeq ($(CONFIG_WIN32),yes) win32dir = win32 -win32obj = $(win32dir)/lib.o endif SUBDIRS = $(beosdir) $(os2dir) $(riscosdir) $(unixdir) $(win32dir) @@ -35,11 +30,6 @@ OBJS = \ osdep.o \ signals.o \ stub.o \ - sysname.o \ - $(beosobj) \ - $(os2obj) \ - $(riscosobj) \ - $(unixobj) \ - $(win32obj) + sysname.o include $(path_to_top)/Makefile.lib diff --git a/src/protocol/Makefile b/src/protocol/Makefile index 9782f8edf..0a1588aa4 100644 --- a/src/protocol/Makefile +++ b/src/protocol/Makefile @@ -1,49 +1,36 @@ path_to_top=../.. include $(path_to_top)/Makefile.config -authobj = auth/lib.o - ifeq ($(CONFIG_BITTORRENT),yes) bittorrentdir = bittorrent -bittorrentobj = $(bittorrentdir)/lib.o endif ifeq ($(CONFIG_DATA),yes) dataobj = data.o endif -fileobj = file/lib.o - ifeq ($(CONFIG_FINGER),yes) fingerdir = finger -fingerobj = $(fingerdir)/lib.o endif ifeq ($(CONFIG_FTP),yes) ftpdir = ftp -ftpobj = $(ftpdir)/lib.o endif ifeq ($(CONFIG_GOPHER),yes) gopherdir = gopher -gopherobj = $(gopherdir)/lib.o endif -httpobj = http/lib.o - ifeq ($(CONFIG_NNTP),yes) nntpdir = nntp -nntpobj = $(nntpdir)/lib.o endif ifeq ($(CONFIG_SMB),yes) smbdir = smb -smbobj = $(smbdir)/lib.o endif ifeq ($(CONFIG_URI_REWRITE),yes) rewritedir = rewrite -rewriteobj = $(rewritedir)/lib.o endif SUBDIRS = \ @@ -58,20 +45,6 @@ SUBDIRS = \ $(rewritedir) \ $(smbdir) -SUB_OBJS = \ - $(authobj) \ - $(bittorrentobj) \ - $(dataobj) \ - $(cgiobj) \ - $(fileobj) \ - $(fingerobj) \ - $(ftpobj) \ - $(gopherobj) \ - $(httpobj) \ - $(nntpobj) \ - $(rewriteobj) \ - $(smbobj) - -OBJS = about.o date.o header.o protocol.o proxy.o uri.o user.o $(SUB_OBJS) +OBJS = about.o $(dataobj) date.o header.o protocol.o proxy.o uri.o user.o include $(path_to_top)/Makefile.lib diff --git a/src/scripting/Makefile b/src/scripting/Makefile index 162c55dc3..8386366a5 100644 --- a/src/scripting/Makefile +++ b/src/scripting/Makefile @@ -3,31 +3,26 @@ include $(path_to_top)/Makefile.config ifeq ($(CONFIG_GUILE),yes) guiledir = guile -guileobj = $(guiledir)/lib.o endif ifeq ($(CONFIG_LUA),yes) luadir = lua -luaobj = $(luadir)/lib.o endif ifeq ($(CONFIG_PERL),yes) perldir = perl -perlobj = $(perldir)/lib.o endif ifeq ($(CONFIG_PYTHON),yes) pythondir = python -pythonobj = $(pythondir)/lib.o endif ifeq ($(CONFIG_RUBY),yes) rubydir = ruby -rubyobj = $(rubydir)/lib.o endif SUBDIRS = $(guiledir) $(luadir) $(perldir) $(pythondir) $(rubydir) -OBJS = scripting.o $(guileobj) $(luaobj) $(perlobj) $(pythonobj) $(rubyobj) +OBJS = scripting.o include $(path_to_top)/Makefile.lib diff --git a/src/viewer/Makefile b/src/viewer/Makefile index 2fdf60a04..3d2e391e7 100644 --- a/src/viewer/Makefile +++ b/src/viewer/Makefile @@ -5,8 +5,6 @@ SUBDIRS = dump text OBJS = \ action.o \ - timer.o \ - dump/lib.o \ - text/lib.o + timer.o include $(path_to_top)/Makefile.lib