about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThordur Bjornsson <thorduri@secnorth.net>2012-11-05 16:05:40 +0100
committerThordur Bjornsson <thorduri@secnorth.net>2012-11-05 16:05:40 +0100
commit79f62757cbacaa269a2264e677bbfd5f6a5b5c07 (patch)
tree861ae73af03d41ace4c6c1062e99b76f09f1d035
parent5c96ff2741fb36c5b9e793a55bd8a8a0bef76021 (diff)
downloadministat-79f62757cbacaa269a2264e677bbfd5f6a5b5c07.tar.gz
ministat-79f62757cbacaa269a2264e677bbfd5f6a5b5c07.tar.xz
ministat-79f62757cbacaa269a2264e677bbfd5f6a5b5c07.zip
"Better" Makefile.
Give up, and use the older (non obj) GNUmakefile, as it seems to
have less issues.

Lawd, how I mess bsd.*.mk;
-rw-r--r--.gitignore3
-rw-r--r--Makefile44
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)