-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
44 lines (34 loc) · 1.18 KB
/
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
39
40
41
42
43
CC=gcc -g
CXX=g++ -g
CFLAGS += -Wall -std=c99 -D_POSIX_C_SOURCE=200809L
CXXFLAGS += -Wall -std=c++11 -D_POSIX_C_SOURCE=200809L
cctest : CC=g++ -g -std=gnu++11
cctest : CFLAGS=-O2 -Wall -D_POSIX_C_SOURCE=200809L
SRCFILES=$(shell find . -name '*.c')
SRCPFILES=$(shell find . -name '*.cpp')
INCFILES=$(shell find . -name '*.h')
THEFILES=$(basename $(SRCFILES))
THEPFILES=$(basename $(SRCPFILES))
THEOBJ=$(addsuffix .o,$(THEFILES))
THEPOBJ=$(addsuffix .o,$(THEPFILES))
.PHONY: all clean
all: isicpu
cctest: all
clean:
@rm -fv isicpu
@rm -fv depends
@rm -fv ${THEOBJ}
depends: ${SRCFILES} ${SRCPFILES} ${INCFILES} Makefile
@rm -fv depends
@for i in ${THEFILES} ; do echo "depends $$(${CC} ${CFLAGS} -MM $$i.c -MT $$i.o) Makefile" >> depends ; done
@for i in ${THEPFILES} ; do echo "depends $$(${CXX} ${CXXFLAGS} -MM $$i.cpp -MT $$i.o) Makefile" >> depends ; done
isicpu: ${THEOBJ} ${THEPOBJ} Makefile depends
@${CXX} ${THEOBJ} ${THEPOBJ} -Wl,-as-needed -lrt -o isicpu
@if [ -x isicpu ] ; then echo "Build complete"; fi
include depends
%.o: %.c Makefile
@echo "CC : $< >> $@ ($*)"
@${CC} ${CFLAGS} -c $< -o $@
%.o: %.cpp Makefile
@echo "C++ : $< >> $@ ($*)"
@${CXX} ${CXXFLAGS} -c $< -o $@