2 # Unified Makefile for Apple 2 SDL
5 # (C) 2005 Underground Software
6 # This software is licensed under the GPL v2
10 FINDSDL2 := $(shell which $(CROSS)sdl2-config 2> /dev/null)
12 # Figure out which system we're compiling for, and set the appropriate variables
15 OSTYPE := $(shell uname -a)
18 ifeq "$(findstring Msys,$(OSTYPE))" "Msys"
20 SYSTYPE = __GCCWIN32__
26 # Should catch both 'darwin' and 'darwin7.0'
27 else ifeq "$(findstring Darwin,$(OSTYPE))" "Darwin"
29 SYSTYPE = __GCCUNIX__ -D_OSX_
32 SDLLIBTYPE = --static-libs
36 else ifeq "$(findstring Linux,$(OSTYPE))" "Linux"
42 MSG = generic Unix/Linux
44 # Throw error, unknown OS
47 $(error OS TYPE UNDETECTED)
50 # Cross compile using MXE under Linux host
53 SYSTYPE = __GCCWIN32__
57 MSG = Win32 under MXE (cross compile)
65 SDL_CFLAGS = `$(CROSS)sdl2-config --cflags`
66 SDL_LIBS = `$(CROSS)sdl2-config $(SDLLIBTYPE)`
67 DEFINES = -D$(SYSTYPE)
70 # Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
71 #CFLAGS = -MMD -Wall -Wno-switch -O2 -D$(SYSTYPE) -ffast-math -fomit-frame-pointer `sdl2-config --cflags`
72 #CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -O2 -D$(SYSTYPE) \
73 # No optimization and w/gcov flags, so that we get an accurate picture from gcov
74 #CFLAGS = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
75 # -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
76 #CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
77 # -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
78 # No optimization for profiling with gprof...
79 #CFLAGS = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
80 # -ffast-math `sdl2-config --cflags` -pg -g
81 #CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
82 # -ffast-math `sdl2-config --cflags` -pg -g
83 # -fomit-frame-pointer `sdl2-config --cflags` -g
84 # -fomit-frame-pointer `sdl2-config --cflags` -DLOG_UNMAPPED_MEMORY_ACCESSES
85 CFLAGS = $(GCC_DEPS) -Wall -Wno-switch $(DEFINES) -ffast-math $(SDL_CFLAGS) -pg -g
86 CPPFLAGS = $(GCC_DEPS) -Wall -Wno-switch -Wno-non-virtual-dtor $(DEFINES) \
87 -ffast-math $(SDL_CFLAGS) -pg -g
91 #LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB)
92 # Link in the gcov library (for profiling purposes)
93 #LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -lgcov
94 # Link in the gprof lib
95 #LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -pg
96 LIBS = -L/usr/local/lib -L/usr/lib $(SDL_LIBS) -lstdc++ -lz $(GLLIB) -pg
98 #INCS = -I. -I./src -I/usr/local/include -I/usr/include
116 obj/sdlemu_config.o \
128 obj/draggablewindow.o \
129 obj/draggablewindow2.o \
137 all: checkenv message obj $(TARGET)$(EXESUFFIX)
139 @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m"
141 # Check the compilation environment, barf if not appropriate
145 @echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
146 ifeq "$(FINDSDL2)" ""
149 @echo -e "\033[01;33mIt seems that you don't have the SDL 2 development libraries installed. If you"
150 @echo -e "have installed them, make sure that the sdl2-config file is somewhere in your"
151 @echo -e "path and is executable.\033[00m"
153 #Is there a better way to break out of the makefile?
156 # YES! But ignores all the echo's above... :-/
157 #$(error SDL2 MISSING)
160 @echo -e "\033[01;37mOK\033[00m"
165 @echo -e "\033[01;33m***\033[00;32m Building Apple2 SDL for $(MSG)...\033[00m"
169 @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
171 @rm -f ./$(TARGET)$(EXESUFFIX)
172 @echo -e "\033[01;37mdone!\033[00m"
177 # This is only done for Win32 at the moment...
180 $(ICON): res/$(TARGET).rc res/$(TARGET).ico
181 @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
182 @$(CROSS)windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
186 @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
187 @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
190 @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
191 @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
194 obj/%.o: src/gui/%.cpp
195 @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
196 @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
198 $(TARGET)$(EXESUFFIX): $(OBJS)
199 @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
200 @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
201 # strip --strip-all vj$(EXESUFFIX)
202 # upx -9 vj$(EXESUFFIX)
205 @echo -n "Lines in source files: "
206 @-$(FIND) ./src -name "*.cpp" | xargs cat | wc -l
207 @echo -n "Lines in header files: "
208 @-$(FIND) ./src -name "*.h" | xargs cat | wc -l
210 # Pull in dependencies autogenerated by gcc's -MMD switch
211 # The "-" in front in there just in case they haven't been created yet