1 ALL_TARGETS += i3 test-tools
2 INSTALL_TARGETS += install-i3
3 CLEAN_TARGETS += clean-i3
5 i3_SOURCES := $(filter-out $(i3_SOURCES_GENERATED),$(wildcard src/*.c))
6 i3_HEADERS_CMDPARSER := $(wildcard include/GENERATED_*.h)
7 i3_HEADERS := $(filter-out $(i3_HEADERS_CMDPARSER),$(wildcard include/*.h))
8 i3_CFLAGS = $(XCB_CFLAGS) $(XCB_KBD_CFLAGS) $(XCB_WM_CFLAGS) $(X11_CFLAGS) $(XCURSOR_CFLAGS) $(PANGO_CFLAGS) $(YAJL_CFLAGS) $(LIBEV_CFLAGS) $(PCRE_CFLAGS) $(LIBSN_CFLAGS)
9 i3_LIBS = $(XCB_LIBS) $(XCB_KBD_LIBS) $(XCB_WM_LIBS) $(X11_LIBS) $(XCURSOR_LIBS) $(PANGO_LIBS) $(YAJL_LIBS) $(LIBEV_LIBS) $(PCRE_LIBS) $(LIBSN_LIBS) -lm -lpthread
11 # When using clang, we use pre-compiled headers to speed up the build. With
12 # gcc, this actually makes the build slower.
14 i3_HEADERS_DEP := $(i3_HEADERS) include/all.h.pch
15 PCH_FLAGS := -include include/all.h
17 i3_HEADERS_DEP := $(i3_HEADERS)
21 i3_OBJECTS := $(i3_SOURCES_GENERATED:.c=.o) $(i3_SOURCES:.c=.o)
23 # The basename/pwd calls are for canonicalizing the path: Instead
24 # of src/main.c, we will see something like ../i3-4.2/src/main.c in
25 # debugger backtraces, making it clearer which code belongs to i3 and
26 # which code doesn’t.
27 # We only do this for src/ since all the other subdirectories contain i3 in
29 canonical_path := ../$(shell basename $(shell pwd -P))
31 include/all.h.pch: $(i3_HEADERS)
33 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -x c-header include/all.h -o include/all.h.pch
35 src/%.o: src/%.c $(i3_HEADERS_DEP)
37 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(PCH_FLAGS) -c -o $@ ${canonical_path}/$<
39 test-tools: test.commands_parser test.config_parser
41 test.commands_parser: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp libi3.a
42 echo "[i3] Link test.commands_parser"
43 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -g -o test.commands_parser $< $(LIBS) $(i3_LIBS)
45 test.config_parser: src/config_parser.c $(i3_HEADERS_DEP) i3-config-parser.stamp libi3.a
46 echo "[i3] Link test.config_parser"
47 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -g -o test.config_parser $< $(LIBS) $(i3_LIBS)
49 src/commands_parser.o: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp
51 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
53 src/config_parser.o: src/config_parser.c $(i3_HEADERS_DEP) i3-config-parser.stamp
55 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
57 i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
58 echo "[i3] Generating command parser"
59 (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/commands.spec --prefix=command)
62 i3-config-parser.stamp: generate-command-parser.pl parser-specs/config.spec
63 echo "[i3] Generating config parser"
64 (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/config.spec --prefix=config)
67 i3: libi3.a $(i3_OBJECTS)
69 $(CC) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_LIBS)
73 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
74 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
75 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
76 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
77 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
78 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
79 $(LN) -sf i3 $(DESTDIR)$(PREFIX)/bin/i3-with-shmlog
80 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
81 $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
82 $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
83 $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
84 $(INSTALL) -m 0755 i3-save-tree $(DESTDIR)$(PREFIX)/bin/
85 $(INSTALL) -m 0755 i3-dmenu-desktop $(DESTDIR)$(PREFIX)/bin/
86 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
87 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
88 $(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
89 $(INSTALL) -m 0644 i3-with-shmlog.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3-with-shmlog.desktop
90 $(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
91 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
95 rm -f $(i3_OBJECTS) $(i3_SOURCES_GENERATED) $(i3_HEADERS_CMDPARSER) include/loglevels.h loglevels.tmp include/all.h.pch i3-command-parser.stamp i3-config-parser.stamp i3 test.config_parser test.commands_parser src/*.gcno src/cfgparse.* src/cmdparse.*