cnotes/Makefile

40 lines
942 B
Makefile
Raw Normal View History

# Makefile for cnotes - GCC on Linux/Unix/macOS
# Strict C89/ANSI compliant build
CC = gcc
CFLAGS = -ansi -pedantic -Wall -Wextra -O2
INCLUDES = -I include
SRCDIR = src
INCDIR = include
BUILDDIR = build
SOURCES = $(SRCDIR)/addnote.c $(SRCDIR)/dumpnotes.c
HEADERS = $(INCDIR)/platform.h
TARGETS = $(BUILDDIR)/addnote $(BUILDDIR)/dumpnotes
.PHONY: all clean install uninstall
all: $(BUILDDIR) $(TARGETS)
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(BUILDDIR)/addnote: $(SRCDIR)/addnote.c $(HEADERS)
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $(SRCDIR)/addnote.c
$(BUILDDIR)/dumpnotes: $(SRCDIR)/dumpnotes.c $(HEADERS)
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $(SRCDIR)/dumpnotes.c
clean:
rm -rf $(BUILDDIR)
# Install to /usr/local/bin (optional, run with sudo)
install: $(TARGETS)
install -m 755 $(BUILDDIR)/addnote /usr/local/bin/
install -m 755 $(BUILDDIR)/dumpnotes /usr/local/bin/
uninstall:
rm -f /usr/local/bin/addnote /usr/local/bin/dumpnotes