]> Shamusworld >> Repos - stargem2/blob - Makefile
More cleanup, chasing down problems with the demo mode
[stargem2] / Makefile
1 #
2 # Makefile for StarGem 2 SDL
3 #
4 # by James L. Hammons
5 # (C) 2005 Underground Software
6 # This software is licensed under the GPL v2
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     = stargem2
44
45 CFLAGS   = -MMD -Wall -Wno-switch -Wno-uninitialized -O2 -D$(SYSTYPE) -fomit-frame-pointer `sdl-config --cflags`
46 CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -Wno-uninitialized -O2 -D$(SYSTYPE) \
47                 -fomit-frame-pointer `sdl-config --cflags` \
48                 -g
49 #               -DLOG_UNMAPPED_MEMORY_ACCESSES
50
51 LDFLAGS =
52
53 LIBS = -L/usr/local/lib `sdl-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB)
54
55 INCS = -I. -Isrc -I/usr/local/include
56
57 OBJS = \
58         obj/dis6808.o       \
59         obj/dis6809.o       \
60         obj/log.o           \
61         obj/v6808.o         \
62         obj/v6809.o         \
63         obj/video.o         \
64         obj/settings.o      \
65         obj/sound.o         \
66         obj/sdlemu_config.o \
67         obj/sdlemu_opengl.o \
68         obj/timing.o        \
69         obj/stargem2.o      \
70         $(ICON)
71
72 all: checkenv message obj $(TARGET)$(EXESUFFIX)
73         @echo
74         @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m"
75
76 # Check the compilation environment, barf if not appropriate
77
78 checkenv:
79         @echo
80         @echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
81 ifeq "" "$(shell which sdl-config)"
82         @echo
83         @echo
84         @echo -e "\033[01;33mIt seems that you don't have the SDL development libraries installed.
85         @echo -e "have installed them, make sure that the sdl-config file is somewhere in your"
86         @echo -e "path and is executable.\033[00m"
87         @echo
88 #Is there a better way to break out of the makefile?
89         @break
90 else
91         @echo -e "\033[01;37mOK\033[00m"
92 endif
93
94 message:
95         @echo
96         @echo -e "\033[01;33m***\033[00;32m Building StarGem 2 for $(MSG)...\033[00m"
97         @echo
98
99 clean:
100         @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
101         @rm -rf obj
102         @rm -f ./$(TARGET)$(EXESUFFIX)
103         @echo -e "\033[01;37mdone!\033[00m"
104
105 obj:
106         @mkdir obj
107
108 # This is only done for Win32 at the moment...
109
110 ifneq "" "$(ICON)"
111 $(ICON): res/$(TARGET).rc res/$(TARGET).ico
112         @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
113         @windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
114 endif
115
116 obj/%.o: src/%.c
117         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
118         @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
119
120 obj/%.o: src/%.cpp
121         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
122         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
123
124 $(TARGET)$(EXESUFFIX): $(OBJS)
125         @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
126         @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
127 #       strip --strip-all $(TARGET)$(EXESUFFIX)
128 #       upx -9 $(TARGET)$(EXESUFFIX)
129
130 # Pull in dependencies autogenerated by gcc's -MMD switch
131 # The "-" in front in there just in case they haven't been created yet
132
133 -include obj/*.d