-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
38 lines (30 loc) · 913 Bytes
/
makefile
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
# Author: David De Potter
# Date: 2024-08-29
CC = gcc
CFLAGS = -O2 -Wall -pedantic -std=c99
LIBDIRS = ../../lib natlib fftlib
LIBOBJS = $(foreach dir, $(LIBDIRS), $(wildcard $(dir)/*.c))
LIBOBJS := $(patsubst %.c, %.o, $(LIBOBJS))
SRCS := $(wildcard *.c)
BINS = $(patsubst %.c, %.out, $(SRCS))
OBJS = $(patsubst %.c, %.o, $(SRCS))
.PHONY: all clean allclean
all: $(BINS)
@echo "Completed.\n\nTo run on test input:"
@echo "$$ ./$(lastword $(BINS)) < tests/<num>.in"
@chmod +x $(BINS)
$(BINS): %.out: %.o $(LIBOBJS)
@echo "Building $@ ..."
@ $(CC) $(CFLAGS) -o $@ $^ -lm
$(OBJS): %.o: %.c
@echo "Compiling $@ ..."
@ $(CC) $(CFLAGS) -c $^
$(LIBOBJS): %.o: %.c
@echo "Compiling $@ ..."
@ (cd $(dir $@) && $(CC) $(CFLAGS) -c $(notdir $^))
clean:
@echo "Cleaning up working directory ..."
@rm -f $(BINS) $(OBJS)
allclean: clean
@echo "Cleaning up all remaining lib objects ..."
@rm -f $(LIBOBJS)