-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (37 loc) · 1.07 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
44
45
46
47
48
49
TARGET = m68k
SUBDIRS =
CFLAGS = -O2 -pipe -fomit-frame-pointer -Wall
MAKETARGET=$(firstword $(MAKECMDGOALS))
ifneq ($(MAKETARGET),$(MAKECMDGOALS))
%:
@echo "ERROR: More than one make-target specified!"
@echo "Targets available: all clean distclean"
@false
else
DEPENDFILE=.depend
DISTDIR=$(PACKAGE)-$(VERSION)
SOURCES=$(wildcard *.c)
HEADERS=$(wildcard *.h)
OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
.PHONY: all clean distclean tar $(TARGET) $(SUBDIRS)
all: $(TARGET)
fastbuild: ${SOURCES}
find *.c -printf "#include \"%p\"\n" > .fastbuild.c
gcc -o ${TARGET} ${CFLAGS} ${LDFLAGS} .fastbuild.c
$(TARGET): $(OBJECTS)
gcc -o $@ $(OBJECTS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
make -C $@ $(MAKETARGET)
# clean intermediate files
clean: subdirs
-rm -f *.o $(TARGET) $(OBJECTS) .fastbuild.c
# clean all unneeded files to simplify re-distribution
distclean: subdirs
-rm -f *~ DEADJOE $(DEPENDFILE)
-rm -f *.o $(TARGET) $(OBJECTS) .fastbuild.c
# automatic dependency updates
$(DEPENDFILE): $(SOURCES) $(HEADERS)
$(CC) $(CFLAGS) -MM $(SOURCES) > $(DEPENDFILE)
-include $(DEPENDFILE)
endif