]> git.sur5r.net Git - i3/i3/commitdiff
fix the build on OS X
authorJean-Philippe Ouellet <jpo@vt.edu>
Tue, 26 Nov 2013 10:41:56 +0000 (05:41 -0500)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 26 Nov 2013 18:56:45 +0000 (19:56 +0100)
OS X doesn't have posix_fallocate() yet, so put
bf760d0241f0f078735e230b4bf6da4fc83368fe in
    #if defined(__APPLE__)

the cd fails with:
    /bin/sh: line 0: cd: include: No such file or directory
so give it a path relative to the top directory

src/i3.mk
src/log.c

index 36a24c8b23ce0e06de642fcd5798637f9da30ff1..395b4cfaf96ea84b2977db3624fdf74715ce011d 100644 (file)
--- a/src/i3.mk
+++ b/src/i3.mk
@@ -54,12 +54,12 @@ src/config_parser.o: src/config_parser.c $(i3_HEADERS_DEP) i3-config-parser.stam
 
 i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
        echo "[i3] Generating command parser"
-       (cd include; ../generate-command-parser.pl --input=../parser-specs/commands.spec --prefix=command)
+       (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/commands.spec --prefix=command)
        touch $@
 
 i3-config-parser.stamp: generate-command-parser.pl parser-specs/config.spec
        echo "[i3] Generating config parser"
-       (cd include; ../generate-command-parser.pl --input=../parser-specs/config.spec --prefix=config)
+       (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/config.spec --prefix=config)
        touch $@
 
 i3: libi3.a $(i3_OBJECTS)
index 34e345322e994e57a07b70e2b0e084c6337b9803..86f47b9acfa7c3c77362d587fce4cc73bfa8579b 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -129,11 +129,16 @@ void open_logbuffer(void) {
             return;
         }
 
+#if defined(__APPLE__)
+        if (ftruncate(logbuffer_shm, logbuffer_size) == -1) {
+            fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
+#else
         int ret;
         if ((ret = posix_fallocate(logbuffer_shm, 0, logbuffer_size)) != 0) {
+            fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(ret));
+#endif
             close(logbuffer_shm);
             shm_unlink(shmlogname);
-            fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(ret));
             return;
         }