From 79f62757cbacaa269a2264e677bbfd5f6a5b5c07 Mon Sep 17 00:00:00 2001 From: Thordur Bjornsson Date: Mon, 5 Nov 2012 16:05:40 +0100 Subject: "Better" Makefile. Give up, and use the older (non obj) GNUmakefile, as it seems to have less issues. Lawd, how I mess bsd.*.mk; --- .gitignore | 3 ++- Makefile | 44 ++++++++++++++++++-------------------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index c968b3a..96f5216 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -obj +ministat +*.o *.core diff --git a/Makefile b/Makefile index ffed7e8..d26c40f 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,34 @@ -CC ?= clang -PREFIX ?= /usr - -CFLAGS += -Wall -Werror -LDFLAGS += -lm - BIN = ministat -SRC = $(BIN).c +SRCS= ministat.c +OBJS= ministat.o -# No user serviceable parts below this line. -OBJS = $(addprefix $(OBJ), $(SRC:.c=.o)) -DEPS = $(addsuffix .depend, $(OBJS)) -OBJ = obj +PKGS = -all: obj $(OBJ)/$(BIN) +CFLAGS += -g -Wall -Werror +CPPFLAGS+= -D_GNU_SOURCE +LDFLAGS += -lm -obj: - -mkdir obj +PREFIX ?= /usr -$(OBJ)$/(BIN): $(OBJS) - $(CC) -o $@ $^ ${LDFLAGS} +# No user serviceable parts below this line. +#PPFLAGS+= $(shell pkg-config --silence-errors --cflags $(PKGS)) +#LDFLAGS += $(shell pkg-config --silence-errors --libs $(PKGS)) +all: $(BIN) -$(OBJ)/%.o: %.c - @echo "Generating $@.depend" - @$(CC) $(CFLAGS) -MM $< | \ - sed 's,$*\.o[ :]*,$@ $@.depend : ,g' >> $@.depend - $(CC) $(CFLAGS) -o $@ -c $< +$(BIN): $(OBJS) + $(CC) $(OBJS) ${LDFLAGS} -o ${BIN} -depend: - @echo "Dependencies are automatically generated." +$(OBJS): %.o: %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< install: install -d $(PREFIX)/bin - install -m 0755 $(OBJ)/$(BIN) $(PREFIX)/bin/$(BIN) + install -m 0755 $(BIN) $(PREFIX)/bin/$(BIN) clean: - -rm -rf $(BIN) obj *.core + -rm -rf $(BIN) *.o *.core -.PHONY: all depend install clean +.PHONY: install clean -include $(DEPS) -- cgit 1.4.1