shrink makefile bloat
This commit is contained in:
parent
e24fecea52
commit
540eb43239
7 changed files with 62 additions and 318 deletions
54
Makefile.common.mk
Normal file
54
Makefile.common.mk
Normal file
|
@ -0,0 +1,54 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BISONFLAGS :=
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
|
||||
SRC := $(wildcard ./*.c) lexer.c parser.c
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) $(BISONFLAGS) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: BISONFLAGS += -Wcounterexamples
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
|
@ -1,54 +1,3 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
TARGET := day_1
|
||||
|
||||
SRC := $(wildcard ./*.cpp) lexer.c parser.c
|
||||
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
||||
include ../Makefile.common.mk
|
||||
|
|
|
@ -1,54 +1,3 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
TARGET := day_2
|
||||
TARGET := day_2_1
|
||||
|
||||
SRC := $(wildcard ./*.cpp) lexer.c parser.c
|
||||
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
||||
include ../Makefile.common.mk
|
||||
|
|
|
@ -1,54 +1,3 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
TARGET := day_2
|
||||
TARGET := day_2_2
|
||||
|
||||
SRC := $(wildcard ./*.cpp) lexer.c parser.c
|
||||
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
||||
include ../Makefile.common.mk
|
||||
|
|
|
@ -1,54 +1,3 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
TARGET := day_4
|
||||
|
||||
SRC := $(wildcard ./*.cpp) lexer.c parser.c
|
||||
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
||||
include ../Makefile.common.mk
|
||||
|
|
|
@ -1,56 +1,3 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BISONFLAGS :=
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
TARGET := day_5
|
||||
|
||||
SRC := $(wildcard ./*.cpp) lexer.c parser.c
|
||||
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) $(BISONFLAGS) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: BISONFLAGS += -Wcounterexamples
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
||||
include ../Makefile.common.mk
|
||||
|
|
|
@ -1,56 +1,3 @@
|
|||
CC := clang
|
||||
YACC := bison
|
||||
LEX := flex
|
||||
CFLAGS := -std=c17 -Wpedantic -Wall -Wextra
|
||||
BISONFLAGS :=
|
||||
BUILD := ./build
|
||||
INCLUDE := -I./
|
||||
OBJ_DIR := $(BUILD)/objects
|
||||
APP_DIR := $(BUILD)/bin
|
||||
TARGET := day_6
|
||||
|
||||
SRC := $(wildcard ./*.cpp) lexer.c parser.c
|
||||
|
||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
# targets
|
||||
all: build $(APP_DIR)/$(TARGET)
|
||||
|
||||
run: all
|
||||
$(APP_DIR)/$(TARGET)
|
||||
|
||||
flex:
|
||||
$(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l
|
||||
|
||||
bison:
|
||||
$(YACC) $(BISONFLAGS) --output=parser.c parser.y
|
||||
|
||||
generate: flex bison
|
||||
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
||||
$(APP_DIR)/$(TARGET): flex bison $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: all build clean debug release
|
||||
|
||||
build:
|
||||
@mkdir -p $(APP_DIR)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: BISONFLAGS += -Wcounterexamples
|
||||
debug: all
|
||||
|
||||
sanitize: CFLAGS += -DDEBUG -g -fsanitize=address
|
||||
sanitize: all
|
||||
|
||||
release: CFLAGS += -O2
|
||||
release: all
|
||||
|
||||
clean:
|
||||
-@rm -rvf $(BUILD)
|
||||
-@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}
|
||||
include ../Makefile.common.mk
|
||||
|
|
Loading…
Reference in a new issue