bsnes-libretro/Makefile

116 lines
3.3 KiB
Makefile
Raw Normal View History

2016-03-30 20:07:55 +00:00
ifeq ($(shell uname -s),Darwin)
default: cocoa
else
default: sdl
endif
VERSION := 0.5
2016-04-01 20:36:43 +00:00
2016-03-30 20:07:55 +00:00
BIN := build/bin
OBJ := build/obj
CC := clang
CFLAGS += -Werror -Wall -std=gnu11 -ICore -D_GNU_SOURCE
SDL_LDFLAGS := -lSDL
LDFLAGS += -lc -lm
2016-04-01 19:53:29 +00:00
CONF ?= debug
2016-03-30 20:07:55 +00:00
ifeq ($(shell uname -s),Darwin)
2016-04-01 20:36:43 +00:00
CFLAGS += -F/Library/Frameworks -DVERSION="$(VERSION)"
2016-03-30 20:07:55 +00:00
OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(shell xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.9
2016-06-09 15:22:47 +00:00
LDFLAGS += -framework AppKit -framework Carbon
2016-03-30 20:07:55 +00:00
SDL_LDFLAGS := -framework SDL
endif
2016-04-01 19:53:29 +00:00
ifeq ($(CONF),debug)
CFLAGS += -g
else ifeq ($(CONF), release)
CFLAGS += -O3
else
$(error Invalid value for CONF: $(CONF). Use "debug" or "release")
endif
2016-03-30 20:07:55 +00:00
cocoa: $(BIN)/Sameboy.app
sdl: $(BIN)/sdl/sameboy $(BIN)/sdl/dmg_boot.bin $(BIN)/sdl/cgb_boot.bin $(BIN)/sdl/LICENSE
2016-03-30 20:07:55 +00:00
bootroms: $(BIN)/BootROMs/cgb_boot.bin $(BIN)/BootROMs/dmg_boot.bin
CORE_SOURCES := $(shell echo Core/*.c)
SDL_SOURCES := $(shell echo SDL/*.c)
ifeq ($(shell uname -s),Darwin)
COCOA_SOURCES := $(shell echo Cocoa/*.m)
SDL_SOURCES += $(shell echo SDL/*.m)
endif
CORE_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(CORE_SOURCES))
COCOA_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(COCOA_SOURCES))
SDL_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(SDL_SOURCES))
ALL_OBJECTS := $(CORE_OBJECTS) $(COCOA_OBJECTS) $(SDL_OBJECTS)
# Automatic dependency generation
-include $(ALL_OBJECTS:.o=.dep)
$(OBJ)/%.dep: %
-@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -MT $(OBJ)/$^.o -M $^ -c -o $@
$(OBJ)/%.c.o: %.c
-@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ)/%.m.o: %.m
-@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(OCFLAGS) -c $< -o $@
# Cocoa Port
Shaders:$(shell echo Shaders/*.fsh)
2016-03-30 20:07:55 +00:00
$(BIN)/Sameboy.app: $(BIN)/Sameboy.app/Contents/MacOS/Sameboy \
$(shell echo Cocoa/*.icns) \
2016-04-01 20:36:43 +00:00
Cocoa/License.html \
Cocoa/info.plist \
2016-03-30 20:07:55 +00:00
$(BIN)/BootROMs/dmg_boot.bin \
$(BIN)/BootROMs/cgb_boot.bin \
$(BIN)/Sameboy.app/Contents/Resources/Base.lproj/Document.nib \
2016-04-13 19:43:16 +00:00
$(BIN)/Sameboy.app/Contents/Resources/Base.lproj/MainMenu.nib \
$(BIN)/Sameboy.app/Contents/Resources/Base.lproj/Preferences.nib \
Shaders
2016-03-30 20:07:55 +00:00
mkdir -p $(BIN)/Sameboy.app/Contents/Resources
cp Cocoa/*.icns $(BIN)/BootROMs/dmg_boot.bin $(BIN)/BootROMs/cgb_boot.bin $(BIN)/Sameboy.app/Contents/Resources/
2016-04-01 20:36:43 +00:00
sed s/@VERSION/$(VERSION)/ < Cocoa/info.plist > $(BIN)/Sameboy.app/Contents/info.plist
2016-04-01 19:13:05 +00:00
cp Cocoa/License.html $(BIN)/Sameboy.app/Contents/Resources/Credits.html
mkdir -p $(BIN)/Sameboy.app/Contents/Resources/Shaders
cp Shaders/*.fsh $(BIN)/Sameboy.app/Contents/Resources/Shaders
2016-03-30 20:07:55 +00:00
$(BIN)/Sameboy.app/Contents/MacOS/Sameboy: $(CORE_OBJECTS) $(COCOA_OBJECTS)
-@mkdir -p $(dir $@)
$(CC) $^ -o $@ $(LDFLAGS) -framework OpenGL -framework AudioUnit
$(BIN)/Sameboy.app/Contents/Resources/Base.lproj/%.nib: Cocoa/%.xib
ibtool --compile $@ $^
$(BIN)/sdl/sameboy: $(CORE_OBJECTS) $(SDL_OBJECTS)
-@mkdir -p $(dir $@)
$(CC) $^ -o $@ $(LDFLAGS) $(SDL_LDFLAGS)
$(BIN)/BootROMs/%.bin: BootROMs/%.asm
-@mkdir -p $(dir $@)
cd BootROMs && rgbasm -o ../$@.tmp ../$<
rgblink -o $@.tmp2 $@.tmp
head -c $(if $(filter dmg,$(CC)), 256, 2309) $@.tmp2 > $@
@rm $@.tmp $@.tmp2
$(BIN)/sdl/%.bin: $(BIN)/BootROMs/%.bin
-@mkdir -p $(dir $@)
cp -f $^ $@
$(BIN)/sdl/LICENSE: LICENSE
cp -f $^ $@
2016-03-30 20:07:55 +00:00
clean:
rm -rf build