Skip to content

Instantly share code, notes, and snippets.

@iPAS
Created July 10, 2022 03:15
Show Gist options
  • Save iPAS/786706e81d5ea50e4b5c415425616279 to your computer and use it in GitHub Desktop.
Save iPAS/786706e81d5ea50e4b5c415425616279 to your computer and use it in GitHub Desktop.
Makefile to compile .cpp to binary and assembly code.
# The build target
TARGET = assignment1
# the compiler: gcc for C program, define as g++ for C++
CC = clang++
# compiler flags:
# -g - this flag adds debugging information to the executable file
# -Wall - this flag is used to turn on most compiler warnings
CFLAGS = -g -Wall
.PHONY: all run clean
$(TARGET): $(TARGET).cpp
$(CC) $(CFLAGS) -S -o $(TARGET).s $(TARGET).cpp
$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).cpp
all: $(TARGET)
run: all
./$(TARGET)
clean:
rm -rf $(TARGET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment