-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
44 lines (33 loc) · 1.11 KB
/
makefile
File metadata and controls
44 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -O2
# Target executables
TARGET_COMPRESS = imageCompression
TARGET_DECOMPRESS = lzwDecompression
# Source files and object files
SRC_COMPRESS = imageCompression.c lzw.c
OBJ_COMPRESS = $(SRC_COMPRESS:.c=.o)
SRC_DECOMPRESS = lzwDecompression.c lzw.c
OBJ_DECOMPRESS = $(SRC_DECOMPRESS:.c=.o)
# Header files
HEADERS = lzw.h
# Default target
all: $(TARGET_COMPRESS) $(TARGET_DECOMPRESS)
# Build the compression target
$(TARGET_COMPRESS): $(OBJ_COMPRESS)
$(CC) $(CFLAGS) -o $@ $(OBJ_COMPRESS)
# Build the decompression target
$(TARGET_DECOMPRESS): $(OBJ_DECOMPRESS)
$(CC) $(CFLAGS) -o $@ $(OBJ_DECOMPRESS)
# Rule for object files
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
# Clean up generated files
clean:
rm -f $(OBJ_COMPRESS) $(OBJ_DECOMPRESS) $(TARGET_COMPRESS) $(TARGET_DECOMPRESS)
# Run the compression program with sample arguments
run_compress: $(TARGET_COMPRESS)
./$(TARGET_COMPRESS) input.txt compressed.txt
# Run the decompression program with sample arguments
run_decompress: $(TARGET_DECOMPRESS)
./$(TARGET_DECOMPRESS) compressed.txt output.txt