# Glyph Keeper Makefile TARGET=ALLEGGL compiler := gcc EXE := COMPDIR = /usr # For windows: # COMPDIR = $(MINGDIR) includedir := $(COMPDIR)/include/ libdir := $(COMPDIR)/lib/ VPATH := vpath %.c src examples vpath %.h src include targetcode := ifeq ($(TARGET),TEXT) targetname := Text targetcode := txt gk_targetlibs := ex_targetlibs := target_sources := glyph_to_text.c endif ifeq ($(TARGET),ALLEGRO) targetname := Allegro targetcode := al gk_targetlibs := `allegro-config --libs` ex_targetlibs := $(gk_targetlibs) target_sources := glyph_to_allegro.c glyph_to_allegro_aa.c glyph_to_allegro_mono.c endif ifeq ($(TARGET),ALLEGGL) targetname := AllegroGL targetcode := agl gk_targetlibs := -lagl `allegro-config --libs` -lGL -lGLU # untested!!!!!! ex_targetlibs := $(gk_targetlibs) target_sources := # I don't know about this << TODO!!! endif ifeq ($(TARGET),SDL) targetname := SDL targetcode := sdl gk_targetlibs := -lSDL ex_targetlibs := $(gk_targetlibs) -lSDLmain target_sources := glyph_to_sdl.c glyph_to_sdl_rect.c endif ifndef targetcode ifdef TARGET $(error Unknown TARGET "$(TARGET)") else $(error TARGET is not specified) endif endif # # CFLAGS # gk_defines := -DGK_NO_LEGACY -DGLYPH_TARGET=GLYPH_TARGET_$(TARGET) CC := gcc CFLAGS := -O3 -s GK_CFLAGS := -std=c89 $(CFLAGS) -Iinclude $(gk_defines) # # Files # static_lib_name := glyph-$(targetcode) static_obj_nameext := $(static_lib_name).o static_lib_nameext := lib$(static_lib_name).a static_obj_path := obj/$(static_obj_nameext) static_lib_path := obj/$(static_lib_nameext) goal_obj_nameext := $(static_obj_nameext) goal_obj_path := $(static_obj_path) goal_lib_nameext := $(static_lib_nameext) goal_lib_path := $(static_lib_path) sources := glyph_dimensions.c glyph_face.c glyph_global_vars.c \ glyph_index.c glyph_internal.h glyph_main.c glyph_rend.c \ glyph_structs.h glyph_utils.c $(target_sources) gk_libs := -lfreetype $(gk_targetlibs) ex_libs := -lfreetype $(ex_targetlibs) #Includes for Glyph Keeper #gk_includes := -Iinclude/freetype2 gk_includes := `freetype-config --cflags` link_gk_libs := $(gk_libs) link_ex_libs := $(ex_libs) example_sources := $(wildcard examples/*_$(targetcode).c) example_executables := $(example_sources:.c=) includedir_u := $(subst \,/,$(includedir)) libdir_u := $(subst \,/,$(libdir)) # # Tools # ifdef WINDOWS_TOOLS delete = del /q $(subst /,\,$(1)) copy = copy $(subst /,\,$(1) $(2)) else delete = rm -f $(1) copy = @cp -v $(1) $(2) endif # # Rules # .PHONY: all lib examples clean veryclean install uninstall all: lib examples lib: $(goal_lib_path) $(static_lib_path): $(static_obj_path) ar r $@ $^ $(goal_obj_path): glyph.c $(sources) glyph.h @-echo Compiling Glyph Keeper / $(targetname) with $(compiler) $(CC) $(GK_CFLAGS) $(gk_includes) -c -o $@ $< examples: lib $(example_executables) $(example_executables): %$(EXE): %.c @echo $(notdir $(basename $@))_extra_libs $(CC) $(GK_CFLAGS) -o $@ $< $(goal_lib_path) $(link_ex_libs) $($(notdir $(basename $@))_extra_libs:lib%.a=-l%) clean: @-echo Cleaning up Glyph Keeper with $(compiler) $(call delete,$(goal_obj_path)) $(call delete,$(goal_lib_path)) $(call delete,$(example_executables)) $(call delete,$(example_executables:%$(EXE)=%.log)) veryclean: @-echo Cleaning up Glyph Keeper $(call delete,glyph.def) $(call delete,obj/*) $(call delete,examples/*.exe) $(call delete,examples/*.log) install: glyph.h lib @-echo Installing Glyph Keeper / $(targetname) for $(compiler) $(call copy,$<,"$(includedir_u)") $(call copy,$(goal_lib_path),"$(libdir_u)") @-echo Glyph Keeper / $(targetname) is now installed. @-echo Dont forget to link your program to: $(goal_lib_nameext) $(ex_libs) uninstall: @-echo Uninstalling Glyph Keeper / $(targetname) for $(compiler) $(call delete,"$(includedir_u)glyph.h") $(call delete,"$(libdir_u)$(goal_lib_nameext)") @-echo Glyph Keeper / $(targetname) is now uninstalled.