2012-05-16 16:19:12 +02:00
|
|
|
|
ALL_TARGETS += i3
|
|
|
|
|
INSTALL_TARGETS += install-i3
|
|
|
|
|
CLEAN_TARGETS += clean-i3
|
|
|
|
|
|
2012-07-22 22:04:14 +02:00
|
|
|
|
i3_SOURCES_GENERATED = src/cfgparse.tab.c src/cfgparse.yy.c
|
|
|
|
|
i3_SOURCES := $(filter-out $(i3_SOURCES_GENERATED),$(wildcard src/*.c))
|
2012-05-16 16:19:12 +02:00
|
|
|
|
i3_HEADERS_CMDPARSER := $(wildcard include/GENERATED_*.h)
|
2012-07-22 22:04:14 +02:00
|
|
|
|
i3_HEADERS := $(filter-out $(i3_HEADERS_CMDPARSER),$(wildcard include/*.h))
|
2012-07-23 00:10:42 +02:00
|
|
|
|
i3_CFLAGS = $(XCB_CFLAGS) $(XCB_KBD_CFLAGS) $(XCB_WM_CFLAGS) $(X11_CFLAGS) $(XCURSOR_CFLAGS) $(YAJL_CFLAGS) $(LIBEV_CFLAGS) $(PCRE_CFLAGS) $(LIBSN_CFLAGS)
|
2012-08-13 00:57:57 +02:00
|
|
|
|
i3_LIBS = $(XCB_LIBS) $(XCB_KBD_LIBS) $(XCB_WM_LIBS) $(X11_LIBS) $(XCURSOR_LIBS) $(YAJL_LIBS) $(LIBEV_LIBS) $(PCRE_LIBS) $(LIBSN_LIBS) -lm -lpthread
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
pre-compile all.h, saves quite some build time
before:
$ time CC=clang make -j16
CC=clang make -j16 6,04s user 0,86s system 468% cpu 1,471 total
CC=clang make -j16 6,05s user 0,87s system 468% cpu 1,477 total
CC=clang make -j16 6,15s user 0,86s system 464% cpu 1,510 total
CC=clang make -j16 6,05s user 0,93s system 467% cpu 1,493 total
CC=clang make -j16 6,10s user 0,84s system 461% cpu 1,507 total
$ time CC=gcc make -j16
CC=gcc make -j16 9,91s user 1,43s system 508% cpu 2,231 total
CC=gcc make -j16 10,02s user 1,37s system 500% cpu 2,275 total
CC=gcc make -j16 9,80s user 1,60s system 507% cpu 2,245 total
CC=gcc make -j16 10,02s user 1,44s system 506% cpu 2,264 total
CC=gcc make -j16 9,99s user 1,45s system 505% cpu 2,261 total
after:
$ time CC=clang make -j16
CC=clang make -j16 3,41s user 0,83s system 375% cpu 1,131 total
CC=clang make -j16 3,29s user 0,90s system 373% cpu 1,122 total
CC=clang make -j16 3,35s user 0,77s system 369% cpu 1,116 total
CC=clang make -j16 3,36s user 0,78s system 374% cpu 1,105 total
CC=clang make -j16 3,46s user 0,75s system 373% cpu 1,126 total
$ time CC=gcc make -j16
CC=gcc make -j16 10,74s user 1,44s system 494% cpu 2,462 total
CC=gcc make -j16 10,68s user 1,54s system 497% cpu 2,453 total
CC=gcc make -j16 10,60s user 1,60s system 488% cpu 2,499 total
CC=gcc make -j16 10,63s user 1,51s system 485% cpu 2,502 total
CC=gcc make -j16 10,70s user 1,51s system 497% cpu 2,453 total
Therefore, we enable pre-compiled headers only when CC=clang.
2012-08-05 16:35:54 +02:00
|
|
|
|
# When using clang, we use pre-compiled headers to speed up the build. With
|
|
|
|
|
# gcc, this actually makes the build slower.
|
|
|
|
|
ifeq ($(CC),clang)
|
|
|
|
|
i3_HEADERS_DEP := $(i3_HEADERS) include/all.h.pch
|
|
|
|
|
PCH_FLAGS := -include include/all.h
|
|
|
|
|
else
|
|
|
|
|
i3_HEADERS_DEP := $(i3_HEADERS)
|
|
|
|
|
PCH_FLAGS :=
|
|
|
|
|
endif
|
|
|
|
|
|
2012-05-16 16:22:57 +02:00
|
|
|
|
i3_OBJECTS := $(i3_SOURCES_GENERATED:.c=.o) $(i3_SOURCES:.c=.o)
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
2012-08-05 17:00:24 +02:00
|
|
|
|
# The basename/readlink calls are for canonicalizing the path: Instead
|
|
|
|
|
# of src/main.c, we will see something like ../i3-4.2/src/main.c in
|
|
|
|
|
# debugger backtraces, making it clearer which code belongs to i3 and
|
|
|
|
|
# which code doesn’t.
|
|
|
|
|
# We only do this for src/ since all the other subdirectories contain i3 in
|
|
|
|
|
# their name already.
|
|
|
|
|
canonical_path := ../$(shell basename $(shell readlink -f .))
|
|
|
|
|
|
pre-compile all.h, saves quite some build time
before:
$ time CC=clang make -j16
CC=clang make -j16 6,04s user 0,86s system 468% cpu 1,471 total
CC=clang make -j16 6,05s user 0,87s system 468% cpu 1,477 total
CC=clang make -j16 6,15s user 0,86s system 464% cpu 1,510 total
CC=clang make -j16 6,05s user 0,93s system 467% cpu 1,493 total
CC=clang make -j16 6,10s user 0,84s system 461% cpu 1,507 total
$ time CC=gcc make -j16
CC=gcc make -j16 9,91s user 1,43s system 508% cpu 2,231 total
CC=gcc make -j16 10,02s user 1,37s system 500% cpu 2,275 total
CC=gcc make -j16 9,80s user 1,60s system 507% cpu 2,245 total
CC=gcc make -j16 10,02s user 1,44s system 506% cpu 2,264 total
CC=gcc make -j16 9,99s user 1,45s system 505% cpu 2,261 total
after:
$ time CC=clang make -j16
CC=clang make -j16 3,41s user 0,83s system 375% cpu 1,131 total
CC=clang make -j16 3,29s user 0,90s system 373% cpu 1,122 total
CC=clang make -j16 3,35s user 0,77s system 369% cpu 1,116 total
CC=clang make -j16 3,36s user 0,78s system 374% cpu 1,105 total
CC=clang make -j16 3,46s user 0,75s system 373% cpu 1,126 total
$ time CC=gcc make -j16
CC=gcc make -j16 10,74s user 1,44s system 494% cpu 2,462 total
CC=gcc make -j16 10,68s user 1,54s system 497% cpu 2,453 total
CC=gcc make -j16 10,60s user 1,60s system 488% cpu 2,499 total
CC=gcc make -j16 10,63s user 1,51s system 485% cpu 2,502 total
CC=gcc make -j16 10,70s user 1,51s system 497% cpu 2,453 total
Therefore, we enable pre-compiled headers only when CC=clang.
2012-08-05 16:35:54 +02:00
|
|
|
|
include/all.h.pch: $(i3_HEADERS)
|
|
|
|
|
echo "[i3] PCH all.h"
|
|
|
|
|
$(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -x c-header include/all.h -o include/all.h.pch
|
|
|
|
|
|
|
|
|
|
src/%.o: src/%.c $(i3_HEADERS_DEP)
|
2012-05-16 16:19:12 +02:00
|
|
|
|
echo "[i3] CC $<"
|
2012-08-05 17:00:24 +02:00
|
|
|
|
$(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(PCH_FLAGS) -c -o $@ ${canonical_path}/$<
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
pre-compile all.h, saves quite some build time
before:
$ time CC=clang make -j16
CC=clang make -j16 6,04s user 0,86s system 468% cpu 1,471 total
CC=clang make -j16 6,05s user 0,87s system 468% cpu 1,477 total
CC=clang make -j16 6,15s user 0,86s system 464% cpu 1,510 total
CC=clang make -j16 6,05s user 0,93s system 467% cpu 1,493 total
CC=clang make -j16 6,10s user 0,84s system 461% cpu 1,507 total
$ time CC=gcc make -j16
CC=gcc make -j16 9,91s user 1,43s system 508% cpu 2,231 total
CC=gcc make -j16 10,02s user 1,37s system 500% cpu 2,275 total
CC=gcc make -j16 9,80s user 1,60s system 507% cpu 2,245 total
CC=gcc make -j16 10,02s user 1,44s system 506% cpu 2,264 total
CC=gcc make -j16 9,99s user 1,45s system 505% cpu 2,261 total
after:
$ time CC=clang make -j16
CC=clang make -j16 3,41s user 0,83s system 375% cpu 1,131 total
CC=clang make -j16 3,29s user 0,90s system 373% cpu 1,122 total
CC=clang make -j16 3,35s user 0,77s system 369% cpu 1,116 total
CC=clang make -j16 3,36s user 0,78s system 374% cpu 1,105 total
CC=clang make -j16 3,46s user 0,75s system 373% cpu 1,126 total
$ time CC=gcc make -j16
CC=gcc make -j16 10,74s user 1,44s system 494% cpu 2,462 total
CC=gcc make -j16 10,68s user 1,54s system 497% cpu 2,453 total
CC=gcc make -j16 10,60s user 1,60s system 488% cpu 2,499 total
CC=gcc make -j16 10,63s user 1,51s system 485% cpu 2,502 total
CC=gcc make -j16 10,70s user 1,51s system 497% cpu 2,453 total
Therefore, we enable pre-compiled headers only when CC=clang.
2012-08-05 16:35:54 +02:00
|
|
|
|
src/cfgparse.yy.c: src/cfgparse.l src/cfgparse.tab.o $(i3_HEADERS_DEP)
|
2012-05-16 16:19:12 +02:00
|
|
|
|
echo "[i3] LEX $<"
|
2012-08-05 17:00:24 +02:00
|
|
|
|
$(FLEX) -i -o $@ ${canonical_path}/$<
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
pre-compile all.h, saves quite some build time
before:
$ time CC=clang make -j16
CC=clang make -j16 6,04s user 0,86s system 468% cpu 1,471 total
CC=clang make -j16 6,05s user 0,87s system 468% cpu 1,477 total
CC=clang make -j16 6,15s user 0,86s system 464% cpu 1,510 total
CC=clang make -j16 6,05s user 0,93s system 467% cpu 1,493 total
CC=clang make -j16 6,10s user 0,84s system 461% cpu 1,507 total
$ time CC=gcc make -j16
CC=gcc make -j16 9,91s user 1,43s system 508% cpu 2,231 total
CC=gcc make -j16 10,02s user 1,37s system 500% cpu 2,275 total
CC=gcc make -j16 9,80s user 1,60s system 507% cpu 2,245 total
CC=gcc make -j16 10,02s user 1,44s system 506% cpu 2,264 total
CC=gcc make -j16 9,99s user 1,45s system 505% cpu 2,261 total
after:
$ time CC=clang make -j16
CC=clang make -j16 3,41s user 0,83s system 375% cpu 1,131 total
CC=clang make -j16 3,29s user 0,90s system 373% cpu 1,122 total
CC=clang make -j16 3,35s user 0,77s system 369% cpu 1,116 total
CC=clang make -j16 3,36s user 0,78s system 374% cpu 1,105 total
CC=clang make -j16 3,46s user 0,75s system 373% cpu 1,126 total
$ time CC=gcc make -j16
CC=gcc make -j16 10,74s user 1,44s system 494% cpu 2,462 total
CC=gcc make -j16 10,68s user 1,54s system 497% cpu 2,453 total
CC=gcc make -j16 10,60s user 1,60s system 488% cpu 2,499 total
CC=gcc make -j16 10,63s user 1,51s system 485% cpu 2,502 total
CC=gcc make -j16 10,70s user 1,51s system 497% cpu 2,453 total
Therefore, we enable pre-compiled headers only when CC=clang.
2012-08-05 16:35:54 +02:00
|
|
|
|
src/cfgparse.tab.c: src/cfgparse.y $(i3_HEADERS_DEP)
|
2012-05-16 16:19:12 +02:00
|
|
|
|
echo "[i3] YACC $<"
|
2012-08-05 17:00:24 +02:00
|
|
|
|
$(BISON) --debug --verbose -b $(basename $< .y) -d ${canonical_path}/$<
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
|
|
|
|
# This target compiles the command parser twice:
|
|
|
|
|
# Once with -DTEST_PARSER, creating a stand-alone executable used for tests,
|
|
|
|
|
# and once as an object file for i3.
|
pre-compile all.h, saves quite some build time
before:
$ time CC=clang make -j16
CC=clang make -j16 6,04s user 0,86s system 468% cpu 1,471 total
CC=clang make -j16 6,05s user 0,87s system 468% cpu 1,477 total
CC=clang make -j16 6,15s user 0,86s system 464% cpu 1,510 total
CC=clang make -j16 6,05s user 0,93s system 467% cpu 1,493 total
CC=clang make -j16 6,10s user 0,84s system 461% cpu 1,507 total
$ time CC=gcc make -j16
CC=gcc make -j16 9,91s user 1,43s system 508% cpu 2,231 total
CC=gcc make -j16 10,02s user 1,37s system 500% cpu 2,275 total
CC=gcc make -j16 9,80s user 1,60s system 507% cpu 2,245 total
CC=gcc make -j16 10,02s user 1,44s system 506% cpu 2,264 total
CC=gcc make -j16 9,99s user 1,45s system 505% cpu 2,261 total
after:
$ time CC=clang make -j16
CC=clang make -j16 3,41s user 0,83s system 375% cpu 1,131 total
CC=clang make -j16 3,29s user 0,90s system 373% cpu 1,122 total
CC=clang make -j16 3,35s user 0,77s system 369% cpu 1,116 total
CC=clang make -j16 3,36s user 0,78s system 374% cpu 1,105 total
CC=clang make -j16 3,46s user 0,75s system 373% cpu 1,126 total
$ time CC=gcc make -j16
CC=gcc make -j16 10,74s user 1,44s system 494% cpu 2,462 total
CC=gcc make -j16 10,68s user 1,54s system 497% cpu 2,453 total
CC=gcc make -j16 10,60s user 1,60s system 488% cpu 2,499 total
CC=gcc make -j16 10,63s user 1,51s system 485% cpu 2,502 total
CC=gcc make -j16 10,70s user 1,51s system 497% cpu 2,453 total
Therefore, we enable pre-compiled headers only when CC=clang.
2012-08-05 16:35:54 +02:00
|
|
|
|
src/commands_parser.o: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp
|
2012-05-16 16:19:12 +02:00
|
|
|
|
echo "[i3] CC $<"
|
2012-08-12 00:59:19 +02:00
|
|
|
|
$(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -o test.commands_parser $< $(LIBS) $(i3_LIBS)
|
2012-08-05 17:00:24 +02:00
|
|
|
|
$(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
|
|
|
|
i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
|
|
|
|
|
echo "[i3] Generating command parser"
|
|
|
|
|
(cd include; ../generate-command-parser.pl)
|
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
|
i3: libi3.a $(i3_OBJECTS)
|
|
|
|
|
echo "[i3] Link i3"
|
2012-08-12 00:59:19 +02:00
|
|
|
|
$(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_LIBS)
|
2012-05-16 16:19:12 +02:00
|
|
|
|
|
|
|
|
|
install-i3: i3
|
|
|
|
|
echo "[i3] Install"
|
|
|
|
|
$(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
|
|
|
|
|
$(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
|
|
|
|
|
$(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
|
|
|
|
|
$(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
|
|
|
|
|
$(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
|
|
|
|
|
$(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
|
$(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
|
$(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
|
$(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
|
$(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
|
test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
|
|
|
|
|
test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
|
|
|
|
|
$(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
|
|
|
|
|
$(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
|
|
|
|
|
$(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
|
|
|
|
|
|
|
|
|
|
clean-i3:
|
|
|
|
|
echo "[i3] Clean"
|
2012-08-07 10:03:10 +02:00
|
|
|
|
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}
|