From: Michał Bartoszkiewicz Date: Mon, 7 Dec 2009 22:50:30 +0000 (+0100) Subject: Uporządkowanie Makefile, dodanie regułek „clean” i „install”. X-Git-Tag: v1.0~4 X-Git-Url: https://git.bzium.org/embe/choinka.git/commitdiff_plain/399984620d6024e4f2f4943bef9a2229457eed50?ds=sidebyside Uporządkowanie Makefile, dodanie regułek „clean” i „install”. --- diff --git a/Makefile b/Makefile index 8207726..c9f6b9b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,40 @@ CC := gcc -CFLAGS := -O2 -Wextra -Wall -std=gnu99 -LDLIBS := -lncurses +CPPFLAGS := +CFLAGS := -O2 -Wextra -Wall +LDFLAGS := +LDLIBS := +RM := rm -all: choinka +override CFLAGS += -std=gnu99 +override LDLIBS += -lncurses + +INSTALL := install + +DESTDIR := +PREFIX := /usr +BINDIR = $(PREFIX)/bin + +EXE := choinka + +CSOURCES := $(wildcard *.c) +COBJECTS := $(CSOURCES:.c=.o) +SOURCES := $(sort $(CSOURCES)) +OBJECTS := $(sort $(COBJECTS)) + +.PHONY: all +all: $(EXE) + +%.o: %.c + $(CC) -c $(CPPFLAGS) $(CFLAGS) $^ -o $@ + +$(EXE): $(OBJECTS) + $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ + +.PHONY: clean +clean: + $(RM) -f $(EXE) *.o *~ *.bak *.orig *.rej + +.PHONY: install +install: $(EXE) + $(INSTALL) -d $(DESTDIR)$(BINDIR) + $(INSTALL) -c $(EXE) $(DESTDIR)$(BINDIR)