aboutsummaryrefslogtreecommitdiff
path: root/weechat/Makefile
blob: 0973efe8af2dd4e5b4dc2bb0c1126998ae82a066 (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
CC = gcc
CFLAGS = -Wall -Wextra -std=c11 -fwrapv -g -O2 -fPIC

SRC_FILES = $(wildcard *.c)
HEADER_FILES = $(wildcard *.h)
OBJECT_FILES = $(patsubst %.c,%.o,$(SRC_FILES))

UNAME = $(shell uname)

ifeq ($(UNAME),Darwin)
	DYLIB_EXT = so  # should really be .dylib, but weechat seems to expect 'so'
	DYLIB_FLAGS = -dynamiclib
else
	DYLIB_EXT = so
	DYLIB_FLAGS = -shared
endif


# Don't remove intermediate files
.SECONDARY:


.PHONY: all clean remake dynamiclib

all: dynamiclib

clean:
	rm -f *.$(DYLIB_EXT) *.o

remake: clean
	$(MAKE) all

dynamiclib: tomsg.$(DYLIB_EXT)


%.o: %.c $(HEADER_FILES)
	$(CC) $(CFLAGS) -c -o $@ $<

%.$(DYLIB_EXT): $(OBJECT_FILES)
	$(CC) $(CFLAGS) $(DYLIB_FLAGS) -o $@ $^