Root/cngt/Makefile

1#
2# Makefile - Makefile of cngt
3#
4# Written 2010 by Werner Almesberger
5# Copyright 2010 by Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13PREFIX ?= /usr/local
14
15SHELL=/bin/bash
16
17MAIN=cngt
18OBJS=cngt.o getkey.o serial.o
19
20CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \
21            -Wmissing-declarations -Wno-format-zero-length
22CFLAGS=$(CFLAGS_WARN) -g
23LDFLAGS=-lm
24
25# ----- Verbosity control -----------------------------------------------------
26
27CC_normal := $(CC)
28DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
29
30CC_quiet = @echo " CC " $@ && $(CC_normal)
31DEPEND_quiet = @$(DEPEND_normal)
32
33ifeq ($(V),1)
34    CC = $(CC_normal)
35    DEPEND = $(DEPEND_normal)
36else
37    CC = $(CC_quiet)
38    DEPEND = $(DEPEND_quiet)
39endif
40
41# ----- Rules -----------------------------------------------------------------
42
43.PHONY: all clean spotless
44
45all: $(MAIN)
46
47$(MAIN): $(OBJS)
48
49clean:
50        rm -f $(OBJS) $(OBJS:.o=.d)
51
52spotless: clean
53        rm -f $(MAIN)
54
55# ----- Install / uninstall ---------------------------------------------------
56
57install: all
58        mkdir -p $(DESTDIR)/$(PREFIX)/bin/
59        install -m 755 $(MAIN) $(DESTDIR)/$(PREFIX)/bin/
60
61uninstall:
62        rm -f $(DESTDIR)/$(PREFIX)/bin/$(MAIN)
63
64# ----- Dependencies ----------------------------------------------------------
65
66# compile and generate dependencies, from fped, based on
67# http://scottmcpeak.com/autodepend/autodepend.html
68
69%.o: %.c
70        $(CC) -c $(CFLAGS) $*.c -o $*.o
71        $(DEPEND) $*.c | \
72          sed -e \
73            '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
74            -e '$${g;p;}' -e d >$*.d; \
75          [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
76
77-include $(OBJS:.o=.d)
78

Archive Download this file

Branches:
master



interactive