complete lab07
This commit is contained in:
7 files changed
+145
No files matched your search
@@ -0,0 +1,45 @@
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -std=c11
|
||||
|
||||
#Input file
|
||||
INPUT = input1.txt
|
||||
OUTPUT = output.txt
|
||||
REF = ref1.txt
|
||||
# Source file
|
||||
SRCS = lab7.c
|
||||
# Output
|
||||
TARGET = lab7.out
|
||||
|
||||
# Default target
|
||||
all: $(TARGET)
|
||||
|
||||
# Rule to build the executable
|
||||
$(TARGET): $(SRCS)
|
||||
$(CC) $(CFLAGS) $(SRCS) -o $(TARGET)
|
||||
|
||||
convert_input: $(INPUT)
|
||||
cat $(INPUT) | dos2unix | tee $(INPUT)
|
||||
@tail -c1 $(INPUT) | grep -q . && echo >> $(INPUT)
|
||||
tr -d '\r' < $(INPUT) > temp_file && mv temp_file $(INPUT)
|
||||
|
||||
convert_output: $(OUTPUT)
|
||||
cat $(OUTPUT) | dos2unix | tee $(OUTPUT)
|
||||
$(tail -c1 ($INPUT)) != "" && echo >> $(INPUT)
|
||||
tr -d '\r' < $(OUTPUT) > temp_file && mv temp_file $(OUTPUT)
|
||||
|
||||
check: $(OUTPUT) $(REF)
|
||||
@diff -q $(OUTPUT) $(REF) > /dev/null; \
|
||||
if [ $$? -eq 0 ]; then \
|
||||
echo "Pass"; \
|
||||
else \
|
||||
echo "Fail"; \
|
||||
fi
|
||||
|
||||
# Rule to run the program
|
||||
run: $(TARGET)
|
||||
./$(TARGET) $(INPUT) $(OUTPUT)
|
||||
|
||||
# Rule to clean generated files
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
Reference in new issue
Block a user