about summary refs log tree commit diff
diff options
context:
space:
mode:
-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)