Permalink
Browse files

Makefile: de-duplicate the main body as between Makefile and distMake…

…file
  • Loading branch information...
ec429 committed Oct 7, 2012
1 parent 3b2ab61 commit 999def14df0e2dda8cc45adbdca9dd91c7788199
Showing with 28 additions and 135 deletions.
  1. +1 −118 Makefile
  2. +27 −17 distMakefile
View
119 Makefile
@@ -1,125 +1,8 @@
# Makefile for quIRC
-CC ?= gcc
-OPTFLAGS := -g
-CFLAGS = -Wall -Wextra -Werror -pedantic -std=gnu99 -D_GNU_SOURCE $(OPTFLAGS)
-AWK := gawk
VERSION := `git describe --tags`
-PREFIX := /usr/local
-LIBS_ASYNCH_NL := -lanl
-OPTLIBS = $(LIBS_ASYNCH_NL)
-LIBS = -lm -lncurses $(OBJS) $(OPTLIBS)
-OBJS := ttyraw.o ttyesc.o irc.o bits.o strbuf.o ctbuf.o colour.o buffer.o names.o config.o input.o logging.o types.o
-INCLUDE := $(OBJS:.o=.h) quirc.h version.h osconf.h
--include config.mak
-
-all: quirc doc
-
-install: all doc
- install -D -m0755 quirc $(PREFIX)/bin/quirc
- install -D -m0644 quirc.1 $(PREFIX)/man/man1/quirc.1
- install -D -m0644 readme.htm $(PREFIX)/share/doc/quirc/readme.htm
- install -D -m0644 readme.css $(PREFIX)/share/doc/quirc/readme.css
- install -D -m0644 config_ref.htm $(PREFIX)/share/doc/quirc/config_ref.htm
- install -D -m0644 tutorial.htm $(PREFIX)/share/doc/quirc/tutorial.htm
-
-uninstall:
- -rm $(PREFIX)/bin/quirc
- -rm $(PREFIX)/man/man1/quirc.1
- -rm $(PREFIX)/share/doc/quirc/readme.htm
- -rm $(PREFIX)/share/doc/quirc/readme.css
- -rm $(PREFIX)/share/doc/quirc/config_ref.htm
- -rm $(PREFIX)/share/doc/quirc/tutorial.htm
-
-quirc: quirc.c $(OBJS) $(INCLUDE)
- $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LIBS) $(DEFINES)
-
-quirc.h: config.h version.h
- touch quirc.h
-
-clean:
- -rm -f *.o quirc genconfig genkeymap
-
-realclean: clean
- -rm -f c_init.c README version.h config_* keymap.c keymod.h quirc.1
-
-doc: README config_ref.htm quirc.1
-
-README: readme.htm
- -sed -e "s/&apos;/'/g" -e "s/&quot;/\"/g" < readme.htm | html2text -nobs -o README
-
-# warning, this explodes if PREFIX contains a !
-quirc.1: man.in
- echo ".\\\"\n.\\\"This man page is automatically generated from man.in by a sedscript; edit man.in, not this file, and 'make doc' to apply the changes.">quirc.1
- sed -e "s!\$$PREFIX!$(PREFIX)!g" < man.in >> quirc.1
-
-# funky make cleverness to generate object files; a %.o /always/ depends on its %.h as well as its %.c
-
-%.o: %.c %.h
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ $(DEFINES)
-
-ttyesc.o: ttyesc.c ttyesc.h bits.h
-
-irc.o: irc.c irc.h bits.h buffer.h colour.h names.h numeric.h osconf.h
-
-irc.h: config.h
- touch irc.h
-
-bits.o: bits.c bits.h ttyesc.h colour.h
-
-bits.h: config.h strbuf.h
- touch bits.h
-
-ctbuf.h: colour.h
- touch ctbuf.h
-
-colour.o: colour.c colour.h c_init.c ttyesc.h
-
-buffer.o: buffer.c buffer.h ttyesc.h colour.h bits.h names.h text.h irc.h version.h input.h logging.h osconf.h ctbuf.h
-
-buffer.h: config.h version.h logging.h
- touch buffer.h
-
-config.o: config.c config.h names.h bits.h colour.h text.h version.h
-
-config.c: config_check.c config_def.c config_need.c config_rcread.c config_pargs.c config_help.c keymap.c
- touch config.c
-
-config.h: config_globals.h version.h keymod.h
- touch config.h
-
-config_%: config.cdl genconfig
- ./genconfig $@ < config.cdl > $@ || (rm $@ && false)
-
-genconfig: genconfig.c strbuf.h strbuf.o
- $(CC) $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS) strbuf.o -o $@
-
-input.h: keymod.h
- touch input.h
-
-input.o: input.c input.h ttyesc.h names.h buffer.h irc.h bits.h config.h logging.h
-
-input.c: config_set.c
- touch input.c
-
-logging.o: types.h bits.h
-
-names.o: names.c names.h buffer.h irc.h
-
-script.o: script.c script.h bits.h buffer.h
-
-c_init.c: colour.d c_init.awk
- $(AWK) -f c_init.awk colour.d > c_init.c
-
-genkeymap: genkeymap.c strbuf.h strbuf.o
- $(CC) $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS) strbuf.o -o $@
-
-keymod.h: keys genkeymap
- ./genkeymap h < keys > $@ || (rm $@ && false)
-
-keymap.c: keys genkeymap
- ./genkeymap c < keys > $@ || (rm $@ && false)
+include distMakefile
FORCE:
version.h: FORCE
View
@@ -1,42 +1,47 @@
# gitless Makefile for quIRC
CC ?= gcc
-OPTFLAGS = -g
-CFLAGS ?= -Wall -Wextra -Werror -pedantic -std=gnu99 $(OPTFLAGS)
-AWK ?= gawk
-PREFIX ?= /usr/local
-# -lanl is for ASYNCH_NL
-OPTLIBS := -lanl
-LIBS := -lncurses ttyraw.o ttyesc.o irc.o bits.o colour.o buffer.o names.o config.o input.o logging.o types.o $(OPTLIBS)
-INCLUDE := ttyraw.h ttyesc.h irc.h bits.h colour.h buffer.h names.h config.h input.h logging.h types.h quirc.h version.h osconf.h
+OPTFLAGS := -g
+CFLAGS = -Wall -Wextra -Werror -pedantic -std=gnu99 -D_GNU_SOURCE $(OPTFLAGS)
+AWK := gawk
+PREFIX := /usr/local
+LIBS_ASYNCH_NL := -lanl
+OPTLIBS = $(LIBS_ASYNCH_NL)
+LIBS = -lm -lncurses $(OBJS) $(OPTLIBS)
+OBJS := ttyraw.o ttyesc.o irc.o bits.o strbuf.o ctbuf.o colour.o buffer.o names.o config.o input.o logging.o types.o
+INCLUDE := $(OBJS:.o=.h) quirc.h version.h osconf.h
+
+-include config.mak
all: quirc doc
install: all doc
install -D -m0755 quirc $(PREFIX)/bin/quirc
install -D -m0644 quirc.1 $(PREFIX)/man/man1/quirc.1
install -D -m0644 readme.htm $(PREFIX)/share/doc/quirc/readme.htm
+ install -D -m0644 readme.css $(PREFIX)/share/doc/quirc/readme.css
install -D -m0644 config_ref.htm $(PREFIX)/share/doc/quirc/config_ref.htm
install -D -m0644 tutorial.htm $(PREFIX)/share/doc/quirc/tutorial.htm
uninstall:
-rm $(PREFIX)/bin/quirc
-rm $(PREFIX)/man/man1/quirc.1
-rm $(PREFIX)/share/doc/quirc/readme.htm
+ -rm $(PREFIX)/share/doc/quirc/readme.css
-rm $(PREFIX)/share/doc/quirc/config_ref.htm
-rm $(PREFIX)/share/doc/quirc/tutorial.htm
-quirc: quirc.c $(LIBS) $(INCLUDE)
- $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LIBS) -lm $(DEFINES)
+quirc: quirc.c $(OBJS) $(INCLUDE)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LIBS) $(DEFINES)
quirc.h: config.h version.h
touch quirc.h
clean:
- -rm *.o quirc genconfig genkeymap
+ -rm -f *.o quirc genconfig genkeymap
realclean: clean
- -rm c_init.c README version.h config_* keymap.c keymod.h
+ -rm -f c_init.c README version.h config_* keymap.c keymod.h quirc.1
doc: README config_ref.htm quirc.1
@@ -62,14 +67,17 @@ irc.h: config.h
bits.o: bits.c bits.h ttyesc.h colour.h
-bits.h: config.h
+bits.h: config.h strbuf.h
touch bits.h
+ctbuf.h: colour.h
+ touch ctbuf.h
+
colour.o: colour.c colour.h c_init.c ttyesc.h
-buffer.o: buffer.c buffer.h ttyesc.h colour.h bits.h names.h text.h irc.h version.h input.h logging.h
+buffer.o: buffer.c buffer.h ttyesc.h colour.h bits.h names.h text.h irc.h version.h input.h logging.h osconf.h ctbuf.h
-buffer.h: config.h version.h types.h
+buffer.h: config.h version.h logging.h
touch buffer.h
config.o: config.c config.h names.h bits.h colour.h text.h version.h
@@ -83,7 +91,8 @@ config.h: config_globals.h version.h keymod.h
config_%: config.cdl genconfig
./genconfig $@ < config.cdl > $@ || (rm $@ && false)
-genconfig: genconfig.c
+genconfig: genconfig.c strbuf.h strbuf.o
+ $(CC) $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS) strbuf.o -o $@
input.h: keymod.h
touch input.h
@@ -102,7 +111,8 @@ script.o: script.c script.h bits.h buffer.h
c_init.c: colour.d c_init.awk
$(AWK) -f c_init.awk colour.d > c_init.c
-genkeymap: genkeymap.c
+genkeymap: genkeymap.c strbuf.h strbuf.o
+ $(CC) $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS) strbuf.o -o $@
keymod.h: keys genkeymap
./genkeymap h < keys > $@ || (rm $@ && false)

0 comments on commit 999def1

Please sign in to comment.