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