-include config.mk VERSION=0.3 GIT_VERSION := $(shell [ -d .git ] && echo "-$$(git describe --always)") CFLAGS ?= -g CFLAGS += -DVERSION=\"$(VERSION)$(GIT_VERSION)\" TARGETS = sircbot sircbot-send ifneq (NOLUA,) LUA_VERSION ?= 5.3 LUAPC ?= lua$(LUA_VERSION) PKGCONFIG ?= pkg-config TARGETS += lua/$(LUA_VERSION)/sircbot.so LUA_CFLAGS = $(shell $(PKGCONFIG) --cflags $(LUAPC)) endif prefix ?= /usr/local bindir ?= $(prefix)/bin DESTDIR ?= LUA_LIBDIR ?= $(prefix)/lib/lua/5.1 LUA_LUADIR ?= $(prefix)/share/lua/5.1 INSTALL ?= install all: $(TARGETS) sircbot: sircbot.o irc.o $(CC) $(LDFLAGS) -o $@ $^ sircbot-send: sircbot-send.o $(CC) $(LDFLAGS) -o $@ $^ lua/$(LUA_VERSION)/sircbot.so: lua/$(LUA_VERSION)/lsircbot.o ln -sf $@ sircbot.so $(CC) -shared $(LDFLAGS) -o $@ $^ $(LUA_LIBS) .c.o: $(CC) -fPIC $(CFLAGS) -c $^ lua/$(LUA_VERSION)/%.o: lua/%.c mkdir -p "$(dir $@)" $(CC) -fPIC $(CFLAGS) $(LUA_CFLAGS) -o $@ -c $^ clean: rm -f *.o $(TARGETS) sircbot.so install: $(TARGETS) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) sircbot $(DESTDIR)$(bindir) $(INSTALL) sircbot-send $(DESTDIR)$(bindir) ifneq (NOLUA,) $(INSTALL) -d $(DESTDIR)$(LUA_LIBDIR) $(INSTALL) sircbot.so $(DESTDIR)$(LUA_LIBDIR) endif