From b3550c35ef785c28a42c41f0e585e907e4175b2c Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Fri, 25 Feb 2022 00:46:59 -0500 Subject: Sixth pass refactoring Makefile. Consolidate release rules into one and eliminate recursive makes. Also use real executable targets, not phony ones. --- .github/workflows/release.yml | 2 +- src/Makefile | 139 ++++++++++++++++++------------------------ 2 files changed, 60 insertions(+), 81 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98866771..f8890d12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: inputs: args: description: Make arguments - default: release-all + default: release tag: description: Optional release tag (normally auto-detected) diff --git a/src/Makefile b/src/Makefile index 881b16b4..a9a7129f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,7 +39,7 @@ define build-cc = $(CC) $(CFLAGS) -c $< -o $@ endef define build-exe = - $(CXX) $(CXXFLAGS) -o ../$@ $^ $(LDFLAGS) $(LDLIBS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) endef # Textadept. @@ -227,30 +227,30 @@ $(osx_objs): glib_flags := $(glib_flags_osx) # Executables. -linux_exes := textadept textadept-curses -win_exes := textadept.exe textadept-curses.exe -osx_exes := textadept-osx textadept-osx-curses +linux_exes := $(addprefix ../, textadept textadept-curses) +win_exes := $(addprefix ../, textadept.exe textadept-curses.exe) +osx_exes := $(addprefix ../, textadept-osx textadept-osx-curses) -.PHONY: all curses win32 osx $(linux_exes) $(win_exes) $(osx_exes) +.PHONY: all curses win32 osx .DEFAULT_GOAL := all all: $(linux_exes) -curses: textadept-curses +curses: ../textadept-curses win32: $(win_exes) osx: $(osx_exes) # Linux. $(linux_exes): $(common_objs) -textadept: $(gui_objs) -textadept-curses: $(curses_objs) $(termkey_unix_objs) +../textadept: $(gui_objs) +../textadept-curses: $(curses_objs) $(termkey_unix_objs) $(linux_exes): LDFLAGS := -rdynamic -Wl,--retain-symbols-file -Wl,$(shell pwd)/lua.sym ifndef GTK3 -textadept: LDFLAGS += $(shell pkg-config --libs gtk+-2.0 gmodule-2.0) +../textadept: LDFLAGS += $(shell pkg-config --libs gtk+-2.0 gmodule-2.0) else -textadept: LDFLAGS += $(shell pkg-config --libs gtk+-3.0 gmodule-2.0) +../textadept: LDFLAGS += $(shell pkg-config --libs gtk+-3.0 gmodule-2.0) endif -textadept-curses: LDFLAGS += $(shell pkg-config --silence-errors --libs ncursesw || \ +../textadept-curses: LDFLAGS += $(shell pkg-config --silence-errors --libs ncursesw || \ pkg-config --silence-errors --libs ncurses || pkg-config --silence-errors --libs curses || \ echo -lncursesw) -lpthread ifeq (Linux, $(shell uname -s)) @@ -264,30 +264,30 @@ $(linux_exes): ; $(build-exe) # Windows. $(win_exes): $(call win-objs, $(common_objs)) $(textadept_rc_objs) -textadept.exe: $(call win-objs, $(gui_objs)) -textadept-curses.exe: $(call win-objs, $(curses_objs)) $(termkey_win_objs) +../textadept.exe: $(call win-objs, $(gui_objs)) +../textadept-curses.exe: $(call win-objs, $(curses_objs)) $(termkey_win_objs) -textadept.exe: CXXFLAGS += -mwindows +../textadept.exe: CXXFLAGS += -mwindows $(win_exes): LDFLAGS := -static-libgcc -static-libstdc++ \ -Wl,--retain-symbols-file -Wl,$(shell pwd)/lua.sym -textadept.exe: LDFLAGS += $(shell PKG_CONFIG_PATH=`pwd`/win32gtk/lib/pkgconfig \ +../textadept.exe: LDFLAGS += $(shell PKG_CONFIG_PATH=`pwd`/win32gtk/lib/pkgconfig \ pkg-config --define-variable=prefix=win32gtk --libs gtk+-2.0 gmodule-2.0) -textadept.exe: LDLIBS := -liconv -textadept-curses.exe: LDLIBS := win32curses/lib/pdcurses.a win32curses/lib/libiconv.a +../textadept.exe: LDLIBS := -liconv +../textadept-curses.exe: LDLIBS := win32curses/lib/pdcurses.a win32curses/lib/libiconv.a $(win_exes): ; $(build-exe) # macOS. $(osx_exes): $(call osx-objs, $(common_objs)) -textadept-osx: $(call osx-objs, $(gui_objs)) -textadept-osx-curses: $(call osx-objs, $(curses_objs) $(termkey_unix_objs)) +../textadept-osx: $(call osx-objs, $(gui_objs)) +../textadept-osx-curses: $(call osx-objs, $(curses_objs) $(termkey_unix_objs)) -textadept-osx: LDFLAGS += $(shell PKG_CONFIG_PATH=`pwd`/gtkosx/lib/pkgconfig \ +../textadept-osx: LDFLAGS += $(shell PKG_CONFIG_PATH=`pwd`/gtkosx/lib/pkgconfig \ pkg-config --define-variable=prefix=gtkosx --libs gtk+-2.0 gmodule-2.0 gtk-mac-integration) \ -framework Cocoa $(osx_exes): LDLIBS := -liconv -textadept-osx-curses: LDLIBS += -lncurses +../textadept-osx-curses: LDLIBS += -lncurses $(osx_exes): ; $(build-exe) @@ -328,9 +328,9 @@ uninstall: # Clean. .PHONY: clean clean-win clean-osx clean-all -clean: ; rm -f $(linux_objs) $(addprefix ../, $(linux_exes)) -clean-win: ; rm -f $(win_objs) $(addprefix ../, $(win_exes)) -clean-osx: ; rm -f $(osx_objs) $(addprefix ../, $(osx_exes)) +clean: ; rm -f $(linux_objs) $(linux_exes) +clean-win: ; rm -f $(win_objs) $(win_exes) +clean-osx: ; rm -f $(osx_objs) $(osx_exes) clean-all: clean clean-win clean-osx # Documentation. @@ -362,69 +362,48 @@ ifndef NIGHTLY else basedir := textadept_nightly_$(shell date +"%F") endif -osxapp := Textadept.app -osxapp_bin := $(osxapp)/Contents/MacOS -osxapp_res := $(osxapp)/Contents/Resources -osxapp_libs := libatk-1.0.0.dylib libcairo.2.dylib libexpat.1.dylib libffi.6.dylib \ - libfontconfig.1.dylib libfreetype.6.dylib libgdk_pixbuf-2.0.0.dylib libgdk-quartz-2.0.0.dylib \ - libgio-2.0.0.dylib libglib-2.0.0.dylib libgmodule-2.0.0.dylib libgobject-2.0.0.dylib \ - libgthread-2.0.0.dylib libgtkmacintegration.2.dylib libgtk-quartz-2.0.0.dylib \ - libharfbuzz.0.dylib libintl.8.dylib libpango-1.0.0.dylib libpangocairo-1.0.0.dylib \ - libpangoft2-1.0.0.dylib libpixman-1.0.dylib libpng16.16.dylib charset.alias gdk-pixbuf-2.0 gtk-2.0 +linux_dir := $(basedir).linux +win_dir := $(basedir).win32 +osx_dir := $(basedir).macOS -.PHONY: release-all release win32-release osx-release modules-release -release-all: release win32-release osx-release #modules-release +.PHONY: release release-linux release-win release-osx +release: $(linux_dir).tgz $(win_dir).zip $(osx_dir).zip | deps win32-deps osx-deps docs ifneq (, $(shell hg summary 2>/dev/null)) archive = hg archive -X ".hg*" $(1) else archive = cd ../ && git archive HEAD --prefix src/$(1)/ | tar -xf - endif -modules := css ctags debugger export file_diff html lsp lua_repl open_file_mode python rest ruby \ - spellcheck yaml - -$(basedir).linux: ; $(call archive,$@) -release: $(basedir).linux - $(MAKE) deps clean docs - $(MAKE) -j4 CXXFLAGS="$(CXXFLAGS) -static-libstdc++" - cp -rL ../docs ../lexers ../textadept ../textadept-curses $< - tar czf $<.tgz $< && rm -rf $< -$(basedir).win32: ; $(call archive,$@) -win32-release: $(basedir).win32 - $(MAKE) -j4 clean win32-deps - cp win32gtk/bin/*.dll $< && cp -r win32gtk/etc win32gtk/lib win32gtk/share $< - rm -r $