hirc

IRC client
git clone https://hhvn.uk/hirc
git clone git://hhvn.uk/hirc
Log | Files | Refs

Makefile (2808B)


      1 # Makefile from hirc
      2 #
      3 # Copyright (c) 2021-2022 hhvn <dev@hhvn.uk>
      4 #
      5 # Permission to use, copy, modify, and distribute this software for any
      6 # purpose with or without fee is hereby granted, provided that the above
      7 # copyright notice and this permission notice appear in all copies.
      8 #
      9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     16 
     17 PREFIX	= /usr/local
     18 BINDIR	= $(PREFIX)/bin
     19 MANDIR	= $(PREFIX)/share/man
     20 BIN	= hirc
     21 PARSE	= src/format.y
     22 SRC	= src/main.c src/mem.c src/handle.c src/hist.c \
     23 	  src/nick.c src/chan.c src/serv.c src/ui.c \
     24 	  src/complete.c src/commands.c src/config.c \
     25 	  src/str.c src/params.c $(PARSE:.y=.c)
     26 OBJ	= $(SRC:.c=.o)
     27 MAN	= doc/hirc.1
     28 MAN5	= doc/hirc.conf.5
     29 COMMIT	= $(shell grep -oE '^.{7}' < .git/refs/heads/master)
     30 CFLAGS	= $(DEBUG)
     31 LDFLAGS = -lncursesw
     32 
     33 include config.mk
     34 
     35 all: $(BIN) $(MAN) misc
     36 
     37 # Some make implementation will
     38 # use a target to create an include
     39 # file if it doesn't yet exist,
     40 # but this is not a standard feature.
     41 config.mk:
     42 	./configure
     43 
     44 # All objects should be rebuilt if
     45 # struct.h changes, as, for example,
     46 # if an enum changes value that will
     47 # only be recognized in source files
     48 # that have been changed aswell.
     49 $(OBJ): src/struct.h
     50 
     51 # Data/ headers
     52 src/config.o: src/data/config.h
     53 src/commands.o: src/data/commands.h
     54 src/format.o: src/data/formats.h
     55 src/handle.o: src/data/handlers.h
     56 
     57 $(BIN): $(OBJ)
     58 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ)
     59 
     60 $(MAN): $(BIN) $(MAN).header $(MAN).footer
     61 	./$(BIN) -d | \
     62 		cat $(MAN).header - $(MAN).footer \
     63 		> $(MAN)
     64 
     65 misc:
     66 	cd misc/ && make \
     67 		CFLAGS="$(CFLAGS)"
     68 
     69 misc-install:
     70 	cd misc/ && make install \
     71 		CFLAGS="$(CFLAGS)"
     72 		PREFIX="$(PREFIX)" \
     73 		BINDIR="$(BINDIR)" \
     74 		MANDIR="$(MANDIR)"
     75 
     76 misc-uninstall:
     77 	cd misc/ && make uninstall \
     78 		PREFIX="$(PREFIX)" \
     79 		BINDIR="$(BINDIR)" \
     80 		MANDIR="$(MANDIR)"
     81 
     82 misc-clean:
     83 	cd misc/ && make clean
     84 
     85 install: all misc-install
     86 	mkdir -p $(BINDIR) $(MANDIR)/man1
     87 	install -m0755 $(BIN) $(BINDIR)/$(BIN)
     88 	sed "s/COMMIT/$(COMMIT)/" \
     89 		< $(MAN) \
     90 		> $(MANDIR)/man1/`basename $(MAN)`
     91 	sed "s/COMMIT/$(COMMIT)/" \
     92 		< $(MAN5) \
     93 		> $(MANDIR)/man5/`basename $(MAN5)`
     94 
     95 uninstall: misc-uninstall
     96 	-rm -f $(BINDIR)/$(BIN)
     97 	-rm -f $(MANDIR)/man1/$(MAN)
     98 
     99 clean: misc-clean
    100 	-rm -f $(OBJ) $(MAN) $(BIN)
    101 
    102 .c.o:
    103 	$(CC) $(CFLAGS) -c $< -o $@
    104 
    105 .PHONY: all misc clean install uninstall misc misc-install misc-uninstall misc-clean