Root/
| 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 | |
| 13 | PREFIX ?= /usr/local |
| 14 | |
| 15 | SHELL=/bin/bash |
| 16 | |
| 17 | MAIN=cngt |
| 18 | OBJS=cngt.o getkey.o serial.o |
| 19 | |
| 20 | CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \ |
| 21 | -Wmissing-declarations -Wno-format-zero-length |
| 22 | CFLAGS=$(CFLAGS_WARN) -g |
| 23 | LDFLAGS=-lm |
| 24 | |
| 25 | # ----- Verbosity control ----------------------------------------------------- |
| 26 | |
| 27 | CC_normal := $(CC) |
| 28 | DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG |
| 29 | |
| 30 | CC_quiet = @echo " CC " $@ && $(CC_normal) |
| 31 | DEPEND_quiet = @$(DEPEND_normal) |
| 32 | |
| 33 | ifeq ($(V),1) |
| 34 | CC = $(CC_normal) |
| 35 | DEPEND = $(DEPEND_normal) |
| 36 | else |
| 37 | CC = $(CC_quiet) |
| 38 | DEPEND = $(DEPEND_quiet) |
| 39 | endif |
| 40 | |
| 41 | # ----- Rules ----------------------------------------------------------------- |
| 42 | |
| 43 | .PHONY: all clean spotless |
| 44 | |
| 45 | all: $(MAIN) |
| 46 | |
| 47 | $(MAIN): $(OBJS) |
| 48 | |
| 49 | clean: |
| 50 | rm -f $(OBJS) $(OBJS:.o=.d) |
| 51 | |
| 52 | spotless: clean |
| 53 | rm -f $(MAIN) |
| 54 | |
| 55 | # ----- Install / uninstall --------------------------------------------------- |
| 56 | |
| 57 | install: all |
| 58 | mkdir -p $(DESTDIR)/$(PREFIX)/bin/ |
| 59 | install -m 755 $(MAIN) $(DESTDIR)/$(PREFIX)/bin/ |
| 60 | |
| 61 | uninstall: |
| 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 |
Branches:
master
