2 INSTALL_TARGETS += install-i3
3 CLEAN_TARGETS += clean-i3
5 i3_SOURCES_GENERATED = src/cfgparse.tab.c src/cfgparse.yy.c
6 i3_SOURCES := $(filter-out $(i3_SOURCES_GENERATED),$(wildcard src/*.c))
7 i3_HEADERS_CMDPARSER := $(wildcard include/GENERATED_*.h)
8 i3_HEADERS := $(filter-out $(i3_HEADERS_CMDPARSER),$(wildcard include/*.h))
9 i3_CFLAGS = $(XCB_CFLAGS) $(XCB_KBD_CFLAGS) $(XCB_WM_CFLAGS) $(X11_CFLAGS) $(XCURSOR_CFLAGS) $(YAJL_CFLAGS) $(LIBEV_CFLAGS) $(PCRE_CFLAGS) $(LIBSN_CFLAGS)
10 i3_LIBS = $(XCB_LIBS) $(XCB_KBD_LIBS) $(XCB_WM_LIBS) $(X11_LIBS) $(XCURSOR_LIBS) $(YAJL_LIBS) $(LIBEV_LIBS) $(PCRE_LIBS) $(LIBSN_LIBS) -lm -lpthread
12 # When using clang, we use pre-compiled headers to speed up the build. With
13 # gcc, this actually makes the build slower.
15 i3_HEADERS_DEP := $(i3_HEADERS) include/all.h.pch
16 PCH_FLAGS := -include include/all.h
18 i3_HEADERS_DEP := $(i3_HEADERS)
22 i3_OBJECTS := $(i3_SOURCES_GENERATED:.c=.o) $(i3_SOURCES:.c=.o)
24 # The basename/readlink calls are for canonicalizing the path: Instead
25 # of src/main.c, we will see something like ../i3-4.2/src/main.c in
26 # debugger backtraces, making it clearer which code belongs to i3 and
27 # which code doesn’t.
28 # We only do this for src/ since all the other subdirectories contain i3 in
30 canonical_path := ../$(shell basename $(shell readlink -f .))
32 include/all.h.pch: $(i3_HEADERS)
34 $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -x c-header include/all.h -o include/all.h.pch
36 src/%.o: src/%.c $(i3_HEADERS_DEP)
38 $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(PCH_FLAGS) -c -o $@ ${canonical_path}/$<
40 src/cfgparse.yy.c: src/cfgparse.l src/cfgparse.tab.o $(i3_HEADERS_DEP)
42 $(FLEX) -i -o $@ ${canonical_path}/$<
44 src/cfgparse.tab.c: src/cfgparse.y $(i3_HEADERS_DEP)
46 $(BISON) --debug --verbose -b $(basename $< .y) -d ${canonical_path}/$<
48 # This target compiles the command parser twice:
49 # Once with -DTEST_PARSER, creating a stand-alone executable used for tests,
50 # and once as an object file for i3.
51 src/commands_parser.o: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp
53 $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -o test.commands_parser $< $(i3_LIBS) $(LIBS)
54 $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
56 i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
57 echo "[i3] Generating command parser"
58 (cd include; ../generate-command-parser.pl)
61 i3: libi3.a $(i3_OBJECTS)
63 $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_LIBS) $(LIBS)
67 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
68 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
69 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
70 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
71 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
72 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
73 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
74 $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
75 $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
76 $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
77 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
78 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
79 $(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
80 $(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
81 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
85 rm -f $(i3_OBJECTS) $(i3_SOURCES_GENERATED) $(i3_HEADERS_CMDPARSER) include/loglevels.h loglevels.tmp include/all.h.pch i3-command-parser.stamp i3 src/*.gcno src/cfgparse.{output,dot}