Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup makefile and add uninstall #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions code/makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
FILENAME = main.c
TARGET = main

INSTALL_NAME = uplow
SOURCE = main.c
TARGET = uplow

# Getting all sources files in src folder
SOURCES = $(wildcard src/*.c)
# Converting source files names to objects files
OBJECTS = $(patsubst src/%.c, obj/%.o, $(SOURCES))

# Rule to compute the main program while requiring the objects files
$(TARGET) : $(FILENAME) $(OBJECTS)
gcc $(FILENAME) $(OBJECTS) -o $(TARGET)
$(TARGET) : $(SOURCE) $(OBJECTS)
gcc $^ -o $@

# Implicit rule to compute the object file
obj/%.o : src/%.c
gcc -c $^ -o $@

run : $(OUT)
./$(OUT)
run : $(TARGET)
./$^

clear :
rm -f $(OUT) $(OBJECTS)
rm -f $(TARGET) obj/*

install : $(TARGET)
mv $(TARGET) ~/bin/$(INSTALL_NAME)
chmod 777 ~/bin/$(INSTALL_NAME)
mv $^ ~/bin/
chmod 777 ~/bin/$^

uninstall:
rm ~/bin/$(TARGET)