Skip to content

Instantly share code, notes, and snippets.

@roboteck
Created April 5, 2020 01:16
Show Gist options
  • Save roboteck/fa00adcaa4355cebabbf64621afe7463 to your computer and use it in GitHub Desktop.
Save roboteck/fa00adcaa4355cebabbf64621afe7463 to your computer and use it in GitHub Desktop.
Example Makfile
# Output directories
BIN = bin
OBJ = obj
VERSION = 1A
NAME_SHORT = IA
OUTPUT = $(NAME_SHORT)_$(VERSION)
MAKE_NAME = 'NAME="TESTBENCH"'
MAKE_VERSION = 'VERSION="$(VERSION)"'
# Append OBJ and BIN directories to output filename
BIN_NAME := $(OUTPUT).bin
OUTPUT := $(BIN)/$(OUTPUT)
CC = g++
CFLAGS += -D$(MAKE_NAME)
CFLAGS += -D$(MAKE_VERSION)
CFLAGS += -std=c++17
CFLAGS += -Wall
CFLAGS += -g
CFLAGS += -Wno-narrowing
CFLAGS += -Wno-comment
CFLAGS += -Wno-unused
CFLAGS += -lpthread
CFLAGS += -pthread
CFLAGS += -D'stdvt=std'
# CFLAGS += -ftime-report
ROOT_LIB =
# font lib
#C_SRCS += ***.c
SRCS += testbench.cpp
INCLUDES += -I .
# INCLUDES += -I Data/
LDFLAGS +=
LIBS += -lm
PROGRAM = TESTBENCH
C_OBJS = $(C_SRCS:.c=.o)
CPP_OBJS = $(SRCS:.cpp=.o)
.PHONY: clean
all: $(PROGRAM)
%.o: %.cpp
$(CC) -c -o $@ $< $(CFLAGS) $(INCLUDES)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(INCLUDES)
$(PROGRAM): $(CPP_OBJS) $(C_OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)
clean:
$(RM) *.o *~ $(PROGRAM)
find ./ -name '*.o' -delete
debug:
gdb ./$(PROGRAM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment