From d00f8b35b4838ba7c6bf00b7b211f463810f4ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 15 Jul 2022 16:57:15 +0200 Subject: Improve makedeps script. --- Makefile | 16 +++++++++------- makedeps | 24 ++++++++++++++++++++++++ makedeps.pl | 20 -------------------- 3 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 makedeps delete mode 100644 makedeps.pl diff --git a/Makefile b/Makefile index df0a190..8a50d02 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,26 @@ -C = c/main.cpp -PL = pl/cfg.pl pl/episode_data.pl pl/local_episodes.pl pl/track_episodes.pl +EXE = EpisodeBrowser.exe OBJ = b/common.obj b/datalistview.obj b/episodelistview.obj b/listview.obj b/pl.obj b/resource.obj +PL = pl/cfg.pl pl/episode_data.pl pl/local_episodes.pl pl/track_episodes.pl CC = swipl-ld CFLAGS += -Wall -Wpedantic -O -cc-options,-std=c++17 -ld-options,-mwindows CFLAGS += -DUNICODE -D_UNICODE LDFLAGS += -lcomctl32 -luxtheme -all: b/EpisodeBrowser.exe +all: b/$(EXE) cp $< "C:\Users\John\Desktop\Delat" clean: - rm -fr b/EpisodeBrowser.exe b/*.obj + rm -fr b/$(EXE) b/*.obj TAGS: c/*.cpp c/*.h pl/*.pl etags c/*.cpp c/*.h -lprolog pl/*.pl deps.mk: c/*.cpp - perl makedeps.pl + perl makedeps -b/EpisodeBrowser.exe: Makefile deps.mk $(C) $(OBJ) $(PL) c/*.h - $(CC) -v $(CFLAGS) $(LDFLAGS) -goal true -o $@ $(C) $(OBJ) $(PL) +b/$(EXE): Makefile deps.mk c/main.cpp $(OBJ) $(PL) + $(CC) -v $(CFLAGS) $(LDFLAGS) -goal true -o $@ c/main.cpp $(OBJ) $(PL) b/resource.obj: c/resource.h c/resource.rc c/application.manifest windres -i c/resource.rc -o b/resource.obj @@ -28,4 +28,6 @@ b/resource.obj: c/resource.h c/resource.rc c/application.manifest b/%.obj: c/%.cpp $(CC) -c $(CFLAGS) -o $@ $< +# deps.mk includes additional, dynamically generated dependencies for +# b/*.obj and b/EpisodeBrowser.exe. -include deps.mk diff --git a/makedeps b/makedeps new file mode 100644 index 0000000..4cfa1ac --- /dev/null +++ b/makedeps @@ -0,0 +1,24 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +open my $fh, ">", "deps.mk"; +print $fh "# This file is generated by makedeps.pl.\n"; +while (my $f = glob("c/*.cpp")) { + open my $gh, "<", $f; + $f =~ s,^c/,,; + $f =~ s/\.cpp$//; + if ($f eq "main") { + print $fh "b/\$(EXE):"; + } else { + print $fh "b/$f.obj:"; + } + while ($_ = <$gh>) { + next if /^$/; + goto n if not /#/; + print $fh " c/$1" if /^#include\s+"([^"]+)"/; + } + n: + print $fh "\n"; +} diff --git a/makedeps.pl b/makedeps.pl deleted file mode 100644 index 8956e81..0000000 --- a/makedeps.pl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; - -open my $fh, ">", "deps.mk"; -print $fh "# This file is generated by makedeps.pl.\n"; -while (my $f = glob("c/*.cpp")) { - open my $gh, "<", $f; - $f =~ s,^c/,,; - $f =~ s/\.cpp$//; - print $fh "b/$f.obj: c/$f.cpp"; - while ($_ = <$gh>) { - next if /^$/; - goto n if not /#/; - print $fh " c/$1" if /^#include\s+"([^"]+)"/; - } - n: - print $fh "\n"; -} -- cgit v1.2.3