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 # This target compiles the command parser twice:
40 # Once with -DTEST_PARSER, creating a stand-alone executable used for tests,
41 # and once as an object file for i3.
42 src/commands_parser.o: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp
44 $(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 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
47 # This target compiles the command parser twice:
48 # Once with -DTEST_PARSER, creating a stand-alone executable used for tests,
49 # and once as an object file for i3.
50 src/config_parser.o: src/config_parser.c $(i3_HEADERS_DEP) i3-config-parser.stamp
52 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -g -o test.config_parser $< $(LIBS) $(i3_LIBS)
53 $(CC) $(I3_CPPFLAGS) $(XCB_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
55 i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
56 echo "[i3] Generating command parser"
57 (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/commands.spec --prefix=command)
60 i3-config-parser.stamp: generate-command-parser.pl parser-specs/config.spec
61 echo "[i3] Generating config parser"
62 (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/config.spec --prefix=config)
65 i3: libi3.a $(i3_OBJECTS)
67 $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_LIBS)
71 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
72 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
73 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
74 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
75 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
76 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
77 $(LN) -sf i3 $(DESTDIR)$(PREFIX)/bin/i3-with-shmlog
78 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
79 $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
80 $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
81 $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
82 $(INSTALL) -m 0755 i3-dmenu-desktop $(DESTDIR)$(PREFIX)/bin/
83 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
84 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
85 $(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
86 $(INSTALL) -m 0644 i3-with-shmlog.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3-with-shmlog.desktop
87 $(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
88 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
92 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.*