Setup the Makefile to allow me to produce a release build and to create some directories if they're not there already.
This commit is contained in:
@@ -1,21 +1,32 @@
|
||||
CC = gcc
|
||||
CFLAGS=-Wall
|
||||
CFLAGS=-Wall -DDEBUG
|
||||
SRC=src
|
||||
OBJ=obj
|
||||
SRCS=$(wildcard $(SRC)/*.c)
|
||||
# Substitute all .c with .o from SRCS
|
||||
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
|
||||
|
||||
BINDIR=bin
|
||||
BIN=$(BINDIR)/clox
|
||||
|
||||
all:$(BIN)
|
||||
all: $(BIN)
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
release: CFLAGS=-Wall -O2
|
||||
release: clean
|
||||
release: $(BIN)
|
||||
|
||||
$(BIN): $(OBJS) $(BINDIR)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $@
|
||||
|
||||
$(OBJ)/%.o: $(SRC)/%.c
|
||||
$(OBJ)/%.o: $(SRC)/%.c $(OBJ)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BINDIR):
|
||||
mkdir $@
|
||||
|
||||
$(OBJ):
|
||||
mkdir $@
|
||||
|
||||
.PHONY: clean
|
||||
.PHONY: test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user