summaryrefslogtreecommitdiff
path: root/Makefile
blob: 1cd5cc894ff314fc251e4a44d3ab1411c1fd05ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
LOLCAT_SRC ?= lolcat.c
CENSOR_SRC ?= censor.c
CFLAGS ?= -std=c11 -Wall -g

DESTDIR ?= /usr/local/bin

all: lolcat-static censor-static

include Makefile.musl

ifeq ($(shell uname -s),Darwin)
	LOLCAT_SRC += memorymapping/src/fmemopen.c
	CENSOR_SRC += memorymapping/src/fmemopen.c
	CFLAGS += -Imemorymapping/src
endif

.PHONY: install clean static

static: lolcat-static censor-static

lolcat-static: lolcat.c
	gcc -c $(CFLAGS) -I$(MUSLDIR)/include -o lolcat.o $<
	gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o $@ lolcat.o $(MUSLDIR)/lib/crt1.o $(MUSLDIR)/lib/libc.a

censor-static: censor.c
	gcc -c $(CFLAGS) -I$(MUSLDIR)/include -o censor.o $<
	gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o $@ censor.o $(MUSLDIR)/lib/crt1.o $(MUSLDIR)/lib/libc.a

lolcat: $(LOLCAT_SRC)
	gcc $(CFLAGS) -o $@ $^

censor: $(CENSOR_SRC)
	gcc $(CFLAGS) -o $@ $^

install: lolcat-static censor-static
	install lolcat-static $(DESTDIR)/lolcat
	install censor-static $(DESTDIR)/censor

clean:
	rm -f lolcat lolcat-static.o lolcat-static censor censor-static.o censor-static
	# make -C musl clean