Commit | Line | Data |
---|---|---|
cf76e892 JPM |
1 | # |
2 | # Makefile for modified UAE 68000 CPU core | |
3 | # | |
4 | # by James Hammons | |
5 | # (C) 2011 Underground Software | |
6 | # | |
7 | # This makefile is released under the GPLv3 or later | |
8 | # | |
9 | ||
10 | ifeq ("$(V)","1") | |
11 | Q := | |
12 | else | |
13 | Q := @ | |
14 | endif | |
15 | ||
16 | # Cross compilation using MXE | |
17 | CROSS = i686-pc-mingw32- | |
18 | #CROSS = i686-w64-mingw32- | |
19 | #CROSS = x86_64-pc-msys- | |
20 | ||
21 | CC := $(CROSS)gcc | |
22 | LD := $(CROSS)gcc | |
23 | AR := $(CROSS)ar | |
24 | HOSTCC := gcc | |
25 | ||
26 | ARFLAGS := -rs | |
27 | GCC_DEPS = -MMD | |
28 | INCS := -I. -I./obj `$(CROSS)sdl-config --cflags` | |
29 | ||
30 | OBJS = \ | |
31 | obj/cpustbl.o \ | |
32 | obj/cpudefs.o \ | |
33 | obj/cpuemu.o \ | |
34 | obj/cpuextra.o \ | |
35 | obj/readcpu.o \ | |
36 | obj/m68kinterface.o \ | |
37 | obj/m68kdasm.o | |
38 | ||
39 | # Targets for convenience sake, not "real" targets | |
40 | .PHONY: clean | |
41 | ||
42 | all: obj obj/libm68k.a | |
43 | @echo "Done!" | |
44 | ||
45 | # Library rules (might not be cross-platform compatible) | |
46 | obj/libm68k.a: $(OBJS) | |
47 | $(Q)$(AR) $(ARFLAGS) obj/libm68k.a $(OBJS) | |
48 | ||
49 | obj: | |
50 | @mkdir ./obj | |
51 | ||
52 | # Main source compilation (implicit rules)... | |
53 | ||
54 | obj/%.o: %.c | |
55 | @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m" | |
56 | $(Q)$(CC) $(GCC_DEPS) $(CFLAGS) $(INCS) -c $< -o $@ | |
57 | ||
58 | obj/%.o: obj/%.c | |
59 | @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m" | |
60 | $(Q)$(CC) $(GCC_DEPS) $(CFLAGS) $(INCS) -c $< -o $@ | |
61 | ||
62 | # Generated code | |
63 | ||
64 | obj/cpuemu.c: obj/gencpu | |
65 | obj/cpustbl.c: obj/gencpu | |
66 | @echo -e "\033[01;33m***\033[00;32m Generating cpuemu.c...\033[00m" | |
67 | @cd obj && ./gencpu | |
68 | ||
69 | obj/gencpu: obj/cpudefs.c | |
70 | @echo -e "\033[01;33m***\033[00;32m Generating gencpu...\033[00m" | |
71 | $(Q)$(HOSTCC) $(GCC_DEPS) $(CFLAGS) gencpu.c readcpu.c obj/cpudefs.c -o obj/gencpu -I. -I./obj | |
72 | ||
73 | obj/cpudefs.c: obj/build68k | |
74 | @echo -e "\033[01;33m***\033[00;32m Generating cpudefs.c...\033[00m" | |
75 | $(Q)obj/build68k < table68k > obj/cpudefs.c | |
76 | ||
77 | obj/build68k: build68k.c | |
78 | @echo -e "\033[01;33m***\033[00;32m Compiling $< ...\033[00m" | |
79 | $(Q)$(HOSTCC) $(GCC_DEPS) $(CFLAGS) build68k.c -o obj/build68k | |
80 | ||
81 | clean: | |
82 | @echo -ne "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m" | |
83 | @-rm -rf ./obj | |
84 | @echo "done!" | |
85 | ||
86 | # Pull in dependencies autogenerated by gcc's -MMD switch | |
87 | # The "-" in front is there just in case they haven't been created yet | |
88 | ||
89 | -include obj/*.d |