summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--Makefile22
-rw-r--r--censor.c2
-rw-r--r--lolcat.c8
m---------memorymapping0
5 files changed, 25 insertions, 10 deletions
diff --git a/.gitmodules b/.gitmodules
index f80450c..a956631 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "musl"]
path = musl
url = git://git.musl-libc.org/musl
+[submodule "memorymapping"]
+ path = memorymapping
+ url = https://github.com/NimbusKit/memorymapping
diff --git a/Makefile b/Makefile
index f6aba9a..8cb68ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,14 @@
+LOLCAT_SRC = lolcat.c
+CENSOR_SRC = censor.c
+CFLAGS = -std=c11 -Wall
+
+ifeq ($(shell uname -s),Darwin)
+ LOLCAT_SRC += memorymapping/src/fmemopen.c
+ CENSOR_SRC += memorymapping/src/fmemopen.c
+ CFLAGS += -Imemorymapping/src
+endif
+
all: lolcat censor
.PHONY: install clean musl static
@@ -12,18 +22,18 @@ musl: musl/lib/libc.a musl/lib/crt1.o
static: lolcat-static censor-static
lolcat-static: lolcat.c musl
- gcc -c -std=c11 -Wall -Imusl/include -o lolcat.o $<
+ gcc -c $(CFLAGS) -Imusl/include -o lolcat.o $<
gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o $@ lolcat.o musl/lib/crt1.o musl/lib/libc.a
censor-static: censor.c musl
- gcc -c -std=c11 -Wall -Imusl/include -o censor.o $<
+ gcc -c $(CFLAGS) -Imusl/include -o censor.o $<
gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o $@ censor.o musl/lib/crt1.o musl/lib/libc.a
-lolcat: lolcat.c
- gcc -std=c11 -Wall -o $@ $<
+lolcat: $(LOLCAT_SRC)
+ gcc $(CFLAGS) -o $@ $^
-censor: censor.c
- gcc -std=c11 -Wall -o $@ $<
+censor: $(CENSOR_SRC)
+ gcc $(CFLAGS) -o $@ $^
install: lolcat censor
install lolcat /usr/local/bin
diff --git a/censor.c b/censor.c
index 7efe81e..c2d5d2f 100644
--- a/censor.c
+++ b/censor.c
@@ -13,8 +13,6 @@
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*/
-#define _GNU_SOURCE //for fmemopen
-
#include <stdint.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lolcat.c b/lolcat.c
index 9e9cdc5..687f259 100644
--- a/lolcat.c
+++ b/lolcat.c
@@ -13,8 +13,6 @@
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*/
-#define _GNU_SOURCE //for fmemopen
-
#include <stdint.h>
#include <stdio.h>
#include <wchar.h>
@@ -27,6 +25,12 @@
#include <unistd.h>
#include <sys/time.h>
+#ifdef __APPLE__
+#include "fmemopen.h"
+#else // __APPLE__
+#define _GNU_SOURCE //for fmemopen
+#endif // __APPLE__
+
static char helpstr[] = "\n"
"Usage: lolcat [-h horizontal_speed] [-v vertical_speed] [--] [FILES...]\n"
diff --git a/memorymapping b/memorymapping
new file mode 160000
+Subproject 79ce0ddd0de4b11e4944625eb866290368f867c