]> Shamusworld >> Repos - apple2/blob - Makefile
Squashed bug that crept in to config.cpp. :-(
[apple2] / Makefile
1 #
2 # Unified Makefile for Apple 2 SDL
3 #
4 # by James Hammons
5 # (C) 2005-2018 Underground Software
6 # This software is licensed under the GPL v3
7 #
8
9 FIND = find
10 FINDSDL2 := $(shell which $(CROSS)sdl2-config 2> /dev/null)
11
12 # Figure out which system we're compiling for, and set the appropriate variables
13
14 ifeq "$(CROSS)" ""
15 OSTYPE   := $(shell uname -a)
16
17 # Win32
18 ifeq "$(findstring Msys,$(OSTYPE))" "Msys"
19
20 SYSTYPE    = __GCCWIN32__
21 EXESUFFIX  = .exe
22 ICON       = obj/icon.o
23 SDLLIBTYPE = --static-libs
24 MSG        = Win32 on MinGW
25 EXTRA      = -static
26
27 # Should catch both 'darwin' and 'darwin7.0'
28 else ifeq "$(findstring Darwin,$(OSTYPE))" "Darwin"
29
30 SYSTYPE    = __GCCUNIX__ -D_OSX_
31 EXESUFFIX  =
32 ICON       =
33 SDLLIBTYPE = --static-libs
34 MSG        = Mac OS X
35
36 # *nix
37 else ifeq "$(findstring Linux,$(OSTYPE))" "Linux"
38
39 SYSTYPE    = __GCCUNIX__
40 EXESUFFIX  =
41 ICON       =
42 SDLLIBTYPE = --libs
43 MSG        = generic Unix/Linux
44
45 # Throw error, unknown OS
46 else
47
48 $(error OS TYPE UNDETECTED)
49
50 endif
51 # Cross compile using MXE under Linux host
52 else
53
54 SYSTYPE    = __GCCWIN32__
55 EXESUFFIX  = .exe
56 ICON       = obj/icon.o
57 SDLLIBTYPE = --libs
58 MSG        = Win32 under MXE (cross compile)
59
60 endif
61
62 CC         = $(CROSS)gcc
63 LD         = $(CROSS)gcc
64 TARGET     = apple2
65
66 SDL_CFLAGS = `$(CROSS)sdl2-config --cflags`
67 SDL_LIBS   = `$(CROSS)sdl2-config $(SDLLIBTYPE)`
68 DEFINES    = -D$(SYSTYPE)
69 GCC_DEPS   = -MMD
70
71 # Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
72 #CFLAGS   = -MMD -Wall -Wno-switch -O2 -D$(SYSTYPE) -ffast-math -fomit-frame-pointer `sdl2-config --cflags`
73 #CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -O2 -D$(SYSTYPE) \
74 # No optimization and w/gcov flags, so that we get an accurate picture from gcov
75 #CFLAGS   = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
76 #               -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
77 #CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
78 #               -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
79 # No optimization for profiling with gprof...
80 #CFLAGS   = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
81 #               -ffast-math `sdl2-config --cflags` -pg -g
82 #CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
83 #               -ffast-math `sdl2-config --cflags` -pg -g
84 #               -fomit-frame-pointer `sdl2-config --cflags` -g
85 #               -fomit-frame-pointer `sdl2-config --cflags` -DLOG_UNMAPPED_MEMORY_ACCESSES
86 CFLAGS   = $(GCC_DEPS) -Wall -Wno-switch $(DEFINES) -ffast-math $(SDL_CFLAGS) -pg -g
87 CPPFLAGS = $(GCC_DEPS) -Wall -Wno-switch -Wno-non-virtual-dtor $(DEFINES) \
88                 -ffast-math $(SDL_CFLAGS) -pg -g
89
90 LDFLAGS = $(EXTRA)
91
92 #LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB)
93 # Link in the gcov library (for profiling purposes)
94 #LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -lgcov
95 # Link in the gprof lib
96 #LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -pg
97 #LIBS = -L/usr/local/lib -L/usr/lib $(SDL_LIBS) -lstdc++ -lz $(GLLIB) -pg
98 LIBS = $(SDL_LIBS) -lstdc++ -lz -lm $(GLLIB) -pg
99
100 #INCS = -I. -I./src -I/usr/local/include -I/usr/include
101 INCS = -I. -I./src
102
103 OBJS = \
104         obj/config.o          \
105         obj/diskselector.o    \
106         obj/font10pt.o        \
107         obj/font12pt.o        \
108         obj/font14pt.o        \
109         obj/gui.o             \
110                               \
111         obj/a2hs-scsi.o       \
112         obj/apple2-fw.o       \
113         obj/apple2e-enh.o     \
114         obj/firmware.o        \
115                               \
116         obj/apple2-icon-64x64.o \
117         obj/charset.o         \
118         obj/crc32.o           \
119         obj/dis65c02.o        \
120         obj/fileio.o          \
121         obj/floppydrive.o     \
122         obj/harddrive.o       \
123         obj/log.o             \
124         obj/mmu.o             \
125         obj/mockingboard.o    \
126         obj/settings.o        \
127         obj/sound.o           \
128         obj/timing.o          \
129         obj/v6522via.o        \
130         obj/v65c02.o          \
131         obj/vay8910.o         \
132         obj/video.o           \
133         obj/apple2.o          \
134         $(ICON)
135
136 all: message obj $(TARGET)$(EXESUFFIX)
137         @echo
138         @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m"
139
140 # Check the compilation environment, barf if not appropriate
141
142 ifeq "$(FINDSDL2)" ""
143   $(info )
144   $(info It seems that you don't have the SDL 2 development libraries installed. If you)
145   $(info have installed them, make sure that the sdl2-config file is somewhere in your)
146   $(info path and is executable.)
147   $(info )
148   $(error SDL2 MISSING)
149 endif
150
151 message:
152         @echo
153         @echo -e "\033[01;33m***\033[00;32m Building Apple2 SDL for $(MSG)...\033[00m"
154         @echo
155
156 clean:
157         @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
158         @rm -rf obj
159         @rm -f ./$(TARGET)$(EXESUFFIX)
160         @echo -e "\033[01;37mdone!\033[00m"
161
162 obj:
163         @mkdir obj
164
165 # Icon creation is only done for Win32 at the moment...
166 ifneq "" "$(ICON)"
167 $(ICON): res/$(TARGET).rc res/$(TARGET).ico
168         @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
169         @$(CROSS)windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
170 endif
171
172 obj/%.o: src/%.c
173         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
174         @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
175
176 obj/%.o: src/%.cpp
177         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
178         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
179
180 #GUI compilation...
181 obj/%.o: src/gui/%.cpp
182         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
183         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
184
185 #Firmware compilation...
186 obj/%.o: src/firmware/%.cpp
187         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
188         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
189
190 $(TARGET)$(EXESUFFIX): $(OBJS)
191         @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
192         @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
193 #       strip --strip-all $(TARGET)$(EXESUFFIX)
194 #       upx -9 $(TARGET)$(EXESUFFIX)
195
196 statistics:
197         @echo -n "Lines in source files: "
198         @-$(FIND) ./src -name "*.cpp" | xargs cat | wc -l
199         @echo -n "Lines in header files: "
200         @-$(FIND) ./src -name "*.h" | xargs cat | wc -l
201
202 # Pull in dependencies autogenerated by gcc's -MMD switch
203 # The "-" in front in there just in case they haven't been created yet
204
205 -include obj/*.d
206