aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-15 13:42:31 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-15 13:42:31 +0200
commit6034fe23fdcf607ecf53bb97223d84864b3af461 (patch)
tree924ed6ba0759b6240574da143c3e6d100dbfa80f
parentf1f9743e14e2da5345824380d8eeb1d5b4e7c810 (diff)
downloadEpisodeBrowser-6034fe23fdcf607ecf53bb97223d84864b3af461.tar.gz
Add makedeps.pl.
-rw-r--r--.gitignore3
-rw-r--r--Makefile29
-rw-r--r--makedeps.pl20
3 files changed, 38 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 44b07c6..e034102 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
-/build/
+/b/
/misc/
TAGS
+deps.mk
*~
*.db
diff --git a/Makefile b/Makefile
index 1ab1213..df0a190 100644
--- a/Makefile
+++ b/Makefile
@@ -1,28 +1,31 @@
-B = build/default/
-
C = c/main.cpp
PL = pl/cfg.pl pl/episode_data.pl pl/local_episodes.pl pl/track_episodes.pl
-OBJ = $(B)common.obj $(B)datalistview.obj $(B)episodelistview.obj $(B)listview.obj $(B)pl.obj $(B)resource.obj
+OBJ = b/common.obj b/datalistview.obj b/episodelistview.obj b/listview.obj b/pl.obj b/resource.obj
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/EpisodeBrowser.exe
cp $< "C:\Users\John\Desktop\Delat"
-$(B)EpisodeBrowser.exe: $(C) $(OBJ) $(PL) c/*.h Makefile
+clean:
+ rm -fr b/EpisodeBrowser.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
+
+b/EpisodeBrowser.exe: Makefile deps.mk $(C) $(OBJ) $(PL) c/*.h
$(CC) -v $(CFLAGS) $(LDFLAGS) -goal true -o $@ $(C) $(OBJ) $(PL)
-$(B)resource.obj: c/resource.h c/resource.rc c/application.manifest
- windres -i c/resource.rc -o $(B)resource.obj
+b/resource.obj: c/resource.h c/resource.rc c/application.manifest
+ windres -i c/resource.rc -o b/resource.obj
-$(B)%.obj: c/%.cpp c/*.h
+b/%.obj: c/%.cpp
$(CC) -c $(CFLAGS) -o $@ $<
-TAGS: c/*.cpp c/*.h pl/*.pl
- etags c/*.cpp c/*.h -lprolog pl/*.pl
-
-clean:
- rm -fr $(B)EpisodeBrowser.exe $(B)*.obj
+-include deps.mk
diff --git a/makedeps.pl b/makedeps.pl
new file mode 100644
index 0000000..8956e81
--- /dev/null
+++ b/makedeps.pl
@@ -0,0 +1,20 @@
+#!/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";
+}