pthreads/{producer_consumer_unbounded_buffer_modularized → mapping_simulation}/Makefile RENAMED
@@ -1,40 +1,47 @@
1
- APPNAME=$(shell basename $(shell pwd))
2
- APPARGS=5 2 3 0 100 0 750
3
-
4
  CC=cc
5
  CXX=g++
6
  CFLAGS=-g -std=gnu11 -Wall -Wextra
7
  LIBS=-pthread
8
  LINTFILTERS=$\
9
  -readability/casting,$\
10
  -build/header_guard,$\
11
  -build/include_subdir
12
 
 
 
 
 
 
13
 
14
- $(APPNAME): main.o queue.o arguments.o simulation.o
15
- $(CC) $(CFLAGS) $^ -o $(APPNAME) $(LIBS)
16
 
17
- %.o: %.c
18
  $(CC) -c $(CFLAGS) $< -o $@ $(LIBS)
19
 
20
- all: $(APPNAME) lint memcheck helgrind
 
 
 
 
21
 
22
  .PHONY: lint
23
  lint:
24
  cpplint --filter=$(LINTFILTERS) *.h *.c
25
 
26
  .PHONY: memcheck
27
  memcheck:
28
- valgrind --tool=memcheck ./$(APPNAME) $(APPARGS)
29
 
30
  .PHONY: helgrind
31
  helgrind:
32
- valgrind --quiet --tool=helgrind ./$(APPNAME) $(APPARGS)
33
 
34
  .PHONY: gitignore
35
  gitignore:
36
- echo $(APPNAME) > .gitignore
 
37
 
38
  .PHONY: clean
39
  clean:
40
- rm -f $(APPNAME) *.o
 
 
 
1
  CC=cc
2
  CXX=g++
3
  CFLAGS=-g -std=gnu11 -Wall -Wextra
4
  LIBS=-pthread
5
  LINTFILTERS=$\
6
  -readability/casting,$\
7
  -build/header_guard,$\
8
  -build/include_subdir
9
 
10
+ APPNAME=$(shell basename $(shell pwd))
11
+ APPARGS=4 < tests/input001.txt
12
+ HEADERS=$(wildcard *.h) # file1.h file2.h fileN.h
13
+ SOURCES=$(wildcard *.c) # file1.c file2.c fileN.c main.c
14
+ OBJECTS=$(SOURCES:%.c=build/%.o) # file1.o file2.o fileN.o
15
 
16
+ bin/$(APPNAME): $(OBJECTS) | bin/.
17
+ $(CC) $(CFLAGS) $^ -o $@ $(LIBS)
18
 
19
+ build/%.o: %.c $(HEADERS) | build/.
20
  $(CC) -c $(CFLAGS) $< -o $@ $(LIBS)
21
 
22
+ .PRECIOUS: %/.
23
+ %/.:
24
+ mkdir -p $(dir $@)
25
+
26
+ all: bin/$(APPNAME) lint memcheck helgrind
27
 
28
  .PHONY: lint
29
  lint:
30
  cpplint --filter=$(LINTFILTERS) *.h *.c
31
 
32
  .PHONY: memcheck
33
  memcheck:
34
+ valgrind --tool=memcheck bin/$(APPNAME) $(APPARGS)
35
 
36
  .PHONY: helgrind
37
  helgrind:
38
+ valgrind --quiet --tool=helgrind bin/$(APPNAME) $(APPARGS)
39
 
40
  .PHONY: gitignore
41
  gitignore:
42
+ echo bin > .gitignore
43
+ echo build >> .gitignore
44
 
45
  .PHONY: clean
46
  clean:
47
+ rm -rf bin build