aboutsummaryrefslogtreecommitdiff
path: root/weechat/Makefile
blob: 650bbf27c19fac1c97c02f3e6c198fc8f5041b5e (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
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 dynamiclib

all: dynamiclib

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

dynamiclib: tomsg.$(DYLIB_EXT)


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

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