]> Shamusworld >> Repos - thunder/blob - makefile
e19b93ab4cb994aad4f93fb354e5e4137f014f9d
[thunder] / makefile
1 #
2 # Makefile for Thunder SDL
3 #
4 # by James Hammons
5 # (C) 2009 Underground Software
6 # This software is licensed under the GPL v3 or later
7 #
8
9 ifeq "$(OSTYPE)" "msys"                                                 # Win32
10
11 SYSTYPE    = __GCCWIN32__
12 EXESUFFIX  = .exe
13 GLLIB      = -lopengl32
14 ICON       = obj/icon.o
15 SDLLIBTYPE = --libs
16 MSG        = Win32 on MinGW
17
18 else
19 #ifeq "$(OSTYPE)" "darwin"
20 ifeq "darwin" "$(findstring darwin,$(OSTYPE))"  # Should catch both 'darwin' and 'darwin7.0'
21
22 SYSTYPE    = __GCCUNIX__ -D_OSX_
23 EXESUFFIX  =
24 GLLIB      =
25 ICON       =
26 SDLLIBTYPE = --static-libs
27 MSG        = Mac OS X
28
29 else    # *nix
30
31 SYSTYPE    = __GCCUNIX__
32 EXESUFFIX  =
33 GLLIB      = -lGL
34 ICON       =
35 SDLLIBTYPE = --libs
36 MSG        = generic Unix/Linux
37
38 endif
39 endif
40
41 CC         = gcc
42 LD         = gcc
43 TARGET     = thunder
44
45 CFLAGS   = -MMD -Wall -Wno-switch -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) -fomit-frame-pointer `sdl2-config --cflags`
46 CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) \
47                 -fomit-frame-pointer `sdl2-config --cflags` \
48                 -g
49 #               -DLOG_UNMAPPED_MEMORY_ACCESSES
50
51 LDFLAGS =
52
53 # Ugh, let's get rid of the ref to -lcurses
54 LIBS = `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz -lm $(GLLIB)
55
56 INCS = -I. -Isrc
57
58 OBJS = \
59         obj/dis63701.o   \
60         obj/dis6809.o    \
61         obj/gui.o        \
62         obj/icon-64x64.o \
63         obj/log.o        \
64         obj/resource.o   \
65         obj/screen.o     \
66         obj/v63701.o     \
67         obj/v6809.o      \
68         obj/video.o      \
69         obj/ym2151.o     \
70         obj/thunder.o    \
71         $(ICON)
72
73 all: checkenv message obj $(TARGET)$(EXESUFFIX)
74         @echo
75         @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m"
76
77 # Check the compilation environment, barf if not appropriate
78
79 checkenv:
80         @echo
81         @echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
82 ifeq "" "$(shell which sdl-config)"
83         @echo
84         @echo
85         @echo -e "\033[01;33mIt seems that you don't have the SDL development libraries installed.
86         @echo -e "have installed them, make sure that the sdl-config file is somewhere in your"
87         @echo -e "path and is executable.\033[00m"
88         @echo
89 #Is there a better way to break out of the makefile?
90         @break
91 else
92         @echo -e "\033[01;37mOK\033[00m"
93 endif
94
95 message:
96         @echo
97         @echo -e "\033[01;33m***\033[00;32m Building Thunder/SDL for $(MSG)...\033[00m"
98         @echo
99
100 clean:
101         @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
102         @rm -rf obj
103         @rm -f ./$(TARGET)$(EXESUFFIX)
104         @echo -e "\033[01;37mdone!\033[00m"
105
106 obj:
107         @mkdir obj
108
109 # This is only done for Win32 at the moment...
110
111 ifneq "" "$(ICON)"
112 $(ICON): res/$(TARGET).rc res/$(TARGET).ico
113         @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
114         @windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
115 endif
116
117 obj/%.o: src/%.c
118         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
119         @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
120
121 obj/%.o: src/%.cpp
122         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
123         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
124
125 obj/%.o: src/%.asm
126         @echo -e "\033[01;33m***\033[00;32m Assembling $<...\033[00m"
127         @nasm -f elf64 -I ./res/ $< -o $@
128
129 $(TARGET)$(EXESUFFIX): $(OBJS)
130         @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
131         @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
132 #       strip --strip-all $(TARGET)$(EXESUFFIX)
133 #       upx -9 $(TARGET)$(EXESUFFIX)
134
135 # Pull in dependencies autogenerated by gcc's -MMD switch
136 # The "-" in front in there just in case they haven't been created yet
137
138 -include obj/*.d