]> Shamusworld >> Repos - apple2/blob - Makefile
b6fed0c244d16d97a8ae4bde56c5a92c51c9cd91
[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/diskselector.o    \
105         obj/font10pt.o        \
106         obj/font12pt.o        \
107         obj/font14pt.o        \
108         obj/gui.o             \
109                               \
110         obj/apple2-icon-64x64.o \
111         obj/charset.o         \
112         obj/crc32.o           \
113         obj/dis65c02.o        \
114         obj/firmware.o        \
115         obj/floppydrive.o     \
116         obj/harddrive.o       \
117         obj/log.o             \
118         obj/mmu.o             \
119         obj/mockingboard.o    \
120         obj/sdlemu_config.o   \
121         obj/settings.o        \
122         obj/sound.o           \
123         obj/timing.o          \
124         obj/v6522via.o        \
125         obj/v65c02.o          \
126         obj/vay8910.o         \
127         obj/video.o           \
128         obj/apple2.o          \
129         $(ICON)
130
131 all: message obj $(TARGET)$(EXESUFFIX)
132         @echo
133         @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m"
134
135 # Check the compilation environment, barf if not appropriate
136
137 ifeq "$(FINDSDL2)" ""
138   $(info )
139   $(info It seems that you don't have the SDL 2 development libraries installed. If you)
140   $(info have installed them, make sure that the sdl2-config file is somewhere in your)
141   $(info path and is executable.)
142   $(info )
143   $(error SDL2 MISSING)
144 endif
145
146 message:
147         @echo
148         @echo -e "\033[01;33m***\033[00;32m Building Apple2 SDL for $(MSG)...\033[00m"
149         @echo
150
151 clean:
152         @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
153         @rm -rf obj
154         @rm -f ./$(TARGET)$(EXESUFFIX)
155         @echo -e "\033[01;37mdone!\033[00m"
156
157 obj:
158         @mkdir obj
159
160 # Icon creation is only done for Win32 at the moment...
161 ifneq "" "$(ICON)"
162 $(ICON): res/$(TARGET).rc res/$(TARGET).ico
163         @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
164         @$(CROSS)windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
165 endif
166
167 obj/%.o: src/%.c
168         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
169         @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
170
171 obj/%.o: src/%.cpp
172         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
173         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
174
175 #GUI compilation...
176 obj/%.o: src/gui/%.cpp
177         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
178         @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
179
180 $(TARGET)$(EXESUFFIX): $(OBJS)
181         @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
182         @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
183 #       strip --strip-all $(TARGET)$(EXESUFFIX)
184 #       upx -9 $(TARGET)$(EXESUFFIX)
185
186 statistics:
187         @echo -n "Lines in source files: "
188         @-$(FIND) ./src -name "*.cpp" | xargs cat | wc -l
189         @echo -n "Lines in header files: "
190         @-$(FIND) ./src -name "*.h" | xargs cat | wc -l
191
192 # Pull in dependencies autogenerated by gcc's -MMD switch
193 # The "-" in front in there just in case they haven't been created yet
194
195 -include obj/*.d
196