pthreads/{relay_race → array_reentrant}/Makefile RENAMED
@@ -1,26 +1,25 @@
1
- APPNAME=$(shell basename $(shell pwd))
2
-
3
- CC=cc
4
  CXX=g++
5
  FLAGS=-g -Wall -Wextra
6
- CFLAGS=$(FLAGS)
7
- CXXFLAGS=$(FLAGS)
8
- LIBS=-pthread
9
- CLIBS=$(LIBS)
10
- CXXLIBS=$(LIBS)
11
-
12
- all: $(APPNAME)
 
 
13
 
14
- %: %.c
15
- $(CC) $(CFLAGS) $^ -o $@ $(CLIBS)
16
 
17
- %: %.cpp
18
- $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS)
19
 
20
- .PHONY: gitignore
21
- gitignore:
22
- echo $(APPNAME) > .gitignore
23
 
24
  .PHONY: clean
25
  clean:
26
- rm -f $(APPNAME)
1
+ CC=gcc
 
 
2
  CXX=g++
3
  FLAGS=-g -Wall -Wextra
4
+ CFLAGS=$(FLAGS) -std=c11
5
+ CXXFLAGS=$(FLAGS) -std=c++11
6
+ LIBS=
7
+
8
+ HEADERS=$(wildcard *.h)
9
+ SOURCES=$(wildcard *.c*)
10
+ COBJECTS=$(SOURCES:.c=.o)
11
+ OBJECTS=$(COBJECTS:.cpp=.o)
12
+ EXECUTABLE=$(shell basename `pwd`)
13
 
14
+ $(EXECUTABLE): $(OBJECTS)
15
+ $(CXX) -o $@ $^ $(CFLAGS) $(LIBS)
16
 
17
+ %.o: %.cpp $(HEADERS)
18
+ $(CXX) -c $< -o $@ $(CXXFLAGS)
19
 
20
+ %.o: %.c $(HEADERS)
21
+ $(CC) -c -o $@ $< $(CFLAGS)
 
22
 
23
  .PHONY: clean
24
  clean:
25
+ rm -rf $(EXECUTABLE) *.o *.dSYM *~