Skip to content
Snippets Groups Projects
Commit e34652aa authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Update make files to be more standardized

parent 9aed04da
Branches
No related merge requests found
......@@ -11,17 +11,8 @@ src/quad_solver
spikes/ieee_floating_point/float
spikes/ieee_floating_point/sandbox/sandbox
spikes/square_root/sqrt
spikes/input_handling/arg_parse
spikes/input_handling/simple_parse
spikes/input_handling/std_in
spikes/logging/log_with_function
spikes/logging/log_with_macro
spikes/logging/log_file.txt
spikes/make/read_from_file
spikes/unit_testing/unit_tests
spikes/variadic_macros/log_file.txt
spikes/variadic_macros/variadic_macro_to_console
spikes/variadic_macros/variadic_macro_to_file
# Ignore vscode files
.vscode
......
TARGET = float
# Makefile for IEE Floating Point spikes.
TARGET = float
LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=gnu99 -g
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean
# Default command if nothing is passed.
default: $(TARGET)
all: default
# Expect a .o for each .c file in the directory
# Expect a .o for each .c file in the directory.
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
# Get all .h files in the directory
# Get all .h files in the directory.
HEADERS = $(wildcard *.h)
%.o: %.c $(HEADERS)
......@@ -21,24 +27,25 @@ HEADERS = $(wildcard *.h)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@
# Remove older builds
# Remove older builds and clear temp files.
clean:
-rm -f $(OBJECTS)
-rm -f $(TARGET)
# Update time of modification
# Update time of modification.
touch:
touch *.h
touch *.c
# Advanced memory usage stats as well as crash reporting
# Advanced memory usage stats as well as crash reporting.
valgrind: $(TARGET)
valgrind --leak-check=full --show-reachable=yes ./$(TARGET)
# Debug
# Debug.
debug:
gdb $(TARGET)
# Run compiled code
# Run compiled code.
test:
./$(TARGET) 123456.78
\ No newline at end of file
./$(TARGET) 123456.78
# Makefile for Input Handling spikes.
all:
Please specify spike.
LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=c99 -g
SRC_DIR = ../../src
arg_parse:
gcc -Wall -Wpedantic -std=c99 -g arg_parse.c ../../src/argparse.c ../../src/helper.c -o arg_parse
simple_parse:
gcc -Wall -Wpedantic -std=c99 -g simple_parse.c -o simple_parse
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean arg_parse simple_parse std_in
std_in:
gcc -Wall -Wpedantic -std=c99 -g std_in.c -o std_in
# Default command if nothing is passed.
default:
@echo Please specify spike: [ arg_parse, simple_parse, std_in ]
all: default
# Arg parse spike.
arg_parse: spike_arg_parse.o src_arg_parse.o helper.o prompt.o
${CC} -o arg_parse.out $^ $(LIBS)
spike_arg_parse.o: arg_parse.c
${CC} -c -o $@ $< ${CFLAGS}
src_arg_parse.o: $(SRC_DIR)/argparse.c
${CC} -c -o $@ $< ${CFLAGS}
helper.o: $(SRC_DIR)/helper.c
${CC} -c -o $@ $< ${CFLAGS}
prompt.o: $(SRC_DIR)/prompt.c
${CC} -c -o $@ $< ${CFLAGS}
# Simple parse spike.
simple_parse: simple_parse.o
${CC} -o simple_parse.out $^ $(LIBS)
simple_parse.o: simple_parse.c
# Std in spike.
std_in: std_in.o
${CC} -o std_in.out $^ $(LIBS)
std_in.o: std_in.c
# Remove older builds and clear temp files.
clean:
-rm -f *.o *.out
# Makefile for Logging spikes.
all:
Please specify spike.
LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=c99 -g
log_with_function:
gcc -Wall -Wpedantic -std=c99 -g log_with_function.c -o log_with_function
log_with_macro:
gcc -Wall -Wpedantic -std=c99 -g log_with_macro.c -o log_with_macro
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean log_with_function log_with_macro
# Default command if nothing is passed.
default:
@echo Please specify spike: [ log_with_function, log_with_macro ]
all: default
# Log with function spike.
log_with_function: log_with_function.o
${CC} -o log_with_function.out $^ $(LIBS)
log_with_function.o: log_with_function.c
# Log with macro spike.
log_with_macro: log_with_macro.o
${CC} -o log_with_macro.out $^ $(LIBS)
log_with_macro.o: log_with_macro.c
# Remove older builds and clear temp files.
clean:
-rm -f *.o *.out log_file.txt
# Makefile for Make spikes.
all:
gcc -Wall -Wpedantic -std=c99 -g *.c -o read_from_file
LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=c99 -g
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean read_from_file
# Default command if nothing is passed.
default: read_from_file
all: default
# Read from file spike.
read_from_file: read_from_file.o
${CC} -o read_from_file.out $^ $(LIBS)
make read
read_from_file.o: read_from_file.c
read:
./read_from_file < input.txt
./read_from_file.out < input.txt
# Remove older builds and clear temp files.
clean:
-rm -f *.o *.out
TARGET = sqrt
# Makefile for Square Root spikes.
TARGET = sqrt
LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=gnu99 -g
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean
# Default command if nothing is passed.
default: $(TARGET)
all: default
# Expect a .o for each .c file in the directory
# Expect a .o for each .c file in the directory.
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
# Get all .h files in the directory
# Get all .h files in the directory.
HEADERS = $(wildcard *.h)
%.o: %.c $(HEADERS)
......@@ -21,24 +27,25 @@ HEADERS = $(wildcard *.h)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@
# Remove older builds
# Remove older builds and clear temp files.
clean:
-rm -f $(OBJECTS)
-rm -f $(TARGET)
# Update time of modification
# Update time of modification.
touch:
touch *.h
touch *.c
# Advanced memory usage stats as well as crash reporting
# Advanced memory usage stats as well as crash reporting.
valgrind: $(TARGET)
valgrind --leak-check=full --show-reachable=yes ./$(TARGET)
# Debug
# Debug.
debug:
gdb $(TARGET)
# Run compiled code
# Run compiled code.
test:
./$(TARGET) 123456.78
\ No newline at end of file
./$(TARGET) 123456.78
# Makefile for Unit Testing spikes.
all:
gcc -Wall -Wpedantic -std=c99 -g *.c -o unit_tests -lcunit
LIBS = -lm -lcunit
CC = gcc
CFLAGS = -Wall -pedantic -std=c99 -g
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean unit_tests
# Default command if nothing is passed.
default: unit_tests
all: default
# Unit test spike.
unit_tests: unit_tests.o dummy_functions.o
${CC} -o unit_tests.out $^ $(LIBS)
unit_tests.o: unit_tests.c
dummy_functions.o: dummy_functions.c
# Remove older builds and clear temp files.
clean:
-rm -f *.o *.out
# Makefile for Variadic Macro spikes.
all:
Please specify spike: [ to_console, to_file ]
LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=c99 -g
to_console:
gcc -Wall -Wpedantic -std=c99 -g variadic_macro_to_console.c -o variadic_macro_to_console
to_file:
gcc -Wall -Wpedantic -std=c99 -g variadic_macro_to_file.c -o variadic_macro_to_file
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean to_console to_file
# Default command if nothing is passed.
default:
@echo Please specify spike: [ to_console, to_file ]
all: default
# Variadic Macro To console spike.
to_console: variadic_macro_to_console.o
${CC} -o variadic_macro_to_console.out $^ $(LIBS)
variadic_macro_to_console.o: variadic_macro_to_console.c
# Variadic Macro To file spike.
to_file: variadic_macro_to_file.o
${CC} -o variadic_macro_to_file.out $^ $(LIBS)
variadic_macro_to_file.o: variadic_macro_to_file.c
# Remove older builds and clear temp files.
clean:
-rm -f *.o *.out log_file.txt
# Makefile for Quad Solver.
# Made from http://stackoverflow.com/questions/1484817/how-do-i-make-a-simple-makefile-for-gcc-on-linux
TARGET = quad_solver
......@@ -5,31 +6,33 @@ LIBS = -lm
CC = gcc
CFLAGS = -Wall -pedantic -std=c99 -g
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean
# Default command if nothing is passed.
default: $(TARGET)
all: default
# Link given dependencies into binary named TARGET
# $^ will be replaced with 'main.o argparse.o ...'
$(TARGET): main.o argparse.o compute.o my_sqrt.o helper.o prompt.o
${CC} -o $(TARGET) $^ $(LIBS)
main.o: main.c argparse.h compute.h helper.h prompt.h
argparse.o: argparse.c argparse.h helper.h
compute.o: compute.c compute.h helper.h
my_sqrt.o: my_sqrt.c my_sqrt.h
helper.o: helper.c helper.h
prompt.o: prompt.c prompt.h helper.h
# Remove older builds and clear temp files.
clean:
-rm -f *.o
-rm -f $(TARGET)
# Advanced memory usage stats as well as crash reporting.
valgrind: $(TARGET)
valgrind --leak-check=full --show-reachable=yes ./$(TARGET) -n 2 4 8
# Makefile for Unit Tests
# Makefile for Tests.
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean test
# Default command if nothing is passed.
default: test
all: default
# Run all types of tests.
test:
make -C unit_tests
make -C integration_tests
# Remove older builds and clear temp files.
clean:
make -C unit_tests clean
make -C integration_tests clean
# Makefile for Integration Tests.
SRC_DIR = ../../src
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean test_int_all quad_solver
# Default command if nothing is passed.
default: test_int_all
all: default
# This will always run make in src
# Run quad solver makefile found in src folder.
quad_solver:
make -C $(SRC_DIR)
......@@ -13,6 +19,7 @@ test_int_all: quad_solver
./test_ranges.sh $(SRC_DIR)
./test_examples.sh $(SRC_DIR)
# Clean does nothing for now
# Remove older builds and clear temp files (Does nothing for now).
clean:
rm -f *.tmp
# Makefile for Unit Tests
# Makefile for Unit Tests.
LIBS = -lm -lcunit
CC = gcc
......@@ -6,36 +6,36 @@ CFLAGS = -Wall -pedantic -std=c99 -g
SRC_DIR = ../../src
CUNIT_DIR = ../cunit
# Ensure that commands run as intended, even if file with same name exists.
.PHONY: default all clean test_unit_all
# Default command if nothing is passed.
default: test_unit_all
all: default
# Run all unit tests.
test_unit_all: test_my_sqrt.out unit_tests.out
./test_my_sqrt.out
./unit_tests.out
# Mini Cunit Library tests
# Mini Cunit Library tests.
test_my_sqrt.out: my_sqrt.o test_my_sqrt.o mock_sqrt.o cunit.o
${CC} -o $@ $^ $(LIBS) -Wl,--wrap=sqrt
my_sqrt.o: $(SRC_DIR)/my_sqrt.c $(SRC_DIR)/my_sqrt.h
${CC} -c -o $@ $< ${CFLAGS}
test_my_sqrt.o: test_my_sqrt.c mock_sqrt.h
mock_sqrt.o: mock_sqrt.c
cunit.o: $(CUNIT_DIR)/cunit.c $(CUNIT_DIR)/cunit.h
${CC} -c -o $@ $< ${CFLAGS}
# Cunit Library tests
# Cunit Library tests.
unit_tests.out : unit_tests.o $(SRC_DIR)/argparse.o $(SRC_DIR)/compute.o $(SRC_DIR)/my_sqrt.o $(SRC_DIR)/helper.o $(SRC_DIR)/prompt.o
${CC} -o unit_tests.out $^ $(LIBS)
unit_tests.o: unit_tests.c
# Remove older builds and clear temp files.
clean:
-rm -f *.o *.out
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment