Skip to content

Commit

Permalink
Fix makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
npetrovski committed Sep 1, 2019
1 parent 7397294 commit 0c09b0d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,31 @@ CFLAGS = -Wall -I./src

TARGET = ioctl

SRCDIR = src
OBJDIR = dist
BINDIR = dist
SRC_DIR = src
DIST_DIR = dist

SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
.PHONY: clean remove

SOURCES := $(wildcard $(SRC_DIR)/*.c)
INCLUDES := $(wildcard $(SRC_DIR)/*.h)
OBJECTS := $(SOURCES:$(SRC_DIR)/%.c=$(DIST_DIR)/%.o)
rm = rm -f

$(BINDIR)/$(TARGET): $(OBJECTS)
$(DIST_DIR)/$(TARGET): $(OBJECTS)
$(CC) $(LFLAGS) $(OBJECTS) -o $@
$(STRIP) $(BINDIR)/$(TARGET)
$(STRIP) $(DIST_DIR)/$(TARGET)
@echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
$(OBJECTS): $(DIST_DIR)/%.o : $(SRC_DIR)/%.c
@mkdir -p $(DIST_DIR)
$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully!"

.PHONY: clean
clean:
@$(rm) $(OBJECTS)
@echo "Cleanup complete!"

.PHONY: remove

remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@$(rm) $(DIST_DIR)/$(TARGET)
@echo "Executable removed!"

0 comments on commit 0c09b0d

Please sign in to comment.