diff --git a/README.md b/README.md index 695c532..4a14851 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,20 @@ Toxic is an ncurses-based instant messaging client for [Tox](https://tox.im) whi ### Compiling 1. `cd build/` -2. `make` -3. `sudo make install DESTDIR="/where/to/install"` +2. `make PREFIX="/where/to/install"` +3. `sudo make install PREFIX="/where/to/install"` ### Compilation Notes * You can add specific flags to the Makefile with `USER_CFLAGS=""` and/or `USER_LDFLAGS=""` * You can pass your own flags to the Makefile with `CFLAGS=""` and/or `LDFLAGS=""` (this will supersede the default ones) * Audio call support is automatically enabled if all dependencies are found +### Packaging +* For packaging purpose, you can use `DESTDIR=""` to specify a temporary directory where store installed files +* `DESTDIR=""` can be used in addition to `PREFIX=""`: + * `DESTDIR=""` is meant to specify a temporary directory where store installed files (ex: "/tmp/build/pkg") + * `PREFIX=""` is meant to specify a prefix directory for binaries and data files (ex: "/usr/local") + ### Troubleshooting If your default prefix is "/usr/local" and you receive the following: ``` diff --git a/build/Makefile b/build/Makefile index b9a943e..cfc4f24 100644 --- a/build/Makefile +++ b/build/Makefile @@ -2,15 +2,21 @@ TOXIC_VERSION = 0.4.2 REV = $(shell git rev-list HEAD --count) VERSION = $(TOXIC_VERSION)_r$(REV) -LIBS = libtoxcore ncursesw - -CFLAGS = -std=gnu99 -pthread -Wimplicit-function-declaration -Wreturn-type -DTOXICVER="\"$(VERSION)\"" -CFLAGS += -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED -CFLAGS += $(USER_CFLAGS) -LDFLAGS = $(USER_LDFLAGS) CFG_DIR = ../cfg SRC_DIR = ../src -DESTDIR = /usr/local +MISC_DIR = ../misc +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin +DATADIR = $(PREFIX)/share/toxic +DATAFILES = $(MISC_DIR)/DHTnodes $(MISC_DIR)/toxic.config + +LIBS = libtoxcore ncursesw + +CFLAGS = -std=gnu99 -pthread -Wimplicit-function-declaration -Wreturn-type +CFLAGS += -DTOXICVER="\"$(VERSION)\"" -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED +CFLAGS += -DPACKAGE_DATADIR="\"$(DATADIR)\"" +CFLAGS += $(USER_CFLAGS) +LDFLAGS = $(USER_LDFLAGS) OBJ = chat.o chat_commands.o configdir.o dns.o execute.o OBJ += file_senders.o friendlist.o global_commands.o groupchat.o line_info.o @@ -82,8 +88,10 @@ toxic: $(OBJ) $(CC) $(CFLAGS) -o toxic $(OBJ) $(LDFLAGS) install: toxic - mkdir -pv $(DESTDIR)/bin - install -m 0755 toxic $(DESTDIR)/bin + @mkdir -p $(DESTDIR)/$(BINDIR) + @mkdir -p $(DESTDIR)/$(DATADIR) + install -m 0755 toxic $(DESTDIR)/$(BINDIR) + install -m 0644 $(DATAFILES) $(PREFIX)/$(DATADIR) %.o: $(SRC_DIR)/%.c $(CC) $(CFLAGS) -o $*.o -c $(SRC_DIR)/$*.c