# $Id$ PKGCONF := pkg-config ifneq ($(shell $(PKGCONF) --exists w3 && echo yes),yes) ifneq ($(WINDOWS),YES) ifneq ($(LIBW3_CHECK),NO) $(error Please install LibW3 first) endif endif endif ifeq ("$(wildcard config.h)","") ifneq ($(CONFIG),NO) $(info Creating config.h) IGNORE := $(shell chmod +x ./config.sh) IGNORE := $(shell ./config.sh > ./config.h || rm ./config.h) $(error Created config.h. Run $(MAKE) again) endif endif ifeq ($(WINDOWS),YES) SUFFIX := .exe CURSES := -lpdcurses MINGW := x86_64-w64-mingw32 CC := $(MINGW)-gcc CFLAGS := -g -std=c99 -I. -Iw3/Library -pthread LDFLAGS := -Lw3/Library -pthread LIBS := -lw3 $(CURSES) else ifeq ($(NCURSES),YES) CURSES := $(shell $(PKGCONF) --libs ncurses) else ifeq ($(NCURSESW),YES) CURSES := $(shell $(PKGCONF) --libs ncursesw) else ifeq ($(XCURSES),YES) CURSES := -L/usr/xcurses/lib -Wl,-R/usr/xcurses/lib -Wl,-R/usr/X11R7/lib -lXCurses else ifeq ($(SDL2CURSES),YES) CURSES := -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lSDL2 pdcurses.a else CURSES := -lcurses endif endif endif endif CC := cc CFLAGS := -g -std=c99 -I. $(shell $(PKGCONF) --cflags w3) -pthread -Iw3/Library ifeq ($(NCURSES),YES) CFLAGS += $(shell $(PKGCONF) --cflags ncurses) endif ifeq ($(NCURSESW),YES) CFLAGS += $(shell $(PKGCONF) --cflags ncursesw) endif ifeq ($(XCURSES),YES) CFLAGS += -I/usr/xcurses/include/xcurses endif ifeq ($(SDL2CURSES),YES) CFLAGS += -I/usr/sdl2curses/include endif LDFLAGS := -pthread -Lw3/Library LIBS := $(shell $(PKGCONF) --libs w3) $(CURSES) endif .PHONY: all clean format archive all: ./nirc$(SUFFIX) ./nirc$(SUFFIX): ./main.o ./util.o ./term.o $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) ./main.o: ./main.c ./nirc.h ./config.h $(CC) $(CFLAGS) -c -o $@ $< ./%.o: ./%.c ./nirc_%.h ./nirc.h ./config.h $(CC) $(CFLAGS) -c -o $@ $< archive: all rm -rf nirc mkdir -p nirc ifeq ($(WINDOWS),YES) cp -rf /usr/$(MINGW)/sys-root/mingw/bin/libwinpthread-*.dll ./nirc/ cp -rf /usr/$(MINGW)/sys-root/mingw/bin/pdcurses.dll ./nirc/ cp -rf ./w3/Library/w3.dll ./nirc/ endif cp -rf ./nirc$(SUFFIX) ./nirc/ zip -rv ./nirc.zip ./nirc tar czvf ./nirc.tar.gz ./nirc format: clang-format -i *.c *.h clean: -rm -f ./nirc$(SUFFIX) ./*.o ./config.h *.zip *.tar.gz